1707786693a948d21c1e868754d1684f2b9a63ce
[git-tools-moved-to-github.git] / id-deb-build / id-pbuild-root.sh
1 #!/bin/sh
2
3 usage()
4 {
5     cat <<EOF
6 Usage: id-pbuild-root.sh [OPTIONS]
7 Options:
8         [--dsc=dscfile]
9         [--dist=distribution]
10         [--arch=architecture]
11         [--home=home]
12
13 This script is should be called with root privilege. It is meant to be
14 called by id-pbuild.sh.
15 EOF
16     exit $1
17 }
18
19 while test $# -gt 0; do
20     case "$1" in
21         -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
22         *) optarg= ;;
23     esac
24     
25     case $1 in
26         --dist=*)
27             dist=$optarg
28             ;;
29         --arch=*)
30             arch=$optarg
31             ;;
32         --dsc=*)
33             dsc=$optarg
34             ;;
35         --home=*)
36             HOME=$optarg
37             ;;
38         -*)
39             usage 1
40             ;;
41     esac
42     shift
43 done
44
45 PBUILDER=/usr/sbin/pbuilder
46
47 if test -z "$dist" -o -z "$arch"; then
48     echo "dist and arch must be given"
49     usage 1
50 fi
51 rm -fr ${dist}-${arch}
52
53 if test ! -f $HOME/.pbuilderrc; then
54     echo "$HOME/.pbuilderrc missing"
55     exit 1
56 fi
57 if test "$dsc"; then
58     if test ! -f /var/cache/pbuilder/${dist}-${arch}-base.tgz; then
59         DIST=$dist ARCH=$arch $PBUILDER --create
60     fi
61     DIST=$dist ARCH=$arch $PBUILDER --update --override-config
62     DIST=$dist ARCH=$arch $PBUILDER --build $dsc
63 fi
64
65 # Local Variables:
66 # mode:shell-script
67 # sh-indentation: 2
68 # sh-basic-offset: 4
69 # End: