diff --git a/tools/build-system/README b/tools/build-system/README new file mode 100644 index 0000000000000000000000000000000000000000..c12a4bbfc40c9996c34d27a21e82deb5588f7720 --- /dev/null +++ b/tools/build-system/README @@ -0,0 +1,42 @@ +# register image +VBoxManage registerimage disk VDI/ubuntu-9.04.vdi -type normal + +# check registration +VBoxManage showvdiinfo VDI/ubuntu-9.04.vdi + +# create VM +VBoxManage createvm -name "ubuntu-9.04" -register + +# check vm creation +VBoxManage list vms + +# update configuration +VBoxManage modifyvm "ubuntu-9.04" -hda "VDI/ubuntu-9.04.vdi" -memory "1024MB" -acpi on -nic1 nat + +#si 64 bits +# VBoxManage modifyvm ubuntu-9.04-64 --ostype Ubuntu_64 +# VBoxManage modifyvm ubuntu-9.04-64 --hwvirtex on + +VBoxManage setextradata "ubuntu-9.04" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol" TCP +VBoxManage setextradata "ubuntu-9.04" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" 50001 +VBoxManage setextradata "ubuntu-9.04" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort" 22 + +# start vm +VBoxHeadless -startvm "ubuntu-9.04" -p 50000 + +# install ssh support +sudo apt-get install openssh-server + +# add office-srv-01 sflphone user ssh key in authorized_keys of vm +ssh -o LogLevel=ERROR -o CheckHostIP=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 50001 sflphone@127.0.0.1 "mkdir ~/.ssh/" +scp -o LogLevel=ERROR -o CheckHostIP=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -P 50001 /home/projects/sflphone/.ssh/id_dsa.pub sflphone@127.0.0.1:~/.ssh/authorized_keys +ssh -o LogLevel=ERROR -o CheckHostIP=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 50001 sflphone@127.0.0.1 "chmod 0600 ~/.ssh/authorized_keys" + +# si nécessaire +# scp -o LogLevel=ERROR -o CheckHostIP=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -P 50001 /home/projects/sflphone/build-system/git-buildpackage_0.4.45_all.deb sflphone@127.0.0.1: + +# update /etc/sudoers +sflphone ALL = NOPASSWD: /sbin/shutdown, /usr/bin/apt-get, /usr/bin/dpkg + +# stop vm +VBoxManage controlvm "ubuntu-9-04" poweroff diff --git a/tools/build-system/automatic-build-machine.sh b/tools/build-system/automatic-build-machine.sh new file mode 100755 index 0000000000000000000000000000000000000000..66882c356977e9059e8951ef54ac15520486c3da --- /dev/null +++ b/tools/build-system/automatic-build-machine.sh @@ -0,0 +1,24 @@ +#!/bin/bash +##################################################### +# File Name: send-emails.sh +# +# Purpose : +# +# Author: Julien Bonjean (julien@bonjean.info) +# +# Creation Date: 2009-04-20 +# Last Modified: +##################################################### + +TAG=`date +%Y-%m-%d` +ROOT_DIR="/home/projects/sflphone" +SCRIPTS_DIR="${ROOT_DIR}/build-system" + +cd ${SCRIPTS_DIR} + +${SCRIPTS_DIR}/launch-build-machine.sh $* + +${SCRIPTS_DIR}/send-emails.sh $? + +exit 0 + diff --git a/tools/build-system/bin/git-dch b/tools/build-system/bin/git-dch new file mode 100755 index 0000000000000000000000000000000000000000..f9ee5bc56f14d320c63c27da987ca0029fbb244f --- /dev/null +++ b/tools/build-system/bin/git-dch @@ -0,0 +1,404 @@ +#!/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\:·: diff --git a/tools/build-system/gpg/setup-gpg.sh b/tools/build-system/gpg/setup-gpg.sh new file mode 100755 index 0000000000000000000000000000000000000000..1a12793003d9f521f582e4535b7e97df1ee47179 --- /dev/null +++ b/tools/build-system/gpg/setup-gpg.sh @@ -0,0 +1,56 @@ +#!/bin/bash +##################################################### +# File Name: setup-gpg.sh +# +# Purpose : +# +# Author: Julien Bonjean (julien@bonjean.info) +# +# Creation Date: 2009-04-20 +# Last Modified: +##################################################### + +# pkill gpg-agent + +export LANG=en_CA.UTF-8 +export LC_ALL=en_CA.UTF-8 + +echo "Check if GPG key is present" +gpg --list-secret-keys | grep "Savoir-Faire Linux Inc." >/dev/null + +if [ "$?" -ne "0" ]; then + echo "!! GPG private key is not present" + exit -1 +fi + +echo "Check GPG agent" +pgrep -u "sflphone-package-manager" gpg-agent > /dev/null +if [ "$?" -ne "0" ]; then + echo "Not running, launching it" + EVAL=`/usr/bin/gpg-agent --daemon --write-env-file $HOME/.gpg-agent-info --default-cache-ttl 2000000000 --max-cache-ttl 2000000000 --pinentry-program /usr/bin/pinentry` + eval ${EVAL} +fi + +if [ "$?" -ne "0" ]; then + echo "!! Error with GPG agent" + exit -1 +fi + +GPG_AGENT_INFO=`cat $HOME/.gpg-agent-info 2> /dev/null` +export ${GPG_AGENT_INFO} + +if [ "${GPG_AGENT_INFO}" == "" ]; then + echo "!! Cannot get GPG agent info" + exit -1 +fi + +GPG_TTY=`tty` +export GPG_TTY + +touch ./test-gpg +gpg -v --clearsign --use-agent ./test-gpg +rm -f ./test-gpg +rm -f ./test-gpg.asc + +exit 0 + diff --git a/tools/build-system/launch-build-machine.sh b/tools/build-system/launch-build-machine.sh new file mode 100755 index 0000000000000000000000000000000000000000..cefc4f4428bf180a251761017ea911020d2cd27c --- /dev/null +++ b/tools/build-system/launch-build-machine.sh @@ -0,0 +1,425 @@ +#!/bin/bash +##################################################### +# File Name: launch-build-machine.sh +# +# Purpose : +# +# Author: Julien Bonjean (julien@bonjean.info) +# +# Creation Date: 2009-04-20 +# Last Modified: +##################################################### + +TAG=`date +%Y-%m-%d` + +# wait delay after startup and shutdown of VMs +STARTUP_WAIT=40 +SHUTDOWN_WAIT=30 + +# ssh stuff +SSH_OPTIONS="-o LogLevel=ERROR -o CheckHostIP=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" +SSH_HOST="sflphone@127.0.0.1" +SSH_REPOSITORY_HOST="sflphone-package-manager@dev.savoirfairelinux.net" +SSH_BASE="ssh ${SSH_OPTIONS} -p 50001 ${SSH_HOST}" +SCP_BASE="scp ${SSH_OPTIONS} -r -P 50001" + +# home directory +ROOT_DIR="/home/projects/sflphone" + +# vbox config directory +export VBOX_USER_HOME="${ROOT_DIR}/vbox" + +# remote home directory +REMOTE_ROOT_DIR="/home/sflphone" + +# scripts +SCRIPTS_DIR="${ROOT_DIR}/build-system" +PACKAGING_SCRIPTS_DIR="${SCRIPTS_DIR}/remote" +BIN_DIR="${SCRIPTS_DIR}/bin" + +# directory that will be deployed to remote machine +TODEPLOY_DIR="${ROOT_DIR}/sflphone-packaging" +TODEPLOY_BUILD_DIR="${TODEPLOY_DIR}/build" + +# remote deployment dir +REMOTE_DEPLOY_DIR="/home/sflphone/sflphone-packaging" + +# cloned repository and archive +REPOSITORY_DIR="${TODEPLOY_BUILD_DIR}/sflphone" +REPOSITORY_ARCHIVE="`dirname ${REPOSITORY_DIR}`/sflphone.tar.gz" +REPOSITORY_SFLPHONE_COMMON_DIR="${REPOSITORY_DIR}/sflphone-common" +REPOSITORY_SFLPHONE_CLIENT_KDE_DIR="${REPOSITORY_DIR}/sflphone-client-kde" +REPOSITORY_SFLPHONE_CLIENT_GNOME_DIR="${REPOSITORY_DIR}/sflphone-client-gnome" + +# where results go +PACKAGING_RESULT_DIR=${ROOT_DIR}/packages-${TAG} + +USER="sflphone" + +RELEASE_MODE= +VERSION_APPEND= + +DO_PREPARE=1 +DO_MAIN_LOOP=1 +DO_SIGNATURES=1 +DO_UPLOAD=1 +DO_LOGGING=1 +DO_SEND_EMAIL=1 + +EDITOR=echo +export EDITOR + +MACHINES=( "ubuntu-8.04" "ubuntu-8.04-64" "ubuntu-8.10" "ubuntu-8.10-64" "ubuntu-9.04" "ubuntu-9.04-64" ) + +######################### +# BEGIN +######################### + +echo +echo " /***********************\\" +echo " | SFLPhone build system |" +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 $* +do + case ${PARAMETER} in + --help) + echo + echo "Options :" + echo " --skip-prepare" + echo " --skip-main-loop" + echo " --skip-signatures" + echo " --skip-upload" + echo " --no-logging" + echo " --machine=MACHINE" + echo " --release-mode=[beta|rc|release]" + echo " --list-machines" + echo + exit 0;; + --skip-prepare) + unset DO_PREPARE;; + --skip-main-loop) + unset DO_MAIN_LOOP;; + --skip-signatures) + unset DO_SIGNATURES;; + --skip-upload) + unset DO_UPLOAD;; + --no-logging) + unset DO_LOGGING;; + --machine=*) + MACHINES=(${PARAMETER##*=});; + --release-mode=*) + RELEASE_MODE=(${PARAMETER##*=});; + --list-machines) + echo "Available machines :" + for MACHINE in ${MACHINES}; do + echo " "${MACHINE} + done + exit 0;; + *) + echo "Unknown parameter : ${PARAMETER}" + exit -1;; + esac +done + +# logging +mkdir ${PACKAGING_RESULT_DIR} 2>/dev/null +if [ ${DO_LOGGING} ]; then + + # open file descriptor + rm -f ${PACKAGING_RESULT_DIR}/packaging.log + exec 3<> ${PACKAGING_RESULT_DIR}/packaging.log + + # redirect outputs (stdout & stderr) + exec 1>&3 + exec 2>&3 +fi + +# check release +if [ ${RELEASE_MODE} ]; then + case ${RELEASE_MODE} in + beta);; + rc[1-9]);; + release);; + *) + echo "Bad release mode" + exit -1;; + esac +fi + +# check machines list +if [ -z "${MACHINES}" ]; then + echo "Need at least a machine name to launch" + exit -1 +fi + +echo +echo "Launching build system with the following machines :" +for MACHINE in ${MACHINES[*]} +do + echo " "${MACHINE} +done +echo + +if [ ${RELEASE_MODE} ]; then + echo "Release mode : ${RELEASE_MODE}" + if [ "${RELEASE_MODE}" != "release" ];then + VERSION_APPEND="~${RELEASE_MODE}" + fi +else + echo "Snapshot mode" +fi + +######################### +# COMMON PART +######################### + +if [ ${DO_PREPARE} ]; then + + echo + echo "Cleaning old deploy dir" + rm -rf ${TODEPLOY_DIR} + mkdir ${TODEPLOY_DIR} + mkdir ${TODEPLOY_BUILD_DIR} + + echo "Clone repository" + git clone ssh://repos-sflphone-git@sflphone.org/~/sflphone.git ${REPOSITORY_DIR} >/dev/null 2>&1 + + + if [ "$?" -ne "0" ]; then + echo " !! Cannot clone repository" + exit -1 + fi + + FULL_VER=`cd ${REPOSITORY_DIR} && git describe --tag HEAD | cut -d "/" -f2 | cut -d "-" -f1-2` + + # change current branch if needed + if [ ${RELEASE_MODE} ]; then + cd ${REPOSITORY_DIR} + echo "Using release branch" + git checkout origin/release -b release + else + echo "Using master branch" + fi + + # generate the changelog, according to the distribution and the git commit messages + echo "Update changelogs" + + # use git to generate changelogs + # 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 + echo "!! Cannot update changelogs" + exit -1 + 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} + echo "Update repository with new changelog" + echo " Switch to master branch to commit" + if [ ${RELEASE_MODE} ]; then + + echo "Switch to master branch for commit" + git checkout master + fi + + echo " Doing commit" + VERSION_COMMIT=${FULL_VER}${VERSION_APPEND} + if [ ! ${RELEASE_MODE} ]; then + VERSION_COMMIT=${FULL_VER}" Snapshot ${TAG}" + fi + git-commit -m "[#1262] Updated changelogs for version ${VERSION_COMMIT}" . >/dev/null + echo " Pushing commit" + git push origin master >/dev/null + + # change back current branch if needed + if [ ${RELEASE_MODE} ]; then + echo "Switch back to release branch" + git checkout release + git merge master + fi + + echo "Archiving repository" + tar czf ${REPOSITORY_ARCHIVE} -C `dirname ${REPOSITORY_DIR}` sflphone + + if [ "$?" -ne "0" ]; then + echo " !! Cannot archive repository" + exit -1 + fi + + echo "Removing repository" + rm -rf ${REPOSITORY_DIR} + + echo "Finish preparing deploy directory" + cp -r ${PACKAGING_SCRIPTS_DIR}/* ${TODEPLOY_DIR} + + if [ "$?" -ne "0" ]; then + echo " !! Cannot prepare scripts for deployment" + exit -1 + fi +fi + +######################### +# MAIN LOOP +######################### + +if [ ${DO_MAIN_LOOP} ]; then + + echo + echo "Entering main loop" + echo + + for MACHINE in ${MACHINES[*]} + do + + echo "Launch machine ${MACHINE}" + VM_STATE=`VBoxManage showvminfo ${MACHINE} | grep State | awk '{print $2}'` + if [ "${VM_STATE}" = "running" ]; then + echo "Not needed, already running" + else + cd ${VBOX_USER_HOME} && VBoxHeadless -startvm "${MACHINE}" -p 50000 & + echo "Wait ${STARTUP_WAIT} s" + sleep ${STARTUP_WAIT} + 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" + ${SSH_BASE} "rm -rf ${REMOTE_DEPLOY_DIR} 2>/dev/null" + + echo "Deploy packaging system" + ${SCP_BASE} ${TODEPLOY_DIR} ${SSH_HOST}: + + if [ "$?" -ne "0" ]; then + echo " !! Cannot deploy packaging system" + exit -1 + fi + + echo "Launch remote build" + ${SSH_BASE} "${REMOTE_DEPLOY_DIR}/build-package-ubuntu.sh ${RELEASE_MODE}" + + if [ "$?" -ne "0" ]; then + echo " !! Error during remote packaging process" + # exit -1 + fi + + echo "Retrieve dists and log files (current tag is ${TAG})" + ${SCP_BASE} ${SSH_HOST}:${REMOTE_DEPLOY_DIR}/dists ${PACKAGING_RESULT_DIR}/ + ${SCP_BASE} ${SSH_HOST}:${REMOTE_DEPLOY_DIR}"/*.log" ${PACKAGING_RESULT_DIR}/ + + if [ "$?" -ne "0" ]; then + echo " !! Cannot retrieve remote files" + exit -1 + fi + + if [ "${VM_STATE}" = "running" ]; then + echo "Leave machine running" + else + echo "Shut down machine ${MACHINE}" + ${SSH_BASE} 'sudo shutdown -h now' + echo "Wait ${SHUTDOWN_WAIT} s" + sleep ${SHUTDOWN_WAIT} + echo "Hard shut down" + cd "${VBOX_USER_HOME}" && VBoxManage controlvm ${MACHINE} poweroff + fi + done +fi + +######################### +# SIGNATURES +######################### + +if [ ${DO_SIGNATURES} ]; then + + echo + echo "Sign packages" + echo + + echo "Check GPG agent" + pgrep -u "sflphone" gpg-agent > /dev/null + if [ "$?" -ne "0" ]; then + echo "!! GPG agent is not running" + exit -1 + fi + GPG_AGENT_INFO=`cat $HOME/.gpg-agent-info 2> /dev/null` + export ${GPG_AGENT_INFO} + + if [ "${GPG_AGENT_INFO}" == "" ]; then + echo "!! Cannot get GPG agent info" + exit -1 + fi + + echo "Sign packages" + find ${PACKAGING_RESULT_DIR} -name "*.deb" -exec dpkg-sig -k 'Savoir-Faire Linux Inc.' --sign builder --sign-changes full {} \; >/dev/null 2>&1 + find ${PACKAGING_RESULT_DIR} -name "*.changes" -printf "debsign -k'Savoir-Faire Linux Inc.' %p\n" | sh >/dev/null 2>&1 +fi + +######################### +# UPLOAD FILES +######################### + +if [ ${DO_UPLOAD} ]; then + + echo + echo "Upload packages" + echo + + echo "Prepare packages upload" + scp ${SSH_OPTIONS} ${PACKAGING_SCRIPTS_DIR}/update-repository.sh ${SSH_REPOSITORY_HOST}: + + if [ "$?" -ne "0" ]; then + echo " !! Cannot deploy repository scripts" + fi + + echo "Upload packages" + echo "Install dists files to repository" + scp -r ${SSH_OPTIONS} ${PACKAGING_RESULT_DIR}/dists ${SSH_REPOSITORY_HOST}: + + if [ "$?" -ne "0" ]; then + echo " !! Cannot upload packages" + exit -1 + fi + + echo "Update repository" + ssh ${SSH_OPTIONS} ${SSH_REPOSITORY_HOST} "./update-repository.sh" + + if [ "$?" -ne "0" ]; then + echo " !! Cannot update repository" + exit -1 + fi +fi + +# close file descriptor +exec 3>&- + +exit 0 + diff --git a/tools/build-system/packages/git-buildpackage_0.4.45_all.deb b/tools/build-system/packages/git-buildpackage_0.4.45_all.deb new file mode 100644 index 0000000000000000000000000000000000000000..cf62358c48f1a5ce054c997b8b87ef9dac677028 Binary files /dev/null and b/tools/build-system/packages/git-buildpackage_0.4.45_all.deb differ diff --git a/tools/build-system/remote/build-package-ubuntu.sh b/tools/build-system/remote/build-package-ubuntu.sh new file mode 100755 index 0000000000000000000000000000000000000000..0a28c1790cc75c6bb621289cced618085ca0640c --- /dev/null +++ b/tools/build-system/remote/build-package-ubuntu.sh @@ -0,0 +1,175 @@ +#!/bin/bash +# +# @author: Yun Liu <yun.liu@savoirfairelinux.com>, Julien Bonjean <julien.bonjean@savoirfairelinux.com> +# +# Refer to http://www.sflphone.org for futher information +# + +PLATFORM="ubuntu" + +ROOT_DIR="/home/sflphone/sflphone-packaging" +BUILD_DIR="${ROOT_DIR}/build" +DIST_DIR="${ROOT_DIR}/dists" +REPOSITORY_ARCHIVE="${BUILD_DIR}/sflphone.tar.gz" +REPOSITORY_DIR="${BUILD_DIR}/sflphone" +REPOSITORY_SFLPHONE_COMMON_DIR="${REPOSITORY_DIR}/sflphone-common" +REPOSITORY_SFLPHONE_CLIENT_KDE_DIR="${REPOSITORY_DIR}/sflphone-client-kde" +REPOSITORY_SFLPHONE_CLIENT_GNOME_DIR="${REPOSITORY_DIR}/sflphone-client-gnome" +USER="sflphone" +DIST_APPEND="-daily" +RELEASE_MODE=$1 +VERSION_APPEND= +EDITOR=echo +export EDITOR + +######################### +# BEGIN +######################### + +WHO=`whoami` + +if [ "${WHO}" != "${USER}" ]; then + echo "!! Please use user ${USER} to run this script" + exit -1; +fi + +if [ ${RELEASE_MODE} ]; then + echo "Release mode : ${RELEASE_MODE}" + if [ "${RELEASE_MODE}" = "release" ]; then + DIST_APPEND="" + else + DIST_APPEND="-testing" + VERSION_APPEND="~${RELEASE_MODE}" + fi +else + echo "Snapshot mode" +fi + +cd ${ROOT_DIR} + +if [ "$?" -ne "0" ]; then + echo " !! Cannot cd to working directory" + exit -1 +fi + +# decompress reppository +echo "Untar repository" +cd ${BUILD_DIR} && tar xf ${REPOSITORY_ARCHIVE} + +if [ "$?" -ne "0" ]; then + echo " !! Cannot untar repository" + exit -1 +fi + +echo "Switch to internal logging" + +# get system parameters +ARCH_FLAG=`getconf -a|grep LONG_BIT | sed -e 's/LONG_BIT\s*//'` +OS_VERSION=`lsb_release -d -s -c | sed -e '1d'` +VER=`cd ${REPOSITORY_DIR} && git describe --tag HEAD | cut -d "/" -f2 | cut -d "-" -f1` +FULL_VER=`cd ${REPOSITORY_DIR} && git describe --tag HEAD | cut -d "/" -f2 | cut -d "-" -f1-2` + +# define log files +GLOBAL_LOG=${ROOT_DIR}/sflphone-${OS_VERSION}-${ARCH_FLAG}.log +PACKAGING_LOG=${ROOT_DIR}/sflphone-debuild-${OS_VERSION}-${ARCH_FLAG}.log + +# open log file +exec 3<>${GLOBAL_LOG} + +# redirect outputs (stdout & stderr) +exec 1>&3 +exec 2>&3 + +echo "SFLPhone version is ${VER}" + +# generate the changelog, according to the distribution and the git commit messages +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_CLIENT_KDE_DIR}/debian/changelog && \ + sed -i 's/SYSTEM/'${OS_VERSION}'/g' ${REPOSITORY_SFLPHONE_CLIENT_GNOME_DIR}/debian/changelog + +if [ "$?" -ne "0" ]; then + echo "!! Cannot generate changelogs" + exit -1 +fi + +# copy the appropriate control file based on different archtecture +echo "Generate control files" +cp ${REPOSITORY_SFLPHONE_COMMON_DIR}/debian/control.$OS_VERSION ${REPOSITORY_SFLPHONE_COMMON_DIR}/debian/control && \ + # cp ${REPOSITORY_SFLPHONE_CLIENT_KDE_DIR}/debian/control.$OS_VERSION ${REPOSITORY_SFLPHONE_CLIENT_KDE_DIR}/debian/control && \ + cp ${REPOSITORY_SFLPHONE_CLIENT_GNOME_DIR}/debian/control.$OS_VERSION ${REPOSITORY_SFLPHONE_CLIENT_GNOME_DIR}/debian/control + +if [ "$?" -ne "0" ]; then + echo "!! Cannot generate control files" + exit -1 +fi + +# provide prerequisite directories used by debuild +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-$VER.orig && \ + # cp -r ${REPOSITORY_SFLPHONE_CLIENT_KDE_DIR} ${BUILD_DIR}/sflphone-client-kde-$VER.orig && \ + cp -r ${REPOSITORY_SFLPHONE_CLIENT_GNOME_DIR} ${BUILD_DIR}/sflphone-client-gnome-$VER.orig && \ +# do a cp to because path must remain for client compilation +mv ${REPOSITORY_SFLPHONE_COMMON_DIR} ${BUILD_DIR}/sflphone-common-$VER && \ + # mv ${REPOSITORY_SFLPHONE_CLIENT_KDE_DIR} ${BUILD_DIR}/sflphone-client-kde-$VER && \ + mv ${REPOSITORY_SFLPHONE_CLIENT_GNOME_DIR} ${BUILD_DIR}/sflphone-client-gnome-$VER + +# build package sflphone-common +cd ${BUILD_DIR}/sflphone-common-$VER/debian && \ +debuild -us -uc >${PACKAGING_LOG} 2>&1 + +if [ "$?" -ne "0" ]; then + echo "!! Cannot generate package sflphone-common" + exit -1 +fi + +# build package sflphone-client-gnome +cd ${BUILD_DIR}/sflphone-client-gnome-$VER/debian && \ +debuild -us -uc >${PACKAGING_LOG} 2>&1 + +if [ "$?" -ne "0" ]; then + echo "!! Cannot generate package sflphone-client-gnome" + exit -1 +fi + +# build package sflphone-client-kde +# cd ${BUILD_DIR}/sflphone-client-kde-$VER/debian && \ +# debuild -us -uc >${PACKAGING_LOG} 2>&1 + +# if [ "$?" -ne "0" ]; then +# echo "!! Cannot generate package sflphone-client-kde" +# exit -1 +# fi + +# move to dist +echo "Deploy files in dist directories" +BINARY_DIR="" +if [ "${ARCH_FLAG}" -eq "32" ]; then + BINARY_DIR="binary-i386" +else + BINARY_DIR="binary-amd64" +fi + +mkdir -p ${DIST_DIR}/${OS_VERSION}${DIST_APPEND}/universe/source +mkdir -p ${DIST_DIR}/${OS_VERSION}${DIST_APPEND}/universe/${BINARY_DIR} + +mv ${BUILD_DIR}/sflphone*.deb ${DIST_DIR}/${OS_VERSION}${DIST_APPEND}/universe/${BINARY_DIR} && \ +mv ${BUILD_DIR}/sflphone*.dsc ${DIST_DIR}/${OS_VERSION}${DIST_APPEND}/universe/source/ && \ +mv ${BUILD_DIR}/sflphone*.build ${DIST_DIR}/${OS_VERSION}${DIST_APPEND}/universe/source/ && \ +mv ${BUILD_DIR}/sflphone*.changes ${DIST_DIR}/${OS_VERSION}${DIST_APPEND}/universe/source/ && \ +mv ${BUILD_DIR}/sflphone*.orig.tar.gz ${DIST_DIR}/${OS_VERSION}${DIST_APPEND}/universe/source/ && \ +mv ${BUILD_DIR}/sflphone*.diff.gz ${DIST_DIR}/${OS_VERSION}${DIST_APPEND}/universe/source/ + +if [ "$?" -ne "0" ]; then + echo "!! Cannot copy dist files" + exit -1 +fi + +echo "All done" + +# close file descriptor +exec 3>&- + +exit 0 + diff --git a/tools/build-system/remote/update-repository.sh b/tools/build-system/remote/update-repository.sh new file mode 100755 index 0000000000000000000000000000000000000000..f03e3b232e6e52166a6d4d38b83930f716324864 --- /dev/null +++ b/tools/build-system/remote/update-repository.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +# Script to update the debian repository description files (Release, Packages, Sources) +# +# @author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com> +# @date: 2008 Jan 16 + +ROOT_DIR="/var/repos/sflphone/debian" +USER="sflphone-package-manager" + +export LANG=en_CA.UTF-8 +export LC_ALL=en_CA.UTF-8 + +WHO=`whoami` + +if [ "${WHO}" != "${USER}" ]; then + echo "!! Please use user ${USER} to run this script" + exit -1; +fi + +echo "Check GPG agent" +pgrep -u "sflphone-package-manager" gpg-agent > /dev/null +if [ "$?" -ne "0" ]; then + echo "!! GPG agent is not running" + exit -1 +fi +GPG_AGENT_INFO=`cat $HOME/.gpg-agent-info 2> /dev/null` +export ${GPG_AGENT_INFO} + +if [ "${GPG_AGENT_INFO}" == "" ]; then + echo "!! Cannot get GPG agent info" + exit -1 +fi + +apt-ftparchive generate conf/apt-ftparchive.conf + +echo "Generate the description file for each distribution" +apt-ftparchive -c conf/apt-hardy-release.conf release dists/hardy > dists/hardy/Release +apt-ftparchive -c conf/apt-hardy-testing.conf release dists/hardy-testing > dists/hardy-testing/Release +apt-ftparchive -c conf/apt-hardy-daily.conf release dists/hardy-daily > dists/hardy-daily/Release + +apt-ftparchive -c conf/apt-intrepid-release.conf release dists/intrepid > dists/intrepid/Release +apt-ftparchive -c conf/apt-intrepid-testing.conf release dists/intrepid-testing > dists/intrepid-testing/Release +apt-ftparchive -c conf/apt-intrepid-daily.conf release dists/intrepid-daily > dists/intrepid-daily/Release + +apt-ftparchive -c conf/apt-jaunty-release.conf release dists/jaunty > dists/jaunty/Release +apt-ftparchive -c conf/apt-jaunty-testing.conf release dists/jaunty-testing > dists/jaunty-testing/Release +apt-ftparchive -c conf/apt-jaunty-daily.conf release dists/jaunty-daily > dists/jaunty-daily/Release + +echo "Sign the Release files" + +rm -f dists/intrepid/Release.gpg +rm -f dists/intrepid-testing/Release.gpg +rm -f dists/intrepid-daily/Release.gpg +gpg --no-tty -u C842D122 --output dists/intrepid/Release.gpg -ba dists/intrepid/Release +gpg --no-tty -u C842D122 --output dists/intrepid-testing/Release.gpg -ba dists/intrepid-testing/Release +gpg --no-tty -u C842D122 --output dists/intrepid-daily/Release.gpg -ba dists/intrepid-daily/Release + +rm -f dists/hardy/Release.gpg +rm -f dists/hardy-testing/Release.gpg +rm -f dists/hardy-daily/Release.gpg +gpg --no-tty -u C842D122 --output dists/hardy/Release.gpg -ba dists/hardy/Release +gpg --no-tty -u C842D122 --output dists/hardy-testing/Release.gpg -ba dists/hardy-testing/Release +gpg --no-tty -u C842D122 --output dists/hardy-daily/Release.gpg -ba dists/hardy-daily/Release + +rm -f dists/jaunty/Release.gpg +rm -f dists/jaunty-testing/Release.gpg +rm -f dists/jaunty-daily/Release.gpg +gpg --no-tty -u C842D122 --output dists/jaunty/Release.gpg -ba dists/jaunty/Release +gpg --no-tty -u C842D122 --output dists/jaunty-testing/Release.gpg -ba dists/jaunty-testing/Release +gpg --no-tty -u C842D122 --output dists/jaunty-daily/Release.gpg -ba dists/jaunty-daily/Release + +echo "All done" +exit 0 diff --git a/tools/build-system/send-emails.sh b/tools/build-system/send-emails.sh new file mode 100755 index 0000000000000000000000000000000000000000..065e9c691a071a48b0f10f5206972b9abf9ad49f --- /dev/null +++ b/tools/build-system/send-emails.sh @@ -0,0 +1,40 @@ +#!/bin/bash +##################################################### +# File Name: send-emails.sh +# +# Purpose : +# +# Author: Julien Bonjean (julien@bonjean.info) +# +# Creation Date: 2009-04-20 +# Last Modified: +##################################################### + +TAG=`date +%Y-%m-%d` +ROOT_DIR="/home/projects/sflphone" +PACKAGING_RESULT_DIR=${ROOT_DIR}/packages-${TAG} +STATUS="OK" + +if [ "$1" -ne 0 ]; then + STATUS="ERROR" +fi + +echo +echo "Send notification emails" +echo + +MAIL_SUBJECT="[ ${TAG} ] SFLphone Automatic Build System : ${STATUS}" + +if [ "$1" -eq 0 ]; then + echo | mail -s "${MAIL_SUBJECT}" -c emmanuel.milou@savoirfairelinux.com julien.bonjean@savoirfairelinux.com +else + ( + for i in ${PACKAGING_RESULT_DIR}/*.log + do + uuencode $i $(basename $i) + done + ) | mail -s "${MAIL_SUBJECT}" -c emmanuel.milou@savoirfairelinux.com julien.bonjean@savoirfairelinux.com +fi + +exit 0 +