1899
|
1 #!/usr/bin/env python
|
|
2
|
|
3 # This script builds a swig-x.y.z distribution.
|
|
4 # Usage : mkdist.py version, where version should be x.y.z
|
|
5
|
|
6 import sys
|
|
7 import string
|
|
8 import os
|
|
9 import subprocess
|
|
10
|
|
11 def failed():
|
|
12 print "mkdist.py failed to complete"
|
|
13 sys.exit(2)
|
|
14
|
|
15
|
|
16 try:
|
|
17 version = sys.argv[1]
|
|
18 dirname = "swig-" + version
|
|
19 except:
|
|
20 print "Usage: mkdist.py version, where version should be x.y.z"
|
|
21 sys.exit(1)
|
|
22
|
|
23 # Check name matches normal unix conventions
|
|
24 if string.lower(dirname) != dirname:
|
|
25 print "directory name ("+dirname+") should be in lowercase"
|
|
26 sys.exit(3)
|
|
27
|
|
28 # If directory and tarball exist, remove it
|
|
29 print "Removing ", dirname
|
|
30 os.system("rm -rf "+dirname)
|
|
31
|
|
32 print "Removing "+dirname+".tar if exists"
|
|
33 os.system("rm -f "+dirname+".tar.gz")
|
|
34
|
|
35 print "Removing "+dirname+".tar.gz if exists"
|
|
36 os.system("rm -f "+dirname+".tar")
|
|
37
|
|
38 # Grab the code from git
|
|
39
|
|
40 print "Checking git repository is in sync with remote repository"
|
|
41 os.system("git remote update") == 0 or failed()
|
|
42 command = ["git", "status", "--porcelain", "-uno"]
|
|
43 out = subprocess.check_output(command)
|
|
44 if out.strip() != "":
|
|
45 print "Local git repository has modifications"
|
|
46 print " ".join(command)
|
|
47 print out
|
|
48 sys.exit(3)
|
|
49
|
|
50 command = ["git", "log", "--oneline", "master..origin/master"]
|
|
51 out = subprocess.check_output(command)
|
|
52 if out.strip() != "":
|
|
53 print "Remote repository has additional modifications to local repository"
|
|
54 print " ".join(command)
|
|
55 print out
|
|
56 sys.exit(3)
|
|
57
|
|
58 command = ["git", "log", "--oneline", "origin/master..master"]
|
|
59 out = subprocess.check_output(command)
|
|
60 if out.strip() != "":
|
|
61 print "Local repository has modifications not pushed to the remote repository"
|
|
62 print "These should be pushed and checked that they pass Continuous Integration testing before continuing"
|
|
63 print " ".join(command)
|
|
64 print out
|
|
65 sys.exit(3)
|
|
66
|
|
67 print "Tagging release"
|
|
68 tag = "'rel-" + version + "'"
|
|
69 os.system("git tag -a -m " + tag + " " + tag) == 0 or failed()
|
|
70
|
|
71 outdir = os.path.basename(os.getcwd()) + "/" + dirname + "/"
|
|
72 print "Grabbing tagged release git repository using 'git archive' into " + outdir
|
|
73 os.system("(cd .. && git archive --prefix=" + outdir + " " + tag + " . | tar -xf -)") == 0 or failed()
|
|
74
|
|
75 # Remove the debian directory -- it's not official
|
|
76
|
|
77 os.system("rm -Rf "+dirname+"/debian") == 0 or failed()
|
|
78
|
|
79 # Go build the system
|
|
80
|
|
81 print "Building system"
|
|
82 os.system("cd "+dirname+" && ./autogen.sh") == 0 or failed()
|
|
83 os.system("cd "+dirname+"/Source/CParse && bison -y -d parser.y && mv y.tab.c parser.c && mv y.tab.h parser.h") == 0 or failed()
|
|
84 os.system("cd "+dirname+" && make -f Makefile.in libfiles srcdir=./") == 0 or failed()
|
|
85
|
|
86 # Remove autoconf files
|
|
87 os.system("find "+dirname+" -name autom4te.cache -exec rm -rf {} \\;")
|
|
88
|
|
89 # Build documentation
|
|
90 print "Building html documentation"
|
|
91 os.system("cd "+dirname+"/Doc/Manual && make all clean-baks") == 0 or failed()
|
|
92 print "Building man pages"
|
|
93 os.system("cd "+dirname+"/CCache && yodl2man -o ccache-swig.1 ccache.yo") == 0 or failed()
|
|
94
|
|
95 # Build the tar-ball
|
|
96 os.system("tar -cf "+dirname+".tar "+dirname) == 0 or failed()
|
|
97 os.system("gzip "+dirname+".tar") == 0 or failed()
|
|
98
|
|
99 print "Finished building "+dirname+".tar.gz"
|
|
100
|