diff --git a/bin/update_mirror.sh b/bin/update_mirror.sh index c254bb10c6f671e696c6b2b3fd39e7dd5a3e4780..0e331e14f28c612052e2402791cb28ef0a77ea8e 100755 --- a/bin/update_mirror.sh +++ b/bin/update_mirror.sh @@ -30,6 +30,11 @@ PUBLISHSCRIPT="$(dirname $0)/le_publish.sh" PROJECT="le" 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