#!/bin/bash usage () { echo "Usage: $0 [-c codename] [-f] [-k] source_directory" exit 1 } . /usr/share/dev-tools/load-config forceDebuild=0 while getopts ":c:fk" option do case $option in f) forceDebuild=1 ;; k) keep=1 ;; \?|:) usage ;; esac done shift $(($OPTIND - 1)) dir=$1 if [ ! $dir ] then usage fi if [ -r $dir/debian/changelog ] then packageDir=$dir/.. if [ "$forceDebuild" -eq "0" ] then if [ -r $dir/debian/files ] then cut -d" " -f1 $dir/debian/files | while read package do if [ -z "$package" ] then continue fi if [ ! -r $packageDir/$package ] then forceDebuild=1 break fi done else forceDebuild=1 fi fi if [ "$forceDebuild" -ne "0" ] then (cd $dir && debuild -uc -us -b) if [ "$?" -ne "0" ] then echo "$0: Error while generating debian packages" exit 3 fi fi cut -d" " -f1 $dir/debian/files | while read package do if [[ ! $package =~ .*\.deb$ ]] then continue fi /usr/bin/dev-upload -c $codename $packageDir/$package if [ "$keep" -eq "0" ] then rm -f $packageDir/$package fi done if [ "$keep" -eq "0" ] then rm -f $packageDir/*.build rm -f $packageDir/*.changes (cd $dir && fakeroot debian/rules clean) fi else echo "$0: Invalid source directory: $dir" exit 2 fi