summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xutils/common/deploy-rbutil.py50
-rwxr-xr-xutils/common/deploy-themeeditor.py10
-rwxr-xr-xutils/common/deploy.py149
-rwxr-xr-xutils/common/gitscraper.py58
-rwxr-xr-xutils/common/tarball.py2
5 files changed, 139 insertions, 130 deletions
diff --git a/utils/common/deploy-rbutil.py b/utils/common/deploy-rbutil.py
index 5085f18efb..2cdbdb52b5 100755
--- a/utils/common/deploy-rbutil.py
+++ b/utils/common/deploy-rbutil.py
@@ -22,30 +22,30 @@ deploy.program = "RockboxUtility"
22deploy.project = "rbutil/rbutilqt/rbutilqt.pro" 22deploy.project = "rbutil/rbutilqt/rbutilqt.pro"
23deploy.svnserver = "svn://svn.rockbox.org/rockbox/" 23deploy.svnserver = "svn://svn.rockbox.org/rockbox/"
24deploy.svnpaths = \ 24deploy.svnpaths = \
25 [ "rbutil/", 25 ["rbutil/",
26 "tools/ucl", 26 "tools/ucl",
27 "tools/rbspeex", 27 "tools/rbspeex",
28 "utils/imxtools", 28 "utils/imxtools",
29 "utils/nwztools", 29 "utils/nwztools",
30 "lib/rbcodec/codecs/libspeex", 30 "lib/rbcodec/codecs/libspeex",
31 "docs/COPYING", 31 "docs/COPYING",
32 "docs/gpl-2.0.html", 32 "docs/gpl-2.0.html",
33 "docs/logo/rockbox-clef.svg", 33 "docs/logo/rockbox-clef.svg",
34 "docs/CREDITS", 34 "docs/CREDITS",
35 "tools/iriver.c", 35 "tools/iriver.c",
36 "tools/Makefile", 36 "tools/Makefile",
37 "tools/mkboot.h", 37 "tools/mkboot.h",
38 "tools/voicefont.c", 38 "tools/voicefont.c",
39 "tools/VOICE_PAUSE.wav", 39 "tools/VOICE_PAUSE.wav",
40 "tools/voice-corrections.txt", 40 "tools/voice-corrections.txt",
41 "tools/wavtrim.h", 41 "tools/wavtrim.h",
42 "tools/iriver.h", 42 "tools/iriver.h",
43 "tools/mkboot.c", 43 "tools/mkboot.c",
44 "tools/telechips.c", 44 "tools/telechips.c",
45 "tools/telechips.h", 45 "tools/telechips.h",
46 "tools/voicefont.h", 46 "tools/voicefont.h",
47 "tools/wavtrim.c", 47 "tools/wavtrim.c",
48 "tools/sapi_voice.vbs" ] 48 "tools/sapi_voice.vbs"]
49deploy.useupx = False 49deploy.useupx = False
50deploy.bundlecopy = { 50deploy.bundlecopy = {
51 "icons/rbutilqt.icns" : "Contents/Resources/", 51 "icons/rbutilqt.icns" : "Contents/Resources/",
@@ -77,7 +77,7 @@ deploy.make = {
77# all files of the program. Will get put into an archive after building 77# all files of the program. Will get put into an archive after building
78# (zip on w32, tar.bz2 on Linux). Does not apply on Mac which uses dmg. 78# (zip on w32, tar.bz2 on Linux). Does not apply on Mac which uses dmg.
79# progexe will get added automatically. 79# progexe will get added automatically.
80deploy.programfiles = [ ] 80deploy.programfiles = list()
81deploy.nsisscript = "" 81deploy.nsisscript = ""
82 82
83deploy.deploy() 83deploy.deploy()
diff --git a/utils/common/deploy-themeeditor.py b/utils/common/deploy-themeeditor.py
index 8b66e5aef4..0b72d43985 100755
--- a/utils/common/deploy-themeeditor.py
+++ b/utils/common/deploy-themeeditor.py
@@ -22,13 +22,13 @@ deploy.program = "rbthemeeditor"
22deploy.project = "utils/themeeditor/themeeditor.pro" 22deploy.project = "utils/themeeditor/themeeditor.pro"
23deploy.svnserver = "svn://svn.rockbox.org/rockbox/" 23deploy.svnserver = "svn://svn.rockbox.org/rockbox/"
24deploy.svnpaths = \ 24deploy.svnpaths = \
25 [ "utils/themeeditor/", 25 ["utils/themeeditor/",
26 "lib/skin_parser/", 26 "lib/skin_parser/",
27 "docs/COPYING" ] 27 "docs/COPYING"]
28deploy.useupx = False 28deploy.useupx = False
29deploy.bundlecopy = { 29deploy.bundlecopy = {
30 "resources/windowicon.icns" : "Contents/Resources/", 30 "resources/windowicon.icns" : "Contents/Resources/",
31 "Info.plist" : "Contents/" 31 "Info.plist" : "Contents/"
32} 32}
33deploy.progexe = { 33deploy.progexe = {
34 "win32" : "release/rbthemeeditor.exe", 34 "win32" : "release/rbthemeeditor.exe",
@@ -52,7 +52,7 @@ deploy.make = {
52# all files of the program. Will get put into an archive after building 52# all files of the program. Will get put into an archive after building
53# (zip on w32, tar.bz2 on Linux). Does not apply on Mac which uses dmg. 53# (zip on w32, tar.bz2 on Linux). Does not apply on Mac which uses dmg.
54# progexe will get added automatically. 54# progexe will get added automatically.
55deploy.programfiles = [ ] 55deploy.programfiles = list()
56deploy.nsisscript = "utils/themeeditor/themeeditor.nsi" 56deploy.nsisscript = "utils/themeeditor/themeeditor.nsi"
57 57
58deploy.deploy() 58deploy.deploy()
diff --git a/utils/common/deploy.py b/utils/common/deploy.py
index 571424756b..e0bb7029b8 100755
--- a/utils/common/deploy.py
+++ b/utils/common/deploy.py
@@ -43,21 +43,21 @@ import getopt
43import time 43import time
44import hashlib 44import hashlib
45import tempfile 45import tempfile
46import gitscraper
47from datetime import datetime 46from datetime import datetime
47import gitscraper
48 48
49# modules that are not part of python itself. 49# modules that are not part of python itself.
50cpus = 1 50cpus = 1
51try: 51try:
52 import multiprocessing 52 import multiprocessing
53 cpus = multiprocessing.cpu_count() 53 cpus = multiprocessing.cpu_count()
54 print "Info: %s cores found." % cpus 54 print("Info: %s cores found." % cpus)
55except ImportError: 55except ImportError:
56 print "Warning: multiprocessing module not found. Assuming 1 core." 56 print("Warning: multiprocessing module not found. Assuming 1 core.")
57 57
58# == Global stuff == 58# == Global stuff ==
59# DLL files to ignore when searching for required DLL files. 59# DLL files to ignore when searching for required DLL files.
60systemdlls = [ 60SYSTEMDLLS = [
61 'advapi32.dll', 61 'advapi32.dll',
62 'comdlg32.dll', 62 'comdlg32.dll',
63 'crypt32.dll', 63 'crypt32.dll',
@@ -94,23 +94,23 @@ gitrepo = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
94 94
95# == Functions == 95# == Functions ==
96def usage(myself): 96def usage(myself):
97 print "Usage: %s [options]" % myself 97 print("Usage: %s [options]" % myself)
98 print " -q, --qmake=<qmake> path to qmake" 98 print(" -q, --qmake=<qmake> path to qmake")
99 print " -p, --project=<pro> path to .pro file for building with local tree" 99 print(" -p, --project=<pro> path to .pro file for building with local tree")
100 print " -t, --tag=<tag> use specified tag from svn" 100 print(" -t, --tag=<tag> use specified tag from svn")
101 print " -a, --add=<file> add file to build folder before building" 101 print(" -a, --add=<file> add file to build folder before building")
102 print " -s, --source-only only create source archive" 102 print(" -s, --source-only only create source archive")
103 print " -b, --binary-only only create binary archive" 103 print(" -b, --binary-only only create binary archive")
104 if nsisscript != "": 104 if nsisscript != "":
105 print " -n, --makensis=<file> path to makensis for building Windows setup program." 105 print(" -n, --makensis=<file> path to makensis for building Windows setup program.")
106 if sys.platform != "darwin": 106 if sys.platform != "darwin":
107 print " -d, --dynamic link dynamically instead of static" 107 print(" -d, --dynamic link dynamically instead of static")
108 if sys.platform != "win32": 108 if sys.platform != "win32":
109 print " -x, --cross= prefix to cross compile for win32" 109 print(" -x, --cross= prefix to cross compile for win32")
110 print " -k, --keep-temp keep temporary folder on build failure" 110 print(" -k, --keep-temp keep temporary folder on build failure")
111 print " -h, --help this help" 111 print(" -h, --help this help")
112 print " If neither a project file nor tag is specified trunk will get downloaded" 112 print(" If neither a project file nor tag is specified trunk will get downloaded")
113 print " from svn." 113 print(" from svn.")
114 114
115 115
116def which(executable): 116def which(executable):
@@ -119,7 +119,7 @@ def which(executable):
119 fullpath = p + "/" + executable 119 fullpath = p + "/" + executable
120 if os.path.exists(fullpath): 120 if os.path.exists(fullpath):
121 return fullpath 121 return fullpath
122 print "which: could not find " + executable 122 print("which: could not find " + executable)
123 return "" 123 return ""
124 124
125 125
@@ -152,7 +152,7 @@ def findversion(versionfile):
152 152
153def findqt(cross=""): 153def findqt(cross=""):
154 '''Search for Qt4 installation. Return path to qmake.''' 154 '''Search for Qt4 installation. Return path to qmake.'''
155 print "Searching for Qt" 155 print("Searching for Qt")
156 bins = [cross + "qmake", cross + "qmake-qt4"] 156 bins = [cross + "qmake", cross + "qmake-qt4"]
157 for binary in bins: 157 for binary in bins:
158 try: 158 try:
@@ -162,7 +162,7 @@ def findqt(cross=""):
162 if not result == "": 162 if not result == "":
163 return result 163 return result
164 except: 164 except:
165 print sys.exc_value 165 print(sys.exc_value)
166 166
167 return "" 167 return ""
168 168
@@ -172,27 +172,27 @@ def checkqt(qmakebin):
172 result = "" 172 result = ""
173 # check if binary exists 173 # check if binary exists
174 if not os.path.exists(qmakebin): 174 if not os.path.exists(qmakebin):
175 print "Specified qmake path does not exist!" 175 print("Specified qmake path does not exist!")
176 return result 176 return result
177 # check version 177 # check version
178 output = subprocess.Popen([qmakebin, "-version"], stdout=subprocess.PIPE, 178 output = subprocess.Popen(
179 stderr=subprocess.PIPE) 179 [qmakebin, "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
180 cmdout = output.communicate() 180 cmdout = output.communicate()
181 # don't check the qmake return code here, Qt3 doesn't return 0 on -version. 181 # don't check the qmake return code here, Qt3 doesn't return 0 on -version.
182 for ou in cmdout: 182 for ou in cmdout:
183 r = re.compile("Qt[^0-9]+([0-9\.]+[a-z]*)") 183 r = re.compile("Qt[^0-9]+([0-9\.]+[a-z]*)")
184 m = re.search(r, ou) 184 m = re.search(r, ou)
185 if not m == None: 185 if not m == None:
186 print "Qt found: %s" % m.group(1) 186 print("Qt found: %s" % m.group(1))
187 s = re.compile("[45]\..*") 187 s = re.compile("[45]\..*")
188 n = re.search(s, m.group(1)) 188 n = re.search(s, m.group(1))
189 if not n == None: 189 if n is not None:
190 result = qmakebin 190 result = qmakebin
191 return result 191 return result
192 192
193 193
194def qmake(qmake, projfile, platform=sys.platform, wd=".", static=True, cross=""): 194def qmake(qmake, projfile, platform=sys.platform, wd=".", static=True, cross=""):
195 print "Running qmake in %s..." % wd 195 print("Running qmake in %s..." % wd)
196 command = [qmake, "-config", "release", "-config", "noccache"] 196 command = [qmake, "-config", "release", "-config", "noccache"]
197 if static == True: 197 if static == True:
198 command.extend(["-config", "-static"]) 198 command.extend(["-config", "-static"])
@@ -206,14 +206,14 @@ def qmake(qmake, projfile, platform=sys.platform, wd=".", static=True, cross="")
206 output = subprocess.Popen(command, stdout=subprocess.PIPE, cwd=wd) 206 output = subprocess.Popen(command, stdout=subprocess.PIPE, cwd=wd)
207 output.communicate() 207 output.communicate()
208 if not output.returncode == 0: 208 if not output.returncode == 0:
209 print "qmake returned an error!" 209 print("qmake returned an error!")
210 return -1 210 return -1
211 return 0 211 return 0
212 212
213 213
214def build(wd=".", platform=sys.platform, cross=""): 214def build(wd=".", platform=sys.platform, cross=""):
215 # make 215 # make
216 print "Building ..." 216 print("Building ...")
217 # use the current platforms make here, cross compiling uses the native make. 217 # use the current platforms make here, cross compiling uses the native make.
218 command = [make[sys.platform]] 218 command = [make[sys.platform]]
219 if cpus > 1: 219 if cpus > 1:
@@ -228,36 +228,36 @@ def build(wd=".", platform=sys.platform, cross=""):
228 sys.stdout.write("\n") 228 sys.stdout.write("\n")
229 sys.stdout.flush() 229 sys.stdout.flush()
230 if not output.returncode == 0: 230 if not output.returncode == 0:
231 print "Build failed!" 231 print("Build failed!")
232 return -1 232 return -1
233 break 233 break
234 if platform != "darwin": 234 if platform != "darwin":
235 # strip. OS X handles this via macdeployqt. 235 # strip. OS X handles this via macdeployqt.
236 print "Stripping binary." 236 print("Stripping binary.")
237 output = subprocess.Popen([cross + "strip", progexe[platform]], \ 237 output = subprocess.Popen([cross + "strip", progexe[platform]], \
238 stdout=subprocess.PIPE, cwd=wd) 238 stdout=subprocess.PIPE, cwd=wd)
239 output.communicate() 239 output.communicate()
240 if not output.returncode == 0: 240 if not output.returncode == 0:
241 print "Stripping failed!" 241 print("Stripping failed!")
242 return -1 242 return -1
243 return 0 243 return 0
244 244
245 245
246def upxfile(wd=".", platform=sys.platform): 246def upxfile(wd=".", platform=sys.platform):
247 # run upx on binary 247 # run upx on binary
248 print "UPX'ing binary ..." 248 print("UPX'ing binary ...")
249 output = subprocess.Popen(["upx", progexe[platform]], \ 249 output = subprocess.Popen(["upx", progexe[platform]], \
250 stdout=subprocess.PIPE, cwd=wd) 250 stdout=subprocess.PIPE, cwd=wd)
251 output.communicate() 251 output.communicate()
252 if not output.returncode == 0: 252 if not output.returncode == 0:
253 print "UPX'ing failed!" 253 print("UPX'ing failed!")
254 return -1 254 return -1
255 return 0 255 return 0
256 256
257 257
258def runnsis(versionstring, nsis, script, srcfolder): 258def runnsis(versionstring, nsis, script, srcfolder):
259 # run script through nsis to create installer. 259 # run script through nsis to create installer.
260 print "Running NSIS ..." 260 print("Running NSIS ...")
261 261
262 # Assume the generated installer gets placed in the same folder the nsi 262 # Assume the generated installer gets placed in the same folder the nsi
263 # script lives in. This seems to be a valid assumption unless the nsi 263 # script lives in. This seems to be a valid assumption unless the nsi
@@ -276,7 +276,7 @@ def runnsis(versionstring, nsis, script, srcfolder):
276 stdout=subprocess.PIPE) 276 stdout=subprocess.PIPE)
277 output.communicate() 277 output.communicate()
278 if not output.returncode == 0: 278 if not output.returncode == 0:
279 print "NSIS failed!" 279 print("NSIS failed!")
280 return -1 280 return -1
281 setupfile = program + "-" + versionstring + "-setup.exe" 281 setupfile = program + "-" + versionstring + "-setup.exe"
282 # find output filename in nsis script file 282 # find output filename in nsis script file
@@ -285,7 +285,7 @@ def runnsis(versionstring, nsis, script, srcfolder):
285 if re.match(r'^[^;]*OutFile\s+', line) != None: 285 if re.match(r'^[^;]*OutFile\s+', line) != None:
286 nsissetup = re.sub(r'^[^;]*OutFile\s+"(.+)"', r'\1', line).rstrip() 286 nsissetup = re.sub(r'^[^;]*OutFile\s+"(.+)"', r'\1', line).rstrip()
287 if nsissetup == "": 287 if nsissetup == "":
288 print "Could not retrieve output file name!" 288 print("Could not retrieve output file name!")
289 return -1 289 return -1
290 shutil.copy(srcfolder + "/" + os.path.dirname(script) + "/" + nsissetup, \ 290 shutil.copy(srcfolder + "/" + os.path.dirname(script) + "/" + nsissetup, \
291 setupfile) 291 setupfile)
@@ -330,29 +330,29 @@ def finddlls(program, extrapaths=[], cross=""):
330 # find DLLs in extrapaths and PATH environment variable. 330 # find DLLs in extrapaths and PATH environment variable.
331 dllpaths = [] 331 dllpaths = []
332 for file in dlls: 332 for file in dlls:
333 if file in systemdlls: 333 if file in SYSTEMDLLS:
334 print "System DLL: " + file 334 print("System DLL: " + file)
335 continue 335 continue
336 dllpath = "" 336 dllpath = ""
337 for path in extrapaths: 337 for path in extrapaths:
338 if os.path.exists(path + "/" + file): 338 if os.path.exists(path + "/" + file):
339 dllpath = re.sub(r"\\", r"/", path + "/" + file) 339 dllpath = re.sub(r"\\", r"/", path + "/" + file)
340 print file + ": found at " + dllpath 340 print(file + ": found at " + dllpath)
341 dllpaths.append(dllpath) 341 dllpaths.append(dllpath)
342 break 342 break
343 if dllpath == "": 343 if dllpath == "":
344 try: 344 try:
345 dllpath = re.sub(r"\\", r"/", which(file)) 345 dllpath = re.sub(r"\\", r"/", which(file))
346 print file + ": found at " + dllpath 346 print(file + ": found at " + dllpath)
347 dllpaths.append(dllpath) 347 dllpaths.append(dllpath)
348 except: 348 except:
349 print "MISSING DLL: " + file 349 print("MISSING DLL: " + file)
350 return dllpaths 350 return dllpaths
351 351
352 352
353def zipball(programfiles, versionstring, buildfolder, platform=sys.platform): 353def zipball(programfiles, versionstring, buildfolder, platform=sys.platform):
354 '''package created binary''' 354 '''package created binary'''
355 print "Creating binary zipball." 355 print("Creating binary zipball.")
356 archivebase = program + "-" + versionstring 356 archivebase = program + "-" + versionstring
357 outfolder = buildfolder + "/" + archivebase 357 outfolder = buildfolder + "/" + archivebase
358 archivename = archivebase + ".zip" 358 archivename = archivebase + ".zip"
@@ -379,7 +379,7 @@ def zipball(programfiles, versionstring, buildfolder, platform=sys.platform):
379 379
380def tarball(programfiles, versionstring, buildfolder): 380def tarball(programfiles, versionstring, buildfolder):
381 '''package created binary''' 381 '''package created binary'''
382 print "Creating binary tarball." 382 print("Creating binary tarball.")
383 archivebase = program + "-" + versionstring 383 archivebase = program + "-" + versionstring
384 outfolder = buildfolder + "/" + archivebase 384 outfolder = buildfolder + "/" + archivebase
385 archivename = archivebase + ".tar.bz2" 385 archivename = archivebase + ".tar.bz2"
@@ -404,7 +404,7 @@ def macdeploy(versionstring, buildfolder, platform=sys.platform):
404 404
405 # workaround to Qt issues when building out-of-tree. Copy files into bundle. 405 # workaround to Qt issues when building out-of-tree. Copy files into bundle.
406 sourcebase = buildfolder + re.sub('[^/]+.pro$', '', project) + "/" 406 sourcebase = buildfolder + re.sub('[^/]+.pro$', '', project) + "/"
407 print sourcebase 407 print(sourcebase)
408 for src in bundlecopy: 408 for src in bundlecopy:
409 shutil.copy(sourcebase + src, appbundle + "/" + bundlecopy[src]) 409 shutil.copy(sourcebase + src, appbundle + "/" + bundlecopy[src])
410 # end of Qt workaround 410 # end of Qt workaround
@@ -413,7 +413,7 @@ def macdeploy(versionstring, buildfolder, platform=sys.platform):
413 stdout=subprocess.PIPE, cwd=buildfolder) 413 stdout=subprocess.PIPE, cwd=buildfolder)
414 output.communicate() 414 output.communicate()
415 if not output.returncode == 0: 415 if not output.returncode == 0:
416 print "macdeployqt failed!" 416 print("macdeployqt failed!")
417 return -1 417 return -1
418 # copy dmg to output folder 418 # copy dmg to output folder
419 shutil.copy(buildfolder + "/" + program + ".dmg", dmgfile) 419 shutil.copy(buildfolder + "/" + program + ".dmg", dmgfile)
@@ -440,32 +440,33 @@ def filestats(filename):
440 if not os.path.exists(filename): 440 if not os.path.exists(filename):
441 return 441 return
442 st = os.stat(filename) 442 st = os.stat(filename)
443 print filename, "\n", "-" * len(filename) 443 print(filename, "\n", "-" * len(filename))
444 print "Size: %i bytes" % st.st_size 444 print("Size: %i bytes" % st.st_size)
445 h = filehashes(filename) 445 h = filehashes(filename)
446 print "md5sum: %s" % h[0] 446 print("md5sum: %s" % h[0])
447 print "sha1sum: %s" % h[1] 447 print("sha1sum: %s" % h[1])
448 print "-" * len(filename), "\n" 448 print("-" * len(filename), "\n")
449 449
450 450
451def tempclean(workfolder, nopro): 451def tempclean(workfolder, nopro):
452 if nopro == True: 452 if nopro == True:
453 print "Cleaning up working folder %s" % workfolder 453 print("Cleaning up working folder %s" % workfolder)
454 shutil.rmtree(workfolder) 454 shutil.rmtree(workfolder)
455 else: 455 else:
456 print "Project file specified or cleanup disabled!" 456 print("Project file specified or cleanup disabled!")
457 print "Temporary files kept at %s" % workfolder 457 print("Temporary files kept at %s" % workfolder)
458 458
459 459
460def deploy(): 460def deploy():
461 startup = time.time() 461 startup = time.time()
462 462
463 try: 463 try:
464 opts, args = getopt.getopt(sys.argv[1:], "q:p:t:a:n:sbdkx:i:h", 464 opts, args = getopt.getopt(
465 sys.argv[1:], "q:p:t:a:n:sbdkx:i:h",
465 ["qmake=", "project=", "tag=", "add=", "makensis=", "source-only", 466 ["qmake=", "project=", "tag=", "add=", "makensis=", "source-only",
466 "binary-only", "dynamic", "keep-temp", "cross=", "buildid=", "help"]) 467 "binary-only", "dynamic", "keep-temp", "cross=", "buildid=", "help"])
467 except getopt.GetoptError, err: 468 except getopt.GetoptError as err:
468 print str(err) 469 print(str(err))
469 usage(sys.argv[0]) 470 usage(sys.argv[0])
470 sys.exit(1) 471 sys.exit(1)
471 qt = "" 472 qt = ""
@@ -516,17 +517,17 @@ def deploy():
516 sys.exit(0) 517 sys.exit(0)
517 518
518 if source == False and binary == False: 519 if source == False and binary == False:
519 print "Building build neither source nor binary means nothing to do. Exiting." 520 print("Building build neither source nor binary means nothing to do. Exiting.")
520 sys.exit(1) 521 sys.exit(1)
521 522
522 print "Building " + progexe[platform] + " for " + platform 523 print("Building " + progexe[platform] + " for " + platform)
523 # search for qmake 524 # search for qmake
524 if qt == "": 525 if qt == "":
525 qm = findqt(cross) 526 qm = findqt(cross)
526 else: 527 else:
527 qm = checkqt(qt) 528 qm = checkqt(qt)
528 if qm == "": 529 if qm == "":
529 print "ERROR: No suitable Qt installation found." 530 print("ERROR: No suitable Qt installation found.")
530 sys.exit(1) 531 sys.exit(1)
531 532
532 # create working folder. Use current directory if -p option used. 533 # create working folder. Use current directory if -p option used.
@@ -552,7 +553,7 @@ def deploy():
552 archivename = program + "-" + str(revision) + versionextra + "-src.tar.bz2" 553 archivename = program + "-" + str(revision) + versionextra + "-src.tar.bz2"
553 ver = str(revision) 554 ver = str(revision)
554 os.mkdir(sourcefolder) 555 os.mkdir(sourcefolder)
555 print "Version: %s" % revision 556 print("Version: %s" % revision)
556 else: 557 else:
557 workfolder = "." 558 workfolder = "."
558 sourcefolder = "." 559 sourcefolder = "."
@@ -561,12 +562,12 @@ def deploy():
561 if proj == "": 562 if proj == "":
562 proj = sourcefolder + project 563 proj = sourcefolder + project
563 # get sources and pack source tarball 564 # get sources and pack source tarball
564 if not getsources(treehash, svnpaths, sourcefolder) == 0: 565 if getsources(treehash, svnpaths, sourcefolder) != 0:
565 tempclean(workfolder, cleanup and not keeptemp) 566 tempclean(workfolder, cleanup and not keeptemp)
566 sys.exit(1) 567 sys.exit(1)
567 568
568 # replace version strings. 569 # replace version strings.
569 print "Updating version information in sources" 570 print("Updating version information in sources")
570 for f in regreplace: 571 for f in regreplace:
571 infile = open(sourcefolder + "/" + f, "r") 572 infile = open(sourcefolder + "/" + f, "r")
572 incontents = infile.readlines() 573 incontents = infile.readlines()
@@ -590,7 +591,7 @@ def deploy():
590 outfile.close() 591 outfile.close()
591 592
592 if source == True: 593 if source == True:
593 print "Creating source tarball %s\n" % archivename 594 print("Creating source tarball %s\n" % archivename)
594 tf = tarfile.open(archivename, mode='w:bz2') 595 tf = tarfile.open(archivename, mode='w:bz2')
595 tf.add(sourcefolder, os.path.basename(re.subn('/$', '', sourcefolder)[0])) 596 tf.add(sourcefolder, os.path.basename(re.subn('/$', '', sourcefolder)[0]))
596 tf.close() 597 tf.close()
@@ -607,7 +608,7 @@ def deploy():
607 608
608 # check project file 609 # check project file
609 if not os.path.exists(proj): 610 if not os.path.exists(proj):
610 print "ERROR: path to project file wrong." 611 print("ERROR: path to project file wrong.")
611 sys.exit(1) 612 sys.exit(1)
612 613
613 # copy specified (--add) files to working folder 614 # copy specified (--add) files to working folder
@@ -615,8 +616,8 @@ def deploy():
615 shutil.copy(f, sourcefolder) 616 shutil.copy(f, sourcefolder)
616 buildstart = time.time() 617 buildstart = time.time()
617 header = "Building %s %s" % (program, ver) 618 header = "Building %s %s" % (program, ver)
618 print header 619 print(header)
619 print len(header) * "=" 620 print(len(header) * "=")
620 621
621 # build it. 622 # build it.
622 if not qmake(qm, proj, platform, sourcefolder, static, cross) == 0: 623 if not qmake(qm, proj, platform, sourcefolder, static, cross) == 0:
@@ -649,8 +650,8 @@ def deploy():
649 if platform == "linux2": 650 if platform == "linux2":
650 for p in progfiles: 651 for p in progfiles:
651 prog = sourcefolder + "/" + p 652 prog = sourcefolder + "/" + p
652 output = subprocess.Popen(["file", prog], 653 output = subprocess.Popen(
653 stdout=subprocess.PIPE) 654 ["file", prog], stdout=subprocess.PIPE)
654 res = output.communicate() 655 res = output.communicate()
655 if re.findall("ELF 64-bit", res[0]): 656 if re.findall("ELF 64-bit", res[0]):
656 ver += "-64bit" 657 ver += "-64bit"
@@ -663,7 +664,7 @@ def deploy():
663 664
664 # display summary 665 # display summary
665 headline = "Build Summary for %s" % program 666 headline = "Build Summary for %s" % program
666 print "\n", headline, "\n", "=" * len(headline) 667 print("\n", headline, "\n", "=" * len(headline))
667 if not archivename == "": 668 if not archivename == "":
668 filestats(archivename) 669 filestats(archivename)
669 filestats(archive) 670 filestats(archive)
@@ -672,10 +673,10 @@ def deploy():
672 dursecs = (int)(duration % 60) 673 dursecs = (int)(duration % 60)
673 buildmins = (int)(buildtime / 60) 674 buildmins = (int)(buildtime / 60)
674 buildsecs = (int)(buildtime % 60) 675 buildsecs = (int)(buildtime % 60)
675 print "Overall time %smin %ssec, building took %smin %ssec." % \ 676 print("Overall time %smin %ssec, building took %smin %ssec." % \
676 (durmins, dursecs, buildmins, buildsecs) 677 (durmins, dursecs, buildmins, buildsecs))
677 678
678 679
679if __name__ == "__main__": 680if __name__ == "__main__":
680 print "You cannot run this module directly!" 681 print("You cannot run this module directly!")
681 print "Set required environment and call deploy()." 682 print("Set required environment and call deploy().")
diff --git a/utils/common/gitscraper.py b/utils/common/gitscraper.py
index 86d6a980cd..496d32bce3 100755
--- a/utils/common/gitscraper.py
+++ b/utils/common/gitscraper.py
@@ -42,10 +42,11 @@ def get_refs(repo):
42 @return Dict matching hashes to each ref. 42 @return Dict matching hashes to each ref.
43 ''' 43 '''
44 print("Getting list of refs") 44 print("Getting list of refs")
45 output = subprocess.Popen(["git", "show-ref", "--abbrev"], 45 output = subprocess.Popen(
46 stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo) 46 ["git", "show-ref", "--abbrev"],
47 stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo)
47 cmdout = output.communicate() 48 cmdout = output.communicate()
48 refs = {} 49 refs = dict()
49 50
50 if len(cmdout[1]) > 0: 51 if len(cmdout[1]) > 0:
51 print("An error occured!\n") 52 print("An error occured!\n")
@@ -53,7 +54,7 @@ def get_refs(repo):
53 return refs 54 return refs
54 55
55 for line in cmdout: 56 for line in cmdout:
56 regex = re.findall(b'([a-f0-9]+)\s+(\S+)', line) 57 regex = re.findall(b'([a-f0-9]+)\\s+(\\S+)', line)
57 for r in regex: 58 for r in regex:
58 # ref is the key, hash its value. 59 # ref is the key, hash its value.
59 refs[r[1].decode()] = r[0].decode() 60 refs[r[1].decode()] = r[0].decode()
@@ -61,7 +62,7 @@ def get_refs(repo):
61 return refs 62 return refs
62 63
63 64
64def get_lstree(repo, start, filterlist=[]): 65def get_lstree(repo, start, filterlist=None):
65 '''Get recursive list of tree objects for a given tree. 66 '''Get recursive list of tree objects for a given tree.
66 @param repo Path to repository root. 67 @param repo Path to repository root.
67 @param start Hash identifying the tree. 68 @param start Hash identifying the tree.
@@ -69,10 +70,13 @@ def get_lstree(repo, start, filterlist=[]):
69 An empty list will retrieve all paths. 70 An empty list will retrieve all paths.
70 @return Dict mapping filename to blob hash 71 @return Dict mapping filename to blob hash
71 ''' 72 '''
72 output = subprocess.Popen(["git", "ls-tree", "-r", start], 73 if filterlist is None:
73 stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo) 74 filterlist = list()
75 output = subprocess.Popen(
76 ["git", "ls-tree", "-r", start],
77 stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo)
74 cmdout = output.communicate() 78 cmdout = output.communicate()
75 objects = {} 79 objects = dict()
76 80
77 if len(cmdout[1]) > 0: 81 if len(cmdout[1]) > 0:
78 print("An error occured!\n") 82 print("An error occured!\n")
@@ -80,8 +84,8 @@ def get_lstree(repo, start, filterlist=[]):
80 return objects 84 return objects
81 85
82 for line in cmdout[0].decode().split('\n'): 86 for line in cmdout[0].decode().split('\n'):
83 regex = re.findall(b'([0-9]+)\s+([a-z]+)\s+([0-9a-f]+)\s+(.*)', 87 regex = re.findall(b'([0-9]+)\\s+([a-z]+)\\s+([0-9a-f]+)\\s+(.*)',
84 line.encode()) 88 line.encode())
85 for rf in regex: 89 for rf in regex:
86 # filter 90 # filter
87 add = False 91 add = False
@@ -107,8 +111,8 @@ def get_file_timestamp(repo, tree, filename):
107 @return Timestamp as string. 111 @return Timestamp as string.
108 ''' 112 '''
109 output = subprocess.Popen( 113 output = subprocess.Popen(
110 ["git", "log", "--format=%ai", "-n", "1", tree, filename], 114 ["git", "log", "--format=%ai", "-n", "1", tree, filename],
111 stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo) 115 stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo)
112 cmdout = output.communicate() 116 cmdout = output.communicate()
113 117
114 return cmdout[0].decode().rstrip() 118 return cmdout[0].decode().rstrip()
@@ -121,8 +125,9 @@ def get_object(repo, blob, destfile):
121 @param destfile filename for blob output. 125 @param destfile filename for blob output.
122 @return True if file was successfully written, False on error. 126 @return True if file was successfully written, False on error.
123 ''' 127 '''
124 output = subprocess.Popen(["git", "cat-file", "-p", blob], 128 output = subprocess.Popen(
125 stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo) 129 ["git", "cat-file", "-p", blob],
130 stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo)
126 cmdout = output.communicate() 131 cmdout = output.communicate()
127 # make sure output path exists 132 # make sure output path exists
128 if len(cmdout[1]) > 0: 133 if len(cmdout[1]) > 0:
@@ -143,8 +148,9 @@ def describe_treehash(repo, treehash):
143 @param treehash Hash identifying the tree / commit to describe. 148 @param treehash Hash identifying the tree / commit to describe.
144 @return Description string. 149 @return Description string.
145 ''' 150 '''
146 output = subprocess.Popen(["git", "describe", treehash], 151 output = subprocess.Popen(
147 stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo) 152 ["git", "describe", treehash],
153 stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=repo)
148 cmdout = output.communicate() 154 cmdout = output.communicate()
149 if len(cmdout[1]) > 0: 155 if len(cmdout[1]) > 0:
150 print("An error occured!\n") 156 print("An error occured!\n")
@@ -153,7 +159,7 @@ def describe_treehash(repo, treehash):
153 return cmdout[0].rstrip() 159 return cmdout[0].rstrip()
154 160
155 161
156def scrape_files(repo, treehash, filelist, dest="", timestamp_files=[]): 162def scrape_files(repo, treehash, filelist, dest=None, timestamp_files=None):
157 '''Scrape list of files from repository. 163 '''Scrape list of files from repository.
158 @param repo Path to repository root. 164 @param repo Path to repository root.
159 @param treehash Hash identifying the tree. 165 @param treehash Hash identifying the tree.
@@ -167,7 +173,9 @@ def scrape_files(repo, treehash, filelist, dest="", timestamp_files=[]):
167 ''' 173 '''
168 print("Scraping files from repository") 174 print("Scraping files from repository")
169 175
170 if dest == "": 176 if timestamp_files is None:
177 timestamp_files = list()
178 if dest is None:
171 dest = tempfile.mkdtemp() 179 dest = tempfile.mkdtemp()
172 treeobjects = get_lstree(repo, treehash, filelist) 180 treeobjects = get_lstree(repo, treehash, filelist)
173 timestamps = {} 181 timestamps = {}
@@ -180,8 +188,8 @@ def scrape_files(repo, treehash, filelist, dest="", timestamp_files=[]):
180 return [dest, timestamps] 188 return [dest, timestamps]
181 189
182 190
183def archive_files(repo, treehash, filelist, basename, tmpfolder="", 191def archive_files(repo, treehash, filelist, basename, tmpfolder=None,
184 archive="tbz"): 192 archive="tbz"):
185 '''Archive list of files into tarball. 193 '''Archive list of files into tarball.
186 @param repo Path to repository root. 194 @param repo Path to repository root.
187 @param treehash Hash identifying the tree. 195 @param treehash Hash identifying the tree.
@@ -197,20 +205,20 @@ def archive_files(repo, treehash, filelist, basename, tmpfolder="",
197 @return Output filename. 205 @return Output filename.
198 ''' 206 '''
199 207
200 if tmpfolder == "": 208 if tmpfolder is None:
201 temp_remove = True 209 temp_remove = True
202 tmpfolder = tempfile.mkdtemp() 210 tmpfolder = tempfile.mkdtemp()
203 else: 211 else:
204 temp_remove = False 212 temp_remove = False
205 workfolder = scrape_files(repo, treehash, filelist, 213 workfolder = scrape_files(
206 os.path.join(tmpfolder, basename))[0] 214 repo, treehash, filelist, os.path.join(tmpfolder, basename))[0]
207 if basename is "": 215 if basename is "":
208 return "" 216 return ""
209 print("Archiving files from repository") 217 print("Archiving files from repository")
210 if archive == "7z": 218 if archive == "7z":
211 outfile = basename + ".7z" 219 outfile = basename + ".7z"
212 output = subprocess.Popen(["7z", "a", 220 output = subprocess.Popen(
213 os.path.join(os.getcwd(), basename + ".7z"), basename], 221 ["7z", "a", os.path.join(os.getcwd(), basename + ".7z"), basename],
214 cwd=tmpfolder, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 222 cwd=tmpfolder, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
215 output.communicate() 223 output.communicate()
216 elif archive == "tbz": 224 elif archive == "tbz":
diff --git a/utils/common/tarball.py b/utils/common/tarball.py
index 2e32776702..3fda206002 100755
--- a/utils/common/tarball.py
+++ b/utils/common/tarball.py
@@ -1,8 +1,8 @@
1#!/usr/bin/python 1#!/usr/bin/python
2 2
3import gitscraper
4import os 3import os
5import sys 4import sys
5import gitscraper
6 6
7if len(sys.argv) < 2: 7if len(sys.argv) < 2:
8 print("Usage: %s <version|hash>" % sys.argv[0]) 8 print("Usage: %s <version|hash>" % sys.argv[0])