From a070886cbe878cbfed4aa6ce58c6f12ca5890c4c Mon Sep 17 00:00:00 2001 From: Greg Price Date: Thu, 7 May 2009 22:42:32 -0400 Subject: [PATCH] begin to sketch git pre-receive hook svn path=/trunk/scripts/git-hooks/; revision=2349 --- notes | 20 ++++++++++++ sub/post-receive | 2 +- super/build-pre-receive | 80 +++++++++++++++++++++++++++++++++++++++++++++++ super/post-receive | 2 +- super/pre-receive | 8 +++++ 5 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 notes create mode 100755 super/build-pre-receive create mode 100755 super/pre-receive diff --git a/notes b/notes new file mode 100644 index 0000000..0663e05 --- /dev/null +++ b/notes @@ -0,0 +1,20 @@ + + +on commit to submodule: + zephyr + nothing else? + +superrepo heads are dev, prod +on commit to superrepo: + for each changed submodule revision: + (as optimization: if same commit already in dev, just reprepro move) + try to build submodule + if fail, abort -- whole commit, probably; else + tag submodule with version + upload to dev/prod respectively + actually commit + zephyr + +This makes a long pre-receive process. Is that cool? +Probably is the right thing. + diff --git a/sub/post-receive b/sub/post-receive index e6987f1..53bd274 100755 --- a/sub/post-receive +++ b/sub/post-receive @@ -1,6 +1,6 @@ #!/bin/sh -file=`mktemp -t git-receive.XXXXXX` || exit $? +file=`mktemp -t git-post-receive.XXXXXX` || exit $? cat >$file "$PWD"/hooks/zephyr-post-receive <$file diff --git a/super/build-pre-receive b/super/build-pre-receive new file mode 100755 index 0000000..0343362 --- /dev/null +++ b/super/build-pre-receive @@ -0,0 +1,80 @@ +#!/bin/bash + +read oldrev newrev head +if [ $head != 'dev' ]; then + echo "error: head not recognized: $head" >&2 + exit 1 +fi + +git ls-tree $newrev packages/ \ + | grep ^160000\ commit \ + | while read x y newsubrev packagepath; do + # XXX deal with new packages + # XX deal with removed packages + oldsubrev=$(git ls-tree $oldrev $packagepath | perl -lane 'print $F[2]') + if [ $newsubrev == $oldsubrev ]; then + continue + fi + + echo "must build $packagepath at new version $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 + reprepro-env copy stable unstable $(sed -ne 's/^Binary: //p' $i) + done + reprepro-env copy stable unstable $Source + + cd .. + rm -rf build-release/$package +done diff --git a/super/post-receive b/super/post-receive index e6987f1..53bd274 100755 --- a/super/post-receive +++ b/super/post-receive @@ -1,6 +1,6 @@ #!/bin/sh -file=`mktemp -t git-receive.XXXXXX` || exit $? +file=`mktemp -t git-post-receive.XXXXXX` || exit $? cat >$file "$PWD"/hooks/zephyr-post-receive <$file diff --git a/super/pre-receive b/super/pre-receive new file mode 100755 index 0000000..bf0a2c0 --- /dev/null +++ b/super/pre-receive @@ -0,0 +1,8 @@ +#!/bin/sh + +file=`mktemp -t git-pre-receive.XXXXXX` || exit $? +cat >$file + +"$PWD"/hooks/build-pre-receive <$file + +rm -f $file -- 1.7.9.5