Merge pull request #647 from pmores/fix-unbootable-dracut-initramfs

rootfs-builder: fix unbootable dracut-based initramfs on Fedora
This commit is contained in:
Fabiano Fidêncio 2020-09-08 22:51:23 +02:00 committed by GitHub
commit 1ab1d0e728
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 10 deletions

View File

@ -186,14 +186,20 @@ check_rootfs() {
OK "init is installed"
systemd_path="/lib/systemd/systemd"
systemd="${rootfs}${systemd_path}"
candidate_systemd_paths="/usr/lib/systemd/systemd /lib/systemd/systemd"
# check agent or systemd
case "${AGENT_INIT}" in
"no")
if [ ! -x "${systemd}" ] && [ ! -L "${systemd}" ]; then
error "${systemd_path} is not installed in ${rootfs}"
for systemd_path in $candidate_systemd_paths; do
systemd="${rootfs}${systemd_path}"
if [ -x "${systemd}" ] || [ -L "${systemd}" ]; then
found="yes"
break
fi
done
if [ ! $found ]; then
error "None of ${candidate_systemd_paths} is installed in ${rootfs}"
return 1
fi
OK "init is systemd"
@ -207,10 +213,13 @@ check_rootfs() {
return 1
fi
# checksum must be different to system
for systemd_path in $candidate_systemd_paths; do
systemd="${rootfs}${systemd_path}"
if [ -f "${systemd}" ] && cmp -s "${systemd}" "${agent}"; then
error "The agent is not the init process. ${agent_path} is systemd"
return 1
fi
done
OK "Agent installed"
;;

View File

@ -441,8 +441,7 @@ prepare_overlay()
# we were passed a pre-populated rootfs directory
if [ ! -e ./sbin/init ]; then
ln -sf ./usr/lib/systemd/systemd ./init
ln -sf ../../init ./lib/systemd/systemd
ln -sf ../init ./sbin/init
ln -sf /init ./sbin/init
fi
# Kata systemd unit file