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