From 6ba552cc5dafcf20522a177095447fb82cfa2040 Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Thu, 5 May 2011 17:19:00 +0000 Subject: deploy.py: support adding a build id. Add support for passing and injecting a build ID to the souces prior to compiling. Allows to easily create rebuilds of Rockbox Utility without creating false positives on update detection. Fix a typo in version.h. Thanks to sideral for noting. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29825 a1c6a512-1295-4272-9138-f99709370657 --- utils/common/deploy-rbutil.py | 5 +++-- utils/common/deploy.py | 52 ++++++++++++++++++++++++++++--------------- 2 files changed, 37 insertions(+), 20 deletions(-) (limited to 'utils') diff --git a/utils/common/deploy-rbutil.py b/utils/common/deploy-rbutil.py index 3273a295e8..31b33da4fb 100755 --- a/utils/common/deploy-rbutil.py +++ b/utils/common/deploy-rbutil.py @@ -53,8 +53,9 @@ deploy.progexe = { "linux2" : "RockboxUtility" } deploy.regreplace = { - "rbutil/rbutilqt/version.h" : ["SVN \$.*\$", "SVN r%REVISION%"], - "rbutil/rbutilqt/Info.plist" : ["SVN \$.*\$", "SVN r%REVISION%"] + "rbutil/rbutilqt/version.h" : [["SVN \$.*\$", "SVN r%REVISION%"], + ["(^#define BUILDID).*", "\\1 \"-%BUILDID%\""]], + "rbutil/rbutilqt/Info.plist" : [["SVN \$.*\$", "SVN r%REVISION%"]], } # OS X 10.6 defaults to gcc 4.2. Building universal binaries that are # compatible with 10.4 requires using gcc-4.0. diff --git a/utils/common/deploy.py b/utils/common/deploy.py index 1e48f8a56f..db97c9b291 100755 --- a/utils/common/deploy.py +++ b/utils/common/deploy.py @@ -469,9 +469,9 @@ def deploy(): startup = time.time() try: - opts, args = getopt.getopt(sys.argv[1:], "q:p:t:a:n:sbdkx:h", + opts, args = getopt.getopt(sys.argv[1:], "q:p:t:a:n:sbdkx:i:h", ["qmake=", "project=", "tag=", "add=", "makensis=", "source-only", - "binary-only", "dynamic", "keep-temp", "cross=", "help"]) + "binary-only", "dynamic", "keep-temp", "cross=", "buildid=", "help"]) except getopt.GetoptError, err: print str(err) usage(sys.argv[0]) @@ -487,6 +487,7 @@ def deploy(): keeptemp = False makensis = "" cross = "" + buildid = None platform = sys.platform if sys.platform != "darwin": static = True @@ -516,6 +517,8 @@ def deploy(): if o in ("-x", "--cross") and sys.platform != "win32": cross = a platform = "win32" + if o in ("-i", "--buildid"): + buildid = a if o in ("-h", "--help"): usage(sys.argv[0]) sys.exit(0) @@ -540,15 +543,19 @@ def deploy(): # make sure the path doesn't contain backslashes to prevent issues # later when running on windows. workfolder = re.sub(r'\\', '/', w) + if buildid == None: + versionextra = "" + else: + versionextra = "-" + buildid if not tag == "": sourcefolder = workfolder + "/" + tag + "/" - archivename = tag + "-src.tar.bz2" + archivename = tag + versionextra + "-src.tar.bz2" # get numeric version part from tag ver = "v" + re.sub('^[^\d]+', '', tag) else: trunk = gettrunkrev(svnbase) - sourcefolder = workfolder + "/" + program + "-r" + str(trunk) + "/" - archivename = program + "-r" + str(trunk) + "-src.tar.bz2" + sourcefolder = workfolder + "/" + program + "-r" + str(trunk) + versionextra + "/" + archivename = program + "-r" + str(trunk) + versionextra + "-src.tar.bz2" ver = "r" + str(trunk) os.mkdir(sourcefolder) else: @@ -563,23 +570,29 @@ def deploy(): tempclean(workfolder, cleanup and not keeptemp) sys.exit(1) - # replace version strings. Only done when building from trunk - if tag == "": - print "Updating version information in sources" - for f in regreplace: - infile = open(sourcefolder + "/" + f, "r") - incontents = infile.readlines() - infile.close() - - outfile = open(sourcefolder + "/" + f, "w") - for line in incontents: + # replace version strings. + print "Updating version information in sources" + for f in regreplace: + infile = open(sourcefolder + "/" + f, "r") + incontents = infile.readlines() + infile.close() + + outfile = open(sourcefolder + "/" + f, "w") + for line in incontents: + newline = line + for r in regreplace[f]: # replacements made on the replacement string: # %REVISION% is replaced with the revision number - replacement = re.sub("%REVISION%", str(trunk), regreplace[f][1]) - outfile.write(re.sub(regreplace[f][0], replacement, line)) - outfile.close() + replacement = re.sub("%REVISION%", str(trunk), r[1]) + # %BUILD% is replace with buildid as passed on the command line + if buildid != None: + replacement = re.sub("%BUILDID%", str(buildid), replacement) + newline = re.sub(r[0], replacement, newline) + outfile.write(newline) + outfile.close() if source == True: + print "Creating source tarball %s\n" % archivename tf = tarfile.open(archivename, mode='w:bz2') tf.add(sourcefolder, os.path.basename(re.subn('/$', '', sourcefolder)[0])) tf.close() @@ -590,6 +603,9 @@ def deploy(): # figure version from sources. Need to take path to project file into account. versionfile = re.subn('[\w\.]+$', "version.h", proj)[0] ver = findversion(versionfile) + # append buildid if any. + if buildid != None: + ver += "-" + buildid # check project file if not os.path.exists(proj): -- cgit v1.2.3