begin to sketch git pre-receive hook
authorGreg Price <price@mit.edu>
Fri, 8 May 2009 02:42:32 +0000 (22:42 -0400)
committerGreg Price <price@mit.edu>
Fri, 8 May 2009 02:42:32 +0000 (22:42 -0400)
svn path=/trunk/scripts/git-hooks/; revision=2349

notes [new file with mode: 0644]
sub/post-receive
super/build-pre-receive [new file with mode: 0755]
super/post-receive
super/pre-receive [new file with mode: 0755]

diff --git a/notes b/notes
new file mode 100644 (file)
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.
+
index e6987f1..53bd274 100755 (executable)
@@ -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 (executable)
index 0000000..0343362
--- /dev/null
@@ -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
index e6987f1..53bd274 100755 (executable)
@@ -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 (executable)
index 0000000..bf0a2c0
--- /dev/null
@@ -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