mirror of
https://abf.rosa.ru/djam/livecd-tools.git
synced 2025-02-23 15:42:58 +00:00
Install packages one-by-one if installing all of them fails
This commit is contained in:
parent
2329e6734a
commit
f81ab0cccc
2 changed files with 73 additions and 34 deletions
|
@ -3,7 +3,7 @@
|
|||
Summary: Tools for building live CDs
|
||||
Name: livecd-tools
|
||||
Version: 21.1
|
||||
Release: 40
|
||||
Release: 41
|
||||
Epoch: 1
|
||||
License: GPLv2+
|
||||
Group: System/Base
|
||||
|
|
|
@ -11,46 +11,85 @@
|
|||
# https://github.com/mikhailnov/docker-rosa/blob/master/mkimage-urpmi.sh
|
||||
set -xefu
|
||||
|
||||
# try to workaround urpmi bug due to which it randomly
|
||||
# can't resolve dependencies during bootstrap
|
||||
urpmi_exec(){
|
||||
urpmi \
|
||||
--urpmi-root "$urpmiRoot" \
|
||||
--root "$rpmRoot" \
|
||||
--debug \
|
||||
${urpmi_options} \
|
||||
${packagesList}
|
||||
urpmi_return_code="$?"
|
||||
}
|
||||
|
||||
urpmi_bootstrap(){
|
||||
for urpmi_options in \
|
||||
"--auto --no-suggests --allow-force --allow-nodeps --split-length 200" \
|
||||
"--auto --no-suggests --allow-force --allow-nodeps --split-length 500" \
|
||||
"--auto --no-suggests"
|
||||
do
|
||||
urpmi \
|
||||
--urpmi-root "$urpmiRoot" \
|
||||
--root "$rpmRoot" \
|
||||
--fastunsafe --debug --no-verify \
|
||||
${urpmi_options} \
|
||||
${packagesList}
|
||||
urpmi_return_code="$?"
|
||||
urpmi_exec
|
||||
done
|
||||
}
|
||||
|
||||
# This will validate that all requested packages do exist
|
||||
# and will print a list of not existing ones.
|
||||
# Returns 0 only if all packages do exist.
|
||||
urpmq --whatprovides --urpmi-root "$urpmiRoot" ${packagesList} >/dev/null
|
||||
process_packages(){
|
||||
|
||||
# temporarily don't fail the whole scripts when not last iteration of urpmi fails
|
||||
set +e
|
||||
for i in $(seq 1 22)
|
||||
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."
|
||||
# This will validate that all requested packages do exist
|
||||
# and will print a list of not existing ones.
|
||||
# Returns 0 only if all packages do exist.
|
||||
urpmq --whatprovides --urpmi-root "$urpmiRoot" ${packagesList} >/dev/null
|
||||
|
||||
# temporarily don't fail the whole scripts when not last iteration of urpmi fails
|
||||
set +e
|
||||
for i in $(seq 1 5)
|
||||
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!"
|
||||
if [ "$EXIT" = 1 ]; then exit "${urpmi_return_code}"; fi
|
||||
return "${urpmi_return_code}"
|
||||
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}"
|
||||
# return failing the whole script on any error
|
||||
set -e
|
||||
}
|
||||
|
||||
packagesList_orig="${packagesList}"
|
||||
|
||||
# bootstrap basesystem first (it's not really necessary, but let's do it)
|
||||
if echo "${packagesList_orig}" | grep -qE 'basesystem | basesystem'; then
|
||||
( packagesList="$(echo "${packagesList_orig}" | tr ' ' '\n' | grep ^basesystem | tr '\n' ' ')"
|
||||
# Exit the whole script if even bootstrapping basesystem failed
|
||||
EXIT=1
|
||||
process_packages )
|
||||
fi
|
||||
# return failing the whole script on any error
|
||||
set -e
|
||||
|
||||
# now let's try to bootstrap the whole list of packages
|
||||
packagesList="${packagesList_orig}"
|
||||
EXIT=0
|
||||
process_packages
|
||||
# exit if all packages have been installed
|
||||
if [ "$urpmi_return_code" = 0 ]; then exit 0; fi
|
||||
|
||||
# If installing packages still failed, let's try to install them one-by-one
|
||||
for i in $(echo "${packagesList_orig}" | sort -u)
|
||||
do
|
||||
( set +e
|
||||
packagesList="$i"
|
||||
urpmi_options="--auto --no-suggests --allow-force --allow-nodeps"
|
||||
urpmi_exec
|
||||
set -e )
|
||||
done
|
||||
|
||||
# Now, regardless success of installing one-by-one, let's install all packages and see if it will be successfull
|
||||
# and exit with error, if it failed
|
||||
packagesList="${packagesList_orig}"
|
||||
EXIT=1
|
||||
process_packages
|
||||
|
|
Loading…
Add table
Reference in a new issue