[scripts] move for loop into separate function, simplify fault-tolerance related code

This commit is contained in:
Fabio Erculiani 2012-10-15 21:25:05 +02:00
parent 8ca973baf5
commit b2357eacc6

View File

@ -9,39 +9,30 @@ if [ -d "/usr/portage/licenses" ]; then
export ACCEPT_LICENSE="$(ls /usr/portage/licenses -1 | xargs)" export ACCEPT_LICENSE="$(ls /usr/portage/licenses -1 | xargs)"
fi fi
export FORCE_EAPI=2 safe_run() {
updated=0 local updated=0
for ((i=0; i < 42; i++)); do for ((i=0; i < 42; i++)); do
equo update && { "${@}" && {
updated=1; updated=1;
break; break;
} }
if [ ${i} -gt 6 ]; then if [ ${i} -gt 6 ]; then
sleep 3600 || exit 1 sleep 3600 || return 1
else else
sleep 1200 || exit 1 sleep 1200 || return 1
fi
done
if [ "${updated}" = "0" ]; then
return 1
fi fi
done return 0
if [ "${updated}" = "0" ]; then }
exit 1
fi export FORCE_EAPI=2
safe_run equo update || exit 1
export ETP_NOINTERACTIVE=1 export ETP_NOINTERACTIVE=1
updated=0 safe_run equo upgrade --fetch || exit 1
for ((i=0; i < 42; i++)); do
equo upgrade --fetch && {
updated=1;
break;
}
if [ ${i} -gt 6 ]; then
sleep 3600 || exit 1
else
sleep 1200 || exit 1
fi
done
if [ "${updated}" = "0" ]; then
exit 1
fi
equo upgrade || exit 1 equo upgrade || exit 1
echo "-5" | equo conf update echo "-5" | equo conf update
rm -rf /var/lib/entropy/client/packages rm -rf /var/lib/entropy/client/packages