Skip to content
Snippets Groups Projects
Commit 584174c4 authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Merge branch 'master' into release

parents 814ccd49 e5e0eedc
Branches
Tags
No related merge requests found
#!/usr/bin/python -u
# vim: set fileencoding=utf-8 :
#
# (C) 2007,2008 Guido Guenther <agx@sigxcpu.org>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
"""Generate Debian changelog entries from git commit messages"""
import sys
import re
import os.path
import shutil
import subprocess
import gbp.command_wrappers as gbpc
from gbp.git_utils import (GitRepositoryError, GitRepository, build_tag)
from gbp.config import GbpOptionParser, GbpOptionGroup
from gbp.errors import GbpError
from gbp.deb_utils import parse_changelog
from gbp.command_wrappers import (Command, CommandExecFailed)
snapshot_re = re.compile("\s*\*\* SNAPSHOT build @(?P<commit>[a-z0-9]+)\s+\*\*")
author_re = re.compile('Author: (?P<author>.*) <(?P<email>.*)>')
bug_r = r'(?:bug)?\#?\s?\d+'
bug_re = re.compile(bug_r, re.I)
def system(cmd):
try:
Command(cmd, shell=True)()
except CommandExecFailed:
raise GbpError
def escape_commit(msg):
return msg.replace('"','\\\"').replace("$","\$").replace("`","\`")
def spawn_dch(msg='', author=None, email=None, newversion=False, version=None, release=False, distribution=None):
distopt = ""
versionopt = ""
env = ""
if newversion:
if version:
versionopt = '--newversion=%s' % version
else:
versionopt = '-i'
elif release:
versionopt = "--release"
msg = None
if author and email:
env = """DEBFULLNAME="%s" DEBEMAIL="%s" """ % (author, email)
if distribution:
distopt = "--distribution=%s" % distribution
cmd = '%(env)s dch --no-auto-nmu %(distopt)s %(versionopt)s ' % locals()
if type(msg) == type(''):
cmd += '"%s"' % escape_commit(msg)
system(cmd)
def add_changelog_entry(msg, author, email):
"add aa single changelog entry"
spawn_dch(msg=msg, author=author, email=email)
def add_changelog_section(msg, distribution, author=None, email=None, version=None):
"add a new changelog section"
spawn_dch(msg=msg, newversion= True, version=version, author=author, email=email, distribution=distribution)
def fixup_trailer(repo, git_author=False):
"""fixup the changelog trailer's comitter and email address - it might
otherwise point to the last git committer instead of the person creating
the changelog"""
author = email = None
if git_author:
try: author = repo.get_config('user.name')
except KeyError: pass
try: email = repo.get_config('user.email')
except KeyError: pass
spawn_dch(msg='', author=author, email=email)
def head_commit():
"""get the full sha1 of the last commit on HEAD"""
commit = subprocess.Popen([ 'git', 'log', 'HEAD^..' ], stdout=subprocess.PIPE).stdout
sha = commit.readline().split()[-1]
return sha
def snapshot_version(version):
"""
get the current release and snapshot version
Format is <debian-version>~<release>.gbp<short-commit-id>
"""
try:
(release, suffix) = version.rsplit('~', 1)
(snapshot, commit) = suffix.split('.', 1)
if not commit.startswith('gbp'):
raise ValueError
else:
snapshot = int(snapshot)
except ValueError: # not a snapshot release
release = version
snapshot = 0
return release, snapshot
def mangle_changelog(changelog, cp, snapshot=''):
"""
Mangle changelog to either add or remove snapshot markers
@param snapshot: SHA1 if snapshot header should be added/maintained, empty if it should be removed
@type snapshot: str
"""
try:
tmpfile = '%s.%s' % (changelog, snapshot)
cw = file(tmpfile, 'w')
cr = file(changelog, 'r')
cr.readline() # skip version and empty line
cr.readline()
print >>cw, "%(Source)s (%(MangledVersion)s) %(Distribution)s; urgency=%(urgency)s\n" % cp
line = cr.readline()
if snapshot_re.match(line):
cr.readline() # consume the empty line after the snapshot header
line = ''
if snapshot:
print >>cw, " ** SNAPSHOT build @%s **\n" % snapshot
if line:
print >>cw, line.rstrip()
shutil.copyfileobj(cr, cw)
cw.close()
cr.close()
os.unlink(changelog)
os.rename(tmpfile, changelog)
except OSError, e:
raise GbpError, "Error mangling changelog %s" % e
def do_release(changelog, cp):
"remove the snapshot header and set the distribution"
(release, snapshot) = snapshot_version(cp['Version'])
if snapshot:
cp['MangledVersion'] = release
mangle_changelog(changelog, cp)
# <julien.bonjean@savoirfairelinux.com>
# prevent doing a release
# spawn_dch(release=True)
def do_snapshot(changelog, next_snapshot):
"""
Add new snapshot banner to most recent changelog section. The next snapshot
number is calculated by eval()'ing next_snapshot
"""
# commit = head_commit()
cp = parse_changelog(changelog)
# <julien.bonjean@savoirfairelinux.com>
# clean version before generate snapshot
version=cp['Version']
try:
(release, suffix) = version.rsplit('~', 1)
except:
pass
try:
(snapshot, commit) = suffix.split('.', 1)
stripped = str(int(snapshot))
except:
version=release
commit = head_commit()
(release, snapshot) = snapshot_version(version)
snapshot = int(eval(next_snapshot))
suffix = "%d.gbp%s" % (snapshot, "".join(commit[0:6]))
cp['MangledVersion'] = "%s~%s" % (release, suffix)
mangle_changelog(changelog, cp, commit)
return snapshot, commit
def get_author(commit):
"""get the author from a commit message"""
for line in commit:
m = author_re.match(line)
if m:
return m.group('author'), m.group('email')
def parse_commit(repo, commitid, options):
"""parse a commit and return message and author"""
msg = ''
thanks = ''
closes = ''
bugs = {}
bts_closes = re.compile(r'(?P<bts>%s):\s+%s' % (options.meta_closes, bug_r), re.I)
commit = repo.show(commitid)
author, email = get_author(commit)
if not author:
raise GbpError, "can't parse author of commit %s" % commit
for line in commit:
if line.startswith(' '): # commit body
line = line[4:]
m = bts_closes.match(line)
if m:
bug_nums = [ bug.strip() for bug in bug_re.findall(line, re.I) ]
try:
bugs[m.group('bts')] += bug_nums
except KeyError:
bugs[m.group('bts')] = bug_nums
elif line.startswith('Thanks: '):
thanks = line.split(' ', 1)[1].strip()
else: # normal commit message
if options.short and msg:
continue
elif line.strip(): # don't add all whitespace lines
msg += line
# start of diff output:
elif line.startswith('diff '):
break
if options.meta:
for bts in bugs:
closes += '(%s: %s) ' % (bts, ', '.join(bugs[bts]))
if thanks:
thanks = '- thanks to %s' % thanks
msg += closes + thanks
if options.idlen:
msg = "[%s] " % commitid[0:options.idlen] + msg
return msg, (author, email)
def shortlog_to_dch(repo, commits, options):
"""convert the changes in git shortlog format to debian changelog format"""
author = 'Unknown'
for commit in commits:
msg, (author, email) = parse_commit(repo, commit, options)
add_changelog_entry(msg, author, email)
def guess_snapshot_commit(cp):
"""guess the last commit documented in the changelog from the snapshot banner"""
sr = re.search(snapshot_re, cp['Changes'])
if sr:
return sr.group('commit')
def main(argv):
ret = 0
changelog = 'debian/changelog'
until = 'HEAD'
found_snapshot_header = False
first_commit = None
parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='',
usage='%prog [options] paths')
range_group = GbpOptionGroup(parser, "commit range options", "which commits to add to the changelog")
version_group = GbpOptionGroup(parser, "release & version number options", "what version number and release to use")
commit_group = GbpOptionGroup(parser, "commit message formatting", "howto format the changelog entries")
naming_group = GbpOptionGroup(parser, "branch and tag naming", "branch names and tag formats")
parser.add_option_group(range_group)
parser.add_option_group(version_group)
parser.add_option_group(commit_group)
parser.add_option_group(naming_group)
naming_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
naming_group.add_config_file_option(option_name="upstream-tag", dest="upstream_tag")
naming_group.add_config_file_option(option_name="debian-tag", dest="debian_tag")
naming_group.add_config_file_option(option_name="snapshot-number", dest="snapshot_number",
help="expression to determine the next snapshot number, default is '%(snapshot-number)s'")
parser.add_config_file_option(option_name="git-log", dest="git_log",
help="options to pass to git-log, default is '%(git-log)s'")
parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
help="verbose command execution")
range_group.add_option("-s", "--since", dest="since", help="commit to start from (e.g. HEAD^^^, debian/0.4.3)")
range_group.add_option("-a", "--auto", action="store_true", dest="auto", default=False,
help="autocomplete changelog from last snapshot or tag")
version_group.add_option("-R", "--release", action="store_true", dest="release", default=False,
help="mark as release")
version_group.add_option("-S", "--snapshot", action="store_true", dest="snapshot", default=False,
help="mark as snapshot build")
version_group.add_option("-N", "--new-version", dest="new_version",
help="use this as base for the new version number")
version_group.add_config_file_option(option_name="git-author", dest="git_author", action="store_true")
version_group.add_config_file_option(option_name="no-git-author", dest="git_author", action="store_false")
commit_group.add_config_file_option(option_name="meta", dest="meta",
help="parse meta tags in commit messages, default is '%(meta)s'", action="store_true")
commit_group.add_config_file_option(option_name="meta-closes", dest="meta_closes",
help="Meta tags for the bts close commands, default is '%(meta-closes)s'")
commit_group.add_option("--full", action="store_false", dest="short", default=True,
help="include the full commit message instead of only the first line")
commit_group.add_config_file_option(option_name="id-length", dest="idlen",
help="include N digits of the commit id in the changelog entry, default is '%(id-length)s'",
type="int", metavar="N")
(options, args) = parser.parse_args(argv[1:])
if options.snapshot and options.release:
parser.error("'--snapshot' and '--release' are incompatible options")
if options.since and options.auto:
parser.error("'--since' and '--auto' are incompatible options")
try:
if options.verbose:
gbpc.Command.verbose = True
try:
repo = GitRepository('.')
except GitRepositoryError:
raise GbpError, "%s is not a git repository" % (os.path.abspath('.'))
branch = repo.get_branch()
if options.debian_branch != branch:
print >>sys.stderr, "You are not on branch '%s' but on '%s'" % (options.debian_branch, branch)
raise GbpError, "Use --debian-branch to set the branch to pick changes from"
cp = parse_changelog(changelog)
if options.since:
since = options.since
else:
since = ''
if options.auto:
since = guess_snapshot_commit(cp)
if since:
print "Continuing from commit '%s'" % since
found_snapshot_header = True
else:
print "Couldn't find snapshot header, using version info"
if not since:
since = build_tag(options.debian_tag, cp['Version'])
if args:
print "Only looking for changes on '%s'" % " ".join(args)
commits = repo.commits(since, until, " ".join(args), options.git_log.split(" "))
# add a new changelog section if:
if cp['Distribution'] != "UNRELEASED" and not found_snapshot_header and commits:
# the last version was a release and we have pending commits
add_section = True
elif options.new_version or not found_snapshot_header:
# the user wants to force a new version or switch to snapshot mode
add_section = True
else:
add_section = False
if add_section:
if commits:
first_commit = commits[0]
commits = commits[1:]
commit_msg, (commit_author, commit_email) = parse_commit(repo, first_commit, options)
else:
commit_msg = "UNRELEASED"
commit_author = None
commit_email = None
add_changelog_section(distribution="UNRELEASED", msg=commit_msg,
version=options.new_version, author=commit_author,
email=commit_email)
if commits:
shortlog_to_dch(repo, commits, options)
fixup_trailer(repo, git_author=options.git_author)
elif not first_commit:
print "No changes detected from %s to %s." % (since, until)
if options.release:
do_release(changelog, cp)
elif options.snapshot:
(snap, version) = do_snapshot(changelog, options.snapshot_number)
print "Changelog has been prepared for snapshot #%d at %s" % (snap, version)
except (GbpError, GitRepositoryError), err:
if len(err.__str__()):
print >>sys.stderr, err
ret = 1
return ret
if __name__ == "__main__":
sys.exit(main(sys.argv))
# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·:
...@@ -7,9 +7,17 @@ ...@@ -7,9 +7,17 @@
# Author: Julien Bonjean (julien@bonjean.info) # Author: Julien Bonjean (julien@bonjean.info)
# #
# Creation Date: 2009-04-20 # Creation Date: 2009-04-20
# Last Modified: # Last Modified: 2009-05-15 12:23:31 -0400
##################################################### #####################################################
#
# Not working with git 1.5.4.3
#
#
#
#
TAG=`date +%Y-%m-%d` TAG=`date +%Y-%m-%d`
# wait delay after startup and shutdown of VMs # wait delay after startup and shutdown of VMs
...@@ -69,6 +77,8 @@ DO_SEND_EMAIL=1 ...@@ -69,6 +77,8 @@ DO_SEND_EMAIL=1
EDITOR=echo EDITOR=echo
export EDITOR export EDITOR
NON_FATAL_ERRORS=
MACHINES=( "ubuntu-8.04" "ubuntu-8.04-64" "ubuntu-8.10" "ubuntu-8.10-64" "ubuntu-9.04" "ubuntu-9.04-64" ) MACHINES=( "ubuntu-8.04" "ubuntu-8.04-64" "ubuntu-8.10" "ubuntu-8.10-64" "ubuntu-9.04" "ubuntu-9.04-64" )
######################### #########################
...@@ -81,20 +91,6 @@ echo " | SFLPhone build system |" ...@@ -81,20 +91,6 @@ echo " | SFLPhone build system |"
echo " \\***********************/" echo " \\***********************/"
echo echo
cd ${SCRIPTS_DIR}
if [ "$?" -ne "0" ]; then
echo " !! Cannot cd to working directory"
exit -1
fi
WHO=`whoami`
if [ "${WHO}" != "${USER}" ]; then
echo "!! Please use user ${USER} to run this script"
exit -1;
fi
for PARAMETER in $* for PARAMETER in $*
do do
case ${PARAMETER} in case ${PARAMETER} in
...@@ -137,6 +133,26 @@ do ...@@ -137,6 +133,26 @@ do
esac esac
done done
# if more than one VM will be launched, automatically stop running VMs
if [ "${#MACHINES[@]}" -gt "1" ]; then
VBoxManage list runningvms | tail -n +5 | awk '{print $1}' | xargs -i VBoxManage controlvm {} poweroff
fi
# change to working directory
cd ${SCRIPTS_DIR}
if [ "$?" -ne "0" ]; then
echo " !! Cannot cd to working directory"
exit -1
fi
WHO=`whoami`
if [ "${WHO}" != "${USER}" ]; then
echo "!! Please use user ${USER} to run this script"
exit -1;
fi
# logging # logging
mkdir ${PACKAGING_RESULT_DIR} 2>/dev/null mkdir ${PACKAGING_RESULT_DIR} 2>/dev/null
if [ ${DO_LOGGING} ]; then if [ ${DO_LOGGING} ]; then
...@@ -200,13 +216,12 @@ if [ ${DO_PREPARE} ]; then ...@@ -200,13 +216,12 @@ if [ ${DO_PREPARE} ]; then
echo "Clone repository" echo "Clone repository"
git clone ssh://repos-sflphone-git@sflphone.org/~/sflphone.git ${REPOSITORY_DIR} >/dev/null 2>&1 git clone ssh://repos-sflphone-git@sflphone.org/~/sflphone.git ${REPOSITORY_DIR} >/dev/null 2>&1
if [ "$?" -ne "0" ]; then if [ "$?" -ne "0" ]; then
echo " !! Cannot clone repository" echo " !! Cannot clone repository"
exit -1 exit -1
fi fi
FULL_VER=`cd ${REPOSITORY_DIR} && git describe --tag HEAD | cut -d "/" -f2 | cut -d "-" -f1-2` FULL_VER=`cd ${REPOSITORY_DIR} && git describe --tag HEAD | cut -d "/" -f2 | cut -d "-" -f1-2 | sed 's/\.rc.*//' | sed 's/\.beta.*//'`
# change current branch if needed # change current branch if needed
if [ ${RELEASE_MODE} ]; then if [ ${RELEASE_MODE} ]; then
...@@ -220,27 +235,13 @@ if [ ${DO_PREPARE} ]; then ...@@ -220,27 +235,13 @@ if [ ${DO_PREPARE} ]; then
# generate the changelog, according to the distribution and the git commit messages # generate the changelog, according to the distribution and the git commit messages
echo "Update changelogs" echo "Update changelogs"
# use git to generate changelogs ${SCRIPTS_DIR}/sfl-git-dch.sh ${RELEASE_MODE}
# TODO : currently do symlink to workaround git-dch bug, check if better way is possible
if [ ${RELEASE_MODE} ]; then
cd ${REPOSITORY_DIR} && ln -s ${REPOSITORY_SFLPHONE_COMMON_DIR}/debian/ . && ${BIN_DIR}/git-dch -a -R -N "${FULL_VER}${VERSION_APPEND}" --debian-branch=release && rm debian && \
# cd ${REPOSITORY_DIR} && ln -s ${REPOSITORY_SFLPHONE_CLIENT_KDE_DIR}/debian . && ${BIN_DIR}/git-dch -a -R -N "${FULL_VER}${VERSION_APPEND}" --debian-branch=release && rm debian && \
cd ${REPOSITORY_DIR} && ln -s ${REPOSITORY_SFLPHONE_CLIENT_GNOME_DIR}/debian . && ${BIN_DIR}/git-dch -a -R -N "${FULL_VER}${VERSION_APPEND}" --debian-branch=release && rm debian
else
cd ${REPOSITORY_DIR} && ln -s ${REPOSITORY_SFLPHONE_COMMON_DIR}/debian . && ${BIN_DIR}/git-dch -a -S && rm debian && \
# cd ${REPOSITORY_DIR} && ln -s ${REPOSITORY_SFLPHONE_CLIENT_KDE_DIR}/debian . && ${BIN_DIR}/git-dch -a -S && rm debian && \
cd ${REPOSITORY_DIR} && ln -s ${REPOSITORY_SFLPHONE_CLIENT_GNOME_DIR}/debian . && ${BIN_DIR}/git-dch -a -S && rm debian
fi
if [ "$?" -ne "0" ]; then if [ "$?" -ne "0" ]; then
echo "!! Cannot update changelogs" echo "!! Cannot update changelogs"
exit -1 exit -1
fi fi
# change UNRELEASED flag to system as we alway do a build for each distribution
# and distribution is set by another script
find ${REPOSITORY_DIR} -name changelog -exec sed -i 's/UNRELEASED/SYSTEM/g' {} \;
cd ${REPOSITORY_DIR} cd ${REPOSITORY_DIR}
echo "Update repository with new changelog" echo "Update repository with new changelog"
echo " Switch to master branch to commit" echo " Switch to master branch to commit"
...@@ -255,7 +256,7 @@ if [ ${DO_PREPARE} ]; then ...@@ -255,7 +256,7 @@ if [ ${DO_PREPARE} ]; then
if [ ! ${RELEASE_MODE} ]; then if [ ! ${RELEASE_MODE} ]; then
VERSION_COMMIT=${FULL_VER}" Snapshot ${TAG}" VERSION_COMMIT=${FULL_VER}" Snapshot ${TAG}"
fi fi
git-commit -m "[#1262] Updated changelogs for version ${VERSION_COMMIT}" . >/dev/null git commit -m "[#1262] Updated changelogs for version ${VERSION_COMMIT}" . >/dev/null
echo " Pushing commit" echo " Pushing commit"
git push origin master >/dev/null git push origin master >/dev/null
...@@ -267,7 +268,7 @@ if [ ${DO_PREPARE} ]; then ...@@ -267,7 +268,7 @@ if [ ${DO_PREPARE} ]; then
fi fi
echo "Archiving repository" echo "Archiving repository"
tar czf ${REPOSITORY_ARCHIVE} -C `dirname ${REPOSITORY_DIR}` sflphone tar czf ${REPOSITORY_ARCHIVE} --exclude .git -C `dirname ${REPOSITORY_DIR}` sflphone
if [ "$?" -ne "0" ]; then if [ "$?" -ne "0" ]; then
echo " !! Cannot archive repository" echo " !! Cannot archive repository"
...@@ -309,10 +310,6 @@ if [ ${DO_MAIN_LOOP} ]; then ...@@ -309,10 +310,6 @@ if [ ${DO_MAIN_LOOP} ]; then
sleep ${STARTUP_WAIT} sleep ${STARTUP_WAIT}
fi fi
echo "Doing updates"
${SSH_BASE} 'sudo apt-get update >/dev/null'
${SSH_BASE} 'sudo apt-get upgrade -y >/dev/null'
echo "Clean remote directory" echo "Clean remote directory"
${SSH_BASE} "rm -rf ${REMOTE_DEPLOY_DIR} 2>/dev/null" ${SSH_BASE} "rm -rf ${REMOTE_DEPLOY_DIR} 2>/dev/null"
...@@ -321,7 +318,7 @@ if [ ${DO_MAIN_LOOP} ]; then ...@@ -321,7 +318,7 @@ if [ ${DO_MAIN_LOOP} ]; then
if [ "$?" -ne "0" ]; then if [ "$?" -ne "0" ]; then
echo " !! Cannot deploy packaging system" echo " !! Cannot deploy packaging system"
exit -1 NON_FATAL_ERRORS="${NON_FATAL_ERRORS} !! Error when packaging for ${MACHINE}\n"
fi fi
echo "Launch remote build" echo "Launch remote build"
...@@ -329,7 +326,7 @@ if [ ${DO_MAIN_LOOP} ]; then ...@@ -329,7 +326,7 @@ if [ ${DO_MAIN_LOOP} ]; then
if [ "$?" -ne "0" ]; then if [ "$?" -ne "0" ]; then
echo " !! Error during remote packaging process" echo " !! Error during remote packaging process"
# exit -1 NON_FATAL_ERRORS="${NON_FATAL_ERRORS} !! Error when packaging for ${MACHINE}\n"
fi fi
echo "Retrieve dists and log files (current tag is ${TAG})" echo "Retrieve dists and log files (current tag is ${TAG})"
...@@ -338,7 +335,7 @@ if [ ${DO_MAIN_LOOP} ]; then ...@@ -338,7 +335,7 @@ if [ ${DO_MAIN_LOOP} ]; then
if [ "$?" -ne "0" ]; then if [ "$?" -ne "0" ]; then
echo " !! Cannot retrieve remote files" echo " !! Cannot retrieve remote files"
exit -1 NON_FATAL_ERRORS="${NON_FATAL_ERRORS} !! Error when packaging for ${MACHINE}\n"
fi fi
if [ "${VM_STATE}" = "running" ]; then if [ "${VM_STATE}" = "running" ]; then
...@@ -348,8 +345,8 @@ if [ ${DO_MAIN_LOOP} ]; then ...@@ -348,8 +345,8 @@ if [ ${DO_MAIN_LOOP} ]; then
${SSH_BASE} 'sudo shutdown -h now' ${SSH_BASE} 'sudo shutdown -h now'
echo "Wait ${SHUTDOWN_WAIT} s" echo "Wait ${SHUTDOWN_WAIT} s"
sleep ${SHUTDOWN_WAIT} sleep ${SHUTDOWN_WAIT}
echo "Hard shut down" # hard shut down (just to be sure)
cd "${VBOX_USER_HOME}" && VBoxManage controlvm ${MACHINE} poweroff cd "${VBOX_USER_HOME}" && VBoxManage controlvm ${MACHINE} poweroff >/dev/null 2>&1
fi fi
done done
fi fi
...@@ -418,6 +415,12 @@ if [ ${DO_UPLOAD} ]; then ...@@ -418,6 +415,12 @@ if [ ${DO_UPLOAD} ]; then
fi fi
fi fi
if [ ${NON_FATAL_ERRORS} ]; then
echo "Non fatal errors :"
echo ${NON_FATAL_ERRORS}
exit -1
fi
# close file descriptor # close file descriptor
exec 3>&- exec 3>&-
......
...@@ -52,7 +52,7 @@ if [ "$?" -ne "0" ]; then ...@@ -52,7 +52,7 @@ if [ "$?" -ne "0" ]; then
exit -1 exit -1
fi fi
# decompress reppository # decompress repository
echo "Untar repository" echo "Untar repository"
cd ${BUILD_DIR} && tar xf ${REPOSITORY_ARCHIVE} cd ${BUILD_DIR} && tar xf ${REPOSITORY_ARCHIVE}
...@@ -66,8 +66,9 @@ echo "Switch to internal logging" ...@@ -66,8 +66,9 @@ echo "Switch to internal logging"
# get system parameters # get system parameters
ARCH_FLAG=`getconf -a|grep LONG_BIT | sed -e 's/LONG_BIT\s*//'` ARCH_FLAG=`getconf -a|grep LONG_BIT | sed -e 's/LONG_BIT\s*//'`
OS_VERSION=`lsb_release -d -s -c | sed -e '1d'` OS_VERSION=`lsb_release -d -s -c | sed -e '1d'`
VER=`cd ${REPOSITORY_DIR} && git describe --tag HEAD | cut -d "/" -f2 | cut -d "-" -f1` PACKAGE_SYSVER="0ubuntu1"
FULL_VER=`cd ${REPOSITORY_DIR} && git describe --tag HEAD | cut -d "/" -f2 | cut -d "-" -f1-2` VERSION=`cd ${REPOSITORY_DIR} && head -n 1 ./sflphone-client-gnome/debian/changelog | awk '{print $2}' | sed -e 's/(//g' -e 's/)//g' | cut -d "-" -f1`
FULL_VERSION=`cd ${REPOSITORY_DIR} && head -n 1 ./sflphone-client-gnome/debian/changelog | awk '{print $2}' | sed -e 's/(//g' -e 's/)//g' -e 's/SYSVER/'${PACKAGE_SYSVER}'/g'`
# define log files # define log files
GLOBAL_LOG=${ROOT_DIR}/sflphone-${OS_VERSION}-${ARCH_FLAG}.log GLOBAL_LOG=${ROOT_DIR}/sflphone-${OS_VERSION}-${ARCH_FLAG}.log
...@@ -80,13 +81,20 @@ exec 3<>${GLOBAL_LOG} ...@@ -80,13 +81,20 @@ exec 3<>${GLOBAL_LOG}
exec 1>&3 exec 1>&3
exec 2>&3 exec 2>&3
echo "SFLPhone version is ${VER}" echo "SFLPhone version is ${VERSION}"
# generate the changelog, according to the distribution and the git commit messages echo "Do updates"
sudo apt-get update >/dev/null
sudo apt-get upgrade -y >/dev/null
# generate the changelog, according to the distribution
echo "Generate changelogs" echo "Generate changelogs"
sed -i 's/SYSTEM/'${OS_VERSION}'/g' ${REPOSITORY_SFLPHONE_COMMON_DIR}/debian/changelog && \ sed -i 's/SYSTEM/'${OS_VERSION}'/g' ${REPOSITORY_SFLPHONE_COMMON_DIR}/debian/changelog && \
sed -i 's/SYSVER/'${PACKAGE_SYSVER}'/g' ${REPOSITORY_SFLPHONE_COMMON_DIR}/debian/changelog && \
# sed -i 's/SYSTEM/'${OS_VERSION}'/g' ${REPOSITORY_SFLPHONE_CLIENT_KDE_DIR}/debian/changelog && \ # sed -i 's/SYSTEM/'${OS_VERSION}'/g' ${REPOSITORY_SFLPHONE_CLIENT_KDE_DIR}/debian/changelog && \
sed -i 's/SYSTEM/'${OS_VERSION}'/g' ${REPOSITORY_SFLPHONE_CLIENT_GNOME_DIR}/debian/changelog # sed -i 's/SYSVER/'${PACKAGE_SYSVER}'/g' ${REPOSITORY_SFLPHONE_CLIENT_KDE_DIR}/debian/changelog && \
sed -i 's/SYSTEM/'${OS_VERSION}'/g' ${REPOSITORY_SFLPHONE_CLIENT_GNOME_DIR}/debian/changelog && \
sed -i 's/SYSVER/'${PACKAGE_SYSVER}'/g' ${REPOSITORY_SFLPHONE_CLIENT_GNOME_DIR}/debian/changelog
if [ "$?" -ne "0" ]; then if [ "$?" -ne "0" ]; then
echo "!! Cannot generate changelogs" echo "!! Cannot generate changelogs"
...@@ -107,16 +115,16 @@ fi ...@@ -107,16 +115,16 @@ fi
# provide prerequisite directories used by debuild # provide prerequisite directories used by debuild
echo "Build sflphone packages on Ubuntu $OS_VERSION $ARCH_FLAG bit architecture...." echo "Build sflphone packages on Ubuntu $OS_VERSION $ARCH_FLAG bit architecture...."
cp -r ${REPOSITORY_SFLPHONE_COMMON_DIR} ${BUILD_DIR}/sflphone-common && \ cp -r ${REPOSITORY_SFLPHONE_COMMON_DIR} ${BUILD_DIR}/sflphone-common && \
cp -r ${REPOSITORY_SFLPHONE_COMMON_DIR} ${BUILD_DIR}/sflphone-common-$VER.orig && \ cp -r ${REPOSITORY_SFLPHONE_COMMON_DIR} ${BUILD_DIR}/sflphone-common-${FULL_VERSION}.orig && \
# cp -r ${REPOSITORY_SFLPHONE_CLIENT_KDE_DIR} ${BUILD_DIR}/sflphone-client-kde-$VER.orig && \ # cp -r ${REPOSITORY_SFLPHONE_CLIENT_KDE_DIR} ${BUILD_DIR}/sflphone-client-kde-${FULL_VERSION}.orig && \
cp -r ${REPOSITORY_SFLPHONE_CLIENT_GNOME_DIR} ${BUILD_DIR}/sflphone-client-gnome-$VER.orig && \ cp -r ${REPOSITORY_SFLPHONE_CLIENT_GNOME_DIR} ${BUILD_DIR}/sflphone-client-gnome-${FULL_VERSION}.orig && \
# do a cp to because path must remain for client compilation # do a cp to because path must remain for client compilation
mv ${REPOSITORY_SFLPHONE_COMMON_DIR} ${BUILD_DIR}/sflphone-common-$VER && \ mv ${REPOSITORY_SFLPHONE_COMMON_DIR} ${BUILD_DIR}/sflphone-common-${FULL_VERSION} && \
# mv ${REPOSITORY_SFLPHONE_CLIENT_KDE_DIR} ${BUILD_DIR}/sflphone-client-kde-$VER && \ # mv ${REPOSITORY_SFLPHONE_CLIENT_KDE_DIR} ${BUILD_DIR}/sflphone-client-kde-${FULL_VERSION} && \
mv ${REPOSITORY_SFLPHONE_CLIENT_GNOME_DIR} ${BUILD_DIR}/sflphone-client-gnome-$VER mv ${REPOSITORY_SFLPHONE_CLIENT_GNOME_DIR} ${BUILD_DIR}/sflphone-client-gnome-${FULL_VERSION}
# build package sflphone-common # build package sflphone-common
cd ${BUILD_DIR}/sflphone-common-$VER/debian && \ cd ${BUILD_DIR}/sflphone-common-${FULL_VERSION}/debian && \
debuild -us -uc >${PACKAGING_LOG} 2>&1 debuild -us -uc >${PACKAGING_LOG} 2>&1
if [ "$?" -ne "0" ]; then if [ "$?" -ne "0" ]; then
...@@ -125,8 +133,8 @@ if [ "$?" -ne "0" ]; then ...@@ -125,8 +133,8 @@ if [ "$?" -ne "0" ]; then
fi fi
# build package sflphone-client-gnome # build package sflphone-client-gnome
cd ${BUILD_DIR}/sflphone-client-gnome-$VER/debian && \ cd ${BUILD_DIR}/sflphone-client-gnome-${FULL_VERSION}/debian && \
debuild -us -uc >${PACKAGING_LOG} 2>&1 debuild -us -uc >>${PACKAGING_LOG} 2>&1
if [ "$?" -ne "0" ]; then if [ "$?" -ne "0" ]; then
echo "!! Cannot generate package sflphone-client-gnome" echo "!! Cannot generate package sflphone-client-gnome"
...@@ -134,8 +142,8 @@ if [ "$?" -ne "0" ]; then ...@@ -134,8 +142,8 @@ if [ "$?" -ne "0" ]; then
fi fi
# build package sflphone-client-kde # build package sflphone-client-kde
# cd ${BUILD_DIR}/sflphone-client-kde-$VER/debian && \ # cd ${BUILD_DIR}/sflphone-client-kde-${FULL_VERSION}/debian && \
# debuild -us -uc >${PACKAGING_LOG} 2>&1 # debuild -us -uc >>${PACKAGING_LOG} 2>&1
# if [ "$?" -ne "0" ]; then # if [ "$?" -ne "0" ]; then
# echo "!! Cannot generate package sflphone-client-kde" # echo "!! Cannot generate package sflphone-client-kde"
......
#!/bin/bash
#####################################################
# File Name: sfl-git-dch.sh
#
# Purpose :
#
# Author: Julien Bonjean (julien@bonjean.info)
#
# Creation Date: 2009-05-13
# Last Modified: 2009-05-14 17:22:48 -0400
#####################################################
# set -x
RELEASE_MODE=$1
ROOT_DIR="/home/projects/sflphone"
TODEPLOY_DIR="${ROOT_DIR}/sflphone-packaging"
TODEPLOY_BUILD_DIR="${TODEPLOY_DIR}/build"
REPOSITORY_DIR="${TODEPLOY_BUILD_DIR}/sflphone"
SCRIPTS_DIR="${ROOT_DIR}/build-system"
CHANGELOG_FILES=( "sflphone-common/debian/changelog" "sflphone-client-gnome/debian/changelog" )
SNAPSHOT_TAG=`date +%s`
export DEBFULLNAME="SFLphone Automatic Build System"
export DEBEMAIL="team@sflphone.org"
export EDITOR="echo"
cd ${REPOSITORY_DIR}
if [ "$?" -ne "0" ]; then
echo " !! Cannot cd to working directory"
exit -1
fi
# get last release tag
LAST_RELEASE_TAG_NAME=`git describe --tag HEAD --match "debian/*" --abbrev=40 | cut -d "-" -f1-2`
if [ "$?" -ne "0" ]; then
echo " !! Error when retrieving last tag"
exit -1
fi
# get last release commit hash
LAST_RELEASE_COMMIT_HASH=`git show --pretty=format:"%H" -s ${LAST_RELEASE_TAG_NAME=} | tail -n 1`
if [ "$?" -ne "0" ]; then
echo " !! Error when retrieving last release commit hash"
exit -1
fi
echo "Last release tag is : ${LAST_RELEASE_TAG_NAME} (commit ${LAST_RELEASE_COMMIT_HASH})"
echo
# use git log to retrieve changelog content
CHANGELOG_CONTENT=`git log --no-merges --pretty=format:"%s" ${LAST_RELEASE_COMMIT_HASH}.. | grep -v "\[\#1262\]"`
if [ "$?" -ne "0" ]; then
echo " !! Error when retrieving changelog content"
exit -1
fi
# get version
SOFTWARE_VERSION=`echo ${LAST_RELEASE_TAG_NAME} | cut -d "/" -f2- | cut -d "-" -f1`
if [ "$?" -ne "0" ]; then
echo " !! Error when retrieving software version"
exit -1
fi
# add version info
SOFTWARE_VERSION_APPEND=
if [ ${RELEASE_MODE} ]
then
if [ "${RELEASE_MODE}" != "release" ]; then
SOFTWARE_VERSION_APPEND="~${RELEASE_MODE}"
fi
else
SOFTWARE_VERSION_APPEND="~snapshot${SNAPSHOT_TAG}"
fi
# iterate throw changelog files
for CHANGELOG_FILE in ${CHANGELOG_FILES[@]}
do
echo "Changelog : ${CHANGELOG_FILE}"
echo
rm -f ${CHANGELOG_FILE}.dch >/dev/null 2>&1
# if previous entry is a snapshot, remove it
sed -n 's/ //g;3p;3q' ${CHANGELOG_FILE} | grep "**SNAPSHOT" >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Previous entry is a snapshot, removing it"
# detect first section length
FIRST_SECTION_LENGTH=`tail -n +2 ${CHANGELOG_FILE} | nl -ba | grep -m 1 "sflphone-.* SYSTEM; urgency=.*" | awk '{print $1}'`
if [ "$?" -ne "0" ] || [ ! ${FIRST_SECTION_LENGTH} ]; then
echo " !! Error when retrieving snapshot entry length"
exit -1
fi
# remove first section
sed -i "1,${FIRST_SECTION_LENGTH}d" ${CHANGELOG_FILE}
if [ "$?" -ne "0" ]; then
echo " !! Error when removing snapshot section"
exit -1
fi
fi
echo -n "Generate changelog "
IS_FIRST=1
echo "${CHANGELOG_CONTENT}" | while read line
do
if [ ${IS_FIRST} ]
then
yes | dch --changelog ${CHANGELOG_FILE} -b --allow-lower-version --no-auto-nmu --distribution SYSTEM --newversion ${SOFTWARE_VERSION}-SYSVER${SOFTWARE_VERSION_APPEND} "$line" >/dev/null 2>&1
if [ "$?" -ne "0" ]; then
echo
echo " !! Error with new version"
exit -1
fi
IS_FIRST=
else
dch --changelog ${CHANGELOG_FILE} --no-auto-nmu "$line"
if [ "$?" -ne "0" ]; then
echo
echo " !! Error when adding changelog entry"
exit -1
fi
fi
echo -n .
done
# add snapshot or release flag if needed
echo
if [ ${RELEASE_MODE} ]; then
sed -i "3i\ ** ${SOFTWARE_VERSION} ${RELEASE_MODE} **\n" ${CHANGELOG_FILE}
if [ "$?" -ne "0" ]; then
echo " !! Error when adding snapshot flag"
exit -1
fi
else
sed -i "3i\ ** SNAPSHOT ${SNAPSHOT_TAG} **\n" ${CHANGELOG_FILE}
if [ "$?" -ne "0" ]; then
echo " !! Error when adding snapshot flag"
exit -1
fi
fi
echo
done
echo "All done !"
exit 0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment