Skip to content

Commit

Permalink
Reworked bootstrapping by urpmi
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhailnov committed Feb 26, 2019
1 parent 3e50056 commit 89be97e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 18 deletions.
4 changes: 2 additions & 2 deletions mkimage-minimal.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# suitable for rosa2014.1, rosa2016.1

export imgType="min"
export basePackages="basesystem-minimal urpmi"
export chrootPackages="bash vim-minimal nano sudo termcap initscripts systemd"
export packagesList="basesystem-minimal urpmi bash vim-minimal nano sudo termcap initscripts systemd branding-configs-fresh"

./mkimage-urpmi.sh
55 changes: 39 additions & 16 deletions mkimage-urpmi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,48 @@ imgType="${imgType:-std}"
rosaVersion="${rosaVersion:-rosa2016.1}"
rootfsDir="${rootfsDir:-./BUILD_rootfs}"
outDir="${outDir:-"."}"
# branding-configs-fresh, rpm-build have problems with dependencies, so let's install them in chroot
basePackages="${basePackages:-basesystem-minimal bash urpmi}"
chrootPackages="${chrootPackages:-systemd initscripts termcap dhcp-client locales locales-en git-core htop iputils iproute2 nano squashfs-tools tar timezone passwd branding-configs-fresh rpm-build}"
packagesList="${packagesList:-basesystem-minimal bash urpmi systemd initscripts termcap dhcp-client locales locales-en git-core htop iputils iproute2 nano squashfs-tools tar timezone passwd branding-configs-fresh rpm-build}"
mirror="${mirror:-http://mirror.yandex.ru/rosa/${rosaVersion}/repository/${arch}/}"
outName="${outName:-"rootfs-${imgType}-${rosaVersion}_${arch}_$(date +%Y-%m-%d)"}"
tarFile="${outDir}/${outName}.tar.xz"
sqfsFile="${outDir}/${outName}.sqfs"

(
urpmi.addmedia --distrib \
--mirrorlist "$mirror" \
--urpmi-root "$rootfsDir"
urpmi ${basePackages} \
--auto \
--no-suggests \
--urpmi-root "$rootfsDir" \
--root "$rootfsDir" \
--clean
)
urpmi.addmedia --distrib \
--mirrorlist "$mirror" \
--urpmi-root "$rootfsDir"

#########################################################
# 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 "$rootfsDir" \
${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
urpmi_bootstrap
if [ "${urpmi_return_code}" = 0 ]; then
echo "urpmi iteration #${i} was successfull."
break
fi
done
# now check the return code of the _last_ urpmi iteration
if [ "${urpmi_return_code}" != 0 ]; then
echo "urpmi bootstrapping failed!"
exit 1
fi
# return failing the whole script on any error
set -e
#########################################################

pushd "$rootfsDir"

Expand All @@ -56,10 +79,10 @@ nameserver 8.8.4.4
nameserver 77.88.8.1
EOF

# Those packages, installation of which fails when they are listed in $basePackages, are installed in chroot
# Fix SSL in chroot (/dev/urandom is needed)
mount --bind -v /dev "${rootfsDir}/dev"
chroot "$rootfsDir" /bin/sh -c "urpmi ${chrootPackages} --auto --no-suggests --clean"
# Let's make sure that all packages have been installed
chroot "$rootfsDir" /bin/sh -c "urpmi ${packagesList} --auto --no-suggests --clean"

# Try to configure root shell
# package 'initscripts' contains important scripts from /etc/profile.d/
Expand Down

0 comments on commit 89be97e

Please sign in to comment.