update_mirror.sh: Improve sanity check for repositories arguments

This prevents accidental copies of packages to wrong repositories.
Signed-off-by: 's avatarDiego Giovane Pasqualin <dpasqualin@c3sl.ufpr.br>
parent 382e455a
......@@ -30,6 +30,11 @@ PUBLISHSCRIPT="$(dirname $0)/le_publish.sh"
PROJECT="le5"
HOST="http://windu.c3sl.ufpr.br/$PROJECT"
# This is the "order" of the repositories, it means that usually the
# developer will upgrade a package from unstable to testing, after that from
# testing to rc, and so on.
REPO_ORDER=( unstable testing rc stable )
function clean() {
rm -rf $TMPDIR
exit 0
......@@ -137,6 +142,30 @@ fi
FROMREPO=$1
TOREPO=$2
# Check repository order and validity
if ! (grep -qw $FROMREPO <<< ${REPO_ORDER[@]} &&
grep -qw $TOREPO <<< ${REPO_ORDER[@]}); then
echo -n "Repositories must be one of the following: "
echo ${REPO_ORDER[@]}
exit 1
fi
for ((i=0; i<${#REPO_ORDER[@]}; i++)); do
if [ ${REPO_ORDER[$i]} = $FROMREPO ]; then
next=${REPO_ORDER[(($i+1))]}
if [ $next != $TOREPO ]; then
echo -n "You are trying to copy a package from $FROMREPO to"
echo " $TOREPO. Usually you'd copy it to $next first."
read -p "Are you sure you wanna do this (y/N)? " yn
if [ "$yn" != "y" ]; then
exit 0
fi
fi
break
fi
done
# Check whether diff argument was given
DIFF=false
if test "$3" = "--diff"; then
DIFF=true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment