#!/bin/sh
-
usage()
{
cat <<EOF
Usage: id-pbuild-root.sh [OPTIONS]
Options:
+ [--arch=architecture]
+ [--dist=distribution]
[--dsc=dscfile]
- [--dist=distribution]
- [--arch=architecture]
+ [--update=true|false]
EOF
exit $1
}
+D0=`dirname $0`
+do_help=false
+update=true
while test $# -gt 0; do
case "$1" in
- -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
- *) optarg= ;;
+ -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) optarg= ;;
esac
-
case $1 in
- --dist=*)
- dist=$optarg
- ;;
- --arch=*)
- arch=$optarg
- ;;
- --dsc=*)
- dsc=$optarg
- ;;
- -*)
- do_help=yes
- ;;
+ --dist=*)
+ DIST=$optarg
+ ;;
+ --arch=*)
+ ARCH=$optarg
+ ;;
+ --dsc=*)
+ DSC=$optarg
+ ;;
+ --update=*)
+ update=$optarg
+ ;;
+ -*)
+ do_help=yes
+ ;;
esac
shift
done
-
-PBUILDER=/usr/sbin/pbuilder
-
-rm -fr ${dist}-${arch}
-
-if test "$dsc"; then
- if test ! -f /var/cache/pbuilder/${dist}-${arch}-base.tgz; then
- DIST=$dist ARCH=$arch $PBUILDER --create
- fi
- DIST=$dist ARCH=$arch $PBUILDER --update --override-config
- DIST=$dist ARCH=$arch $PBUILDER --build $dsc
+if test "$do_help" = "yes"; then
+ usage 1 1>&2
+fi
+if test -z "$DIST"; then
+ echo "id-pbuild-root.sh: missing --dist"
+ exit 1
+fi
+if test -z "$ARCH"; then
+ echo "id-pbuild-root.sh: missing --arch"
+ exit 1
fi
+if test -z "$DSC"; then
+ echo "id-pbuild-root.sh: missing --dsc"
+ exit 1
+fi
+if test ! -x /usr/bin/lxc-attach; then
+ echo "No lxc-attach. Probably not running on mochi!!"
+ exit 1
+fi
+export DIST ARCH # export for pbuilder to see
+echo "$DIST-$ARCH begin"
+if $update; then
+ if ! lxc-attach -n pbuilder -- pbuilder --update --override-config >update-${DIST}-${ARCH}.log 2>&1; then
+ if ! lxc-attach -n pbuilder -- pbuilder --create >create-${DIST}-${ARCH}.log 2>&1; then
+ echo "$DIST-$ARCH failed. Inspect deb-src/create-${DIST}-${ARCH}.log"
+ exit 2
+ fi
+ if ! lxc-attach -n pbuilder -- pbuilder --update --override-config >update-${DIST}-${ARCH}.log 2>&1; then
+ echo "$DIST-$ARCH failed. Inspect deb-src/update-${DIST}-${ARCH}.log"
+ exit 2
+ fi
+ fi
+fi
+if ! lxc-attach -n pbuilder -- pbuilder --build $DSC >build-${DIST}-${ARCH}.log 2>&1; then
+ echo "$DIST-$ARCH failed. Inspect deb-src/build-${DIST}-${ARCH}.log"
+ exit 3
+fi
+echo "$DIST-$ARCH done"
+exit 0
# Local Variables:
# mode:shell-script
-# sh-indentation: 2
+# sh-indentation: 4
# sh-basic-offset: 4
# End:
+