Skip to content
Snippets Groups Projects
Commit 90dd3c78 authored by Diego Giovane Pasqualin's avatar Diego Giovane Pasqualin
Browse files

update_mirror.sh: Improve sanity check for repositories arguments


This prevents accidental copies of packages to wrong repositories.

Signed-off-by: default avatarDiego Giovane Pasqualin <dpasqualin@c3sl.ufpr.br>
parent e1cb9f53
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment