diff options
author | Colin Guthrie <colin@mageia.org> | 2014-07-31 21:28:32 +0100 |
---|---|---|
committer | Colin Guthrie <colin@mageia.org> | 2014-07-31 21:28:32 +0100 |
commit | 9ac5845999f980880dcf5ce381a35aae56e08e8a (patch) | |
tree | 9f10a2ea050146080f184dea689acfee807b6e10 | |
parent | 8fe4fd8722fa03b9a118b20ad826085279dd78e6 (diff) | |
download | mgatools-9ac5845999f980880dcf5ce381a35aae56e08e8a.tar mgatools-9ac5845999f980880dcf5ce381a35aae56e08e8a.tar.gz mgatools-9ac5845999f980880dcf5ce381a35aae56e08e8a.tar.bz2 mgatools-9ac5845999f980880dcf5ce381a35aae56e08e8a.tar.xz mgatools-9ac5845999f980880dcf5ce381a35aae56e08e8a.zip |
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.
-rwxr-xr-x | mga-move-pkg | 25 |
1 files 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] <release>/<section>/<pkg> [<release>/<section>/<pkg>...]" >&2 + echo "Usage: $(basename $0) [--dry-run] [--sync] [--no-confirm] [--backport] <release>/<section>/<pkg> [[--backport] <release>/<section>/<pkg>...]" >&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 "$@" |