SPS · log · files · refs · tags · releases · people · languages · GitHub · commit
fdf15e7
mkiso: zstd live root and a working Plasma session
Parents
Stat
bin/mkiso | 25 +++++++++++++++++++------ lib/mkiso/initrd-init | 18 +++++++++++------- lib/mkiso/live-plasma | 41 ++++++++++++++++++++++++++++++++++++++--- lib/mkiso/live-rc | 15 ++++++++++++++- lib/mkiso/plasma-trees | 3 +++ man/mkiso.1 | 2 ++ tests/test_mkiso.sh | 7 +++++++ 7 files changed, 94 insertions(+), 17 deletions(-)
Diff
diff --git a/bin/mkiso b/bin/mkiso
index fafacd9..d8265df 100755
--- a/bin/mkiso
+++ b/bin/mkiso
@@ -351,7 +351,11 @@ mkiso_close_libs()
find $mkiso_find -type f -print 2>/dev/null |
while IFS= read -r mkiso_elf || [ -n "$mkiso_elf" ]; do
[ -n "$mkiso_elf" ] || continue
- mkiso_copy_libs "$mkiso_elf"
+ # Scripts and data are not DT_NEEDED sources.
+ mkiso_magic=$(dd if="$mkiso_elf" bs=4 count=1 2>/dev/null) || continue
+ case $mkiso_magic in
+ *$'\x7fELF'*) mkiso_copy_libs "$mkiso_elf" ;;
+ esac
done
}
@@ -792,10 +796,19 @@ mkiso_iso=$mkiso_work/iso
mkdir -p "$mkiso_iso/live" "$mkiso_iso/boot/grub"
cp -a "$mkiso_kernel" "$mkiso_iso/live/vmlinuz"
-printf '%s: writing squashfs (this takes a while)\n' "$sps_prog" >&2
-mksquashfs "$mkiso_live" "$mkiso_iso/live/filesystem.squashfs" \
- -comp xz -e boot -noappend >/dev/null ||
- sps_die "$SPS_EX_BUILD" "mksquashfs failed"
+printf '%s: writing squashfs (zstd)\n' "$sps_prog" >&2
+# zstd mounts in seconds; xz is what made QEMU sit on loop0 while the
+# 4G Plasma root decompressed. Level 5 is a live-ISO default: fast
+# to build, fast to boot, still smaller than gzip.
+if ! mksquashfs "$mkiso_live" "$mkiso_iso/live/filesystem.squashfs" \
+ -comp zstd -Xcompression-level 5 -b 262144 -noappend -no-progress \
+ -e boot
+then
+ printf '%s: zstd squashfs failed, trying xz\n' "$sps_prog" >&2
+ mksquashfs "$mkiso_live" "$mkiso_iso/live/filesystem.squashfs" \
+ -comp xz -noappend -no-progress -e boot ||
+ sps_die "$SPS_EX_BUILD" "mksquashfs failed"
+fi
# Initramfs: busybox + init + filesystem modules.
mkiso_ird=$mkiso_work/initrd-root
@@ -863,7 +876,7 @@ printf '%s: packing initramfs\n' "$sps_prog" >&2
(
cd "$mkiso_ird" || exit 1
find . | cpio -o -H newc 2>/dev/null
-) | gzip -n -9 >"$mkiso_iso/live/initrd.img" ||
+) | gzip -n -6 >"$mkiso_iso/live/initrd.img" ||
sps_die "$SPS_EX_BUILD" "initramfs cpio failed"
mkiso_title="SPS Linux live (Splux)"
diff --git a/lib/mkiso/initrd-init b/lib/mkiso/initrd-init
index 7eccc1d..e97babf 100755
--- a/lib/mkiso/initrd-init
+++ b/lib/mkiso/initrd-init
@@ -23,6 +23,11 @@ mkdir -p /proc /sys /dev /tmp /mnt/iso /mnt/ro /mnt/rw /mnt/new
mkdir -p /dev/pts
"$bb" mount -t devpts devpts /dev/pts 2>/dev/null || :
+say()
+{
+ printf '%s\n' "$*" >/dev/console 2>/dev/null || printf '%s\n' "$*"
+}
+
rescue()
{
printf '%s\n' "$*"
@@ -44,18 +49,15 @@ do
"$bb" modprobe "$mod" 2>/dev/null || :
done
-sleep 1
-
found=
i=0
-while [ "$i" -lt 15 ]
+while [ "$i" -lt 20 ]
do
i=$((i + 1))
- for dev in /dev/sr0 /dev/sr1 /dev/sr2 /dev/cdrom \
+ for dev in /dev/sr0 /dev/sr1 /dev/vda /dev/vda1 /dev/vdb /dev/vdb1 \
/dev/nvme0n1 /dev/nvme0n1p1 /dev/nvme1n1p1 \
/dev/sda /dev/sda1 /dev/sdb /dev/sdb1 /dev/sdc /dev/sdc1 \
- /dev/vda /dev/vda1 /dev/vdb /dev/vdb1 \
- /dev/xvda /dev/xvda1
+ /dev/xvda /dev/xvda1 /dev/sr2 /dev/cdrom
do
[ -b "$dev" ] || continue
if "$bb" mount -t iso9660 -o ro "$dev" /mnt/iso 2>/dev/null ||
@@ -68,11 +70,12 @@ do
fi
done
[ -n "$found" ] && break
- sleep 1
+ "$bb" sleep 1
done
[ -n "$found" ] || rescue "mkiso: cannot find the SPS Linux live filesystem on a CD/USB."
+say "SPS: mounting live filesystem..."
"$bb" mount -t squashfs -o ro /mnt/iso/live/filesystem.squashfs /mnt/ro ||
rescue "mkiso: squashfs mount failed"
@@ -94,6 +97,7 @@ if [ ! -e /mnt/new/sbin/init ] && [ ! -L /mnt/new/sbin/init ]; then
rescue "mkiso: /sbin/init missing on the live filesystem"
fi
+say "SPS: starting live system..."
# busybox switch_root replaces PID 1. If the new init cannot exec, we
# would panic; the live /sbin/init is an ELF (busybox or systemd), not
# a script that execs a console.
diff --git a/lib/mkiso/live-plasma b/lib/mkiso/live-plasma
index 999dd62..e2d987f 100644
--- a/lib/mkiso/live-plasma
+++ b/lib/mkiso/live-plasma
@@ -3,22 +3,49 @@
# and run setup(1). If Plasma is missing, a shell stays on this tty.
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
+PATH=/usr/lib64/qt6/bin:/usr/lib/qt6/bin:$PATH
export PATH
export HOME=/root
export XDG_RUNTIME_DIR=/run/user/0
export XDG_SESSION_TYPE=wayland
export QT_QPA_PLATFORM=wayland
export TERM=${TERM:-linux}
+export LANG=${LANG:-C.UTF-8}
+export LC_ALL=${LC_ALL:-C.UTF-8}
-mkdir -p "$XDG_RUNTIME_DIR"
+mkdir -p "$XDG_RUNTIME_DIR" /run/dbus /var/lib/dbus /etc/dbus-1
chmod 700 "$XDG_RUNTIME_DIR"
# Live NVIDIA is nouveau. Keep the proprietary stack unloaded.
modprobe nouveau 2>/dev/null || :
+if [ ! -e /var/run ]; then
+ mkdir -p /var
+ ln -s ../run /var/run
+fi
+if [ ! -s /etc/machine-id ]; then
+ if command -v dbus-uuidgen >/dev/null 2>&1; then
+ dbus-uuidgen --ensure=/etc/machine-id 2>/dev/null || :
+ fi
+fi
+if [ ! -e /var/lib/dbus/machine-id ] && [ -s /etc/machine-id ]; then
+ ln -sf /etc/machine-id /var/lib/dbus/machine-id
+fi
+# The stock system.conf drops privileges to messagebus. The live passwd
+# has no such account, so dbus-daemon --system exits and Plasma cannot
+# talk to the bus. Override that for this disc only.
+if [ ! -f /etc/dbus-1/system-local.conf ]; then
+ printf '%s\n' \
+ '<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"' \
+ ' "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">' \
+ '<busconfig>' \
+ ' <user>root</user>' \
+ '</busconfig>' >/etc/dbus-1/system-local.conf
+fi
+
if command -v dbus-daemon >/dev/null 2>&1; then
- if [ ! -S /run/dbus/system_bus_socket ]; then
- mkdir -p /run/dbus
+ if [ ! -S /run/dbus/system_bus_socket ] &&
+ [ ! -S /var/run/dbus/system_bus_socket ]; then
dbus-daemon --system --fork 2>/dev/null || :
fi
fi
@@ -30,6 +57,14 @@ fi
if command -v startplasma-wayland >/dev/null 2>&1; then
# Give the user a console they can see if Wayland dies.
chvt 1 2>/dev/null || :
+ # startplasma needs a *session* bus. The system bus above is not that.
+ if command -v dbus-run-session >/dev/null 2>&1; then
+ exec dbus-run-session -- startplasma-wayland
+ fi
+ if command -v dbus-launch >/dev/null 2>&1; then
+ eval "$(dbus-launch --sh-syntax)"
+ exec startplasma-wayland
+ fi
exec startplasma-wayland
fi
diff --git a/lib/mkiso/live-rc b/lib/mkiso/live-rc
index 1697202..834b5cc 100644
--- a/lib/mkiso/live-rc
+++ b/lib/mkiso/live-rc
@@ -11,8 +11,10 @@ export PATH
export HOME=/root
export TERM=${TERM:-linux}
export CARGO_HOME=${CARGO_HOME:-/root/.cargo}
+export LANG=${LANG:-C.UTF-8}
+export LC_ALL=${LC_ALL:-C.UTF-8}
-mkdir -p /proc /sys /dev /run /tmp /root /mnt /etc/sps
+mkdir -p /proc /sys /dev /run /tmp /root /mnt /etc/sps /var/lib/dbus
mount -t proc proc /proc 2>/dev/null || :
mount -t sysfs sysfs /sys 2>/dev/null || :
mount -t devtmpfs devtmpfs /dev 2>/dev/null || :
@@ -20,6 +22,11 @@ mkdir -p /dev/pts /dev/shm
mount -t devpts devpts /dev/pts 2>/dev/null || :
mount -t tmpfs tmpfs /run 2>/dev/null || :
mount -t tmpfs tmpfs /tmp 2>/dev/null || :
+mkdir -p /run/dbus
+if [ ! -e /var/run ]; then
+ mkdir -p /var
+ ln -s ../run /var/run
+fi
if command -v ldconfig >/dev/null 2>&1; then
ldconfig 2>/dev/null || :
@@ -32,6 +39,12 @@ ln -sf /proc/self/fd/2 /dev/stderr 2>/dev/null || :
hostname splux-live 2>/dev/null || :
[ -f /etc/hostname ] || printf '%s\n' splux-live >/etc/hostname
+if [ ! -f /etc/locale.conf ]; then
+ printf '%s\n' 'LANG=C.UTF-8' >/etc/locale.conf
+fi
+if [ ! -s /etc/machine-id ] && command -v dbus-uuidgen >/dev/null 2>&1; then
+ dbus-uuidgen --ensure=/etc/machine-id 2>/dev/null || :
+fi
# NVIDIA live path is nouveau. Do not load proprietary nvidia* next to KWin.
mkdir -p /etc/modprobe.d
diff --git a/lib/mkiso/plasma-trees b/lib/mkiso/plasma-trees
index 2494e0e..bd40364 100644
--- a/lib/mkiso/plasma-trees
+++ b/lib/mkiso/plasma-trees
@@ -19,6 +19,9 @@
/usr/share/kglobalaccel
/usr/share/kded6
/usr/share/dbus-1
+/etc/dbus-1
+/usr/lib64/locale/C.utf8
+/usr/lib/locale/C.utf8
/usr/share/polkit-1
/usr/share/wayland-protocols
/usr/share/libdrm
diff --git a/man/mkiso.1 b/man/mkiso.1
index a9e1ff2..f20ebf9 100644
--- a/man/mkiso.1
+++ b/man/mkiso.1
@@ -29,6 +29,8 @@ is always busybox. Host bash is copied as
only with its library closure, including the real
.B libtinfo
file behind the soname symlink.
+The squashfs uses zstd so the live root mounts quickly; xz made QEMU
+sit on the loop0 probe while a multi-gigabyte Plasma image decompressed.
.B --layout
writes the live root only, for tests and inspection.
.PP
diff --git a/tests/test_mkiso.sh b/tests/test_mkiso.sh
index c22eb3b..0a2a37f 100755
--- a/tests/test_mkiso.sh
+++ b/tests/test_mkiso.sh
@@ -88,6 +88,13 @@ fi
if grep -q 'ln -sf bash .*/bin/sh' "$mkiso"; then
fail 'mkiso must not point /bin/sh at bash'
fi
+grep -q dbus-run-session "$layout/etc/sps/live-plasma" ||
+ fail 'live-plasma must start Plasma under a session bus'
+grep -q C.UTF-8 "$layout/etc/sps/live-plasma" ||
+ fail 'live-plasma must set a UTF-8 locale'
+grep -q -- '-comp zstd' "$mkiso" || fail 'mkiso must write a zstd squashfs'
+grep -q 'mounting live filesystem' "$project_dir/lib/mkiso/initrd-init" ||
+ fail 'initrd must print before squashfs mount'
if [ -x /usr/bin/dialog ]; then
[ -e "$layout/usr/bin/dialog" ] || fail 'dialog missing from slim layout'
fi