summarylogtreecommitdiffstats
path: root/initcpio-install-systemd
diff options
context:
space:
mode:
Diffstat (limited to 'initcpio-install-systemd')
-rw-r--r--initcpio-install-systemd167
1 files changed, 65 insertions, 102 deletions
diff --git a/initcpio-install-systemd b/initcpio-install-systemd
index 8fb4441f7c76..d59900c35b51 100644
--- a/initcpio-install-systemd
+++ b/initcpio-install-systemd
@@ -1,50 +1,5 @@
#!/bin/bash
-strip_quotes() {
- local len=${#1} quotes=$'[\'"]' str=${!1}
-
- if [[ ${str:0:1} = ${str: -1} && ${str:0:1} = $quotes ]]; then
- printf -v "$1" %s "${str:1:-1}"
- fi
-}
-
-add_udev_rule() {
- # Add an udev rules file to the initcpio image. Dependencies on binaries
- # will be discovered and added.
- # $1: path to rules file (or name of rules file)
-
- local rules= rule= key= value= binary=
-
- rules=$(PATH=/usr/lib/udev/rules.d:/lib/udev/rules.d type -P "$1")
- if [[ -z $rules ]]; then
- # complain about not found rules
- return 1
- fi
-
- add_file "$rules"
-
- while IFS=, read -ra rule; do
- # skip empty lines, comments
- [[ -z $rule || $rule = @(+([[:space:]])|#*) ]] && continue
-
- for pair in "${rule[@]}"; do
- IFS=' =' read -r key value <<< "$pair"
- case $key in
- RUN@({program}|+)|IMPORT{program}|ENV{REMOVE_CMD})
- strip_quotes 'value'
- # just take the first word as the binary name
- binary=${value%% *}
- [[ ${binary:0:1} == '$' ]] && continue
- if [[ ${binary:0:1} != '/' ]]; then
- binary=$(PATH=/usr/lib/udev:/lib/udev type -P "$binary")
- fi
- add_binary "$binary"
- ;;
- esac
- done
- done <"$rules"
-}
-
add_systemd_unit() {
# Add a systemd unit file to the initcpio image. Hard dependencies on binaries
# and other unit files will be discovered and added.
@@ -69,10 +24,13 @@ add_systemd_unit() {
map add_systemd_unit "${values[@]}"
;;
Exec*)
- # don't add binaries unless they are required
- if [[ ${values[0]:0:1} != '-' ]]; then
- add_binary "${values[0]}"
- fi
+ # do not add binaries unless they are required,
+ # strip special executable prefixes
+ case ${values[0]} in
+ -*) ;;
+ !!*) add_binary "${values[0]#!!}" ;;
+ *) add_binary "${values[0]#[@!:+]}" ;;
+ esac
;;
esac
@@ -103,13 +61,14 @@ add_systemd_drop_in() {
build() {
local rules unit
- # from base
- add_binary /bin/mount
add_binary /usr/bin/kmod /usr/bin/modprobe
- add_binary /usr/lib/systemd/systemd /init
+ add_binary /usr/bin/mount
add_binary /usr/bin/sulogin
+ add_binary /usr/bin/umount
+ add_binary /usr/lib/systemd/systemd /init
map add_binary \
+ /usr/bin/journalctl \
/usr/bin/systemd-tmpfiles \
/usr/lib/systemd/systemd-hibernate-resume \
/usr/lib/systemd/systemd-shutdown \
@@ -118,68 +77,72 @@ build() {
/usr/lib/systemd/system-generators/systemd-gpt-auto-generator \
/usr/lib/systemd/system-generators/systemd-hibernate-resume-generator
- # for journalctl in emergency shell
- add_binary journalctl
-
- # udev rules and systemd units
+ # udev rules
map add_udev_rule "$rules" \
- 50-udev-default.rules \
- 60-persistent-storage.rules \
- 64-btrfs.rules \
- 80-drivers.rules \
- 99-systemd.rules
+ 50-udev-default.rules \
+ 60-persistent-storage.rules \
+ 64-btrfs.rules \
+ 80-drivers.rules \
+ 99-systemd.rules
+ # systemd units
map add_systemd_unit \
- initrd-cleanup.service \
- initrd-fs.target \
- initrd-parse-etc.service \
- initrd-root-fs.target \
- initrd-root-device.target \
- initrd-switch-root.service \
- initrd-switch-root.target \
- initrd-udevadm-cleanup-db.service \
- initrd.target \
- kmod-static-nodes.service \
- local-fs.target \
- local-fs-pre.target \
- paths.target \
- reboot.target \
- slices.target \
- sockets.target \
- swap.target \
- systemd-fsck@.service \
- systemd-hibernate-resume@.service \
- systemd-journald.service \
- systemd-journald-audit.socket \
- systemd-journald-dev-log.socket \
- systemd-modules-load.service \
- systemd-tmpfiles-setup-dev.service \
- systemd-udev-trigger.service \
- systemd-udevd-control.socket \
- systemd-udevd-kernel.socket \
- systemd-udevd.service \
- timers.target \
- rescue.target \
- emergency.target
+ initrd-cleanup.service \
+ initrd-fs.target \
+ initrd-parse-etc.service \
+ initrd-root-fs.target \
+ initrd-root-device.target \
+ initrd-switch-root.service \
+ initrd-switch-root.target \
+ initrd-udevadm-cleanup-db.service \
+ initrd.target \
+ kmod-static-nodes.service \
+ local-fs.target \
+ local-fs-pre.target \
+ paths.target \
+ reboot.target \
+ slices.target \
+ sockets.target \
+ swap.target \
+ systemd-battery-check.service \
+ systemd-fsck@.service \
+ systemd-journald-audit.socket \
+ systemd-journald-dev-log.socket \
+ systemd-journald.service \
+ systemd-modules-load.service \
+ systemd-pcrphase-initrd.service \
+ systemd-tmpfiles-setup-dev.service \
+ systemd-udevd-control.socket \
+ systemd-udevd-kernel.socket \
+ systemd-udevd.service \
+ systemd-udev-trigger.service \
+ systemd-vconsole-setup.service \
+ timers.target \
+ rescue.target \
+ emergency.target
+
+ # add libraries dlopen()ed by tpm2-util
+ for LIB in tss2-{esys,rc,mu,tcti-'*'}; do
+ for FILE in $(find /usr/lib/ -maxdepth 1 -name "lib${LIB}.so*"); do
+ if [[ -L "${FILE}" ]]; then
+ add_symlink "${FILE}"
+ else
+ add_binary "${FILE}"
+ fi
+ done
+ done
add_symlink "/usr/lib/systemd/system/default.target" "initrd.target"
add_symlink "/usr/lib/systemd/system/ctrl-alt-del.target" "reboot.target"
- add_binary "$(readlink -f /usr/lib/libnss_files.so)"
printf '%s\n' >"$BUILDROOT/etc/nsswitch.conf" \
'passwd: files' \
'group: files' \
'shadow: files'
- echo "root:x:0:0:root:/:/bin/sh" >"$BUILDROOT/etc/passwd"
- echo "root:x:0:root" >"$BUILDROOT/etc/group"
- echo "root::::::::" >"$BUILDROOT/etc/shadow"
-
- add_systemd_drop_in systemd-udevd.service resolve-names <<EOF
-[Service]
-ExecStart=
-ExecStart=/usr/lib/systemd/systemd-udevd --resolve-names=never
-EOF
+ echo "root:x:0:0:root:/root:/bin/sh" >"$BUILDROOT/etc/passwd"
+ echo 'root:*:::::::' >"$BUILDROOT/etc/shadow"
+ getent group root audio disk input kmem kvm lp optical render sgx storage tty uucp video | awk -F: ' { print $1 ":x:" $3 ":" }' >"$BUILDROOT/etc/group"
add_dir "/etc/modules-load.d"
(