1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Make update-initrd(8) invoke its sysmerge replacement if any.

This commit is contained in:
Jonas 'Sortie' Termansen 2016-10-09 21:47:05 +02:00
parent 0bb608b09e
commit 2a143e6875
2 changed files with 26 additions and 27 deletions

View file

@ -1,5 +1,5 @@
#!/bin/sh -e
# Copyright (c) 2015 Jonas 'Sortie' Termansen.
#!/bin/sh
# Copyright (c) 2015, 2016 Jonas 'Sortie' Termansen.
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@ -16,27 +16,7 @@
# update-initrd
# Generate a mkinitrd that locates and chain boots the real root filesystem.
show_version() {
cat << EOF
$0 (Sortix)
EOF
exit 0
}
show_help() {
cat << EOF
Usage: $0 [OPTION]...
Generate a mkinitrd that locates and chain boots the real root filesystem.
Configuration:
--help display this help and exit
--version display version information and exit
--sysroot=DIR operate on this root filesystem [/]
EOF
exit 0
}
set -e
sysroot=
@ -66,16 +46,22 @@ for argument do
esac
done
if [ ! -e "$sysroot/etc/fstab" ]; then
echo "$0: $sysroot/etc/fstab: Need a filesystem table to make an initrd" >&2
exit 1
fi
sysmerge=false
exec_prefix="$sysroot"
if [ -d "$sysroot/sysmerge" ]; then
# If an upgrade is pending, invoke the update-initrd of the new system, if
# we're not already it.
if [ "$(realpath -- "$(which -- "$0")")" != \
"$(realpath -- "$sysroot/sysmerge/sbin/update-initrd")" ]; then
exec "$sysroot/sysmerge/sbin/update-initrd" "$@"
fi
sysmerge=true
exec_prefix="$sysroot/sysmerge"
fi
if [ ! -e "$sysroot/etc/fstab" ]; then
echo "$0: $sysroot/etc/fstab: Need a filesystem table to make an initrd" >&2
exit 1
fi
tmp=$(mktemp -d)
trap 'rm -rf "$tmp"' EXIT HUP INT QUIT TERM
mkdir "$tmp/bin"

View file

@ -30,6 +30,18 @@ If any of those files are updated then the
should be regenerated by invoking
.Nm .
.Pp
.Nm
is aware of
.Xr sysmerge 8
pending upgrades and will instead invoke the new
.Nm
in
.Pa /sysmerge
if an upgrade is pending.
.Nm
is written as a script so the initrd of the new system can produced even
across incompatible ABI changes.
.Pp
The options are as follows:
.Bl -tag -width "12345678"
.It Fl \-sysroot Ns "=" Ns Ar sysroot
@ -58,4 +70,5 @@ will exit 0 on success and non-zero otherwise.
.Xr init 8 ,
.Xr initrdfs 8 ,
.Xr mkinitrd 8 ,
.Xr sysmerge 8 ,
.Xr update-grub 8