From 3c4ee771bae6bad3eb5727982345bde2322cab59 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Sat, 13 Jun 2009 17:46:28 -0400 Subject: [PATCH] integrate most of invirt-build-receive into build-pre-receive svn path=/trunk/scripts/git-hooks/; revision=2355 --- super/build-pre-receive | 102 +++++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 47 deletions(-) diff --git a/super/build-pre-receive b/super/build-pre-receive index 0343362..d6f84cb 100755 --- a/super/build-pre-receive +++ b/super/build-pre-receive @@ -1,10 +1,63 @@ #!/bin/bash +set -e read oldrev newrev head -if [ $head != 'dev' ]; then +if [ $head != 'refs/heads/dev' ]; then echo "error: head not recognized: $head" >&2 exit 1 fi +if read; then + echo "error: one update at a time, please" >&2 + exit 1 +fi + +tmpdir=$(mktemp -d /tmp/xvm-git-XXXXXX) +echo "build directory $tmpdir" + +# XXX fixme +sbuild () { echo " SBUILD" "$@"; } + +build_package () { + packagepath=$1 + rev=$2 + + package=${packagepath#packages/} + url=$(git config -f $tmpdir/git/.gitmodules submodule.$packagepath.url) + echo "building $package at new version $rev" + + srcdir=$tmpdir/$package + mkdir $srcdir + # XXX remove that .git -- be sure to include it in `git submodule add` + git --git-dir=$url.git archive $rev | tar -xf - -C $srcdir + pushd $srcdir >/dev/null + + eval $(perl -ne 'print if s/^(Version|Source|Distribution): /\1=/' \ + <(dpkg-parsechangelog)) + dpkg-buildpackage -us -uc -rfakeroot -S + cd .. + + eval $(perl -ne 'print if s/^(Architecture): /\1=/' ${Source}_${Version}.dsc) + case $Architecture in + all) + sbuild -d $distribution --arch-all ${Source}_${Version}.dsc;; + any) + sbuild -d $distribution --arch amd64 --arch-all ${Source}_${Version}.dsc + sbuild -d $distribution --arch i386 ${Source}_${Version}.dsc;; + *) + echo "build-pre-receive: arch '$Architecture' unimplemented" >&2 + exit 1 + esac + + echo "XXX tag submodule as $Version" + + [ $Distribution = 'unstable' ] \ + || echo "$(basename $0): warning: Distribution is $Distribution, script expects unstable" + + echo "built $package version $Version from commit $rev" + popd >/dev/null +} + +git clone . $tmpdir/git git ls-tree $newrev packages/ \ | grep ^160000\ commit \ @@ -16,58 +69,13 @@ git ls-tree $newrev packages/ \ continue fi - echo "must build $packagepath at new version $newsubrev" + build_package $packagepath $newsubrev done - - - exit 0 -distribution=hardy -svnuri="$(invirt-getconf svn.uri)" - -set -e -if [ $# -eq 0 ] ; then - echo " usage: invirt-build-release package_name [package_name [...]]" - exit 1 -fi - for package; do - rm -rf build-release/$package - svn export $svnuri/trunk/packages/$package build-release/$package - cd build-release/$package - - eval $(perl -ne 'print if s/^(Version|Source|Distribution): /\1=/' \ - <(dpkg-parsechangelog)) - dpkg-buildpackage -us -uc -rfakeroot -S - cd .. - eval $(perl -ne 'print if s/^(Architecture): /\1=/' ${Source}_${Version}.dsc) - case $Architecture in - all) - sbuild -d $distribution --arch-all ${Source}_${Version}.dsc;; - any) - sbuild -d $distribution --arch amd64 --arch-all ${Source}_${Version}.dsc - sbuild -d $distribution --arch i386 ${Source}_${Version}.dsc;; - *) - echo "invirt-build-release: arch '$Architecture' unimplemented" >&2 - exit 1 - esac - - if ! svn ls $svnuri/package_tags/$Source >/dev/null 2>&1; then - svn mkdir $svnuri/package_tags/$Source \ - -m "Create package tags directory" - fi - if ! svn ls $svnuri/package_tags/$Source/$Version >/dev/null 2>&1; then - svn cp $svnuri/trunk/packages/$package $svnuri/package_tags/$Source/$Version \ - -m "Tag $Version of $Source" - else - echo "$(basename $0): tag already exists, not making again" - fi - - [ $Distribution = 'unstable' ] \ - || echo "$(basename $0): warning: Distribution is $Distribution, script expects unstable" changesfile=`pwd`/${Source}_*${Version}*.changes for i in $changesfile; do reprepro-env include unstable $i -- 1.7.9.5