finish-install: slim and improve script
This commit is contained in:
parent
9b01ea21cd
commit
c49ef5c8e2
2 changed files with 36 additions and 54 deletions
|
|
@ -3,65 +3,47 @@
|
||||||
# Runs before 10update-initramfs, so we only call update-grub here.
|
# Runs before 10update-initramfs, so we only call update-grub here.
|
||||||
#
|
#
|
||||||
|
|
||||||
set -e
|
# Run only on UEFI installs
|
||||||
|
|
||||||
# UEFI only in installer env
|
|
||||||
[ -d /sys/firmware/efi ] || exit 0
|
[ -d /sys/firmware/efi ] || exit 0
|
||||||
|
|
||||||
# Desktop detection (target): Trisquel desktop metas OR common DMs
|
# Require plymouth in the target system (otherwise splash is pointless)
|
||||||
if in-target dpkg -s trisquel-desktop-common >/dev/null 2>&1 \
|
in-target dpkg -s plymouth >/dev/null 2>&1 || exit 0
|
||||||
|| in-target dpkg -s triskel >/dev/null 2>&1 \
|
|
||||||
|| in-target dpkg -s trisquel-gnome >/dev/null 2>&1 \
|
# Heuristic “desktop present?” check — avoid debconf; rely on packages/DM.
|
||||||
|| in-target dpkg -s trisquel-mini >/dev/null 2>&1 \
|
if ! in-target sh -c '
|
||||||
|| in-target dpkg -s lightdm >/dev/null 2>&1 \
|
dpkg -s trisquel-desktop-common >/dev/null 2>&1 ||
|
||||||
|| in-target dpkg -s gdm3 >/dev/null 2>&1 \
|
dpkg -s triskel >/dev/null 2>&1 ||
|
||||||
|| in-target dpkg -s sddm >/dev/null 2>&1; then
|
dpkg -s trisquel-gnome >/dev/null 2>&1 ||
|
||||||
logger -t trisquel-uefi-splash "desktop detected (packages)"
|
dpkg -s trisquel-mini >/dev/null 2>&1 ||
|
||||||
else
|
dpkg -s lightdm >/dev/null 2>&1 ||
|
||||||
logger -t trisquel-uefi-splash "no desktop; skip"
|
dpkg -s gdm3 >/dev/null 2>&1 ||
|
||||||
|
dpkg -s sddm >/dev/null 2>&1
|
||||||
|
'; then
|
||||||
|
# No desktop, then do nothing
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Plymouth present in target?
|
CFG=/target/etc/default/grub
|
||||||
in-target dpkg -s plymouth >/dev/null 2>&1 || { logger -t trisquel-uefi-splash "no plymouth; skip"; exit 0; }
|
[ -f "$CFG" ] || exit 0
|
||||||
|
|
||||||
# Edit /etc/default/grub inside target: ensure GRUB_CMDLINE_LINUX_DEFAULT includes 'splash'
|
# If the key is missing entirely, create it with just "splash"
|
||||||
in-target sh -s <<'INCHROOT'
|
grep -q '^GRUB_CMDLINE_LINUX_DEFAULT=' "$CFG" \
|
||||||
set -e
|
|| echo 'GRUB_CMDLINE_LINUX_DEFAULT="splash"' >> "$CFG"
|
||||||
CFG="/etc/default/grub"
|
|
||||||
[ -f "$CFG" ] || touch "$CFG"
|
|
||||||
|
|
||||||
awk -v key="GRUB_CMDLINE_LINUX_DEFAULT" '
|
# Normalize trivial cases:
|
||||||
BEGIN{done=0}
|
# - empty quotes > "splash"
|
||||||
# Match the variable (with or without quotes around value)
|
# - unquoted value > quote it
|
||||||
($0 ~ "^"key"=") {
|
sed -i -r \
|
||||||
line = $0
|
-e 's/^GRUB_CMDLINE_LINUX_DEFAULT=""$/GRUB_CMDLINE_LINUX_DEFAULT="splash"/' \
|
||||||
val = $0
|
-e 's/^(GRUB_CMDLINE_LINUX_DEFAULT)=([^"].*)$/\1="\2"/' \
|
||||||
sub("^"key"=","",val)
|
"$CFG"
|
||||||
# strip surrounding double quotes if present
|
|
||||||
if (val ~ /^"/) sub(/^"/,"",val)
|
|
||||||
if (val ~ /"$/) sub(/"$/,"",val)
|
|
||||||
# normalize trailing spaces
|
|
||||||
gsub(/[[:space:]]+$/, "", val)
|
|
||||||
# check presence of splash
|
|
||||||
found=0
|
|
||||||
n=split(val, tok, /[[:space:]]+/)
|
|
||||||
for (i=1;i<=n;i++) if (tok[i]=="splash") { found=1; break }
|
|
||||||
if (!found) {
|
|
||||||
if (val == "") val = "quiet splash"; else val = val " splash"
|
|
||||||
}
|
|
||||||
print key "=\"" val "\""
|
|
||||||
done=1
|
|
||||||
next
|
|
||||||
}
|
|
||||||
{ print }
|
|
||||||
END{
|
|
||||||
if (!done) print key "=\"quiet splash\""
|
|
||||||
}
|
|
||||||
' "$CFG" > "$CFG.tmp" && mv "$CFG.tmp" "$CFG"
|
|
||||||
|
|
||||||
update-grub || true
|
# If 'splash' is already present, leave as-is; otherwise append it
|
||||||
INCHROOT
|
grep -q '^GRUB_CMDLINE_LINUX_DEFAULT=.*\bsplash\b' "$CFG" || \
|
||||||
|
sed -i -r 's/^(GRUB_CMDLINE_LINUX_DEFAULT="[^"]*)"/\1 splash"/' "$CFG"
|
||||||
|
|
||||||
logger -t trisquel-uefi-splash "splash ensured; update-grub called"
|
# Regenerate grub.cfg; never fail finish-install
|
||||||
|
in-target update-grub >/dev/null 2>&1 || true
|
||||||
|
|
||||||
|
# Always succeed so remaining finish-install hooks run
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
# such packages from Debian in order to build the required udeb packages.
|
# such packages from Debian in order to build the required udeb packages.
|
||||||
##
|
##
|
||||||
|
|
||||||
VERSION=2.2
|
VERSION=2.3
|
||||||
EXTERNAL='deb-src http://ftp.debian.org/debian trixie main'
|
EXTERNAL='deb-src http://ftp.debian.org/debian trixie main'
|
||||||
REPOKEY=6ED0E7B82643E131
|
REPOKEY=6ED0E7B82643E131
|
||||||
NETINST=true
|
NETINST=true
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue