summaryrefslogtreecommitdiff
path: root/backport
diff options
context:
space:
mode:
Diffstat (limited to 'backport')
-rwxr-xr-xbackport45
1 files changed, 32 insertions, 13 deletions
diff --git a/backport b/backport
index 4941aa0..2eb6b05 100755
--- a/backport
+++ b/backport
@@ -25,23 +25,34 @@ usage()
{
echo "Usage: ./backport [options] sourcepackage squeeze|wheezy|jessie"
echo "Options:"
-echo " -n Skip apt-get update/upgrade and pbuilder update"
+echo " -k, --keep Keep copied source package and directory used for package building"
+echo " -s, --skip Skip apt-get update/upgrade and pbuilder update"
}
-update=true
-while getopts ":n" flag; do
- case $flag in
- n)
- update=false
+# Loop over options
+skip=false
+keep=false
+while test -n "${1}"; do
+ case "$1" in
+ -k | --keep)
+ keep=true
+ shift
;;
- \?)
- echo "Invalid option: -$OPTARG" >&2
+ -s | --skip)
+ skip=true
+ shift
+ ;;
+ -*)
+ echo "Error: Unknown option: $1" >&2
+ exit 1
+ ;;
+ *) # No more options
+ break
;;
esac
- shift $((OPTIND-1))
done
-# Check for number of arguments
+# Positional arguments
if [ $# -lt 2 ]; then usage; exit 1; fi
pkg=$1
DIST=$2
@@ -60,7 +71,7 @@ then
fi
# Get current source from unstable
-if [ "$update" = true ]
+if [ "$skip" = false ]
then
sudo apt-get update
sudo apt-get upgrade
@@ -69,6 +80,7 @@ sudo apt-get source $pkg
# Copy sources to $DIST directory to enable parallel builds
mkdir -p $DIST
+cp -r $pkg\_* $DIST
cp -r $pkg-* $DIST
# Go to package building directory
@@ -99,7 +111,7 @@ script=../$pkg-reverts.sh
if [ -f $script ]; then source $script; fi
-if [ "$update" = true ]
+if [ "$skip" = false ]
then
sudo -E pbuilder update
fi
@@ -112,4 +124,11 @@ if [ $? -ne 0 ]; then
exit
fi
-cd ..
+cd ../..
+
+# Clean sources from $DIST directory
+if [ "$keep" = false ]
+then
+ rm -f $DIST/$pkg\_*
+ rm -rf $DIST/$pkg-*
+fi

Contact - Imprint