mirror of
https://github.com/kairos-io/packages.git
synced 2025-08-14 06:06:28 +00:00
Fix alpine init to deal with netboot (#296)
Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
This commit is contained in:
parent
23033a7e5b
commit
c5903e30ab
@ -1,7 +1,7 @@
|
||||
packages:
|
||||
- name: "alpine"
|
||||
category: "distro-kernel"
|
||||
version: "6.1.33"
|
||||
version: "6.1.34"
|
||||
description: "Provides kernel and custom initrd for alpine"
|
||||
labels:
|
||||
autobump.strategy: "custom"
|
||||
@ -11,10 +11,10 @@ packages:
|
||||
curl -s https://raw.githubusercontent.com/alpinelinux/aports/3.18-stable/main/linux-lts/APKBUILD | grep "pkgver=" | awk -F"=" '{print $2}'
|
||||
autobump.version_hook: |
|
||||
curl -s https://raw.githubusercontent.com/alpinelinux/aports/3.18-stable/main/linux-lts/APKBUILD | grep "pkgver=" | awk -F"=" '{print $2}'
|
||||
package.version: "6.1.33"
|
||||
package.version: "6.1.34"
|
||||
- name: "alpine-rpi"
|
||||
category: "distro-kernel"
|
||||
version: "6.1.33"
|
||||
version: "6.1.34"
|
||||
description: "Provides kernel and custom initrd for alpine"
|
||||
labels:
|
||||
autobump.strategy: "custom"
|
||||
@ -24,4 +24,4 @@ packages:
|
||||
curl -s https://raw.githubusercontent.com/alpinelinux/aports/3.18-stable/main/linux-rpi/APKBUILD | grep "pkgver=" | awk -F"=" '{print $2}'
|
||||
autobump.version_hook: |
|
||||
curl -s https://raw.githubusercontent.com/alpinelinux/aports/3.18-stable/main/linux-rpi/APKBUILD | grep "pkgver=" | awk -F"=" '{print $2}'
|
||||
package.version: "6.1.33"
|
||||
package.version: "6.1.34"
|
||||
|
@ -211,6 +211,15 @@ configure_ip() {
|
||||
eend $?
|
||||
}
|
||||
|
||||
is_url() {
|
||||
case "$1" in
|
||||
http://*|https://*|ftp://*)
|
||||
return 0;;
|
||||
*)
|
||||
return 1;;
|
||||
esac
|
||||
}
|
||||
|
||||
/bin/busybox mkdir -p "$ROOT"/usr/bin \
|
||||
"$ROOT"/usr/sbin \
|
||||
"$ROOT"/proc \
|
||||
@ -296,8 +305,40 @@ if grep -q "rd.neednet=1" /proc/cmdline;then
|
||||
configure_ip
|
||||
fi
|
||||
|
||||
# Path for booting from livecd/netboot/rd.{cos,immucore}.disable
|
||||
if grep -q cdroot /proc/cmdline || grep -q netboot /proc/cmdline || grep -q "rd.immucore.disable" /proc/cmdline || grep -q "rd.cos.disable" /proc/cmdline;then
|
||||
# Path for booting from netboot
|
||||
if grep -q netboot /proc/cmdline; then
|
||||
echo "Netbooting"
|
||||
|
||||
for x in $(cat /proc/cmdline); do
|
||||
# shellcheck disable=SC2039
|
||||
[[ $x = root=live:* ]] || continue
|
||||
root=${x#root=live:}
|
||||
done
|
||||
|
||||
if ! is_url "$root";then
|
||||
echo "$root is not a valid url, cannot continue"
|
||||
echo "initramfs emergency recovery shell launched"
|
||||
exec /bin/busybox sh
|
||||
fi
|
||||
sync
|
||||
# Create mountpoints
|
||||
ebegin "Create mountpoints"
|
||||
mkdir -p /media/root-rw /run/rootfsbase $sysroot/media/root-rw $sysroot/run/rootfsbase
|
||||
eend $?
|
||||
|
||||
ebegin "Download rootfs"
|
||||
wget -q "$root" -O /tmp/rootfs.squashfs
|
||||
eend $?
|
||||
|
||||
# Mount squashfs into loop device
|
||||
ebegin "Mount rootfs as squashfs device"
|
||||
retry 5 losetup /dev/loop0 /tmp/rootfs.squashfs
|
||||
eend $?
|
||||
sync
|
||||
fi
|
||||
|
||||
# Path for booting from livecd
|
||||
if grep -q cdroot /proc/cmdline ;then
|
||||
echo "Mounting LiveCD"
|
||||
sync
|
||||
# Create mountpoints
|
||||
@ -318,43 +359,46 @@ if grep -q cdroot /proc/cmdline || grep -q netboot /proc/cmdline || grep -q "rd.
|
||||
retry 5 losetup /dev/loop0 /media/root-ro/rootfs.squashfs
|
||||
eend $?
|
||||
sync
|
||||
# Mount loop device into the rootfsbase
|
||||
ebegin "Mount loop device into rootfsbase"
|
||||
retry 5 mount /dev/loop0 /run/rootfsbase
|
||||
eend $?
|
||||
sync
|
||||
# Mount writable overlay tmpfs
|
||||
ebegin "Mount base overlay"
|
||||
mount -t tmpfs -o "mode=0755,rw,size=25%" root-tmpfs /media/root-rw
|
||||
eend $?
|
||||
sync
|
||||
# Create additional mountpoints and do the overlay mount
|
||||
mkdir -p /media/root-rw/work /media/root-rw/root
|
||||
ebegin "Mount rootfs overlay into sysroot"
|
||||
mount -t overlay -o lowerdir=/run/rootfsbase,upperdir=/media/root-rw/root,workdir=/media/root-rw/work overlayfs $sysroot
|
||||
eend $?
|
||||
sync
|
||||
# immucore to run the initramfs and rootfs stages
|
||||
ebegin "Run immucore"
|
||||
immucore
|
||||
eend $?
|
||||
# Move current mounts into sysroot mounts
|
||||
# shellcheck disable=SC2002
|
||||
cat "$ROOT"/proc/mounts 2>/dev/null | while read DEV DIR TYPE OPTS ; do
|
||||
# shellcheck disable=SC2166
|
||||
if [ "$DIR" != "/" -a "$DIR" != "$sysroot" -a -d "$DIR" ]; then
|
||||
ebegin "Moving $DIR to $sysroot/$DIR"
|
||||
mkdir -p $sysroot/$DIR
|
||||
mount -o move $DIR $sysroot/$DIR
|
||||
eend $?
|
||||
fi
|
||||
done
|
||||
# shellcheck disable=SC2093
|
||||
exec switch_root "$sysroot" "$INIT"
|
||||
echo "initramfs emergency recovery shell launched"
|
||||
exec /bin/busybox sh
|
||||
fi
|
||||
|
||||
# shared path for netboot and livecd, we expect the rootfs to be already in /dev/loop0
|
||||
if grep -q cdroot /proc/cmdline || grep -q netboot /proc/cmdline;then
|
||||
# Mount loop device into the rootfsbase
|
||||
ebegin "Mount loop device into rootfsbase"
|
||||
retry 5 mount /dev/loop0 /run/rootfsbase
|
||||
eend $?
|
||||
sync
|
||||
# Mount writable overlay tmpfs
|
||||
ebegin "Mount base overlay"
|
||||
mount -t tmpfs -o "mode=0755,rw,size=25%" root-tmpfs /media/root-rw
|
||||
eend $?
|
||||
sync
|
||||
# Create additional mountpoints and do the overlay mount
|
||||
mkdir -p /media/root-rw/work /media/root-rw/root
|
||||
ebegin "Mount rootfs overlay into sysroot"
|
||||
mount -t overlay -o lowerdir=/run/rootfsbase,upperdir=/media/root-rw/root,workdir=/media/root-rw/work overlayfs $sysroot
|
||||
eend $?
|
||||
sync
|
||||
# immucore to run the initramfs and rootfs stages
|
||||
ebegin "Run immucore"
|
||||
immucore
|
||||
eend $?
|
||||
# Move current mounts into sysroot mounts
|
||||
# shellcheck disable=SC2002
|
||||
cat "$ROOT"/proc/mounts 2>/dev/null | while read DEV DIR TYPE OPTS ; do
|
||||
# shellcheck disable=SC2166
|
||||
if [ "$DIR" != "/" -a "$DIR" != "$sysroot" -a -d "$DIR" ]; then
|
||||
ebegin "Moving $DIR to $sysroot/$DIR"
|
||||
mkdir -p $sysroot/$DIR
|
||||
mount -o move $DIR $sysroot/$DIR
|
||||
eend $?
|
||||
fi
|
||||
done
|
||||
# shellcheck disable=SC2093
|
||||
exec switch_root "$sysroot" "$INIT"
|
||||
echo "initramfs emergency recovery shell launched"
|
||||
exec /bin/busybox sh
|
||||
fi
|
||||
|
||||
# Path for booting active/passive/recovery
|
||||
ebegin "Run immucore"
|
||||
|
Loading…
Reference in New Issue
Block a user