source: trunk/scripts/git-hooks/super/build-pre-receive @ 2389

Last change on this file since 2389 was 2355, checked in by price, 15 years ago

integrate most of invirt-build-receive into build-pre-receive

  • Property svn:executable set to *
File size: 2.3 KB
Line 
1#!/bin/bash
2set -e
3
4read oldrev newrev head
5if [ $head != 'refs/heads/dev' ]; then
6  echo "error: head not recognized: $head" >&2
7  exit 1
8fi
9if read; then
10  echo "error: one update at a time, please" >&2
11  exit 1
12fi
13
14tmpdir=$(mktemp -d /tmp/xvm-git-XXXXXX)
15echo "build directory $tmpdir"
16
17# XXX fixme
18sbuild () { echo "  SBUILD" "$@"; }
19
20build_package () {
21  packagepath=$1
22  rev=$2
23
24  package=${packagepath#packages/}
25  url=$(git config -f $tmpdir/git/.gitmodules submodule.$packagepath.url)
26  echo "building $package at new version $rev"
27
28  srcdir=$tmpdir/$package
29  mkdir $srcdir
30  # XXX remove that .git -- be sure to include it in `git submodule add`
31  git --git-dir=$url.git archive $rev | tar -xf - -C $srcdir
32  pushd $srcdir >/dev/null
33
34  eval $(perl -ne 'print if s/^(Version|Source|Distribution): /\1=/' \
35           <(dpkg-parsechangelog))
36  dpkg-buildpackage -us -uc -rfakeroot -S
37  cd ..
38
39  eval $(perl -ne 'print if s/^(Architecture): /\1=/' ${Source}_${Version}.dsc)
40  case $Architecture in
41    all)
42      sbuild -d $distribution --arch-all   ${Source}_${Version}.dsc;;
43    any)
44      sbuild -d $distribution --arch amd64 --arch-all ${Source}_${Version}.dsc
45      sbuild -d $distribution --arch i386  ${Source}_${Version}.dsc;;
46    *)
47      echo "build-pre-receive: arch '$Architecture' unimplemented" >&2
48      exit 1
49  esac
50
51  echo "XXX tag submodule as $Version"
52
53  [ $Distribution = 'unstable' ] \
54      || echo "$(basename $0): warning: Distribution is $Distribution, script expects unstable"
55
56  echo "built $package version $Version from commit $rev"
57  popd >/dev/null
58}
59
60git clone . $tmpdir/git
61
62git ls-tree $newrev packages/ \
63 | grep ^160000\ commit \
64 | while read x y newsubrev packagepath; do
65     # XXX deal with new packages
66     # XX deal with removed packages
67     oldsubrev=$(git ls-tree $oldrev $packagepath | perl -lane 'print $F[2]')
68     if [ $newsubrev == $oldsubrev ]; then
69       continue
70     fi
71
72     build_package $packagepath $newsubrev
73   done
74
75
76exit 0
77
78for package; do
79    changesfile=`pwd`/${Source}_*${Version}*.changes
80    for i in $changesfile; do
81        reprepro-env include unstable $i
82        reprepro-env copy stable unstable $(sed -ne 's/^Binary: //p' $i)
83    done
84    reprepro-env copy stable unstable $Source
85   
86    cd ..
87    rm -rf build-release/$package
88done
Note: See TracBrowser for help on using the repository browser.