]> git.donarmstrong.com Git - neurodebian.git/blob - tools/nd_build
Move args checks into each script.
[neurodebian.git] / tools / nd_build
1 #!/bin/bash
2
3 if [ -z "$1" ]; then
4 cat << EOT
5 Script to build a source package in one of the available cowbuilders.
6
7 Synopsis
8 --------
9
10   nd_build <family> <codename> [arch] <dsc file> [cowbuilder options]
11
12
13 Examples
14 --------
15
16 Build for a single specific arch:
17
18   nd_build nd+debian lenny i386 someting.dsc
19
20
21 Build for all archs (will just build once for arch 'all'):
22
23   nd_build ubuntu jaunty something.dsc
24
25
26 Build the same way but don't put results in current dir:
27
28   nd_build debian sid something.dsc --buildresult to-upload/
29
30 EOT
31 exit 1
32 fi
33
34 family=$1
35 dist=$2
36
37 set -e
38
39 if [ -z "$family" ]; then
40   echo "You need to provide a distribution family ('debian', 'ubuntu'); prefix with 'nd+' to enable the NeuroDebian repository."
41   exit 1
42 fi
43
44 if [ -z "$dist" ]; then
45   echo "You need to provide a distribution codename (e.g. 'lenny', 'squeeze')."
46   exit 1
47 fi
48
49 . /home/neurodebian/neurodebian.git/tools/nd_cmdsettings.sh
50
51 # common options
52 opts="--distribution $dist --aptcache $aptcache --buildplace $buildplace"
53
54 if [ -z "$3" ]; then
55   echo "You need to provide a .dsc file"
56   exit 1
57 fi
58
59 if [ ! "$3" = "${3%*.dsc}" ]; then
60   dscfile=$3
61   # must already be the dsc file, hence no arch info given
62   if [ "$(grep '^Architecture' $dscfile | awk '{ print $2 }')" = "all" ]; then
63     echo "Arch 'all' package detected -- using amd64 system to build it"
64     arch="amd64"
65   else
66     arch="i386 amd64"
67   fi
68   shift; shift; shift
69 else
70   # must be arch given and dsc as 4th
71   arch=$3
72   dscfile=$4
73   if [ -z "$dscfile" ]; then
74     echo "You need to provide a .dsc file"
75     exit 1
76   fi
77   shift; shift; shift; shift
78 fi
79
80 for a in $arch; do
81   echo "Building for $family $dist $a ..."
82   cowbuilder --build $dscfile \
83              --basepath ${cowbuilderroot}/cow/${family}-${dist}-${a}.cow \
84              --buildresult . \
85              $opts \
86              $*
87 done