livecd-tools/urpmi-bootstrapper.sh
Mikhail Novosyolov 0c027d116e Better debug
2019-03-08 20:11:12 +03:00

50 lines
1.6 KiB
Bash
Executable file

#!/bin/sh
# Author: Mikhail Novosyolov <m.novosyolov@rosalinux.ru>
# This script tries to "solve" problems with bootstrapping chroot,
# where urpmi fails due to failed dependencies,
# but, if we run it for multiple times, it does bootstrap all required packages.
# Unfortunately, we currently don't have enought time to solve bootstrapping issues properly,
# so let's make this ugly hack.
# Sometimes it's possible to understand which dependencies fail,
# bacause the last iteration after several failed ones will install those failing packages.
# I previously made this hack in
# https://github.com/mikhailnov/docker-rosa/blob/master/mkimage-urpmi.sh
set -efu
# try to workaround urpmi bug due to which it randomly
# can't resolve dependencies during bootstrap
urpmi_bootstrap(){
for urpmi_options in \
"--auto --no-suggests --allow-force --allow-nodeps --ignore-missing" \
"--auto --no-suggests"
do
urpmi \
--urpmi-root "$urpmiRoot" \
--root "$rpmRoot" \
--fastunsafe --debug --no-verify \
${urpmi_options} \
${packagesList}
urpmi_return_code="$?"
done
}
# temporarily don't fail the whole scripts when not last iteration of urpmi fails
set +e
for i in $(seq 1 10)
do
echo "Starting urpmi bootstrap iteration #${i}..."
urpmi_bootstrap
if [ "${urpmi_return_code}" = 0 ]
then
echo "urpmi iteration #${i} was successfull."
break
else
echo "urpmi iteration #${i} failed."
fi
done
# now check the return code of the _last_ urpmi iteration
if [ "${urpmi_return_code}" != 0 ]; then
echo "urpmi bootstrapping failed!"
exit "${urpmi_return_code}"
fi
# return failing the whole script on any error
set -e