summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2014-07-31 17:31:36 +0100
committerColin Guthrie <colin@mageia.org>2014-07-31 17:31:36 +0100
commit8fe4fd8722fa03b9a118b20ad826085279dd78e6 (patch)
tree07d39be7ad1cbb45266cde240d17876f34eb0e93
parent6efe180a02aa2c41808b817df504781a434673d0 (diff)
downloadmgatools-8fe4fd8722fa03b9a118b20ad826085279dd78e6.tar
mgatools-8fe4fd8722fa03b9a118b20ad826085279dd78e6.tar.gz
mgatools-8fe4fd8722fa03b9a118b20ad826085279dd78e6.tar.bz2
mgatools-8fe4fd8722fa03b9a118b20ad826085279dd78e6.tar.xz
mgatools-8fe4fd8722fa03b9a118b20ad826085279dd78e6.zip
move: Bail if we pass --no-confirm, but do not supply all SRPM names.
As --no-confirm may be used from automated scripts, better bail out here rather than waiting for user input that will never come.
-rwxr-xr-xmga-move-pkg40
1 files changed, 24 insertions, 16 deletions
diff --git a/mga-move-pkg b/mga-move-pkg
index 6662476..0f5af54 100755
--- a/mga-move-pkg
+++ b/mga-move-pkg
@@ -145,25 +145,33 @@ function sanity_check()
{
local cauldronmsg
- if [ "$_fullsrpmname" != "y" -o -z "$noconfirm" ]; then
- echo "The following SRPMs (and matching binaries) will be moved:"
- for ((i=0;i<${#_releases[*]};++i)); do
- echo "- ${_pkgfiles[$i]}"
- if [ 'release' = "${_destsubsections[$i]}" -a -n "${_oldpkgfiles[$i]}" ]; then
- cauldronmsg="${cauldronmsg}- ${_oldpkgfiles[$i]}\n"
- fi
- done
- echo
- if [ -n "$cauldronmsg" ]; then
- echo "The following SRPMs (and matching binaries) will be moved from 'release' to '\~schedbot/old':"
- echo "$cauldronmsg"
+ if [ -n "$noconfirm" ]; then
+ # We've requested no confirmation. This is only valid when the user
+ # supplies a full SRPM name for every package.
+ [ "$_fullsrpmname" = "y" ] && return 0
+ echo "Sorry, but you requested --no-confirm, but did not give me full SRPM names." >&1
+ exit 1
+ fi
+
+ echo "The following SRPMs (and their corresponding binaries) will be moved:"
+ for ((i=0;i<${#_releases[*]};++i)); do
+ echo "- ${_pkgfiles[$i]}"
+ if [ 'release' = "${_destsubsections[$i]}" -a -n "${_oldpkgfiles[$i]}" ]; then
+ cauldronmsg="${cauldronmsg}- ${_oldpkgfiles[$i]}\n"
fi
+ done
+ echo
- read -n 1 -p "Are you sure? [Y/n] " yn
- [ -n "$yn" ] && echo
- [ -z "$yn" -o "Y" = "$yn" ] && yn=y
- [ "y" != "$yn" ] && exit
+ if [ -n "$cauldronmsg" ]; then
+ echo "The following SRPMs (and their corresponding binaries) will be moved from 'release' to '\~schedbot/old':"
+ echo "$cauldronmsg"
+ # The above always ends with a blank line... so no need to echo another
fi
+
+ read -n 1 -p "Are you sure? [Y/n] " yn
+ [ -n "$yn" ] && echo
+ [ -z "$yn" -o "Y" = "$yn" ] && yn=y
+ [ "y" != "$yn" ] && exit
return 0
}
sanity_check