480cf36f88a765082fe7c917e49b6338abf4a16f
[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 -ne 'print if s/^(Version|Source|Distribution): /\1=/' \
16              <(dpkg-parsechangelog))
17     dpkg-buildpackage -us -uc -rfakeroot -S
18     cd ..
19     eval $(perl -ne 'print if s/^(Architecture): /\1=/' ${Source}_${Version}.dsc)
20     case $Architecture in
21       all)
22         sbuild -A -d hardy ${Source}_${Version}.dsc;;
23       any)
24         sbuild -d hardy-amd64 ${Source}_${Version}.dsc
25         sbuild -d hardy-i386  ${Source}_${Version}.dsc;;
26       *)
27         echo "invirt-build-release: arch '$Architecture' unimplemented" >&2
28         exit 1
29     esac
30
31     if ! svn ls $svnuri/package_tags/$Source >/dev/null 2>&1; then
32         svn mkdir $svnuri/package_tags/$Source \
33             -m "Create package tags directory"
34     fi
35     if ! svn ls $svnuri/package_tags/$Source/$Version >/dev/null 2>&1; then
36         svn cp $svnuri/trunk/packages/$package $svnuri/package_tags/$Source/$Version \
37             -m "Tag $Version of $Source"
38     else
39         echo "$(basename $0): tag already exists, not making again"
40     fi
41     
42     [ $Distribution = 'unstable' ] \
43         || echo "$(basename $0): warning: Distribution is $Distribution, script expects unstable"
44     changesfile=`pwd`/${Source}_*${Version}*.changes
45     for i in $changesfile; do
46         reprepro-env include unstable $i
47         reprepro-env copy stable unstable $(sed -ne 's/^Binary: //p' $i)
48     done
49     reprepro-env copy stable unstable $Source
50     
51     cd ..
52     rm -rf build-release/$package
53 done