[arch-projects] [mkinitcpio][PATCH v2] [WIP] systemd: add systemd hook
Tom Gundersen
teg at jklm.no
Fri Mar 1 12:15:05 EST 2013
Note: generate initramfs with
HOOKS=('base' 'systemd' 'autodetect' 'block' 'filesystems')
This relies on patches patches soon to be posted on the systemd mailinglist.
This hook would live in the systemd package, but posting it as a mkinitcpio
patch because SVN.
Ideally, we would eventaully introduce "add_unit" and "add_rules" functions that
would allow us to add a few udev rules and systemd units, and have
everything else
in this hook (e.g., binaries from RUN= or ExecStart= and other units based on
Wants/Requires dependencise) pulled in automatically.
v2: don't parse /sysroot/etc for new settings
---
install/systemd | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
create mode 100644 install/systemd
diff --git a/install/systemd b/install/systemd
new file mode 100644
index 0000000..2737c81
--- /dev/null
+++ b/install/systemd
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+build() {
+ local rules tool socket service
+
+ # from base
+ add_binary /bin/mount
+
+ # systemd
+ add_binary /usr/lib/systemd/systemd /init
+ add_binary /usr/bin/systemctl
+ add_binary /usr/bin/udevadm
+ add_binary /usr/lib/systemd/systemd-udevd
+ add_binary /usr/lib/systemd/systemd-journald
+
+ # generate sysroot.mount and sysroot-usr.mount
+ add_file "/usr/lib/systemd/system-generators/systemd-fstab-generator"
+
+ # libdbus needs the passwd info of the root user
+ # TODO: patch dbus to avoid this hack
+ add_file "/etc/nsswitch.conf"
+ add_file "/etc/passwd"
+ add_file "/lib/libnss_files-2.17.so"
+ add_symlink "/lib/libnss_files.so.2" "libnss_files-2.17.so"
+ add_symlink "/lib/libnss_files.so" "libnss_files.so.2"
+
+ # udev rules and systemd units
+ for rules in 50-udev-default.rules 60-persistent-storage.rules
64-btrfs.rules 80-drivers.rules 99-systemd.rules; do
+ add_file "/usr/lib/udev/rules.d/$rules"
+ done
+ for tool in ata_id scsi_id; do
+ add_file "/usr/lib/udev/$tool"
+ done
+ for socket in systemd-udevd-control systemd-udevd-kernel
systemd-journald; do
+ add_file "/usr/lib/systemd/system/$socket.socket"
+ add_symlink
"/usr/lib/systemd/system/sockets.target.wants/$socket.socket"
"../$socket.socket"
+ done
+ for service in systemd-udevd systemd-udev-trigger systemd-journald; do
+ add_file "/usr/lib/systemd/system/$service.service"
+ add_symlink
"/usr/lib/systemd/system/sysinit.target.wants/$service.service"
"../$service.service"
+ done
+ for target in sysinit sockets basic emergency local-fs-pre
local-fs swap remote-fs-pre initrd-switch-root; do
+ add_file "/usr/lib/systemd/system/$target.target"
+ done
+
+ add_file "/usr/lib/systemd/system/systemd-fsck at .service"
+ add_file "/usr/lib/systemd/system/systemd-reboot.service"
"/usr/lib/systemd/system/ctrl-alt-del.service"
+
+ add_file "/usr/lib/systemd/system/initrd-cleanup.service"
+ add_symlink
"/usr/lib/systemd/system/basic.target.wants/initrd-cleanup.service"
"../initrd-cleanup.service"
+ add_file "/usr/lib/systemd/system/initrd-switch-root.service"
+ add_file "/usr/lib/systemd/system/initrd-udevadm-cleanup-db.service"
+
+ add_symlink "/usr/lib/systemd/system/default.target" "basic.target"
+}
+
+help() {
+ cat <<HELPEOF
+This will install a basic systemd setup on your initrd, you might
want to add more hooks to get more advanced functionality.
+HELPEOF
+}
+
+# vim: set ft=sh ts=4 sw=4 et:
--
1.8.1.4
More information about the arch-projects
mailing list