#!/bin/bash # # Build package in local directory (or upwards) and optionally install on target host # set -e host='' rootcmd='fakeroot' usage () { local rc=$1 echo '-l opt_local - it seems to have no meaning' echo '-C Perform a "cvs update -Pd" first' echo '-c Perform a "debian/rules clean" first' echo '-h host where the packages will be installed on' echo '-r the rootcmd (default: fakeroot)' echo '-i install the package even if it was not installed before' echo '-a architecture amd64|i386' exit $rc } if [ -z "$TEST_PKG" ] then argv="$@" else argv="${TEST_PKG}$@" fi opts=`getopt -l "help" "lh:Ccr:a:i" $argv` eval set -- "$opts" while true do case "$1" in -l) opt_local="1" shift ;; -C) opt_cvs="1" shift ;; -c) opt_clean="1" shift ;; -h) host="$2" shift 2 || usage 2 >&2 ;; -r) rootcmd="$2" shift 2 || usage 2 >&2 ;; -i) install="1" shift ;; -a) arch=$(echo "$2" | sed -e 's/^\ *//') export $(dpkg-architecture -a"$arch") shift 2 || usage 2 >&2 ;; --help) usage 0 ;; --) shift break ;; esac done while ! [ -f debian/rules ] do if [ "$PWD" = "/" ] then echo "no source package" exit 1 fi cd .. done # cvs update if [ -n "$opt_cvs" ] then if test -d CVS then cvs update -Pd elif test -d .svn then svn up else echo "Not version control information found." >&2 exit 1 fi fi [ -n "$opt_clean" ] && $rootcmd debian/rules clean $rootcmd debian/rules binary || exit 1 set -o pipefail if [ -n "$host" ] then cut -d\ -f1 debian/files | tar -c -f - -C .. -T - | ssh $host ' inst-pkg () { p=$(echo "$1" | sed "s,^.*/\([^_]*\)[^/]*,\1,") if [ -n '"$install"' ] || dpkg -s "$p" 2>/dev/null | grep -q "^Status: install" then yes "" | PATH=/usr/sbin:/sbin:$PATH dpkg --force-confnew -i "$1" fi } T=$(mktemp -d) trap "rm -rf \"\$T\"" EXIT tar -xC "$T" for a in "$T"/*.deb do inst-pkg "$a" done' fi