From 9ac5845999f980880dcf5ce381a35aae56e08e8a Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Thu, 31 Jul 2014 21:28:32 +0100 Subject: move: Make the --backport argument only apply to the next package spec on the cmd line. This allows you to mix moving backports and regular updates in one command should you wish. I don't expect this to be used much, but it's more correct to do it this way I think. --- mga-move-pkg | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/mga-move-pkg b/mga-move-pkg index 0f5af54..f7602c1 100755 --- a/mga-move-pkg +++ b/mga-move-pkg @@ -21,22 +21,13 @@ if [ "$1" = "--no-confirm" ]; then shift fi -backport= -if [ "$1" = "--backport" ]; then - backport=y - shift -fi - function usage() { - echo "Usage: $(basename $0) [--dry-run] [--sync] [--no-confirm] [--backport] /
/ [/
/...]" >&2 + echo "Usage: $(basename $0) [--dry-run] [--sync] [--no-confirm] [--backport] /
/ [[--backport] /
/...]" >&2 exit 1 } [ $# -lt 1 ] && usage -declare subsection='updates'; -[ -n "$backport" ] && subsection='backports'; - declare -a _releases; declare -a _sections; declare -a _srcsubsections; @@ -51,10 +42,17 @@ declare _fullsrpmname="y" function parse_args() { local -a tmptriplet; + local subsection; local -i i=0; - for arg in "$@"; do - OIFS="$IFS"; IFS=/; tmptriplet=($arg); IFS="$OIFS"; + while [ $# -gt 0 ]; do + subsection='updates'; + if [ "$1" = "--backport" ]; then + subsection='backports'; + shift + fi + + OIFS="$IFS"; IFS=/; tmptriplet=($1); IFS="$OIFS"; [ ${#tmptriplet[*]} -ne 3 ] && usage @@ -70,13 +68,14 @@ function parse_args() # Special case in cauldron where we move updates_testing -> release if [ 'cauldron' = "${_releases[$i]}" ]; then - if [ -n "$backport" ]; then + if [ 'backports' = "$subsection" ]; then echo "Error: Cannot use --backport with cauldron" >&2 exit 1 fi _destsubsections[$i]="release" fi ((++i)) + shift done } parse_args "$@" -- cgit v1.2.1