invirt-build-release: handle amd64 and i386
[invirt/packages/invirt-dev.git] / invirt-build-release
1 #!/bin/bash
2 svnuri="$(invirt-getconf svn.uri)"
3
4 set -e
5 if  [ $# -eq 0 ] ; then
6         echo " usage: invirt-build-release package_name [package_name [...]]"
7         exit 1
8 fi
9
10 for package; do
11     rm -rf build-release/$package
12     svn export $svnuri/trunk/packages/$package build-release/$package
13     cd build-release/$package
14     
15     eval  `perl '-F:\s+' -lane 'print  $F[0]."=".$F[1] if /^Version|^Source|^Distribution/' \
16         <(dpkg-parsechangelog)`
17     eval $(perl '-F:\s+' -lane 'print $F[0]."=".$F[1] if /^Binary|Architecture/' <"../${Source}_${Version}.dsc")
18
19     dpkg-buildpackage -us -uc -rfakeroot -S
20     cd ..
21     case $Architecture in
22       all)
23         sbuild -A -d hardy "${Source}_${Version}.dsc";;
24       any)
25         sbuild -d hardy-amd64 "${Source}_${Version}.dsc"
26         sbuild -d hardy-i386  "${Source}_${Version}.dsc";;
27       *)
28         echo "invirt-build-release: architecture '$Architecture' not 'all' or 'any'" >&2
29         exit 1
30     esac
31
32     if ! svn ls $svnuri/package_tags/$Source >/dev/null 2>&1; then
33         svn mkdir $svnuri/package_tags/$Source \
34             -m "Create package tags directory"
35     fi
36     if ! svn ls $svnuri/package_tags/$Source/$Version >/dev/null 2>&1; then
37         svn cp $svnuri/trunk/packages/$package $svnuri/package_tags/$Source/$Version \
38             -m "Tag $Version of $Source"
39     else
40         echo "$(basename $0): tag already exists, not making again"
41     fi
42     
43     [ $Distribution = 'unstable' ] \
44         || echo "$(basename $0): warning: Distribution is ${Distribution}, script expects unstable"
45     changesfile=`pwd`/${Source}_*${Version}*.changes
46     for i in $changesfile; do
47         reprepro-env include unstable $i
48         reprepro-env copy stable unstable \
49             $(perl '-F:\s+' -lane 'print $F[1]." " if /^Binary/' <$i)
50     done
51     reprepro-env copy stable unstable ${Source}
52     
53     cd ..
54     rm -rf build-release
55 done