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
This commit is contained in:
Dominik Riebeling 2011-05-05 17:19:00 +00:00
parent e90d53cea8
commit 6ba552cc5d
3 changed files with 39 additions and 22 deletions

View file

@ -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()
# 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:
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):