2009-06-18 22:17:17 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
# __________ __ ___.
|
|
|
|
# Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
# \/ \/ \/ \/ \/
|
|
|
|
# $Id$
|
|
|
|
#
|
|
|
|
# Copyright (c) 2009 Dominik Riebeling
|
|
|
|
#
|
|
|
|
# All files in this archive are subject to the GNU General Public License.
|
|
|
|
# See the file COPYING in the source tree root for full license agreement.
|
|
|
|
#
|
|
|
|
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
# KIND, either express or implied.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Automate building releases for deployment.
|
2009-10-04 16:45:59 +00:00
|
|
|
# Run from any folder to build
|
|
|
|
# - trunk
|
|
|
|
# - any tag (using the -t option)
|
|
|
|
# - any local folder (using the -p option)
|
|
|
|
# Will build a binary archive (tar.bz2 / zip) and source archive.
|
|
|
|
# The source archive won't be built for local builds. Trunk and
|
|
|
|
# tag builds will retrieve the sources directly from svn and build
|
|
|
|
# below the systems temporary folder.
|
|
|
|
#
|
2009-06-18 22:17:17 +00:00
|
|
|
# If the required Qt installation isn't in PATH use --qmake option.
|
|
|
|
# Tested on Linux and MinGW / W32
|
|
|
|
#
|
|
|
|
# requires python which package (http://code.google.com/p/which/)
|
2009-10-04 16:45:59 +00:00
|
|
|
# requires pysvn package.
|
2009-06-18 22:17:17 +00:00
|
|
|
# requires upx.exe in PATH on Windows.
|
|
|
|
#
|
|
|
|
|
|
|
|
import re
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import tarfile
|
|
|
|
import zipfile
|
|
|
|
import shutil
|
|
|
|
import subprocess
|
|
|
|
import getopt
|
2009-09-20 14:59:29 +00:00
|
|
|
import time
|
2009-10-04 16:45:59 +00:00
|
|
|
import hashlib
|
|
|
|
import tempfile
|
2009-06-18 22:17:17 +00:00
|
|
|
|
2009-10-30 21:40:07 +00:00
|
|
|
# modules that are not part of python itself.
|
|
|
|
try:
|
|
|
|
import pysvn
|
|
|
|
except ImportError:
|
|
|
|
print "Fatal: This script requires the pysvn package to run."
|
|
|
|
print " See http://pysvn.tigris.org/."
|
|
|
|
sys.exit(-5)
|
|
|
|
try:
|
|
|
|
import which
|
|
|
|
except ImportError:
|
|
|
|
print "Fatal: This script requires the which package to run."
|
|
|
|
print " See http://code.google.com/p/which/."
|
|
|
|
sys.exit(-5)
|
|
|
|
|
2009-06-18 22:17:17 +00:00
|
|
|
# == Global stuff ==
|
|
|
|
# Windows nees some special treatment. Differentiate between program name
|
|
|
|
# and executable filename.
|
2010-07-28 18:37:12 +00:00
|
|
|
program = ""
|
|
|
|
project = ""
|
2009-11-29 21:09:21 +00:00
|
|
|
environment = os.environ
|
2010-07-28 18:37:12 +00:00
|
|
|
progexe = ""
|
2009-11-29 21:09:21 +00:00
|
|
|
make = "make"
|
2010-07-28 18:37:12 +00:00
|
|
|
programfiles = []
|
|
|
|
|
|
|
|
svnserver = ""
|
2009-10-04 16:45:59 +00:00
|
|
|
# Paths and files to retrieve from svn when creating a tarball.
|
|
|
|
# This is a mixed list, holding both paths and filenames.
|
2010-07-28 18:37:12 +00:00
|
|
|
svnpaths = [ ]
|
2010-06-11 20:02:59 +00:00
|
|
|
# set this to true to run upx on the resulting binary, false to skip this step.
|
|
|
|
# only used on w32.
|
|
|
|
useupx = False
|
2009-06-18 22:17:17 +00:00
|
|
|
|
2010-07-10 21:22:22 +00:00
|
|
|
# OS X: files to copy into the bundle. Workaround for out-of-tree builds.
|
2010-07-28 18:37:12 +00:00
|
|
|
bundlecopy = { }
|
2010-07-10 21:22:22 +00:00
|
|
|
|
2009-06-18 22:17:17 +00:00
|
|
|
# == Functions ==
|
|
|
|
def usage(myself):
|
|
|
|
print "Usage: %s [options]" % myself
|
|
|
|
print " -q, --qmake=<qmake> path to qmake"
|
2009-10-04 16:45:59 +00:00
|
|
|
print " -p, --project=<pro> path to .pro file for building with local tree"
|
|
|
|
print " -t, --tag=<tag> use specified tag from svn"
|
2009-10-04 21:17:59 +00:00
|
|
|
print " -a, --add=<file> add file to build folder before building"
|
2009-10-05 18:35:28 +00:00
|
|
|
print " -s, --source-only only create source archive"
|
|
|
|
print " -b, --binary-only only create binary archive"
|
2009-11-29 21:09:21 +00:00
|
|
|
if sys.platform != "darwin":
|
|
|
|
print " -d, --dynamic link dynamically instead of static"
|
2010-03-31 20:52:07 +00:00
|
|
|
print " -k, --keep-temp keep temporary folder on build failure"
|
2009-06-18 22:17:17 +00:00
|
|
|
print " -h, --help this help"
|
2009-10-04 16:45:59 +00:00
|
|
|
print " If neither a project file nor tag is specified trunk will get downloaded"
|
|
|
|
print " from svn."
|
|
|
|
|
|
|
|
def getsources(svnsrv, filelist, dest):
|
|
|
|
'''Get the files listed in filelist from svnsrv and put it at dest.'''
|
|
|
|
client = pysvn.Client()
|
|
|
|
print "Checking out sources from %s, please wait." % svnsrv
|
|
|
|
|
|
|
|
for elem in filelist:
|
|
|
|
url = re.subn('/$', '', svnsrv + elem)[0]
|
|
|
|
destpath = re.subn('/$', '', dest + elem)[0]
|
2009-11-20 21:04:23 +00:00
|
|
|
# make sure the destination path does exist
|
|
|
|
d = os.path.dirname(destpath)
|
|
|
|
if not os.path.exists(d):
|
|
|
|
os.makedirs(d)
|
|
|
|
# get from svn
|
2009-10-04 16:45:59 +00:00
|
|
|
try:
|
|
|
|
client.export(url, destpath)
|
|
|
|
except:
|
|
|
|
print "SVN client error: %s" % sys.exc_value
|
2009-11-20 21:04:23 +00:00
|
|
|
print "URL: %s, destination: %s" % (url, destpath)
|
2009-10-04 16:45:59 +00:00
|
|
|
return -1
|
|
|
|
print "Checkout finished."
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
def gettrunkrev(svnsrv):
|
|
|
|
'''Get the revision of trunk for svnsrv'''
|
|
|
|
client = pysvn.Client()
|
|
|
|
entries = client.info2(svnsrv, recurse=False)
|
|
|
|
return entries[0][1].rev.number
|
2009-06-18 22:17:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
def findversion(versionfile):
|
|
|
|
'''figure most recent program version from version.h,
|
|
|
|
returns version string.'''
|
|
|
|
h = open(versionfile, "r")
|
|
|
|
c = h.read()
|
|
|
|
h.close()
|
|
|
|
r = re.compile("#define +VERSION +\"(.[0-9\.a-z]+)\"")
|
|
|
|
m = re.search(r, c)
|
|
|
|
s = re.compile("\$Revision: +([0-9]+)")
|
|
|
|
n = re.search(s, c)
|
|
|
|
if n == None:
|
|
|
|
print "WARNING: Revision not found!"
|
|
|
|
return m.group(1)
|
|
|
|
|
|
|
|
|
|
|
|
def findqt():
|
|
|
|
'''Search for Qt4 installation. Return path to qmake.'''
|
|
|
|
print "Searching for Qt"
|
|
|
|
bins = ["qmake", "qmake-qt4"]
|
|
|
|
for binary in bins:
|
2009-10-03 18:16:41 +00:00
|
|
|
try:
|
|
|
|
q = which.which(binary)
|
|
|
|
if len(q) > 0:
|
|
|
|
result = checkqt(q)
|
|
|
|
if not result == "":
|
|
|
|
return result
|
|
|
|
except:
|
|
|
|
print sys.exc_value
|
|
|
|
|
|
|
|
return ""
|
2009-10-03 17:19:07 +00:00
|
|
|
|
2009-06-18 22:17:17 +00:00
|
|
|
|
2009-10-03 17:19:07 +00:00
|
|
|
def checkqt(qmakebin):
|
|
|
|
'''Check if given path to qmake exists and is a suitable version.'''
|
|
|
|
result = ""
|
|
|
|
# check if binary exists
|
|
|
|
if not os.path.exists(qmakebin):
|
|
|
|
print "Specified qmake path does not exist!"
|
|
|
|
return result
|
|
|
|
# check version
|
|
|
|
output = subprocess.Popen([qmakebin, "-version"], stdout=subprocess.PIPE,
|
|
|
|
stderr=subprocess.PIPE)
|
|
|
|
cmdout = output.communicate()
|
|
|
|
# don't check the qmake return code here, Qt3 doesn't return 0 on -version.
|
|
|
|
for ou in cmdout:
|
|
|
|
r = re.compile("Qt[^0-9]+([0-9\.]+[a-z]*)")
|
|
|
|
m = re.search(r, ou)
|
|
|
|
if not m == None:
|
|
|
|
print "Qt found: %s" % m.group(1)
|
|
|
|
s = re.compile("4\..*")
|
|
|
|
n = re.search(s, m.group(1))
|
|
|
|
if not n == None:
|
|
|
|
result = qmakebin
|
2009-06-18 22:17:17 +00:00
|
|
|
return result
|
|
|
|
|
|
|
|
|
2009-10-05 18:35:28 +00:00
|
|
|
def qmake(qmake="qmake", projfile=project, wd=".", static=True):
|
2009-10-04 16:45:59 +00:00
|
|
|
print "Running qmake in %s..." % wd
|
2009-10-05 18:35:28 +00:00
|
|
|
command = [qmake, "-config", "release", "-config", "noccache"]
|
|
|
|
if static == True:
|
|
|
|
command.append("-config")
|
|
|
|
command.append("static")
|
|
|
|
command.append(projfile)
|
2009-11-29 21:09:21 +00:00
|
|
|
output = subprocess.Popen(command, stdout=subprocess.PIPE, cwd=wd, env=environment)
|
2009-10-03 17:19:07 +00:00
|
|
|
output.communicate()
|
|
|
|
if not output.returncode == 0:
|
|
|
|
print "qmake returned an error!"
|
|
|
|
return -1
|
|
|
|
return 0
|
2009-06-18 22:17:17 +00:00
|
|
|
|
|
|
|
|
2009-10-04 16:45:59 +00:00
|
|
|
def build(wd="."):
|
2009-06-18 22:17:17 +00:00
|
|
|
# make
|
|
|
|
print "Building ..."
|
2009-11-04 22:24:47 +00:00
|
|
|
output = subprocess.Popen([make], stdout=subprocess.PIPE, cwd=wd)
|
2009-10-22 22:02:56 +00:00
|
|
|
while True:
|
|
|
|
c = output.stdout.readline()
|
|
|
|
sys.stdout.write(".")
|
|
|
|
sys.stdout.flush()
|
|
|
|
if not output.poll() == None:
|
|
|
|
sys.stdout.write("\n")
|
|
|
|
sys.stdout.flush()
|
|
|
|
if not output.returncode == 0:
|
|
|
|
print "Build failed!"
|
|
|
|
return -1
|
|
|
|
break
|
2009-11-29 21:09:21 +00:00
|
|
|
if sys.platform != "darwin":
|
|
|
|
# strip. OS X handles this via macdeployqt.
|
|
|
|
print "Stripping binary."
|
|
|
|
output = subprocess.Popen(["strip", progexe], stdout=subprocess.PIPE, cwd=wd)
|
|
|
|
output.communicate()
|
|
|
|
if not output.returncode == 0:
|
|
|
|
print "Stripping failed!"
|
|
|
|
return -1
|
2009-10-03 17:19:07 +00:00
|
|
|
return 0
|
2009-06-18 22:17:17 +00:00
|
|
|
|
|
|
|
|
2009-10-04 16:45:59 +00:00
|
|
|
def upxfile(wd="."):
|
2009-06-18 22:17:17 +00:00
|
|
|
# run upx on binary
|
|
|
|
print "UPX'ing binary ..."
|
2009-10-04 16:45:59 +00:00
|
|
|
output = subprocess.Popen(["upx", progexe], stdout=subprocess.PIPE, cwd=wd)
|
2009-10-03 17:19:07 +00:00
|
|
|
output.communicate()
|
|
|
|
if not output.returncode == 0:
|
|
|
|
print "UPX'ing failed!"
|
|
|
|
return -1
|
|
|
|
return 0
|
2009-06-18 22:17:17 +00:00
|
|
|
|
|
|
|
|
2009-10-04 16:45:59 +00:00
|
|
|
def zipball(versionstring, buildfolder):
|
2009-06-18 22:17:17 +00:00
|
|
|
'''package created binary'''
|
|
|
|
print "Creating binary zipball."
|
2009-10-04 16:45:59 +00:00
|
|
|
archivebase = program + "-" + versionstring
|
|
|
|
outfolder = buildfolder + "/" + archivebase
|
|
|
|
archivename = archivebase + ".zip"
|
2009-06-18 22:17:17 +00:00
|
|
|
# create output folder
|
|
|
|
os.mkdir(outfolder)
|
|
|
|
# move program files to output folder
|
|
|
|
for f in programfiles:
|
2009-10-04 16:45:59 +00:00
|
|
|
shutil.copy(buildfolder + "/" + f, outfolder)
|
2009-06-18 22:17:17 +00:00
|
|
|
# create zipball from output folder
|
|
|
|
zf = zipfile.ZipFile(archivename, mode='w', compression=zipfile.ZIP_DEFLATED)
|
|
|
|
for root, dirs, files in os.walk(outfolder):
|
|
|
|
for name in files:
|
2009-10-04 16:45:59 +00:00
|
|
|
physname = os.path.join(root, name)
|
|
|
|
filename = re.sub("^" + buildfolder, "", physname)
|
|
|
|
zf.write(physname, filename)
|
2009-06-18 22:17:17 +00:00
|
|
|
for name in dirs:
|
2009-10-04 16:45:59 +00:00
|
|
|
physname = os.path.join(root, name)
|
|
|
|
filename = re.sub("^" + buildfolder, "", physname)
|
|
|
|
zf.write(physname, filename)
|
2009-06-18 22:17:17 +00:00
|
|
|
zf.close()
|
|
|
|
# remove output folder
|
2009-10-04 16:45:59 +00:00
|
|
|
shutil.rmtree(outfolder)
|
2009-10-03 17:19:07 +00:00
|
|
|
return archivename
|
2009-06-18 22:17:17 +00:00
|
|
|
|
|
|
|
|
2009-10-04 16:45:59 +00:00
|
|
|
def tarball(versionstring, buildfolder):
|
2009-06-18 22:17:17 +00:00
|
|
|
'''package created binary'''
|
|
|
|
print "Creating binary tarball."
|
2009-10-04 16:45:59 +00:00
|
|
|
archivebase = program + "-" + versionstring
|
|
|
|
outfolder = buildfolder + "/" + archivebase
|
|
|
|
archivename = archivebase + ".tar.bz2"
|
2009-06-18 22:17:17 +00:00
|
|
|
# create output folder
|
|
|
|
os.mkdir(outfolder)
|
|
|
|
# move program files to output folder
|
|
|
|
for f in programfiles:
|
2009-10-04 16:45:59 +00:00
|
|
|
shutil.copy(buildfolder + "/" + f, outfolder)
|
2009-06-18 22:17:17 +00:00
|
|
|
# create tarball from output folder
|
|
|
|
tf = tarfile.open(archivename, mode='w:bz2')
|
2009-10-04 16:45:59 +00:00
|
|
|
tf.add(outfolder, archivebase)
|
2009-06-18 22:17:17 +00:00
|
|
|
tf.close()
|
|
|
|
# remove output folder
|
2009-10-04 16:45:59 +00:00
|
|
|
shutil.rmtree(outfolder)
|
2009-10-03 17:19:07 +00:00
|
|
|
return archivename
|
2009-06-18 22:17:17 +00:00
|
|
|
|
|
|
|
|
2009-11-29 21:09:21 +00:00
|
|
|
def macdeploy(versionstring, buildfolder):
|
|
|
|
'''package created binary to dmg'''
|
|
|
|
dmgfile = program + "-" + versionstring + ".dmg"
|
|
|
|
appbundle = buildfolder + "/" + progexe
|
|
|
|
|
2010-07-10 21:22:22 +00:00
|
|
|
# workaround to Qt issues when building out-of-tree. Copy files into bundle.
|
2010-07-28 21:05:16 +00:00
|
|
|
sourcebase = buildfolder + re.sub('[^/]+.pro$', '', project) + "/"
|
|
|
|
print sourcebase
|
2010-07-10 21:22:22 +00:00
|
|
|
for src in bundlecopy:
|
2010-07-28 21:05:16 +00:00
|
|
|
shutil.copy(sourcebase + src, appbundle + "/" + bundlecopy[src])
|
2009-11-29 21:09:21 +00:00
|
|
|
# end of Qt workaround
|
|
|
|
|
|
|
|
output = subprocess.Popen(["macdeployqt", progexe, "-dmg"], stdout=subprocess.PIPE, cwd=buildfolder)
|
|
|
|
output.communicate()
|
|
|
|
if not output.returncode == 0:
|
|
|
|
print "macdeployqt failed!"
|
|
|
|
return -1
|
|
|
|
# copy dmg to output folder
|
|
|
|
shutil.copy(buildfolder + "/" + program + ".dmg", dmgfile)
|
|
|
|
return dmgfile
|
|
|
|
|
2009-10-04 16:45:59 +00:00
|
|
|
def filehashes(filename):
|
|
|
|
'''Calculate md5 and sha1 hashes for a given file.'''
|
|
|
|
if not os.path.exists(filename):
|
|
|
|
return ["", ""]
|
|
|
|
m = hashlib.md5()
|
|
|
|
s = hashlib.sha1()
|
|
|
|
f = open(filename, 'rb')
|
|
|
|
while True:
|
|
|
|
d = f.read(65536)
|
|
|
|
if d == "":
|
|
|
|
break
|
|
|
|
m.update(d)
|
|
|
|
s.update(d)
|
|
|
|
return [m.hexdigest(), s.hexdigest()]
|
|
|
|
|
|
|
|
|
|
|
|
def filestats(filename):
|
|
|
|
if not os.path.exists(filename):
|
|
|
|
return
|
|
|
|
st = os.stat(filename)
|
|
|
|
print filename, "\n", "-" * len(filename)
|
|
|
|
print "Size: %i bytes" % st.st_size
|
|
|
|
h = filehashes(filename)
|
|
|
|
print "md5sum: %s" % h[0]
|
|
|
|
print "sha1sum: %s" % h[1]
|
|
|
|
print "-" * len(filename), "\n"
|
|
|
|
|
|
|
|
|
2010-03-31 20:52:07 +00:00
|
|
|
def tempclean(workfolder, nopro):
|
|
|
|
if nopro == True:
|
|
|
|
print "Cleaning up working folder %s" % workfolder
|
|
|
|
shutil.rmtree(workfolder)
|
|
|
|
else:
|
|
|
|
print "Project file specified or cleanup disabled!"
|
|
|
|
print "Temporary files kept at %s" % workfolder
|
|
|
|
|
|
|
|
|
2010-07-28 18:37:12 +00:00
|
|
|
def deploy():
|
2009-09-20 14:59:29 +00:00
|
|
|
startup = time.time()
|
2010-07-28 18:37:12 +00:00
|
|
|
|
2009-06-18 22:17:17 +00:00
|
|
|
try:
|
2010-03-31 20:52:07 +00:00
|
|
|
opts, args = getopt.getopt(sys.argv[1:], "q:p:t:a:sbdkh",
|
|
|
|
["qmake=", "project=", "tag=", "add=", "source-only", "binary-only", "dynamic", "keep-temp", "help"])
|
2009-06-18 22:17:17 +00:00
|
|
|
except getopt.GetoptError, err:
|
|
|
|
print str(err)
|
|
|
|
usage(sys.argv[0])
|
|
|
|
sys.exit(1)
|
|
|
|
qt = ""
|
2009-10-04 16:45:59 +00:00
|
|
|
proj = ""
|
|
|
|
svnbase = svnserver + "trunk/"
|
|
|
|
tag = ""
|
2009-10-04 21:17:59 +00:00
|
|
|
addfiles = []
|
2009-10-04 16:45:59 +00:00
|
|
|
cleanup = True
|
2009-10-05 18:35:28 +00:00
|
|
|
binary = True
|
|
|
|
source = True
|
2010-03-31 20:52:07 +00:00
|
|
|
keeptemp = False
|
2009-11-29 21:09:21 +00:00
|
|
|
if sys.platform != "darwin":
|
|
|
|
static = True
|
|
|
|
else:
|
|
|
|
static = False
|
2009-06-18 22:17:17 +00:00
|
|
|
for o, a in opts:
|
|
|
|
if o in ("-q", "--qmake"):
|
|
|
|
qt = a
|
2009-10-03 20:42:02 +00:00
|
|
|
if o in ("-p", "--project"):
|
|
|
|
proj = a
|
2009-10-04 16:45:59 +00:00
|
|
|
cleanup = False
|
|
|
|
if o in ("-t", "--tag"):
|
|
|
|
tag = a
|
|
|
|
svnbase = svnserver + "tags/" + tag + "/"
|
2009-10-04 21:17:59 +00:00
|
|
|
if o in ("-a", "--add"):
|
|
|
|
addfiles.append(a)
|
2009-10-05 18:35:28 +00:00
|
|
|
if o in ("-s", "--source-only"):
|
|
|
|
binary = False
|
|
|
|
if o in ("-b", "--binary-only"):
|
|
|
|
source = False
|
2009-11-29 21:09:21 +00:00
|
|
|
if o in ("-d", "--dynamic") and sys.platform != "darwin":
|
2009-10-05 18:35:28 +00:00
|
|
|
static = False
|
2010-03-31 20:52:07 +00:00
|
|
|
if o in ("-k", "--keep-temp"):
|
|
|
|
keeptemp = True
|
2009-06-18 22:17:17 +00:00
|
|
|
if o in ("-h", "--help"):
|
|
|
|
usage(sys.argv[0])
|
|
|
|
sys.exit(0)
|
|
|
|
|
2009-10-05 18:35:28 +00:00
|
|
|
if source == False and binary == False:
|
|
|
|
print "Building build neither source nor binary means nothing to do. Exiting."
|
|
|
|
sys.exit(1)
|
|
|
|
|
2009-10-04 16:45:59 +00:00
|
|
|
# search for qmake
|
2009-06-18 22:17:17 +00:00
|
|
|
if qt == "":
|
2009-10-03 17:19:07 +00:00
|
|
|
qm = findqt()
|
|
|
|
else:
|
|
|
|
qm = checkqt(qt)
|
|
|
|
if qm == "":
|
2009-06-18 22:17:17 +00:00
|
|
|
print "ERROR: No suitable Qt installation found."
|
2009-10-03 17:19:07 +00:00
|
|
|
sys.exit(1)
|
2009-10-04 16:45:59 +00:00
|
|
|
|
|
|
|
# create working folder. Use current directory if -p option used.
|
|
|
|
if proj == "":
|
|
|
|
w = tempfile.mkdtemp()
|
|
|
|
# make sure the path doesn't contain backslashes to prevent issues
|
|
|
|
# later when running on windows.
|
|
|
|
workfolder = re.sub(r'\\', '/', w)
|
|
|
|
if not tag == "":
|
|
|
|
sourcefolder = workfolder + "/" + tag + "/"
|
|
|
|
archivename = tag + "-src.tar.bz2"
|
|
|
|
# get numeric version part from tag
|
|
|
|
ver = "v" + re.sub('^[^\d]+', '', tag)
|
|
|
|
else:
|
|
|
|
trunk = gettrunkrev(svnbase)
|
2010-06-08 19:19:19 +00:00
|
|
|
sourcefolder = workfolder + "/" + program + "-r" + str(trunk) + "/"
|
|
|
|
archivename = program + "-r" + str(trunk) + "-src.tar.bz2"
|
2009-10-04 16:45:59 +00:00
|
|
|
ver = "r" + str(trunk)
|
|
|
|
os.mkdir(sourcefolder)
|
|
|
|
else:
|
|
|
|
workfolder = "."
|
|
|
|
sourcefolder = "."
|
|
|
|
archivename = ""
|
|
|
|
# check if project file explicitly given. If yes, don't get sources from svn
|
|
|
|
if proj == "":
|
|
|
|
proj = sourcefolder + project
|
|
|
|
# get sources and pack source tarball
|
|
|
|
if not getsources(svnbase, svnpaths, sourcefolder) == 0:
|
2010-03-31 20:52:07 +00:00
|
|
|
tempclean(workfolder, cleanup and not keeptemp)
|
2009-10-04 16:45:59 +00:00
|
|
|
sys.exit(1)
|
|
|
|
|
2009-10-05 18:35:28 +00:00
|
|
|
if source == True:
|
|
|
|
tf = tarfile.open(archivename, mode='w:bz2')
|
|
|
|
tf.add(sourcefolder, os.path.basename(re.subn('/$', '', sourcefolder)[0]))
|
|
|
|
tf.close()
|
|
|
|
if binary == False:
|
|
|
|
shutil.rmtree(workfolder)
|
|
|
|
sys.exit(0)
|
2009-10-04 16:45:59 +00:00
|
|
|
else:
|
|
|
|
# figure version from sources. Need to take path to project file into account.
|
|
|
|
versionfile = re.subn('[\w\.]+$', "version.h", proj)[0]
|
|
|
|
ver = findversion(versionfile)
|
|
|
|
|
2009-10-03 20:42:02 +00:00
|
|
|
# check project file
|
|
|
|
if not os.path.exists(proj):
|
2009-10-04 16:45:59 +00:00
|
|
|
print "ERROR: path to project file wrong."
|
2009-10-03 20:42:02 +00:00
|
|
|
sys.exit(1)
|
2009-06-18 22:17:17 +00:00
|
|
|
|
2009-10-04 21:17:59 +00:00
|
|
|
# copy specified (--add) files to working folder
|
|
|
|
for f in addfiles:
|
|
|
|
shutil.copy(f, sourcefolder)
|
2009-10-04 16:45:59 +00:00
|
|
|
buildstart = time.time()
|
2009-06-18 22:17:17 +00:00
|
|
|
header = "Building %s %s" % (program, ver)
|
|
|
|
print header
|
|
|
|
print len(header) * "="
|
|
|
|
|
|
|
|
# build it.
|
2009-10-05 18:35:28 +00:00
|
|
|
if not qmake(qm, proj, sourcefolder, static) == 0:
|
2010-03-31 20:52:07 +00:00
|
|
|
tempclean(workfolder, cleanup and not keeptemp)
|
2009-10-04 16:45:59 +00:00
|
|
|
sys.exit(1)
|
|
|
|
if not build(sourcefolder) == 0:
|
2010-03-31 20:52:07 +00:00
|
|
|
tempclean(workfolder, cleanup and not keeptemp)
|
2009-10-03 17:19:07 +00:00
|
|
|
sys.exit(1)
|
2009-06-18 22:17:17 +00:00
|
|
|
if sys.platform == "win32":
|
2010-06-11 20:02:59 +00:00
|
|
|
if useupx == True:
|
|
|
|
if not upxfile(sourcefolder) == 0:
|
|
|
|
tempclean(workfolder, cleanup and not keeptemp)
|
|
|
|
sys.exit(1)
|
2009-10-04 16:45:59 +00:00
|
|
|
archive = zipball(ver, sourcefolder)
|
2009-11-29 21:09:21 +00:00
|
|
|
elif sys.platform == "darwin":
|
|
|
|
archive = macdeploy(ver, sourcefolder)
|
2009-06-18 22:17:17 +00:00
|
|
|
else:
|
2010-06-23 20:15:14 +00:00
|
|
|
if os.uname()[4].endswith("64"):
|
|
|
|
ver += "-64bit"
|
2009-10-04 16:45:59 +00:00
|
|
|
archive = tarball(ver, sourcefolder)
|
|
|
|
|
|
|
|
# remove temporary files
|
2010-03-31 20:52:07 +00:00
|
|
|
tempclean(workfolder, cleanup)
|
2009-10-04 16:45:59 +00:00
|
|
|
|
|
|
|
# display summary
|
|
|
|
headline = "Build Summary for %s" % program
|
|
|
|
print "\n", headline, "\n", "=" * len(headline)
|
|
|
|
if not archivename == "":
|
|
|
|
filestats(archivename)
|
|
|
|
filestats(archive)
|
2009-09-20 14:59:29 +00:00
|
|
|
duration = time.time() - startup
|
2009-10-04 16:45:59 +00:00
|
|
|
building = time.time() - buildstart
|
2009-09-20 14:59:29 +00:00
|
|
|
durmins = (int)(duration / 60)
|
2009-10-03 17:19:07 +00:00
|
|
|
dursecs = (int)(duration % 60)
|
2009-10-04 16:45:59 +00:00
|
|
|
buildmins = (int)(building / 60)
|
|
|
|
buildsecs = (int)(building % 60)
|
|
|
|
print "Overall time %smin %ssec, building took %smin %ssec." % \
|
|
|
|
(durmins, dursecs, buildmins, buildsecs)
|
2009-06-18 22:17:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2010-07-28 18:37:12 +00:00
|
|
|
deploy()
|
2009-06-18 22:17:17 +00:00
|
|
|
|