summaryrefslogtreecommitdiff
path: root/nonsystemd/mkinitcpio/nosystemd.patch
blob: 80349ed9845336051b017ad654614a9deaaf0a44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
 Makefile            |   6 +-
 hooks/udev          |   6 +-
 init_functions      |  11 ----
 install/lvm2        |   8 +--
 install/mdadm_udev  |   3 -
 install/sd-encrypt  |  67 --------------------
 install/sd-shutdown |  19 ------
 install/sd-vconsole | 119 -----------------------------------
 install/systemd     | 174 ----------------------------------------------------
 install/udev        |   4 +-
 10 files changed, 8 insertions(+), 409 deletions(-)

diff --git a/Makefile b/Makefile
index 824387b..f73df17 100644
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,6 @@ DIRS = \
 	/usr/share/man/man5 \
 	/usr/share/man/man1 \
 	/usr/share/mkinitcpio \
-	/usr/lib/systemd/system/shutdown.target.wants \
 	/usr/lib/tmpfiles.d \
 	/usr/share/libalpm/hooks \
 	/usr/share/libalpm/scripts
@@ -63,10 +62,7 @@ install-generator: all prepare

 	cp -at $(DESTDIR)/usr/lib/initcpio hooks install
 	install -m644 -t $(DESTDIR)/usr/share/mkinitcpio mkinitcpio.d/*
-	install -m644 systemd/mkinitcpio-generate-shutdown-ramfs.service \
-			$(DESTDIR)/usr/lib/systemd/system/mkinitcpio-generate-shutdown-ramfs.service
-	ln -s ../mkinitcpio-generate-shutdown-ramfs.service \
-			$(DESTDIR)/usr/lib/systemd/system/shutdown.target.wants/mkinitcpio-generate-shutdown-ramfs.service
+
 	install -m644 tmpfiles/mkinitcpio.conf $(DESTDIR)/usr/lib/tmpfiles.d/mkinitcpio.conf

 	install -m755 kernel-install/50-mkinitcpio.install $(DESTDIR)/usr/lib/kernel/install.d/50-mkinitcpio.install
diff --git a/hooks/udev b/hooks/udev
index 951c95e..4b67922 100644
--- a/hooks/udev
+++ b/hooks/udev
@@ -2,13 +2,13 @@

 run_earlyhook() {
     kmod static-nodes --format=tmpfiles --output=/run/tmpfiles.d/kmod.conf
-    systemd-tmpfiles --prefix=/dev --create --boot
+    etmpfiles --prefix=/dev --create --boot
     # assigned by parse_cmdline
     # shellcheck disable=SC2154
     if [ "${quiet}" = "y" ]; then
-        /usr/lib/systemd/systemd-udevd --daemon --resolve-names=never >/dev/null 2>&1
+        /usr/bin/udevd --daemon --resolve-names=never >/dev/null 2>&1
     else
-        /usr/lib/systemd/systemd-udevd --daemon --resolve-names=never
+        /usr/bin/udevd --daemon --resolve-names=never
     fi
     # used externally by poll_device()
     # shellcheck disable=SC2034
diff --git a/init_functions b/init_functions
index 0abfde7..e33b2a5 100644
--- a/init_functions
+++ b/init_functions
@@ -338,17 +338,6 @@ fsck_root() {
         elif bitfield_has_bit "$fsckret" 128; then
             err "fatal error invoking fsck"
         fi
-
-        # ensure that root is going to be mounted rw. Otherwise, systemd
-        # might fsck the device again. Annoy the user so that they fix this.
-        if [ "${rwopt:-ro}" != 'rw' ]; then
-            echo "********************** WARNING **********************"
-            echo "*                                                   *"
-            echo "*  The root device is not configured to be mounted  *"
-            echo "*  read-write! It may be fsck'd again later.        *"
-            echo "*                                                   *"
-            echo "*****************************************************"
-        fi
     fi
 }

diff --git a/install/lvm2 b/install/lvm2
index c2dc8a6..42884dc 100644
--- a/install/lvm2
+++ b/install/lvm2
@@ -33,12 +33,8 @@ build() {
         '95-dm-notify.rules' \
         '/usr/lib/initcpio/udev/11-dm-initramfs.rules'

-    # this udev rule is specific for systemd and non-systemd systems
-    if declare -F add_systemd_unit &>/dev/null; then
-        add_udev_rule '69-dm-lvm.rules'
-    else
-        add_udev_rule '/usr/lib/initcpio/udev/69-dm-lvm.rules'
-    fi
+    # this udev rule is specific for non-systemd systems
+    add_udev_rule '/usr/lib/initcpio/udev/69-dm-lvm.rules'

     # config file
     add_file '/etc/lvm/lvm.conf'
diff --git a/install/mdadm_udev b/install/mdadm_udev
index f8ad731..af6adf6 100644
--- a/install/mdadm_udev
+++ b/install/mdadm_udev
@@ -15,9 +15,6 @@ build() {

     # For external metadata arrays (e.g. IMSM)
     add_binary mdmon
-    if declare -F add_systemd_unit &>/dev/null; then
-        add_systemd_unit 'mdmon@.service'
-    fi
 }

 help() {
diff --git a/install/sd-encrypt b/install/sd-encrypt
deleted file mode 100644
index e60d883..0000000
--- a/install/sd-encrypt
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/bin/bash
-
-build() {
-    local mod
-
-    add_module 'dm-crypt'
-    add_module 'dm-integrity'
-    if [[ -n "$CRYPTO_MODULES" ]]; then
-        for mod in $CRYPTO_MODULES; do
-            add_module "$mod"
-        done
-    else
-        add_all_modules '/crypto/'
-    fi
-    add_checked_modules '/drivers/char/tpm/'
-
-    map add_udev_rule \
-        '10-dm.rules' \
-        '13-dm-disk.rules' \
-        '60-fido-id.rules' \
-        '95-dm-notify.rules' \
-        '/usr/lib/initcpio/udev/11-dm-initramfs.rules'
-
-    map add_systemd_unit 'cryptsetup.target' \
-        'systemd-ask-password-console.path' \
-        'systemd-ask-password-console.service'
-    map add_binary \
-        '/usr/lib/systemd/system-generators/systemd-cryptsetup-generator' \
-        '/usr/lib/systemd/systemd-cryptsetup' \
-        '/usr/lib/systemd/systemd-makefs' \
-        '/usr/lib/cryptsetup/libcryptsetup-token-systemd-fido2.so' \
-        '/usr/lib/cryptsetup/libcryptsetup-token-systemd-pkcs11.so' \
-        '/usr/lib/cryptsetup/libcryptsetup-token-systemd-tpm2.so'
-
-    # cryptsetup calls pthread_create(), which dlopen()s libgcc_s.so.1
-    add_binary '/usr/lib/libgcc_s.so.1'
-
-    # cryptsetup loads the legacy provider which is required for whirlpool
-    add_binary '/usr/lib/ossl-modules/legacy.so'
-
-    # add libraries dlopen()ed by systemd-cryptsetup
-    LC_ALL=C.UTF-8 find /usr/lib/ -maxdepth 1 -name "libfido2.so*" | while read -r -d '' FILE; do
-        if [[ -L "${FILE}" ]]; then
-            add_symlink "${FILE}"
-        else
-            add_binary "${FILE}"
-        fi
-    done
-
-    # add mkswap for creating swap space on the fly (see 'swap' in crypttab(5))
-    add_binary 'mkswap'
-
-    [[ -f /etc/crypttab.initramfs ]] && add_file '/etc/crypttab.initramfs' '/etc/crypttab'
-}
-
-help() {
-    cat <<HELPEOF
-This hook allows for an encrypted root device with systemd initramfs.
-
-See the manpage of systemd-cryptsetup-generator(8) for available kernel
-command line options. Alternatively, if the file /etc/crypttab.initramfs
-exists, it will be added to the initramfs as /etc/crypttab. See the
-crypttab(5) manpage for more information on crypttab syntax.
-HELPEOF
-}
-
-# vim: set ft=sh ts=4 sw=4 et:
diff --git a/install/sd-shutdown b/install/sd-shutdown
deleted file mode 100644
index f8aad2e..0000000
--- a/install/sd-shutdown
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/env bash
-# SPDX-License-Identifier: GPL-2.0-only
-
-build() {
-    add_binary /usr/lib/systemd/systemd-shutdown /shutdown
-
-    if type -P kexec >/dev/null; then
-        add_binary kexec
-    fi
-}
-
-help() {
-    cat <<HELPEOF
-This hook adds systemd-shutdown to the initramfs. This is only
-if the image is extracted to /run/initramfs before shutdown.
-HELPEOF
-}
-
-# vim: set ft=sh ts=4 sw=4 et:
diff --git a/install/sd-vconsole b/install/sd-vconsole
deleted file mode 100644
index 971b264..0000000
--- a/install/sd-vconsole
+++ /dev/null
@@ -1,119 +0,0 @@
-#!/usr/bin/env bash
-# SPDX-License-Identifier: GPL-2.0-only
-
-build() {
-    # prevent conflicting variables from affecting vconsole.conf values
-    # shellcheck disable=SC2034
-    local KEYMAP KEYMAP_TOGGLE FONT FONT_MAP FONT_UNIMAP XKBLAYOUT XKBMODEL XKBVARIANT XKBOPTIONS
-
-    add_systemd_unit systemd-vconsole-setup.service
-    add_binary /usr/lib/systemd/systemd-vconsole-setup
-    add_binary loadkeys
-    add_binary setfont
-    add_file /etc/vconsole.conf
-    add_udev_rule 90-vconsole.rules
-
-    # subshell to avoid namespace pollution
-    (
-        shopt -s extglob nullglob
-
-        get_decompressor() {
-            case "$1" in
-                *.gz)
-                    cat='zcat'
-                    of="${1%.gz}"
-                    ;;
-                *.bz2)
-                    cat='bzcat'
-                    of="${1%.bz2}"
-                    ;;
-                *.zst)
-                    cat='zstdcat'
-                    of="${1%.zst}"
-                    ;;
-                *)
-                    cat='cat'
-                    of="$1"
-                    ;;
-            esac
-        }
-
-        add_keymap_file() {
-            local cat cmd rest f of
-
-            while read -r f; do
-                get_decompressor "$f"
-                while read -r cmd rest; do
-                    if [[ "$cmd" == 'include' ]]; then
-                        eval set "$rest"
-                        add_keymap_file "$1"
-                    fi
-                done < <("$cat" "$f")
-                add_dir "${of%/*}"
-                "$cat" "$f" >"$BUILDROOT/$of"
-            done < <(LC_ALL=C.UTF-8 find /usr/share/kbd/keymaps/ -type f -regex ".*/$1\(\.inc\)?\(\.gz\|\.bz2|\.zst\)?")
-        }
-
-        add_font_file() {
-            local cat file filename fontfile="$1"
-            get_decompressor "$fontfile"
-            add_dir "${of%/*}"
-            "$cat" "$fontfile" >"$BUILDROOT/$of"
-            if [[ "$(head -c 23 "$BUILDROOT/$of" | tr -d '\0')" == '# combine partial fonts' ]]; then
-                while read -r filename; do
-                    for file in "/usr/share/kbd/consolefonts/partialfonts/$filename"?('.gz'|'.bz2'|'.zst'); do
-                        add_font_file "$file"
-                    done
-                done < <(sed '/^#/d' "$BUILDROOT/$of")
-            fi
-        }
-
-        # shellcheck disable=SC1091
-        [[ -s /etc/vconsole.conf ]] && . /etc/vconsole.conf
-
-        [[ "$KEYMAP" != '@kernel' ]] && add_keymap_file "${KEYMAP:-us}.map"
-        [[ -n "$KEYMAP_TOGGLE" ]] && add_keymap_file "${KEYMAP_TOGGLE}.map"
-
-        if [[ -n "$FONT_MAP" ]]; then
-            FONT_MAP="${FONT_MAP%.trans}"
-            if [[ -f "/usr/share/kbd/consoletrans/$FONT_MAP" ]]; then
-                add_file "/usr/share/kbd/consoletrans/$FONT_MAP"
-            elif [[ -f "/usr/share/kbd/consoletrans/$FONT_MAP.trans" ]]; then
-                add_file "/usr/share/kbd/consoletrans/$FONT_MAP.trans"
-            elif [[ -f "/usr/share/kbd/consoletrans/${FONT_MAP}_to_uni.trans" ]]; then
-                add_file "/usr/share/kbd/consoletrans/${FONT_MAP}_to_uni.trans"
-            else
-                error "sd-vconsole: requested font map not found: '%s'" "$FONT_MAP"
-                return 1
-            fi
-        fi
-
-        if [[ -n "$FONT_UNIMAP" ]]; then
-            FONT_UNIMAP="${FONT_UNIMAP%.uni}"
-            if [[ -f "/usr/share/kbd/unimaps/$FONT_UNIMAP.uni" ]]; then
-                add_file "/usr/share/kbd/unimaps/$FONT_UNIMAP.uni"
-            else
-                error "sd-vconsole: requested font unimap not found: '%s'" "$FONT_UNIMAP"
-                return 1
-            fi
-        fi
-
-        if [[ -n "$FONT" ]]; then
-            for file in "/usr/share/kbd/consolefonts/$FONT"?('.psfu'|'.psf'|'.cp'|'.fnt')?('.gz'|'.bz2'|'.zst'); do
-                add_font_file "$file"
-                return
-            done
-            error "sd-vconsole: requested font not found: '%s'" "$FONT"
-            return 1
-        fi
-    )
-}
-
-help() {
-    cat <<HELPEOF
-This hook adds the keymap(s) and font specified in vconsole.conf to the image and
-loads them during early userspace.
-HELPEOF
-}
-
-# vim: set ft=sh ts=4 sw=4 et:
diff --git a/install/systemd b/install/systemd
deleted file mode 100644
index 808750c..0000000
--- a/install/systemd
+++ /dev/null
@@ -1,174 +0,0 @@
-#!/bin/bash
-
-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.
-    #   $1: path to rules file (or name of rules file)
-
-    local unit key dep
-
-    unit=$(PATH=/usr/lib/systemd/system:/lib/systemd/system type -P "$1")
-    if [[ -z $unit ]]; then
-        # complain about not found unit file
-        return 1
-    fi
-
-    add_file "$unit"
-
-    while IFS='=' read -r key values; do
-        read -ra values <<< "$values"
-
-        case $key in
-            Requires|OnFailure)
-                # only add hard dependencies (not Wants)
-                map add_systemd_unit "${values[@]}"
-                ;;
-            Exec*)
-                # 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
-
-    done <"$unit"
-
-    # preserve reverse soft dependency
-    for dep in {/usr,}/lib/systemd/system/*.wants/"${unit##*/}"; do
-        if [[ -L $dep ]]; then
-            add_symlink "$dep"
-        fi
-    done
-
-    # add hard dependencies
-    if [[ -d $unit.requires ]]; then
-        for dep in "$unit".requires/*; do
-            add_systemd_unit "${dep##*/}"
-        done
-    fi
-}
-
-add_systemd_drop_in() {
-    local unit=$1
-
-    mkdir -p "$BUILDROOT/etc/systemd/system/$unit.d"
-    cat >"$BUILDROOT/etc/systemd/system/$unit.d/$2.conf"
-}
-
-build() {
-    local rules unit
-
-    add_binary /usr/bin/kmod /usr/bin/modprobe
-    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-executor \
-        /usr/lib/systemd/systemd-hibernate-resume \
-        /usr/lib/systemd/systemd-shutdown \
-        /usr/lib/systemd/systemd-sulogin-shell \
-        /usr/lib/systemd/system-generators/systemd-fstab-generator \
-        /usr/lib/systemd/system-generators/systemd-gpt-auto-generator \
-        /usr/lib/systemd/system-generators/systemd-hibernate-resume-generator
-
-    # udev rules
-    map add_udev_rule "$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-battery-check.service \
-        systemd-bsod.service \
-        systemd-fsck@.service \
-        systemd-hibernate-resume.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 \
-        timers.target \
-        rescue.target \
-        emergency.target
-
-    # add libraries dlopen()ed (hard and optional dependencies):
-    #  tss2-*   -> tpm2-util
-    #  kmod     -> systemd-shared
-    #  qrencode -> bsod
-    for LIB in kmod tss2-{esys,rc,mu,tcti-'*'} qrencode; do
-        LC_ALL=C.UTF-8 find /usr/lib/ -maxdepth 1 -name "lib${LIB}.so*" | while read -r -d '' FILE; 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"
-
-    printf '%s\n' >"$BUILDROOT/etc/nsswitch.conf" \
-        'passwd: files' \
-        'group: files' \
-        'shadow: files'
-
-    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"
-    (
-      # FIXME: this should be a function in mkinitcpio
-      # shellcheck disable=SC1091,SC2154 source=mkinitcpio.conf
-      . "$_f_config"
-      set -f
-      printf '%s\n' "${MODULES[@]}" >"$BUILDROOT/etc/modules-load.d/MODULES.conf"
-    )
-
-    [[ -f /etc/fstab.initramfs ]] && add_file "/etc/fstab.initramfs" "/etc/fstab"
-}
-
-help() {
-    cat <<HELPEOF
-This will install a basic systemd setup in your initramfs, and is meant to
-replace the 'base', 'usr', 'udev' and 'resume' hooks. Other hooks with runtime
-components will need to be ported, and will not work as intended. You also may
-wish to still include the 'base' hook (before this hook) to ensure that a
-rescue shell exists on your initramfs.
-HELPEOF
-}
-
-# vim: set ft=sh ts=4 sw=4 et:
diff --git a/install/udev b/install/udev
index 8b51f44..9aa9ca8 100644
--- a/install/udev
+++ b/install/udev
@@ -2,9 +2,9 @@

 build() {
     map add_binary \
-        '/usr/lib/systemd/systemd-udevd' \
+        '/usr/bin/udevd' \
         '/usr/bin/udevadm' \
-        '/usr/bin/systemd-tmpfiles' \
+        '/usr/bin/etmpfiles' \
         '/usr/lib/udev/ata_id' \
         '/usr/lib/udev/scsi_id'