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