From b8b2e403ae64b417a5928cb6a96b00478869b4f3 Mon Sep 17 00:00:00 2001 From: ranke Date: Mon, 14 Dec 2015 05:31:40 +0000 Subject: Fix and improvements - Copy sources to $DIST directory so quilt using packages work (littler, r-cran-coda, r-cran-rjags...) - Do not use getopts as the approach used did not work with multiple options - Use -s/--skip instead of -n to skip updates - Use -k/--keep to keep sources under $DIST directory git-svn-id: svn+ssh://stiller/home/schatz/reps/r-backports@112 f247ebf9-aa24-0410-a698-f940e971ad2b --- backport | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) (limited to 'backport') 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 -- cgit v1.2.1