1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 from os import getcwd, path, sep, system, waitpid, walk
26 from re import search
27 from subprocess import PIPE, Popen
28 import sys
29 from tarfile import TarFile
30 from zipfile import ZipFile
31
32
33 from version import version
34
35
37 """Builder action for creating a GPG signature of the binary distribution file."""
38
39
40 print('')
41 print("############################################")
42 print("# GPG signing the binary distribution file #")
43 print("############################################\n\n")
44
45
46 type_list = [env['DIST_TYPE']]
47 if type_list[0] == 'ALL':
48 type_list = ['zip', 'tar']
49
50
51 key = env['GPG_KEY']
52 if key == None:
53 sys.stderr.write("The GPG key needs to be supplied on the command line as key=xxxxx, where xxxxx is the name of your key.\n\n")
54 return
55
56
57 for dist_type in type_list:
58
59 if dist_type == 'zip':
60 file = env['DIST_FILE'] + '.zip'
61 elif dist_type == 'tar':
62 file = env['DIST_FILE'] + '.tar.bz2'
63 elif dist_type == 'dmg':
64 file = env['DIST_FILE'] + '.dmg'
65
66
67 print(("\n\nSigning the distribution package " + repr(file) + ".\n"))
68
69
70 system("gpg --detach-sign --default-key " + key + " " + path.pardir + path.sep + file)
71
72
73 print("\n\n\n")
74
75
77 """Builder action for packaging the distribution archives."""
78
79
80 print('')
81 print("#######################")
82 print("# Packaging the files #")
83 print("#######################")
84
85
86 type_list = [env['DIST_TYPE']]
87 if type_list[0] == 'ALL':
88 type_list = ['zip', 'tar']
89
90
91 for dist_type in type_list:
92
93 if dist_type == 'zip':
94 file = env['DIST_FILE'] + '.zip'
95 elif dist_type == 'tar':
96 file = env['DIST_FILE'] + '.tar.bz2'
97 elif dist_type == 'dmg':
98 file = env['DIST_FILE'] + '.dmg'
99
100
101 print(("\n\nCreating the package distribution " + repr(file) + ".\n"))
102
103
104 if dist_type == 'dmg':
105
106 print("\n# Creating the Mac OS X universal application.\n\n")
107 cmd = '%s setup.py py2app' % sys.executable
108 print("%s\n" % cmd)
109 pipe = Popen(cmd, shell=True, stdin=PIPE, close_fds=False)
110 waitpid(pipe.pid, 0)
111
112
113 print("\n\n# Creating the DMG image.\n\n")
114 cmd = 'hdiutil create -ov -fs HFS+ -volname "relax" -srcfolder dist/relax.app ../%s' % file
115 print("%s\n" % cmd)
116 pipe = Popen(cmd, shell=True, stdin=PIPE, close_fds=False)
117 waitpid(pipe.pid, 0)
118
119
120 return
121
122
123 if dist_type == 'zip':
124 archive = ZipFile(path.pardir + path.sep + file, 'w', compression=8)
125
126
127 elif dist_type == 'tar':
128 if search('.bz2$', file):
129 archive = TarFile.bz2open(path.pardir + path.sep + file, 'w')
130 elif search('.gz$', file):
131 archive = TarFile.gzopen(path.pardir + path.sep + file, 'w')
132 else:
133 archive = TarFile.open(path.pardir + path.sep + file, 'w')
134
135
136 base = getcwd() + sep
137
138
139 for root, dirs, files in walk(getcwd()):
140
141 if search("\.svn", root):
142 continue
143
144
145 for i in xrange(len(files)):
146
147 if search("\.sconsign", files[i]) or search("^\.", files[i]) or search("\.pyc$", files[i]) or search("\.o$", files[i]) or search("\.os$", files[i]) or search("\.obj$", files[i]) or search("\.lib$", files[i]) or search("\.exp$", files[i]):
148 continue
149
150
151 name = path.join(root, files[i])
152 name = name[len(base):]
153 print(('relax-' + version + path.sep + name))
154
155
156 arcname = 'relax-' + version + path.sep + name
157
158
159 if dist_type == 'zip':
160 archive.write(filename=name, arcname=arcname)
161
162
163 if dist_type == 'tar':
164 archive.add(name=name, arcname=arcname)
165
166
167 archive.close()
168
169
170 print("\n\n\n")
171