From 8396ffec5c522aabbdf4c4e995aa5f071ec32879 Mon Sep 17 00:00:00 2001 From: Timothy Kenno Handojo Date: Fri, 13 Sep 2024 22:33:59 +0700 Subject: [PATCH] Early implementation of feature modularization Signed-off-by: Timothy Kenno Handojo --- .gitignore | 1 + Makefile | 32 +- README | 29 + doc/genkernel.8.txt | 121 +- features/-sample/append_base_layout | 0 features/-sample/create_initramfs | 0 features/-sample/determine_real_args | 0 features/-sample/genkernel_conf | 0 features/-sample/initramfs_append_func | 0 features/-sample/longusage | 0 features/-sample/man_genkernel_8 | 0 features/-sample/parse_cmdline | 0 features/b2sum/append_base_layout | 1 + features/b2sum/create_initramfs | 1 + features/b2sum/determine_real_args | 1 + features/b2sum/genkernel_conf | 2 + features/b2sum/initramfs_append_func | 25 + features/b2sum/longusage | 3 + features/b2sum/man_genkernel_8 | 3 + features/b2sum/parse_cmdline | 4 + features/bcache/append_base_layout | 1 + features/bcache/create_initramfs | 1 + features/bcache/determine_real_args | 1 + features/bcache/genkernel_conf | 2 + features/bcache/initramfs_append_func | 25 + features/bcache/longusage | 2 + features/bcache/man_genkernel_8 | 3 + features/bcache/parse_cmdline | 4 + features/btrfs/append_base_layout | 1 + features/btrfs/create_initramfs | 1 + features/btrfs/determine_real_args | 1 + features/btrfs/genkernel_conf | 2 + features/btrfs/initramfs_append_func | 25 + features/btrfs/longusage | 2 + features/btrfs/man_genkernel_8 | 3 + features/btrfs/parse_cmdline | 4 + features/dmraid/append_base_layout | 1 + features/dmraid/create_initramfs | 1 + features/dmraid/determine_real_args | 1 + features/dmraid/genkernel_conf | 2 + features/dmraid/initramfs_append_func | 32 + features/dmraid/longusage | 2 + features/dmraid/man_genkernel_8 | 3 + features/dmraid/parse_cmdline | 4 + features/e2fsprogs/append_base_layout | 1 + features/e2fsprogs/create_initramfs | 1 + features/e2fsprogs/determine_real_args | 1 + features/e2fsprogs/genkernel_conf | 2 + features/e2fsprogs/initramfs_append_func | 25 + features/e2fsprogs/longusage | 2 + features/e2fsprogs/man_genkernel_8 | 3 + features/e2fsprogs/parse_cmdline | 4 + features/iscsi/append_base_layout | 1 + features/iscsi/create_initramfs | 1 + features/iscsi/determine_real_args | 1 + features/iscsi/genkernel_conf | 2 + features/iscsi/initramfs_append_func | 25 + features/iscsi/longusage | 2 + features/iscsi/man_genkernel_8 | 3 + features/iscsi/parse_cmdline | 4 + features/luks/append_base_layout | 3 + features/luks/create_initramfs | 3 + features/luks/determine_real_args | 3 + features/luks/genkernel_conf | 8 + features/luks/initramfs_append_func | 82 ++ features/luks/longusage | 6 + features/luks/man_genkernel_8 | 15 + features/luks/parse_cmdline | 12 + features/lvm/append_base_layout | 1 + features/lvm/create_initramfs | 1 + features/lvm/determine_real_args | 1 + features/lvm/genkernel_conf | 2 + features/lvm/initramfs_append_func | 84 ++ features/lvm/longusage | 2 + features/lvm/man_genkernel_8 | 3 + features/lvm/parse_cmdline | 10 + features/mdadm/append_base_layout | 1 + features/mdadm/create_initramfs | 1 + features/mdadm/determine_real_args | 2 + features/mdadm/genkernel_conf | 7 + features/mdadm/initramfs_append_func | 49 + features/mdadm/longusage | 3 + features/mdadm/man_genkernel_8 | 8 + features/mdadm/parse_cmdline | 8 + features/multipath/append_base_layout | 1 + features/multipath/create_initramfs | 1 + features/multipath/determine_real_args | 1 + features/multipath/genkernel_conf | 2 + features/multipath/initramfs_append_func | 68 + features/multipath/longusage | 2 + features/multipath/man_genkernel_8 | 3 + features/multipath/parse_cmdline | 4 + features/plymouth/append_base_layout | 1 + features/plymouth/create_initramfs | 1 + features/plymouth/determine_real_args | 1 + features/plymouth/genkernel_conf | 6 + features/plymouth/initramfs_append_func | 54 + features/plymouth/longusage | 3 + features/plymouth/man_genkernel_8 | 6 + features/plymouth/parse_cmdline | 11 + features/splash/append_base_layout | 1 + features/splash/create_initramfs | 1 + features/splash/determine_real_args | 1 + features/splash/genkernel_conf | 7 + features/splash/initramfs_append_func | 45 + features/splash/longusage | 2 + features/splash/man_genkernel_8 | 13 + features/splash/parse_cmdline | 36 + features/ssh/append_base_layout | 1 + features/ssh/create_initramfs | 1 + features/ssh/determine_real_args | 3 + features/ssh/genkernel_conf | 2 + features/ssh/initramfs_append_func | 295 ++++ features/ssh/longusage | 9 + features/ssh/man_genkernel_8 | 16 + features/ssh/parse_cmdline | 17 + features/strace/append_base_layout | 1 + features/strace/create_initramfs | 1 + features/strace/determine_real_args | 1 + features/strace/genkernel_conf | 2 + features/strace/initramfs_append_func | 25 + features/strace/longusage | 2 + features/strace/man_genkernel_8 | 2 + features/strace/parse_cmdline | 4 + features/unionfs/append_base_layout | 1 + features/unionfs/create_initramfs | 1 + features/unionfs/determine_real_args | 1 + features/unionfs/genkernel_conf | 2 + features/unionfs/initramfs_append_func | 25 + features/unionfs/longusage | 2 + features/unionfs/man_genkernel_8 | 3 + features/unionfs/parse_cmdline | 4 + features/xfsprogs/append_base_layout | 1 + features/xfsprogs/create_initramfs | 1 + features/xfsprogs/determine_real_args | 1 + features/xfsprogs/genkernel_conf | 2 + features/xfsprogs/initramfs_append_func | 25 + features/xfsprogs/longusage | 2 + features/xfsprogs/man_genkernel_8 | 3 + features/xfsprogs/parse_cmdline | 4 + features/zfs/append_base_layout | 1 + features/zfs/create_initramfs | 5 + features/zfs/determine_real_args | 1 + features/zfs/genkernel_conf | 3 + features/zfs/initramfs_append_func | 80 ++ features/zfs/longusage | 2 + features/zfs/man_genkernel_8 | 2 + features/zfs/parse_cmdline | 4 + gen_cmdline.sh | 242 +--- gen_determineargs.sh | 42 +- gen_funcs.sh | 2 +- gen_initramfs.sh | 1611 ++++------------------ genkernel.conf | 91 +- load_features.sh | 1 + 154 files changed, 1796 insertions(+), 1762 deletions(-) create mode 100644 features/-sample/append_base_layout create mode 100644 features/-sample/create_initramfs create mode 100644 features/-sample/determine_real_args create mode 100644 features/-sample/genkernel_conf create mode 100644 features/-sample/initramfs_append_func create mode 100644 features/-sample/longusage create mode 100644 features/-sample/man_genkernel_8 create mode 100644 features/-sample/parse_cmdline create mode 100644 features/b2sum/append_base_layout create mode 100644 features/b2sum/create_initramfs create mode 100644 features/b2sum/determine_real_args create mode 100644 features/b2sum/genkernel_conf create mode 100644 features/b2sum/initramfs_append_func create mode 100644 features/b2sum/longusage create mode 100644 features/b2sum/man_genkernel_8 create mode 100644 features/b2sum/parse_cmdline create mode 100644 features/bcache/append_base_layout create mode 100644 features/bcache/create_initramfs create mode 100644 features/bcache/determine_real_args create mode 100644 features/bcache/genkernel_conf create mode 100644 features/bcache/initramfs_append_func create mode 100644 features/bcache/longusage create mode 100644 features/bcache/man_genkernel_8 create mode 100644 features/bcache/parse_cmdline create mode 100644 features/btrfs/append_base_layout create mode 100644 features/btrfs/create_initramfs create mode 100644 features/btrfs/determine_real_args create mode 100644 features/btrfs/genkernel_conf create mode 100644 features/btrfs/initramfs_append_func create mode 100644 features/btrfs/longusage create mode 100644 features/btrfs/man_genkernel_8 create mode 100644 features/btrfs/parse_cmdline create mode 100644 features/dmraid/append_base_layout create mode 100644 features/dmraid/create_initramfs create mode 100644 features/dmraid/determine_real_args create mode 100644 features/dmraid/genkernel_conf create mode 100644 features/dmraid/initramfs_append_func create mode 100644 features/dmraid/longusage create mode 100644 features/dmraid/man_genkernel_8 create mode 100644 features/dmraid/parse_cmdline create mode 100644 features/e2fsprogs/append_base_layout create mode 100644 features/e2fsprogs/create_initramfs create mode 100644 features/e2fsprogs/determine_real_args create mode 100644 features/e2fsprogs/genkernel_conf create mode 100644 features/e2fsprogs/initramfs_append_func create mode 100644 features/e2fsprogs/longusage create mode 100644 features/e2fsprogs/man_genkernel_8 create mode 100644 features/e2fsprogs/parse_cmdline create mode 100644 features/iscsi/append_base_layout create mode 100644 features/iscsi/create_initramfs create mode 100644 features/iscsi/determine_real_args create mode 100644 features/iscsi/genkernel_conf create mode 100644 features/iscsi/initramfs_append_func create mode 100644 features/iscsi/longusage create mode 100644 features/iscsi/man_genkernel_8 create mode 100644 features/iscsi/parse_cmdline create mode 100644 features/luks/append_base_layout create mode 100644 features/luks/create_initramfs create mode 100644 features/luks/determine_real_args create mode 100644 features/luks/genkernel_conf create mode 100644 features/luks/initramfs_append_func create mode 100644 features/luks/longusage create mode 100644 features/luks/man_genkernel_8 create mode 100644 features/luks/parse_cmdline create mode 100644 features/lvm/append_base_layout create mode 100644 features/lvm/create_initramfs create mode 100644 features/lvm/determine_real_args create mode 100644 features/lvm/genkernel_conf create mode 100644 features/lvm/initramfs_append_func create mode 100644 features/lvm/longusage create mode 100644 features/lvm/man_genkernel_8 create mode 100644 features/lvm/parse_cmdline create mode 100644 features/mdadm/append_base_layout create mode 100644 features/mdadm/create_initramfs create mode 100644 features/mdadm/determine_real_args create mode 100644 features/mdadm/genkernel_conf create mode 100644 features/mdadm/initramfs_append_func create mode 100644 features/mdadm/longusage create mode 100644 features/mdadm/man_genkernel_8 create mode 100644 features/mdadm/parse_cmdline create mode 100644 features/multipath/append_base_layout create mode 100644 features/multipath/create_initramfs create mode 100644 features/multipath/determine_real_args create mode 100644 features/multipath/genkernel_conf create mode 100644 features/multipath/initramfs_append_func create mode 100644 features/multipath/longusage create mode 100644 features/multipath/man_genkernel_8 create mode 100644 features/multipath/parse_cmdline create mode 100644 features/plymouth/append_base_layout create mode 100644 features/plymouth/create_initramfs create mode 100644 features/plymouth/determine_real_args create mode 100644 features/plymouth/genkernel_conf create mode 100644 features/plymouth/initramfs_append_func create mode 100644 features/plymouth/longusage create mode 100644 features/plymouth/man_genkernel_8 create mode 100644 features/plymouth/parse_cmdline create mode 100644 features/splash/append_base_layout create mode 100644 features/splash/create_initramfs create mode 100644 features/splash/determine_real_args create mode 100644 features/splash/genkernel_conf create mode 100644 features/splash/initramfs_append_func create mode 100644 features/splash/longusage create mode 100644 features/splash/man_genkernel_8 create mode 100644 features/splash/parse_cmdline create mode 100644 features/ssh/append_base_layout create mode 100644 features/ssh/create_initramfs create mode 100644 features/ssh/determine_real_args create mode 100644 features/ssh/genkernel_conf create mode 100644 features/ssh/initramfs_append_func create mode 100644 features/ssh/longusage create mode 100644 features/ssh/man_genkernel_8 create mode 100644 features/ssh/parse_cmdline create mode 100644 features/strace/append_base_layout create mode 100644 features/strace/create_initramfs create mode 100644 features/strace/determine_real_args create mode 100644 features/strace/genkernel_conf create mode 100644 features/strace/initramfs_append_func create mode 100644 features/strace/longusage create mode 100644 features/strace/man_genkernel_8 create mode 100644 features/strace/parse_cmdline create mode 100644 features/unionfs/append_base_layout create mode 100644 features/unionfs/create_initramfs create mode 100644 features/unionfs/determine_real_args create mode 100644 features/unionfs/genkernel_conf create mode 100644 features/unionfs/initramfs_append_func create mode 100644 features/unionfs/longusage create mode 100644 features/unionfs/man_genkernel_8 create mode 100644 features/unionfs/parse_cmdline create mode 100644 features/xfsprogs/append_base_layout create mode 100644 features/xfsprogs/create_initramfs create mode 100644 features/xfsprogs/determine_real_args create mode 100644 features/xfsprogs/genkernel_conf create mode 100644 features/xfsprogs/initramfs_append_func create mode 100644 features/xfsprogs/longusage create mode 100644 features/xfsprogs/man_genkernel_8 create mode 100644 features/xfsprogs/parse_cmdline create mode 100644 features/zfs/append_base_layout create mode 100644 features/zfs/create_initramfs create mode 100644 features/zfs/determine_real_args create mode 100644 features/zfs/genkernel_conf create mode 100644 features/zfs/initramfs_append_func create mode 100644 features/zfs/longusage create mode 100644 features/zfs/man_genkernel_8 create mode 100644 features/zfs/parse_cmdline create mode 100644 load_features.sh diff --git a/.gitignore b/.gitignore index 75e2eda1..5acba6ea 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /genkernel-*.tar.xz /ChangeLog /arch/*/generated-config +/build \ No newline at end of file diff --git a/Makefile b/Makefile index 1e20ef5d..0553e565 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ ifeq ("$(PACKAGE_VERSION)", "") PACKAGE_VERSION = $(shell git describe --tags |sed 's,^v,,g') endif distdir = genkernel-$(PACKAGE_VERSION) -MANPAGE = genkernel.8 +MANPAGE := genkernel.8 # Add off-Git/generated files here that need to be shipped with releases EXTRA_DIST = ChangeLog $(KCONF) @@ -69,6 +69,14 @@ SOFTWARE = BCACHE_TOOLS \ ZLIB \ ZSTD +FEATURE_COMPONENTS = append_base_layout \ + create_initramfs \ + determine_real_args \ + genkernel_conf \ + initramfs_append_func \ + longusage \ + parse_cmdline + SOFTWARE_VERSION = $(foreach entry, $(SOFTWARE), "VERSION_$(entry)=${VERSION_$(entry)}\n") PREFIX = /usr/local @@ -80,12 +88,15 @@ else endif MANDIR = $(PREFIX)/share/man +FEATURE_FILES = $(addprefix $(addprefix $(BUILD_DIR)/features/, $(GK_FEATURES))/, $(FEATURE_COMPONENTS)) + all: $(BUILD_DIR)/genkernel $(BUILD_DIR)/build-config man kconfig debug: @echo "ARCH_KCONF=$(ARCH_KCONF)" @echo "GENERATED_KCONF=$(GENERATED_KCONF)" @echo "PACKAGE_VERSION=$(PACKAGE_VERSION)" + @echo "FEATURE_FILES: $(FEATURE_FILES)" kconfig: $(GENERATED_KCONF) man: $(addprefix $(BUILD_DIR)/,$(MANPAGE)) @@ -186,8 +197,23 @@ $(BUILD_DIR)/software.sh: echo -e $(SOFTWARE_VERSION) > $(BUILD_DIR)/temp/versions cat $(BUILD_DIR)/temp/versions defaults/software.sh > $(BUILD_DIR)/software.sh -$(BUILD_DIR)/doc/genkernel.8.txt: - install -D doc/genkernel.8.txt $(BUILD_DIR)/doc/genkernel.8.txt +$(BUILD_DIR)/temp/%: + install -d $(@D) + echo > $@ +ifdef GK_FEATURES + cat $(addsuffix /$(@F) <(echo), $(addprefix features/,${GK_FEATURES})) > $@ +endif + +$(BUILD_DIR)/doc/genkernel.8.txt: $(BUILD_DIR)/temp/man_genkernel_8 + install -d $(BUILD_DIR)/doc/ + cat doc/genkernel.8.txt | sed \ + -e '/\/\/ BEGIN FEATURES man_genkernel_8/ r $(BUILD_DIR)/temp/man_genkernel_8' \ + > $(BUILD_DIR)/doc/genkernel.8.txt + +$(BUILD_DIR)/genkernel.conf: $(BUILD_DIR)/temp/genkernel_conf + cat genkernel.conf | sed \ + -e '/# BEGIN FEATURES genkernel_conf/ r $(BUILD_DIR)/temp/genkernel_conf' \ + > $(BUILD_DIR)/genkernel.conf $(BUILD_DIR)/%: % install -D $< $@ diff --git a/README b/README index 1df4231d..29ec6b5d 100644 --- a/README +++ b/README @@ -14,8 +14,22 @@ things mentioned above. DEPENDENCIES: - GCC and binutils - GNU Bash + - GNU Make - PaX Utilities - Autoconf and Automake + - Asciidoc + - Dependencies of each feature included + +INSTALLATION: + Build with ``make PREFIX= GK_FEATURES='' + is a space-separated list containing files in features/ directory, + e.g. GK_FEATURES="luks, lvm, plymouth". See MODULAR FEATURES section for detail. + Optionally: + - BINDIR: defaults to "$PREFIX/bin" + - SYSCONFDIR: defaults to "/etc" for PREFIX=/usr or "$PREFIX/etc" otherwise + - MANDIR: defaults to "$PREFIX/share/man" + + Then install with ``make install'', optionally with DESTDIR USAGE: See https://wiki.gentoo.org/wiki/Genkernel or @@ -62,3 +76,18 @@ BOOTING A KERNEL WITH INITRAMFS: NOTE: The example above uses genkernel's --symlink feature and initramfs was built with --lvm, --luks and --ssh. + +MODULAR FEATURES + +It is possible to include or exclude features +It is also possible to add your own. +Each feature is contained in a subdirectory within features/ +which then includes these files: + - genkernel_conf + - man_genkernel_8 + - parse_cmdline + - longusage + - append_base_layout + - create_initramfs + - initramfs_append_func + - determine_real_args diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt index 571ab065..d1603b32 100644 --- a/doc/genkernel.8.txt +++ b/doc/genkernel.8.txt @@ -107,10 +107,6 @@ KERNEL CONFIGURATION Saves, or does not save the kernel configuration to '/etc/kernels' if the kernel is successfully compiled. -*--*[*no-*]*bcache*:: - Adds, or skip adding block layer cache (bcache) support to kernel - configuration. - *--*[*no-*]*hyperv*:: Adds, or skip adding Microsoft Hyper-V support to kernel configuration. @@ -186,9 +182,6 @@ specified. Runs, or does not run, "make oldconfig" before compilation. Specifying *--oldconfig* implies *--no-clean*. -*--*[*no-*]*splash*:: - Installs, or not, framebuffer splash support into initramfs. - *--*[*no-*]*ramdisk-modules*:: Copies or does not copy configured modules to the ramdisk. @@ -349,23 +342,9 @@ LOW-LEVEL COMPILATION OPTIONS INITIALIZATION ~~~~~~~~~~~~~~ -*--splash*=:: - Enable framebuffer splash using . - -*--splash-res*=:: - Select gensplash resolutions to include. - -*--*[*no-*]*splash*=:: - If the extra argument is specified, splash is forced using - rather than the default theme specified in your splash - configuration. If *--no-splash* is specified, then splash is disabled. - -*--*[*no-*]*plymouth*:: - Includes or excludes Plymouth from the initramfs. If "splash" is - passed at boot, Plymouth will be activated. - -*--plymouth-theme*=:: - Embeds the given Plymouth theme into the initramfs. +*--*[*no-*]*busybox*:: + Includes or excludes busybox in the initramfs. + When enabled, this will compile busybox for you. *--do-keymap-auto*:: Force keymap selection at boot. @@ -373,18 +352,14 @@ INITIALIZATION *--*[*no-*]*keymap*:: Enables or disables keymap selection at boot. -*--*[*no-*]*lvm*:: - Includes or excludes LVM support. - When enabled, this will compile LVM for you. +*--*[*no-*]*nfs*:: + Includes or excludes NFS support. -*--*[*no-*]*mdadm*:: - Includes or excludes mdadm support. - When enabled, this will compile mdadm for you. +*--*[*no-*]*netboot*:: + Creates or does not create a self-contained env in the initramfs. -*--mdadm-config*=:: - Use as configfile for MDADM. - By default the ramdisk will be built *without* an 'mdadm.conf' and - will auto-detect arrays during boot-up. +// BEGIN FEATURES man_genkernel_8 +// END FEATURES man_genkernel_8 *--*[*no-*]*microcode-initramfs*:: Prepends, or do not prepend ucode(s) to the initramfs. @@ -394,56 +369,9 @@ INITIALIZATION NOTE: Embedding microcode updates into initramfs is *deprecated* when system is able to load multiple initramfs. -*--*[*no-*]*dmraid*:: - Includes or excludes DMRAID support. - When enabled, this will compile dmraid for you. - -*--*[*no-*]*nfs*:: - Includes or excludes NFS support. - -*--*[*no-*]*e2fsprogs*:: - Includes or excludes e2fsprogs. - When enabled, this will compile e2fsprogs for you. - -*--*[*no-*]*xfsprogs*:: - Includes or excludes xfsprogs. - When enabled, this will compile xfsprogs for you. - -*--*[*no-*]*zfs*:: - Includes or excludes ZFS support. - -*--*[*no-*]*btrfs*:: - Includes or excludes Btrfs support. - When enabled, this will compile btrfs-progs for you. - -*--*[*no-*]*multipath*:: - Includes or excludes Multipath support. - When enabled, this will compile multipath-tools for you. - -*--*[*no-*]*iscsi*:: - Includes or excludes iSCSI support. - When enabled, this will compile open-iscsi for you. - *--*[*no-*]*sandbox*:: Enables or disables sandbox-ing when building initramfs. -*--*[*no-*]*ssh*:: - Includes or excludes SSH (dropbear) support for remote LUKS keys. - When enabled, this will compile dropbear for you. - -*--ssh-authorized-keys-file*=:: - Specifies a user created authorized_keys file. By default genkernel - will use '/etc/dropbear/authorized_keys'. - -*--ssh-host-keys*=:: - When set to *create*, which is the default value, genkernel will embed - SSH host keys from '/etc/dropbear' and will create those keys when missing. - When set to *create-from-host*, genkernel will embed SSH host keys from - '/etc/dropbear' but will create those keys from '/etc/ssh' when missing - (not recommended for security reasons). - When set to *runtime*, genkernel will not embed any SSH host key in - initramfs and dropbear will generate needed host key at runtime (`dropbear -R`). - *--boot-font*=|none>:: When set to *current*, genkernel will use "setfont" to dump and embed current active console font into initramfs. @@ -466,37 +394,6 @@ system is able to load multiple initramfs. *--genzimage*:: Make and install kernelz image from 'arch/powerpc/boot/zImage.initrd'. -*--*[*no-*]*luks*:: - Includes or excludes LUKS support. - When enabled, this will compile cryptsetup for you. - -*--*[*no-*]*gpg*:: - Includes or excludes support for GnuPG 1.x, the portable standalone branch - of GnuPG. A key can be made from - `gpg --symmetric -o /path/to/LUKS-key.gpg /path/to/LUKS-key` . - After that, re-point the *root_key* argument to the new .gpg file. - -*--*[*no-*]*keyctl*:: - Includes or excludes support for keyutils keyctl. - This way a LUKS passphrase can be loaded into a keyring at boot time - to unlock multiple devices (root, swap, etc.) without retyping it for each - one. - -*--*[*no-*]*b2sum*:: - Includes or excludes b2sum in the initramfs. - When enabled, this will compile coreutils' b2sum for you. - -*--*[*no-*]*busybox*:: - Includes or excludes busybox in the initramfs. - When enabled, this will compile busybox for you. - -*--*[*no-*]*unionfs*:: - Includes or excludes support for unionfs. - When enabled, this will compile unionfs-fuse for you. - -*--*[*no-*]*netboot*:: - Creates or does not create a self-contained env in the initramfs. - *--real-root*=:: Specify a default for *real_root*= kernel option which will be embedded into initramfs. diff --git a/features/-sample/append_base_layout b/features/-sample/append_base_layout new file mode 100644 index 00000000..e69de29b diff --git a/features/-sample/create_initramfs b/features/-sample/create_initramfs new file mode 100644 index 00000000..e69de29b diff --git a/features/-sample/determine_real_args b/features/-sample/determine_real_args new file mode 100644 index 00000000..e69de29b diff --git a/features/-sample/genkernel_conf b/features/-sample/genkernel_conf new file mode 100644 index 00000000..e69de29b diff --git a/features/-sample/initramfs_append_func b/features/-sample/initramfs_append_func new file mode 100644 index 00000000..e69de29b diff --git a/features/-sample/longusage b/features/-sample/longusage new file mode 100644 index 00000000..e69de29b diff --git a/features/-sample/man_genkernel_8 b/features/-sample/man_genkernel_8 new file mode 100644 index 00000000..e69de29b diff --git a/features/-sample/parse_cmdline b/features/-sample/parse_cmdline new file mode 100644 index 00000000..e69de29b diff --git a/features/b2sum/append_base_layout b/features/b2sum/append_base_layout new file mode 100644 index 00000000..f7cfaba4 --- /dev/null +++ b/features/b2sum/append_base_layout @@ -0,0 +1 @@ + isTrue "${B2SUM}" && build_parameters+=( --b2sum ) || build_parameters+=( --no-b2sum ) diff --git a/features/b2sum/create_initramfs b/features/b2sum/create_initramfs new file mode 100644 index 00000000..e9b819f4 --- /dev/null +++ b/features/b2sum/create_initramfs @@ -0,0 +1 @@ + append_data 'b2sum' "${B2SUM}" diff --git a/features/b2sum/determine_real_args b/features/b2sum/determine_real_args new file mode 100644 index 00000000..94a33ae2 --- /dev/null +++ b/features/b2sum/determine_real_args @@ -0,0 +1 @@ + set_config_with_override BOOL B2SUM CMD_B2SUM "no" diff --git a/features/b2sum/genkernel_conf b/features/b2sum/genkernel_conf new file mode 100644 index 00000000..17274d2d --- /dev/null +++ b/features/b2sum/genkernel_conf @@ -0,0 +1,2 @@ +# Add b2sum support +#B2SUM="no" diff --git a/features/b2sum/initramfs_append_func b/features/b2sum/initramfs_append_func new file mode 100644 index 00000000..5ffba4df --- /dev/null +++ b/features/b2sum/initramfs_append_func @@ -0,0 +1,25 @@ +append_b2sum() { + local PN="coreutils" + local TDIR="${TEMP}/initramfs-b2sum-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi + + populate_binpkg ${PN} + + mkdir -p "${TDIR}" || gen_die "Failed to create '${TDIR}'!" + + unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append b2sum to cpio!" + + cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" + if isTrue "${CLEANUP}" + then + rm -rf "${TDIR}" + fi +} diff --git a/features/b2sum/longusage b/features/b2sum/longusage new file mode 100644 index 00000000..3a2bbd8b --- /dev/null +++ b/features/b2sum/longusage @@ -0,0 +1,3 @@ + # b2sum + echo " --b2sum Include b2sum" + echo " --no-b2sum Exclude b2sum" diff --git a/features/b2sum/man_genkernel_8 b/features/b2sum/man_genkernel_8 new file mode 100644 index 00000000..f650f686 --- /dev/null +++ b/features/b2sum/man_genkernel_8 @@ -0,0 +1,3 @@ +*--*[*no-*]*b2sum*:: + Includes or excludes b2sum in the initramfs. + When enabled, this will compile coreutils' b2sum for you. diff --git a/features/b2sum/parse_cmdline b/features/b2sum/parse_cmdline new file mode 100644 index 00000000..89a8f65b --- /dev/null +++ b/features/b2sum/parse_cmdline @@ -0,0 +1,4 @@ + --b2sum|--no-b2sum) + CMD_B2SUM=$(parse_optbool "$*") + print_info 3 "CMD_B2SUM: ${CMD_B2SUM}" + ;; diff --git a/features/bcache/append_base_layout b/features/bcache/append_base_layout new file mode 100644 index 00000000..2893d628 --- /dev/null +++ b/features/bcache/append_base_layout @@ -0,0 +1 @@ + isTrue "${BCACHE}" && build_parameters+=( --bcache ) || build_parameters+=( --no-bcache ) diff --git a/features/bcache/create_initramfs b/features/bcache/create_initramfs new file mode 100644 index 00000000..581d9e5c --- /dev/null +++ b/features/bcache/create_initramfs @@ -0,0 +1 @@ + append_data 'bcache' "${BCACHE}" diff --git a/features/bcache/determine_real_args b/features/bcache/determine_real_args new file mode 100644 index 00000000..b5f1642d --- /dev/null +++ b/features/bcache/determine_real_args @@ -0,0 +1 @@ + set_config_with_override BOOL BCACHE CMD_BCACHE "no" diff --git a/features/bcache/genkernel_conf b/features/bcache/genkernel_conf new file mode 100644 index 00000000..29bad832 --- /dev/null +++ b/features/bcache/genkernel_conf @@ -0,0 +1,2 @@ +# Add bcache support +#BCACHE="no" diff --git a/features/bcache/initramfs_append_func b/features/bcache/initramfs_append_func new file mode 100644 index 00000000..96cabc67 --- /dev/null +++ b/features/bcache/initramfs_append_func @@ -0,0 +1,25 @@ +append_bcache() { + local PN="bcache-tools" + local TDIR="${TEMP}/initramfs-bcache-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi + + populate_binpkg ${PN} + + mkdir -p "${TDIR}" || gen_die "Failed to create '${TDIR}'!" + + unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append bcache to cpio!" + + cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" + if isTrue "${CLEANUP}" + then + rm -rf "${TDIR}" + fi +} diff --git a/features/bcache/longusage b/features/bcache/longusage new file mode 100644 index 00000000..d9049101 --- /dev/null +++ b/features/bcache/longusage @@ -0,0 +1,2 @@ + echo " --bcache Include block layer cache (bcache) support" + echo " --no-bcache Exclude block layer cache (bcache) support" diff --git a/features/bcache/man_genkernel_8 b/features/bcache/man_genkernel_8 new file mode 100644 index 00000000..796d59aa --- /dev/null +++ b/features/bcache/man_genkernel_8 @@ -0,0 +1,3 @@ +*--*[*no-*]*bcache*:: + Includes or excludes block layer cache (bcache) support. + When enabled, this will compile bcache-tools for you. diff --git a/features/bcache/parse_cmdline b/features/bcache/parse_cmdline new file mode 100644 index 00000000..b2702513 --- /dev/null +++ b/features/bcache/parse_cmdline @@ -0,0 +1,4 @@ + --bcache|--no-bcache) + CMD_BCACHE=$(parse_optbool "$*") + print_info 3 "CMD_BCACHE: ${CMD_BCACHE}" + ;; diff --git a/features/btrfs/append_base_layout b/features/btrfs/append_base_layout new file mode 100644 index 00000000..81ed5787 --- /dev/null +++ b/features/btrfs/append_base_layout @@ -0,0 +1 @@ + isTrue "${BTRFS}" && build_parameters+=( --btrfs ) || build_parameters+=( --no-btrfs ) diff --git a/features/btrfs/create_initramfs b/features/btrfs/create_initramfs new file mode 100644 index 00000000..30a2db0f --- /dev/null +++ b/features/btrfs/create_initramfs @@ -0,0 +1 @@ + append_data 'btrfs' "${BTRFS}" diff --git a/features/btrfs/determine_real_args b/features/btrfs/determine_real_args new file mode 100644 index 00000000..c6df3ddc --- /dev/null +++ b/features/btrfs/determine_real_args @@ -0,0 +1 @@ + set_config_with_override BOOL BTRFS CMD_BTRFS "$(rootfs_type_is btrfs)" diff --git a/features/btrfs/genkernel_conf b/features/btrfs/genkernel_conf new file mode 100644 index 00000000..8a42049a --- /dev/null +++ b/features/btrfs/genkernel_conf @@ -0,0 +1,2 @@ +# Add BTRFS support +#BTRFS="no" diff --git a/features/btrfs/initramfs_append_func b/features/btrfs/initramfs_append_func new file mode 100644 index 00000000..30a3dd39 --- /dev/null +++ b/features/btrfs/initramfs_append_func @@ -0,0 +1,25 @@ +append_btrfs() { + local PN=btrfs-progs + local TDIR="${TEMP}/initramfs-${PN}-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi + + populate_binpkg ${PN} + + mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" + + unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append ${PN} to cpio!" + + cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" + if isTrue "${CLEANUP}" + then + rm -rf "${TDIR}" + fi +} diff --git a/features/btrfs/longusage b/features/btrfs/longusage new file mode 100644 index 00000000..4a6486f2 --- /dev/null +++ b/features/btrfs/longusage @@ -0,0 +1,2 @@ + echo " --btrfs Include Btrfs support (enabled by default if rootfs is Btrfs)" + echo " --no-btrfs Exclude Btrfs support" diff --git a/features/btrfs/man_genkernel_8 b/features/btrfs/man_genkernel_8 new file mode 100644 index 00000000..f20861c4 --- /dev/null +++ b/features/btrfs/man_genkernel_8 @@ -0,0 +1,3 @@ +*--*[*no-*]*btrfs*:: + Includes or excludes Btrfs support. + When enabled, this will compile btrfs-progs for you. diff --git a/features/btrfs/parse_cmdline b/features/btrfs/parse_cmdline new file mode 100644 index 00000000..81680ad9 --- /dev/null +++ b/features/btrfs/parse_cmdline @@ -0,0 +1,4 @@ + --btrfs|--no-btrfs) + CMD_BTRFS=$(parse_optbool "$*") + print_info 3 "CMD_BTRFS: ${CMD_BTRFS}" + ;; diff --git a/features/dmraid/append_base_layout b/features/dmraid/append_base_layout new file mode 100644 index 00000000..b626863b --- /dev/null +++ b/features/dmraid/append_base_layout @@ -0,0 +1 @@ + isTrue "${DMRAID}" && build_parameters+=( --dmraid ) || build_parameters+=( --no-dmraid ) diff --git a/features/dmraid/create_initramfs b/features/dmraid/create_initramfs new file mode 100644 index 00000000..7048ffd4 --- /dev/null +++ b/features/dmraid/create_initramfs @@ -0,0 +1 @@ + append_data 'dmraid' "${DMRAID}" diff --git a/features/dmraid/determine_real_args b/features/dmraid/determine_real_args new file mode 100644 index 00000000..66edd098 --- /dev/null +++ b/features/dmraid/determine_real_args @@ -0,0 +1 @@ + set_config_with_override BOOL DMRAID CMD_DMRAID "no" diff --git a/features/dmraid/genkernel_conf b/features/dmraid/genkernel_conf new file mode 100644 index 00000000..0ca1796e --- /dev/null +++ b/features/dmraid/genkernel_conf @@ -0,0 +1,2 @@ +# Add DMRAID support +#DMRAID="no" diff --git a/features/dmraid/initramfs_append_func b/features/dmraid/initramfs_append_func new file mode 100644 index 00000000..98113bac --- /dev/null +++ b/features/dmraid/initramfs_append_func @@ -0,0 +1,32 @@ +append_dmraid() { + local PN=dmraid + local TDIR="${TEMP}/initramfs-${PN}-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi + + populate_binpkg ${PN} + + mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" + + unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + + # Delete unneeded files + rm -rf \ + usr/lib \ + usr/share \ + usr/include + + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append dmraid to cpio!" + + cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" + if isTrue "${CLEANUP}" + then + rm -rf "${TDIR}" + fi +} diff --git a/features/dmraid/longusage b/features/dmraid/longusage new file mode 100644 index 00000000..f2b8c354 --- /dev/null +++ b/features/dmraid/longusage @@ -0,0 +1,2 @@ + echo " --dmraid Include DMRAID support" + echo " --no-dmraid Exclude DMRAID support" diff --git a/features/dmraid/man_genkernel_8 b/features/dmraid/man_genkernel_8 new file mode 100644 index 00000000..021587cb --- /dev/null +++ b/features/dmraid/man_genkernel_8 @@ -0,0 +1,3 @@ +*--*[*no-*]*dmraid*:: + Includes or excludes DMRAID support. + When enabled, this will compile dmraid for you. diff --git a/features/dmraid/parse_cmdline b/features/dmraid/parse_cmdline new file mode 100644 index 00000000..aeed69bb --- /dev/null +++ b/features/dmraid/parse_cmdline @@ -0,0 +1,4 @@ + --dmraid|--no-dmraid) + CMD_DMRAID=$(parse_optbool "$*") + print_info 3 "CMD_DMRAID: ${CMD_DMRAID}" + ;; diff --git a/features/e2fsprogs/append_base_layout b/features/e2fsprogs/append_base_layout new file mode 100644 index 00000000..18467efa --- /dev/null +++ b/features/e2fsprogs/append_base_layout @@ -0,0 +1 @@ + isTrue "${E2FSPROGS}" && build_parameters+=( --e2fsprogs ) || build_parameters+=( --no-e2fsprogs ) diff --git a/features/e2fsprogs/create_initramfs b/features/e2fsprogs/create_initramfs new file mode 100644 index 00000000..b2660763 --- /dev/null +++ b/features/e2fsprogs/create_initramfs @@ -0,0 +1 @@ + append_data 'e2fsprogs' "${E2FSPROGS}" diff --git a/features/e2fsprogs/determine_real_args b/features/e2fsprogs/determine_real_args new file mode 100644 index 00000000..ea2f1e6d --- /dev/null +++ b/features/e2fsprogs/determine_real_args @@ -0,0 +1 @@ + set_config_with_override BOOL E2FSPROGS CMD_E2FSPROGS "no" diff --git a/features/e2fsprogs/genkernel_conf b/features/e2fsprogs/genkernel_conf new file mode 100644 index 00000000..9e801cbe --- /dev/null +++ b/features/e2fsprogs/genkernel_conf @@ -0,0 +1,2 @@ +# Add e2fsprogs support +#E2FSPROGS="no" diff --git a/features/e2fsprogs/initramfs_append_func b/features/e2fsprogs/initramfs_append_func new file mode 100644 index 00000000..c157c7ad --- /dev/null +++ b/features/e2fsprogs/initramfs_append_func @@ -0,0 +1,25 @@ +append_e2fsprogs() { + local PN=e2fsprogs + local TDIR="${TEMP}/initramfs-${PN}-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi + + populate_binpkg ${PN} + + mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" + + unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append ${PN} to cpio!" + + cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" + if isTrue "${CLEANUP}" + then + rm -rf "${TDIR}" + fi +} diff --git a/features/e2fsprogs/longusage b/features/e2fsprogs/longusage new file mode 100644 index 00000000..47dada6a --- /dev/null +++ b/features/e2fsprogs/longusage @@ -0,0 +1,2 @@ + echo " --e2fsprogs Include e2fsprogs" + echo " --no-e2fsprogs Exclude e2fsprogs" diff --git a/features/e2fsprogs/man_genkernel_8 b/features/e2fsprogs/man_genkernel_8 new file mode 100644 index 00000000..76dfc37c --- /dev/null +++ b/features/e2fsprogs/man_genkernel_8 @@ -0,0 +1,3 @@ +*--*[*no-*]*e2fsprogs*:: + Includes or excludes e2fsprogs. + When enabled, this will compile e2fsprogs for you. diff --git a/features/e2fsprogs/parse_cmdline b/features/e2fsprogs/parse_cmdline new file mode 100644 index 00000000..7e0e3f06 --- /dev/null +++ b/features/e2fsprogs/parse_cmdline @@ -0,0 +1,4 @@ + --e2fsprogs|--no-e2fsprogs) + CMD_E2FSPROGS=$(parse_optbool "$*") + print_info 3 "CMD_E2FSPROGS: ${CMD_E2FSPROGS}" + ;; diff --git a/features/iscsi/append_base_layout b/features/iscsi/append_base_layout new file mode 100644 index 00000000..df568fc7 --- /dev/null +++ b/features/iscsi/append_base_layout @@ -0,0 +1 @@ + isTrue "${ISCSI}" && build_parameters+=( --iscsi ) || build_parameters+=( --no-iscsi ) diff --git a/features/iscsi/create_initramfs b/features/iscsi/create_initramfs new file mode 100644 index 00000000..f02d8297 --- /dev/null +++ b/features/iscsi/create_initramfs @@ -0,0 +1 @@ + append_data 'iscsi' "${ISCSI}" diff --git a/features/iscsi/determine_real_args b/features/iscsi/determine_real_args new file mode 100644 index 00000000..d13c2a85 --- /dev/null +++ b/features/iscsi/determine_real_args @@ -0,0 +1 @@ + set_config_with_override BOOL ISCSI CMD_ISCSI "no" diff --git a/features/iscsi/genkernel_conf b/features/iscsi/genkernel_conf new file mode 100644 index 00000000..bb8498cb --- /dev/null +++ b/features/iscsi/genkernel_conf @@ -0,0 +1,2 @@ +# Add iSCSI support +#ISCSI="no" diff --git a/features/iscsi/initramfs_append_func b/features/iscsi/initramfs_append_func new file mode 100644 index 00000000..7d3740e8 --- /dev/null +++ b/features/iscsi/initramfs_append_func @@ -0,0 +1,25 @@ +append_iscsi() { + local PN=open-iscsi + local TDIR="${TEMP}/initramfs-${PN}-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi + + populate_binpkg ${PN} + + mkdir -p "${TDIR}" || gen_die "Failed to create '${TDIR}'!" + + unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append iscsi to cpio!" + + cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" + if isTrue "${CLEANUP}" + then + rm -rf "${TDIR}" + fi +} diff --git a/features/iscsi/longusage b/features/iscsi/longusage new file mode 100644 index 00000000..fa023047 --- /dev/null +++ b/features/iscsi/longusage @@ -0,0 +1,2 @@ + echo " --iscsi Include iSCSI support" + echo " --no-iscsi Exclude iSCSI support" diff --git a/features/iscsi/man_genkernel_8 b/features/iscsi/man_genkernel_8 new file mode 100644 index 00000000..6ec686fa --- /dev/null +++ b/features/iscsi/man_genkernel_8 @@ -0,0 +1,3 @@ +*--*[*no-*]*iscsi*:: + Includes or excludes iSCSI support. + When enabled, this will compile open-iscsi for you. diff --git a/features/iscsi/parse_cmdline b/features/iscsi/parse_cmdline new file mode 100644 index 00000000..6a8d6ed1 --- /dev/null +++ b/features/iscsi/parse_cmdline @@ -0,0 +1,4 @@ + --iscsi|--no-iscsi) + CMD_ISCSI=$(parse_optbool "$*") + print_info 3 "CMD_ISCSI: ${CMD_ISCSI}" + ;; diff --git a/features/luks/append_base_layout b/features/luks/append_base_layout new file mode 100644 index 00000000..b7402359 --- /dev/null +++ b/features/luks/append_base_layout @@ -0,0 +1,3 @@ + isTrue "${KEYCTL}" && build_parameters+=( --keyctl ) || build_parameters+=( --no-keyctl ) + isTrue "${GPG}" && build_parameters+=( --gpg ) || build_parameters+=( --no-gpg ) + isTrue "${LUKS}" && build_parameters+=( --luks ) || build_parameters+=( --no-luks ) diff --git a/features/luks/create_initramfs b/features/luks/create_initramfs new file mode 100644 index 00000000..df226f74 --- /dev/null +++ b/features/luks/create_initramfs @@ -0,0 +1,3 @@ + append_data 'luks' "${LUKS}" + append_data 'gpg' "${GPG}" + append_data 'keyutils' "${KEYCTL}" diff --git a/features/luks/determine_real_args b/features/luks/determine_real_args new file mode 100644 index 00000000..6410ad55 --- /dev/null +++ b/features/luks/determine_real_args @@ -0,0 +1,3 @@ + set_config_with_override BOOL LUKS CMD_LUKS "no" + set_config_with_override BOOL GPG CMD_GPG "no" + set_config_with_override BOOL KEYCTL CMD_KEYCTL "no" diff --git a/features/luks/genkernel_conf b/features/luks/genkernel_conf new file mode 100644 index 00000000..b555abae --- /dev/null +++ b/features/luks/genkernel_conf @@ -0,0 +1,8 @@ +# Add LUKS support +#LUKS="no" + +# Add GnuPG support +#GPG="no" + +# Add keyctl support for loading LUKS passphrase into a keyring +#KEYCTL="no" diff --git a/features/luks/initramfs_append_func b/features/luks/initramfs_append_func new file mode 100644 index 00000000..5de5ddea --- /dev/null +++ b/features/luks/initramfs_append_func @@ -0,0 +1,82 @@ +append_keyutils() { + local PN=keyutils + local TDIR="${TEMP}/initramfs-${PN}-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi + + populate_binpkg ${PN} + + mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" + + unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append ${PN} to cpio!" + + cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" + if isTrue "${CLEANUP}" + then + rm -rf "${TDIR}" + fi +} + +append_luks() { + local PN=cryptsetup + local TDIR="${TEMP}/initramfs-luks-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi + + populate_binpkg ${PN} + + mkdir -p "${TDIR}" || gen_die "Failed to create '${TDIR}'!" + + unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + + # Delete unneeded files + rm -rf usr/ + + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append luks to cpio!" + + cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" + if isTrue "${CLEANUP}" + then + rm -rf "${TDIR}" + fi +} + +append_gpg() { + local PN=gnupg + local TDIR="${TEMP}/initramfs-${PN}-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi + + populate_binpkg ${PN} + + mkdir -p "${TDIR}" || gen_die "Failed to create '${TDIR}'!" + + unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append ${PN} to cpio!" + + cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" + if isTrue "${CLEANUP}" + then + rm -rf "${TDIR}" + fi +} diff --git a/features/luks/longusage b/features/luks/longusage new file mode 100644 index 00000000..e231cfad --- /dev/null +++ b/features/luks/longusage @@ -0,0 +1,6 @@ + echo " --luks Include LUKS support" + echo " --no-luks Exclude LUKS support" + echo " --gpg Include GPG-armored LUKS key support" + echo " --no-gpg Exclude GPG-armored LUKS key support" + echo " --keyctl Include keyctl support for loading LUKS passphrase into a keyring" + echo " --no-keyctl Exclude keyctl support for loading LUKS passphrase into a keyring" diff --git a/features/luks/man_genkernel_8 b/features/luks/man_genkernel_8 new file mode 100644 index 00000000..6ed81525 --- /dev/null +++ b/features/luks/man_genkernel_8 @@ -0,0 +1,15 @@ +*--*[*no-*]*luks*:: + Includes or excludes LUKS support. + When enabled, this will compile cryptsetup for you. + +*--*[*no-*]*gpg*:: + Includes or excludes support for GnuPG 1.x, the portable standalone branch + of GnuPG. A key can be made from + `gpg --symmetric -o /path/to/LUKS-key.gpg /path/to/LUKS-key` . + After that, re-point the *root_key* argument to the new .gpg file. + +*--*[*no-*]*keyctl*:: + Includes or excludes support for keyutils keyctl. + This way a LUKS passphrase can be loaded into a keyring at boot time + to unlock multiple devices (root, swap, etc.) without retyping it for each + one. diff --git a/features/luks/parse_cmdline b/features/luks/parse_cmdline new file mode 100644 index 00000000..206a9e16 --- /dev/null +++ b/features/luks/parse_cmdline @@ -0,0 +1,12 @@ + --luks|--no-luks) + CMD_LUKS=$(parse_optbool "$*") + print_info 3 "CMD_LUKS: ${CMD_LUKS}" + ;; + --gpg|--no-gpg) + CMD_GPG=$(parse_optbool "$*") + print_info 3 "CMD_GPG: ${CMD_GPG}" + ;; + --keyctl|--no-keyctl) + CMD_KEYCTL=$(parse_optbool "$*") + print_info 3 "CMD_KEYCTL: ${CMD_KEYCTL}" + ;; diff --git a/features/lvm/append_base_layout b/features/lvm/append_base_layout new file mode 100644 index 00000000..e90020bd --- /dev/null +++ b/features/lvm/append_base_layout @@ -0,0 +1 @@ + isTrue "${LVM}" && build_parameters+=( --lvm ) || build_parameters+=( --no-lvm ) diff --git a/features/lvm/create_initramfs b/features/lvm/create_initramfs new file mode 100644 index 00000000..83a48ecf --- /dev/null +++ b/features/lvm/create_initramfs @@ -0,0 +1 @@ + append_data 'lvm' "${LVM}" diff --git a/features/lvm/determine_real_args b/features/lvm/determine_real_args new file mode 100644 index 00000000..f08ed0a3 --- /dev/null +++ b/features/lvm/determine_real_args @@ -0,0 +1 @@ + set_config_with_override BOOL LVM CMD_LVM "no" diff --git a/features/lvm/genkernel_conf b/features/lvm/genkernel_conf new file mode 100644 index 00000000..d8611beb --- /dev/null +++ b/features/lvm/genkernel_conf @@ -0,0 +1,2 @@ +# Add LVM support +#LVM="no" diff --git a/features/lvm/initramfs_append_func b/features/lvm/initramfs_append_func new file mode 100644 index 00000000..52960ef0 --- /dev/null +++ b/features/lvm/initramfs_append_func @@ -0,0 +1,84 @@ +append_lvm() { + local PN=lvm + local TDIR="${TEMP}/initramfs-${PN}-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi + + populate_binpkg ${PN} + populate_binpkg thin-provisioning-tools + + mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" + + unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" + unpack "$(get_gkpkg_binpkg "thin-provisioning-tools")" "${TDIR}" + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + + local mydir= + for mydir in \ + etc/lvm/cache \ + sbin \ + ; do + mkdir -p ${mydir} || gen_die "Failed to create '${TDIR}/${mydir}'!" + done + + # Delete unneeded files + rm -rf \ + usr/lib/device-mapper \ + usr/lib/pkgconfig \ + usr/lib/lib* \ + usr/sbin/dm* \ + usr/share \ + usr/include + + # Include the LVM config + if [ -x /sbin/lvm -o -x /bin/lvm ] + then + local ABORT_ON_ERRORS=$(kconfig_get_opt "/etc/lvm/lvm.conf" "abort_on_errors") + if isTrue "${ABORT_ON_ERRORS}" && [[ ${CBUILD} == ${CHOST} ]] + then + # Make sure the LVM binary we created is able to handle + # system's lvm.conf + "${TDIR}"/sbin/lvm dumpconfig 1>"${TDIR}"/etc/lvm/lvm.conf 2>/dev/null \ + || gen_die "Bundled LVM version does NOT support system's lvm.conf!" + + # Sanity check + if [ ! -s "${TDIR}/etc/lvm/lvm.conf" ] + then + gen_die "Sanity check failed: '${TDIR}/etc/lvm/lvm.conf' looks empty?!" + fi + else + cp -aL /etc/lvm/lvm.conf "${TDIR}"/etc/lvm/lvm.conf 2>/dev/null \ + || gen_die "Failed to copy '/etc/lvm/lvm.conf'!" + fi + + # Some LVM config options need changing, because the functionality is + # not compiled in: + sed -r -i \ + -e '/^[[:space:]]*obtain_device_list_from_udev/s,=.*,= 1,g' \ + -e '/^[[:space:]]*udev_sync/s,=.*,= 1,g' \ + -e '/^[[:space:]]*use_lvmetad/s,=.*,= 0,g' \ + -e '/^[[:space:]]*use_lvmlockd/s,=.*,= 0,g' \ + -e '/^[[:space:]]*use_lvmpolld/s,=.*,= 0,g' \ + -e '/^[[:space:]]*monitoring/s,=.*,= 0,g' \ + -e '/^[[:space:]]*external_device_info_source/s,=.*,= "none",g' \ + -e '/^[[:space:]]*units/s,=.*"r",= "h",g' \ + -e '/^[[:space:]]*thin_repair_executable/s,=.*,= /usr/sbin/thin_repair,g' \ + -e '/^[[:space:]]*thin_dump_executable/s,=.*,= /usr/sbin/thin_dump,g' \ + -e '/^[[:space:]]*thin_check_executable/s,=.*,= /usr/sbin/thin_check,g' \ + "${TDIR}"/etc/lvm/lvm.conf \ + || gen_die 'Could not sed lvm.conf!' + fi + + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append lvm to cpio!" + + cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" + if isTrue "${CLEANUP}" + then + rm -rf "${TDIR}" + fi +} diff --git a/features/lvm/longusage b/features/lvm/longusage new file mode 100644 index 00000000..f2554372 --- /dev/null +++ b/features/lvm/longusage @@ -0,0 +1,2 @@ + echo " --lvm Include LVM support" + echo " --no-lvm Exclude LVM support" diff --git a/features/lvm/man_genkernel_8 b/features/lvm/man_genkernel_8 new file mode 100644 index 00000000..c6b437b4 --- /dev/null +++ b/features/lvm/man_genkernel_8 @@ -0,0 +1,3 @@ +*--*[*no-*]*lvm*:: + Includes or excludes LVM support. + When enabled, this will compile LVM for you. diff --git a/features/lvm/parse_cmdline b/features/lvm/parse_cmdline new file mode 100644 index 00000000..259f4125 --- /dev/null +++ b/features/lvm/parse_cmdline @@ -0,0 +1,10 @@ + --lvm|--no-lvm) + CMD_LVM=$(parse_optbool "$*") + print_info 3 "CMD_LVM: ${CMD_LVM}" + ;; + --lvm2|--no-lvm2) + CMD_LVM=$(parse_optbool "$*") + print_info 3 "CMD_LVM: ${CMD_LVM}" + echo + print_warning 1 "Please use --lvm, as --lvm2 is deprecated." + ;; diff --git a/features/mdadm/append_base_layout b/features/mdadm/append_base_layout new file mode 100644 index 00000000..c3dacbc1 --- /dev/null +++ b/features/mdadm/append_base_layout @@ -0,0 +1 @@ + isTrue "${MDADM}" && build_parameters+=( --mdadm ) || build_parameters+=( --no-mdadm ) diff --git a/features/mdadm/create_initramfs b/features/mdadm/create_initramfs new file mode 100644 index 00000000..10e9da3e --- /dev/null +++ b/features/mdadm/create_initramfs @@ -0,0 +1 @@ + append_data 'mdadm' "${MDADM}" diff --git a/features/mdadm/determine_real_args b/features/mdadm/determine_real_args new file mode 100644 index 00000000..b4bd8f9c --- /dev/null +++ b/features/mdadm/determine_real_args @@ -0,0 +1,2 @@ + set_config_with_override BOOL MDADM CMD_MDADM "no" + set_config_with_override STRING MDADM_CONFIG CMD_MDADM_CONFIG diff --git a/features/mdadm/genkernel_conf b/features/mdadm/genkernel_conf new file mode 100644 index 00000000..f91b847f --- /dev/null +++ b/features/mdadm/genkernel_conf @@ -0,0 +1,7 @@ +# Add MDRAID support +#MDADM="no" + +# Specify a custom mdadm.conf. +# By default the initramfs will be built *without* an mdadm.conf and will auto-detect +# arrays during bootup. Usually, this should not be needed. +#MDADM_CONFIG="/etc/mdadm.conf" diff --git a/features/mdadm/initramfs_append_func b/features/mdadm/initramfs_append_func new file mode 100644 index 00000000..06eba5b3 --- /dev/null +++ b/features/mdadm/initramfs_append_func @@ -0,0 +1,49 @@ +append_mdadm() { + local PN=mdadm + local TDIR="${TEMP}/initramfs-${PN}-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi + + populate_binpkg ${PN} + + mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + + local mydir= + for mydir in \ + etc \ + sbin \ + ; do + mkdir -p "${TDIR}"/${mydir} || gen_die "Failed to create '${TDIR}/${mydir}'!" + done + + unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" + + if [ -n "${MDADM_CONFIG}" ] + then + print_info 2 "$(get_indent 2)${PN}: >> Adding '${MDADM_CONFIG}' ..." + + if [ -f "${MDADM_CONFIG}" ] + then + cp -aL "${MDADM_CONFIG}" "${TDIR}"/etc/mdadm.conf 2>/dev/null \ + || gen_die "Failed to copy '${MDADM_CONFIG}'!" + else + gen_die "Specified '${MDADM_CONFIG}' does not exist!" + fi + else + print_info 2 "$(get_indent 2)${PN}: >> --mdadm-config not set; Skipping inclusion of mdadm.conf ..." + fi + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append ${PN} to cpio!" + + cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" + if isTrue "${CLEANUP}" + then + rm -rf "${TDIR}" + fi +} diff --git a/features/mdadm/longusage b/features/mdadm/longusage new file mode 100644 index 00000000..054cbaa6 --- /dev/null +++ b/features/mdadm/longusage @@ -0,0 +1,3 @@ + echo " --mdadm Include MDADM/MDMON support" + echo " --no-mdadm Exclude MDADM/MDMON support" + echo " --mdadm-config= Use file as mdadm.conf in initramfs" diff --git a/features/mdadm/man_genkernel_8 b/features/mdadm/man_genkernel_8 new file mode 100644 index 00000000..549830be --- /dev/null +++ b/features/mdadm/man_genkernel_8 @@ -0,0 +1,8 @@ +*--*[*no-*]*mdadm*:: + Includes or excludes mdadm support. + When enabled, this will compile mdadm for you. + +*--mdadm-config*=:: + Use as configfile for MDADM. + By default the ramdisk will be built *without* an 'mdadm.conf' and + will auto-detect arrays during boot-up. diff --git a/features/mdadm/parse_cmdline b/features/mdadm/parse_cmdline new file mode 100644 index 00000000..ec82a88b --- /dev/null +++ b/features/mdadm/parse_cmdline @@ -0,0 +1,8 @@ + --mdadm|--no-mdadm) + CMD_MDADM=$(parse_optbool "$*") + print_info 3 "CMD_MDADM: ${CMD_MDADM}" + ;; + --mdadm-config=*) + CMD_MDADM_CONFIG="${*#*=}" + print_info 3 "CMD_MDADM_CONFIG: ${CMD_MDADM_CONFIG}" + ;; diff --git a/features/multipath/append_base_layout b/features/multipath/append_base_layout new file mode 100644 index 00000000..a6da8093 --- /dev/null +++ b/features/multipath/append_base_layout @@ -0,0 +1 @@ + isTrue "${MULTIPATH}" && build_parameters+=( --multipath ) || build_parameters+=( --no-multipath ) diff --git a/features/multipath/create_initramfs b/features/multipath/create_initramfs new file mode 100644 index 00000000..30c0dede --- /dev/null +++ b/features/multipath/create_initramfs @@ -0,0 +1 @@ + append_data 'multipath' "${MULTIPATH}" diff --git a/features/multipath/determine_real_args b/features/multipath/determine_real_args new file mode 100644 index 00000000..589d140a --- /dev/null +++ b/features/multipath/determine_real_args @@ -0,0 +1 @@ + set_config_with_override BOOL MULTIPATH CMD_MULTIPATH "no" diff --git a/features/multipath/genkernel_conf b/features/multipath/genkernel_conf new file mode 100644 index 00000000..2778a910 --- /dev/null +++ b/features/multipath/genkernel_conf @@ -0,0 +1,2 @@ +# Add Multipath support +#MULTIPATH="no" diff --git a/features/multipath/initramfs_append_func b/features/multipath/initramfs_append_func new file mode 100644 index 00000000..1b3a85b6 --- /dev/null +++ b/features/multipath/initramfs_append_func @@ -0,0 +1,68 @@ +append_multipath() { + local PN=multipath-tools + local TDIR="${TEMP}/initramfs-${PN}-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi + + mkdir -p "${TDIR}"/etc || gen_die "Failed to create '${TDIR}/etc'!" + + mkdir -p "${TDIR}"/usr/lib/udev/rules.d || gen_die "Failed to create '${TDIR}/usr/lib/udev/rules.d'!" + + local libdir=$(get_chost_libdir) + if [[ "${libdir}" =~ ^/usr ]] + then + libdir=${libdir/\/usr/} + fi + + copy_binaries \ + "${TDIR}" \ + /sbin/multipath \ + /sbin/kpartx \ + /sbin/mpathpersist \ + ${libdir}/multipath/lib*.so + + local udevdir=$(get_udevdir) + local udevdir_initramfs="/usr/lib/udev" + local udev_files=( $(qlist -eC sys-fs/multipath-tools:0 \ + | grep -E -- "^${udevdir}") + ) + + if [ ${#udev_files[@]} -eq 0 ] + then + gen_die "Something went wrong: Did not found any udev-related files for sys-fs/multipath-tools!" + fi + + local udev_files + for udev_file in "${udev_files[@]}" + do + local dest_file="${TDIR%/}${udev_file/${udevdir}/${udevdir_initramfs}}" + cp -aL "${udev_file}" "${dest_file}" \ + || gen_die "Failed to copy '${udev_file}' to '${dest_file}'" + done + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + + cp -aL /etc/multipath.conf "${TDIR}"/etc/multipath.conf 2>/dev/null \ + || gen_die "Failed to copy '/etc/multipath.conf'!" + + # /etc/scsi_id.config does not exist in newer udevs + # copy it optionally. + if [ -f /etc/scsi_id.config ] + then + cp -aL /etc/scsi_id.config "${TDIR}"/etc/scsi_id.config 2>/dev/null \ + || gen_die "Failed to copy '/etc/scsi_id.config'!" + fi + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append ${PN} to cpio!" + + cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" + if isTrue "${CLEANUP}" + then + rm -rf "${TDIR}" + fi +} diff --git a/features/multipath/longusage b/features/multipath/longusage new file mode 100644 index 00000000..2d682164 --- /dev/null +++ b/features/multipath/longusage @@ -0,0 +1,2 @@ + echo " --multipath Include Multipath support" + echo " --no-multipath Exclude Multipath support" diff --git a/features/multipath/man_genkernel_8 b/features/multipath/man_genkernel_8 new file mode 100644 index 00000000..fe7dba47 --- /dev/null +++ b/features/multipath/man_genkernel_8 @@ -0,0 +1,3 @@ +*--*[*no-*]*multipath*:: + Includes or excludes Multipath support. + When enabled, this will compile multipath-tools for you. diff --git a/features/multipath/parse_cmdline b/features/multipath/parse_cmdline new file mode 100644 index 00000000..5be1f643 --- /dev/null +++ b/features/multipath/parse_cmdline @@ -0,0 +1,4 @@ + --multipath|--no-multipath) + CMD_MULTIPATH=$(parse_optbool "$*") + print_info 3 "CMD_MULTIPATH: ${CMD_MULTIPATH}" + ;; diff --git a/features/plymouth/append_base_layout b/features/plymouth/append_base_layout new file mode 100644 index 00000000..b0601db8 --- /dev/null +++ b/features/plymouth/append_base_layout @@ -0,0 +1 @@ + isTrue "${PLYMOUTH}" && build_parameters+=( --plymouth ) || build_parameters+=( --no-plymouth ) diff --git a/features/plymouth/create_initramfs b/features/plymouth/create_initramfs new file mode 100644 index 00000000..dcd84de1 --- /dev/null +++ b/features/plymouth/create_initramfs @@ -0,0 +1 @@ + append_data 'plymouth' "${PLYMOUTH}" diff --git a/features/plymouth/determine_real_args b/features/plymouth/determine_real_args new file mode 100644 index 00000000..420b0cd3 --- /dev/null +++ b/features/plymouth/determine_real_args @@ -0,0 +1 @@ + set_config_with_override BOOL PLYMOUTH CMD_PLYMOUTH "no" diff --git a/features/plymouth/genkernel_conf b/features/plymouth/genkernel_conf new file mode 100644 index 00000000..7682d2e2 --- /dev/null +++ b/features/plymouth/genkernel_conf @@ -0,0 +1,6 @@ +# Includes or excludes Plymouth from the initramfs. If "splash" is +# passed at boot, Plymouth will be activated. +#PLYMOUTH="no" + +# Embeds the given plymouth theme in the initramfs. +#PLYMOUTH_THEME="text" diff --git a/features/plymouth/initramfs_append_func b/features/plymouth/initramfs_append_func new file mode 100644 index 00000000..5ab6ac22 --- /dev/null +++ b/features/plymouth/initramfs_append_func @@ -0,0 +1,54 @@ +append_plymouth() { + local PN=plymouth + local TDIR="${TEMP}/initramfs-${PN}-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi + + mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + + # set plymouth theme + if [ -n "${PLYMOUTH_THEME}" ] + then + plymouth-set-default-theme ${PLYMOUTH_THEME} || gen_die "Failed to set default plymouth theme!" + fi + if [ -z "${PLYMOUTH_THEME}" -a -e /etc/plymouth/plymouthd.conf ] + then + PLYMOUTH_THEME=$(plymouth-set-default-theme) || gen_die "Failed to set default plymouth theme!" + fi + if [ -z "${PLYMOUTH_THEME}" ] + then + PLYMOUTH_THEME=text + fi + + print_info 1 "$(get_indent 1)>> Installing plymouth [ using the '${PLYMOUTH_THEME}' theme ]..." + + /usr/libexec/plymouth/plymouth-populate-initrd -t "${TDIR}" \ + || gen_die "Failed to build plymouth cpio archive!" + + # can probably get rid of this; depends if plymouth was built with static libs + # rm -f "${TDIR}"/lib*/{ld*,libc*,libz*} \ + # || gen_die "Failed to clean up plymouth cpio archive!" + + ln -sf "${PLYMOUTH_THEME}/${PLYMOUTH_THEME}.plymouth" "${TDIR}/usr/share/plymouth/themes/default.plymouth" \ + || gen_die "Failed to set the default plymouth theme!" + + # include required udev rules + mkdir -p "${TDIR}"/usr/lib/udev/rules.d || gen_die "Failed to create '${TDIR}/usr/lib/udev/rules.d'!" + cp -aL /lib/udev/rules.d/70-uaccess.rules "${TDIR}/usr/lib/udev/rules.d" || gen_die "Failed to copy '70-uaccess.rules'!" + cp -aL /lib/udev/rules.d/71-seat.rules "${TDIR}/usr/lib/udev/rules.d" || gen_die "Failed to copy '71-seat.rules'!" + + # clean up + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append ${PN} to cpio!" + + cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" + if isTrue "${CLEANUP}" + then + rm -rf "${TDIR}" + fi +} diff --git a/features/plymouth/longusage b/features/plymouth/longusage new file mode 100644 index 00000000..7a596879 --- /dev/null +++ b/features/plymouth/longusage @@ -0,0 +1,3 @@ + echo " --plymouth Enable Plymouth support" + echo " --no-plymouth Do not enable Plymouth support" + echo " --plymouth-theme= Embed the given Plymouth theme" diff --git a/features/plymouth/man_genkernel_8 b/features/plymouth/man_genkernel_8 new file mode 100644 index 00000000..ac7b6a58 --- /dev/null +++ b/features/plymouth/man_genkernel_8 @@ -0,0 +1,6 @@ +*--*[*no-*]*plymouth*:: + Includes or excludes Plymouth from the initramfs. If "splash" is + passed at boot, Plymouth will be activated. + +*--plymouth-theme*=:: + Embeds the given Plymouth theme into the initramfs. diff --git a/features/plymouth/parse_cmdline b/features/plymouth/parse_cmdline new file mode 100644 index 00000000..595c5abe --- /dev/null +++ b/features/plymouth/parse_cmdline @@ -0,0 +1,11 @@ + --plymouth) + CMD_PLYMOUTH="yes" + PLYMOUTH_THEME='text' + print_info 3 "CMD_PLYMOUTH: ${CMD_PLYMOUTH}" + ;; + --plymouth-theme=*) + CMD_PLYMOUTH="yes" + PLYMOUTH_THEME="${*#*=}" + print_info 3 "CMD_PLYMOUTH: ${CMD_PLYMOUTH}" + print_info 3 "PLYMOUTH_THEME: ${PLYMOUTH_THEME}" + ;; diff --git a/features/splash/append_base_layout b/features/splash/append_base_layout new file mode 100644 index 00000000..5a0ccaee --- /dev/null +++ b/features/splash/append_base_layout @@ -0,0 +1 @@ + isTrue "${SPLASH}" && build_parameters+=( --splash ) || build_parameters+=( --no-splash ) diff --git a/features/splash/create_initramfs b/features/splash/create_initramfs new file mode 100644 index 00000000..a87ee0d7 --- /dev/null +++ b/features/splash/create_initramfs @@ -0,0 +1 @@ + append_data 'splash' "${SPLASH}" diff --git a/features/splash/determine_real_args b/features/splash/determine_real_args new file mode 100644 index 00000000..61833e6a --- /dev/null +++ b/features/splash/determine_real_args @@ -0,0 +1 @@ + set_config_with_override BOOL SPLASH CMD_SPLASH "no" diff --git a/features/splash/genkernel_conf b/features/splash/genkernel_conf new file mode 100644 index 00000000..146213d5 --- /dev/null +++ b/features/splash/genkernel_conf @@ -0,0 +1,7 @@ +# Add boot splash using splashutils +#SPLASH="no" + +# Use this splash theme. If commented out - the "default" name theme is used. +# Also, SPLASH="yes" needs to be enabled for this one to work. +# This supersedes the "SPLASH_THEME" option in '/etc/conf.d/splash'. +#SPLASH_THEME="gentoo" diff --git a/features/splash/initramfs_append_func b/features/splash/initramfs_append_func new file mode 100644 index 00000000..37a72ab0 --- /dev/null +++ b/features/splash/initramfs_append_func @@ -0,0 +1,45 @@ +append_splash() { + local TDIR="${TEMP}/initramfs-splash-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi + + mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + + if [ -z "${SPLASH_THEME}" -a -e /etc/conf.d/splash ] + then + source /etc/conf.d/splash &>/dev/null || gen_die "Failed to source '/etc/conf.d/splash'!" + fi + + if [ -z "${SPLASH_THEME}" ] + then + SPLASH_THEME=default + fi + + print_info 1 "$(get_indent 1)>> Installing splash [ using the ${SPLASH_THEME} theme ] ..." + + local res_param="" + [ -n "${SPLASH_RES}" ] && res_param="-r ${SPLASH_RES}" + splash_geninitramfs -c "${TDIR}" ${res_param} ${SPLASH_THEME} \ + || gen_die "Failed to build splash cpio archive" + + if [ -e "/usr/share/splashutils/initrd.splash" ] + then + mkdir -p "${TDIR}"/etc || gen_die "Failed to create '${TDIR}/etc'!" + cp -f /usr/share/splashutils/initrd.splash "${TDIR}"/etc/ 2>/dev/null \ + gen_die "Failed to copy '/usr/share/splashutils/initrd.splash'!" + fi + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append splash to cpio!" + + cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" + if isTrue "${CLEANUP}" + then + rm -rf "${TDIR}" + fi +} diff --git a/features/splash/longusage b/features/splash/longusage new file mode 100644 index 00000000..d938c58e --- /dev/null +++ b/features/splash/longusage @@ -0,0 +1,2 @@ + echo " --splash= Enable framebuffer splash using " + echo " --splash-res= Select splash theme resolutions to install" diff --git a/features/splash/man_genkernel_8 b/features/splash/man_genkernel_8 new file mode 100644 index 00000000..47fba507 --- /dev/null +++ b/features/splash/man_genkernel_8 @@ -0,0 +1,13 @@ +*--*[*no-*]*splash*:: + Installs, or not, framebuffer splash support into initramfs. + +*--*[*no-*]*splash*=:: + If the extra argument is specified, splash is forced using + rather than the default theme specified in your splash + configuration. If *--no-splash* is specified, then splash is disabled. + +*--splash*=:: + Enable framebuffer splash using . + +*--splash-res*=:: + Select gensplash resolutions to include. diff --git a/features/splash/parse_cmdline b/features/splash/parse_cmdline new file mode 100644 index 00000000..130d1691 --- /dev/null +++ b/features/splash/parse_cmdline @@ -0,0 +1,36 @@ + --gensplash=*) + CMD_SPLASH="yes" + SPLASH_THEME="${*#*=}" + print_info 3 "CMD_SPLASH: ${CMD_SPLASH}" + print_info 3 "SPLASH_THEME: ${SPLASH_THEME}" + echo + print_warning 1 "Please use --splash, as --gensplash is deprecated." + ;; + --gensplash|--no-gensplash) + CMD_SPLASH=$(parse_optbool "$*") + SPLASH_THEME='default' + print_info 3 "CMD_SPLASH: ${CMD_SPLASH}" + echo + print_warning 1 "Please use --splash, as --gensplash is deprecated." + ;; + --splash=*) + CMD_SPLASH="yes" + SPLASH_THEME="${*#*=}" + print_info 3 "CMD_SPLASH: ${CMD_SPLASH}" + print_info 3 "SPLASH_THEME: ${SPLASH_THEME}" + ;; + --splash|--no-splash) + CMD_SPLASH=$(parse_optbool "$*") + SPLASH_THEME='default' + print_info 3 "CMD_SPLASH: ${CMD_SPLASH}" + ;; + --gensplash-res=*) + SPLASH_RES="${*#*=}" + print_info 3 "SPLASH_RES: ${SPLASH_RES}" + echo + print_warning 1 "Please use --splash-res, as --gensplash-res is deprecated." + ;; + --splash-res=*) + SPLASH_RES="${*#*=}" + print_info 3 "SPLASH_RES: ${SPLASH_RES}" + ;; diff --git a/features/ssh/append_base_layout b/features/ssh/append_base_layout new file mode 100644 index 00000000..1b24b2ad --- /dev/null +++ b/features/ssh/append_base_layout @@ -0,0 +1 @@ + isTrue "${SSH}" && build_parameters+=( --ssh ) || build_parameters+=( --no-ssh ) diff --git a/features/ssh/create_initramfs b/features/ssh/create_initramfs new file mode 100644 index 00000000..652ff3fc --- /dev/null +++ b/features/ssh/create_initramfs @@ -0,0 +1 @@ + append_data 'dropbear' "${SSH}" diff --git a/features/ssh/determine_real_args b/features/ssh/determine_real_args new file mode 100644 index 00000000..a21c5e99 --- /dev/null +++ b/features/ssh/determine_real_args @@ -0,0 +1,3 @@ + set_config_with_override BOOL SSH CMD_SSH "no" + set_config_with_override STRING SSH_AUTHORIZED_KEYS_FILE CMD_SSH_AUTHORIZED_KEYS_FILE "/etc/dropbear/authorized_keys" + set_config_with_override STRING SSH_HOST_KEYS CMD_SSH_HOST_KEYS "create" diff --git a/features/ssh/genkernel_conf b/features/ssh/genkernel_conf new file mode 100644 index 00000000..b107fca9 --- /dev/null +++ b/features/ssh/genkernel_conf @@ -0,0 +1,2 @@ +# Add SSH support +#SSH="no" diff --git a/features/ssh/initramfs_append_func b/features/ssh/initramfs_append_func new file mode 100644 index 00000000..212b6802 --- /dev/null +++ b/features/ssh/initramfs_append_func @@ -0,0 +1,295 @@ +append_dropbear() { + local PN=dropbear + local TDIR="${TEMP}/initramfs-${PN}-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi + + local dropbear_command= + if ! isTrue "$(is_valid_ssh_host_keys_parameter_value "${SSH_HOST_KEYS}")" + then + gen_die "--ssh-host-keys value '${SSH_HOST_KEYS}' is unsupported!" + elif [[ "${SSH_HOST_KEYS}" == 'create' ]] + then + dropbear_command=dropbearkey + else + dropbear_command=dropbearconvert + fi + + if [ -z "${DROPBEAR_AUTHORIZED_KEYS_FILE}" ] + then + gen_die "Something went wrong: DROPBEAR_AUTHORIZED_KEYS_FILE should already been set but is missing!" + fi + + populate_binpkg ${PN} + + mkdir -p "${TDIR}" || gen_die "Failed to create '${TDIR}'!" + + unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" + + if [[ "${SSH_HOST_KEYS}" == 'runtime' ]] + then + print_info 2 "$(get_indent 2)${PN}: >> No SSH host key embedded due to --ssh-host-key=runtime; Dropbear will generate required host key(s) at runtime!" + else + if ! hash ssh-keygen &>/dev/null + then + gen_die "'ssh-keygen' program is required but missing!" + fi + + local initramfs_dropbear_dir="${TDIR}/etc/dropbear" + + if [[ "${SSH_HOST_KEYS}" == 'create-from-host' ]] + then + print_info 3 "$(get_indent 2)${PN}: >> Checking for existence of all SSH host keys ..." + local missing_ssh_host_keys=no + + if [ ! -f "/etc/ssh/ssh_host_rsa_key" ] + then + print_info 3 "$(get_indent 2)${PN}: >> SSH host key '/etc/ssh/ssh_host_rsa_key' is missing!" + missing_ssh_host_keys=yes + fi + + if [ ! -f "/etc/ssh/ssh_host_ecdsa_key" ] + then + print_info 3 "$(get_indent 2)${PN}: >> SSH host key '/etc/ssh/ssh_host_ecdsa_key' is missing!" + missing_ssh_host_keys=yes + fi + + if [ ! -f "/etc/ssh/ssh_host_ed25519_key" ] + then + print_info 3 "$(get_indent 2)${PN}: >> SSH host key '/etc/ssh/ssh_host_ed25519_key' is missing!" + missing_ssh_host_keys=yes + fi + + if isTrue "${missing_ssh_host_keys}" + then + # Should only happen when installing a new system ... + print_info 3 "$(get_indent 2)${PN}: >> Creating missing SSH host key(s) ..." + ssh-keygen -A || gen_die "Failed to generate host's SSH host key(s) using 'ssh-keygen -A'!" + fi + fi + + local -a required_dropbear_host_keys=( + /etc/dropbear/dropbear_ecdsa_host_key + /etc/dropbear/dropbear_ed25519_host_key + /etc/dropbear/dropbear_rsa_host_key + ) + + local i=0 + local n_required_dropbear_keys=${#required_dropbear_host_keys[@]} + local required_key= + while [[ ${i} < ${n_required_dropbear_keys} ]] + do + required_key=${required_dropbear_host_keys[${i}]} + print_info 3 "$(get_indent 2)${PN}: >> Checking for existence of dropbear host key '${required_key}' ..." + if [[ -f "${required_key}" ]] + then + if [[ ! -s "${required_key}" ]] + then + print_info 1 "$(get_indent 2)${PN}: >> Dropbear host key '${required_key}' exists but is empty; Removing ..." + rm "${required_key}" || gen_die "Failed to remove invalid '${required_key}' null byte file!" + elif [[ "${SSH_HOST_KEYS}" == 'create-from-host' ]] \ + && [[ "${required_key}" == *_rsa_* ]] \ + && [[ "${required_key}" -ot "/etc/ssh/ssh_host_rsa_key" ]] + then + print_info 1 "$(get_indent 2)${PN}: >> Dropbear host key '${required_key}' exists but is older than '/etc/ssh/ssh_host_rsa_key'; Removing to force update due to --ssh-host-key=create-from-host ..." + rm "${required_key}" || gen_die "Failed to remove outdated '${required_key}' file!" + elif [[ "${SSH_HOST_KEYS}" == 'create-from-host' ]] \ + && [[ "${required_key}" == *_ecdsa_* ]] \ + && [[ "${required_key}" -ot "/etc/ssh/ssh_host_ecdsa_key" ]] + then + print_info 1 "$(get_indent 2)${PN}: >> Dropbear host key '${required_key}' exists but is older than '/etc/ssh/ssh_host_ecdsa_key'; Removing to force update due to --ssh-host-key=create-from-host ..." + rm "${required_key}" || gen_die "Failed to remove outdated '${required_key}' file!" + elif [[ "${SSH_HOST_KEYS}" == 'create-from-host' ]] \ + && [[ "${required_key}" == *_ed25519_* ]] \ + && [[ "${required_key}" -ot "/etc/ssh/ssh_host_ed25519_key" ]] + then + print_info 1 "$(get_indent 2)${PN}: >> Dropbear host key '${required_key}' exists but is older than '/etc/ssh/ssh_host_ed25519_key'; Removing to force update due to --ssh-host-key=create-from-host ..." + rm "${required_key}" || gen_die "Failed to remove outdated '${required_key}' file!" + else + print_info 3 "$(get_indent 2)${PN}: >> Dropbear host key '${required_key}' exists!" + unset required_dropbear_host_keys[${i}] + fi + else + print_info 3 "$(get_indent 2)${PN}: >> Dropbear host key '${required_key}' is missing! Will create ..." + fi + + i=$((i + 1)) + done + + if [[ ${#required_dropbear_host_keys[@]} -gt 0 ]] + then + if isTrue "$(can_run_programs_compiled_by_genkernel)" + then + dropbear_command="${TDIR}/usr/bin/${dropbear_command}" + print_info 3 "$(get_indent 2)${PN}: >> Will use '${dropbear_command}' to create missing keys ..." + elif hash ${dropbear_command} &>/dev/null + then + print_info 3 "$(get_indent 2)${PN}: >> Will use existing '${dropbear_command}' program from path to create missing keys ..." + else + local error_msg="Need to generate '${required_dropbear_host_keys[*]}' but '${dropbear_command}'" + error_msg+=" program is missing. Please install net-misc/dropbear and re-run genkernel!" + gen_die "${error_msg}" + fi + + local missing_key= + for missing_key in ${required_dropbear_host_keys[@]} + do + dropbear_create_key "${missing_key}" "${dropbear_command}" + + # just in case ... + if [ -f "${missing_key}" ] + then + print_info 3 "$(get_indent 2)${PN}: >> Dropbear host key '${missing_key}' successfully created!" + else + gen_die "Sanity check failed: '${missing_key}' should exist at this stage but does NOT." + fi + done + else + print_info 2 "$(get_indent 2)${PN}: >> Using existing dropbear host keys from /etc/dropbear ..." + fi + + cp -aL --target-directory "${initramfs_dropbear_dir}" /etc/dropbear/dropbear_{rsa,ecdsa,ed25519}_host_key \ + || gen_die "Failed to copy '/etc/dropbear/dropbear_{rsa,ecdsa,ed25519}_host_key'" + + # Try to show embedded dropbear host key details for security reasons. + # We do it that complicated to get common used formats. + local -a key_info_files=() + local -a missing_key_info_files=() + + local host_key_file= host_key_file_checksum= host_key_info_file= + while IFS= read -r -u 3 -d $'\0' host_key_file + do + host_key_file_checksum=$(sha256sum "${host_key_file}" 2>/dev/null | awk '{print $1}') + if [ -z "${host_key_file_checksum}" ] + then + gen_die "Failed to generate SHA256 checksum of '${host_key_file}'!" + fi + + host_key_info_file="${GK_V_CACHEDIR}/$(basename "${host_key_file}").${host_key_file_checksum:0:10}.info" + + if [ ! -s "${host_key_info_file}" ] + then + missing_key_info_files+=( ${host_key_info_file} ) + else + key_info_files+=( ${host_key_info_file} ) + fi + done 3< <(find "${initramfs_dropbear_dir}" -type f -name '*_key' -print0 2>/dev/null) + unset host_key_file host_key_file_checksum host_key_info_file + IFS="${GK_DEFAULT_IFS}" + + if [[ ${#missing_key_info_files[@]} -ne 0 ]] + then + dropbear_command= + if isTrue "$(can_run_programs_compiled_by_genkernel)" + then + dropbear_command="${TDIR}/usr/bin/dropbearconvert" + print_info 3 "$(get_indent 2)${PN}: >> Will use '${dropbear_command}' to extract embedded host key information ..." + elif hash dropbearconvert &>/dev/null + then + dropbear_command=dropbearconvert + print_info 3 "$(get_indent 2)${PN}: >> Will use existing '${dropbear_command}' program to extract embedded host key information ..." + else + print_warning 2 "$(get_indent 2)${PN}: >> 'dropbearconvert' program not available; Cannot generate missing key information for ${#missing_key_info_files[@]} key(s)!" + fi + + if [[ -n "${dropbear_command}" ]] + then + # We are missing at least information for one embedded key + # but looks like we are able to generate the missing information ... + local missing_key_info_file= + for missing_key_info_file in "${missing_key_info_files[@]}" + do + dropbear_generate_key_info_file "${dropbear_command}" "${missing_key_info_file}" "${initramfs_dropbear_dir}" + key_info_files+=( ${missing_key_info_file} ) + done + unset missing_key_info_file + fi + fi + + if [[ ${#key_info_files[@]} -gt 0 ]] + then + # We have at least information about one embedded key ... + print_info 1 "=================================================================" 1 0 1 + print_info 1 "This initramfs' sshd will use the following host key(s):" 1 0 1 + + local key_info_file= + for key_info_file in "${key_info_files[@]}" + do + print_info 1 "$(cat "${key_info_file}")" 1 0 1 + done + unset key_info_file + + if [ ${LOGLEVEL} -lt 3 ] + then + # Don't clash with output from log_future_cpio_content + print_info 1 "=================================================================" 1 0 1 + fi + else + print_warning 2 "$(get_indent 2)${PN}: >> No information about embedded SSH host key(s) available." + fi + fi + + if isTrue "$(is_glibc)" + then + local libdir=$(get_chost_libdir) + local libnss_files="${libdir}/libnss_files.so" + + # NSS files module was moved into libc in >=glibc-2.34 + # but when this file exists we are probably dealing with older glibc + # and need to manually copy the module. + if [[ -f "${libnss_files}" ]] + then + mkdir -p "${TDIR}"/lib || gen_die "Failed to create '${TDIR}/lib'!" + copy_system_binaries "${TDIR}"/lib "${libnss_files}" + fi + fi + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + + cp -a "${GK_SHARE}"/defaults/login-remote.sh "${TDIR}"/usr/bin/ \ + || gen_die "Failed to copy '${GK_SHARE}/defaults/login-remote.sh'" + + cp -a "${GK_SHARE}"/defaults/resume-boot.sh "${TDIR}"/usr/sbin/resume-boot \ + || gen_die "Failed to copy '${GK_SHARE}/defaults/resume-boot.sh' to '${TDIR}/usr/sbin/resume-boot'" + + cp -a "${GK_SHARE}"/defaults/unlock-luks.sh "${TDIR}"/usr/sbin/unlock-luks \ + || gen_die "Failed to copy '${GK_SHARE}/defaults/unlock-luks.sh' to '${TDIR}/usr/sbin/unlock-luks'" + + cp -a "${GK_SHARE}"/defaults/unlock-zfs.sh "${TDIR}"/usr/sbin/unlock-zfs \ + || gen_die "Failed to copy '${GK_SHARE}/defaults/unlock-zfs.sh' to '${TDIR}/usr/sbin/unlock-zfs'" + + cp -aL "${DROPBEAR_AUTHORIZED_KEYS_FILE}" "${TDIR}"/root/.ssh/ \ + || gen_die "Failed to copy '${DROPBEAR_AUTHORIZED_KEYS_FILE}'!" + + cp -aL /etc/localtime "${TDIR}"/etc/ \ + || gen_die "Failed to copy '/etc/localtime'. Please set system's timezone!" + + + echo "/usr/bin/login-remote.sh" > "${TDIR}"/etc/shells \ + || gen_die "Failed to create '/etc/shells'!" + + chmod 0755 "${TDIR}"/usr/bin/login-remote.sh \ + || gen_die "Failed to chmod of '${TDIR}/usr/bin/login-remote.sh'!" + + chmod 0755 "${TDIR}"/usr/sbin/resume-boot \ + || gen_die "Failed to chmod of '${TDIR}/usr/sbin/resume-boot'!" + + chmod 0755 "${TDIR}"/usr/sbin/unlock-luks \ + || gen_die "Failed to chmod of '${TDIR}/usr/sbin/unlock-luks'!" + + chmod 0755 "${TDIR}"/usr/sbin/unlock-zfs \ + || gen_die "Failed to chmod of '${TDIR}/usr/sbin/unlock-zfs'!" + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append ${PN} to cpio!" + + cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" + if isTrue "${CLEANUP}" + then + rm -rf "${TDIR}" + fi +} diff --git a/features/ssh/longusage b/features/ssh/longusage new file mode 100644 index 00000000..738fbe94 --- /dev/null +++ b/features/ssh/longusage @@ -0,0 +1,9 @@ + echo " --ssh Include SSH (dropbear) support" + echo " --no-ssh Exclude SSH (dropbear) support" + echo " --ssh-authorized-keys-file=" + echo " Specifies a user created authorized_keys file" + echo " --ssh-host-keys=(create|create-from-host|runtime)" + echo " Use host keys from /etc/dropbear, but CREATE (default) new host key(s)" + echo " if missing, CREATE host key(s) FROM current HOST running genkernel" + echo " (not recommended) or don't embed any host key in initramfs and" + echo " generate at RUNTIME (dropbear -R)" diff --git a/features/ssh/man_genkernel_8 b/features/ssh/man_genkernel_8 new file mode 100644 index 00000000..a7b7ba7d --- /dev/null +++ b/features/ssh/man_genkernel_8 @@ -0,0 +1,16 @@ +*--*[*no-*]*ssh*:: + Includes or excludes SSH (dropbear) support for remote LUKS keys. + When enabled, this will compile dropbear for you. + +*--ssh-authorized-keys-file*=:: + Specifies a user created authorized_keys file. By default genkernel + will use '/etc/dropbear/authorized_keys'. + +*--ssh-host-keys*=:: + When set to *create*, which is the default value, genkernel will embed + SSH host keys from '/etc/dropbear' and will create those keys when missing. + When set to *create-from-host*, genkernel will embed SSH host keys from + '/etc/dropbear' but will create those keys from '/etc/ssh' when missing + (not recommended for security reasons). + When set to *runtime*, genkernel will not embed any SSH host key in + initramfs and dropbear will generate needed host key at runtime (`dropbear -R`). diff --git a/features/ssh/parse_cmdline b/features/ssh/parse_cmdline new file mode 100644 index 00000000..ace8fe98 --- /dev/null +++ b/features/ssh/parse_cmdline @@ -0,0 +1,17 @@ + --ssh|--no-ssh) + CMD_SSH=$(parse_optbool "$*") + print_info 3 "CMD_SSH: ${CMD_SSH}" + ;; + --ssh-authorized-keys-file=*) + CMD_SSH_AUTHORIZED_KEYS_FILE="${*#*=}" + print_info 3 "CMD_SSH_AUTHORIZED_KEYS_FILE: ${CMD_SSH_AUTHORIZED_KEYS_FILE}" + ;; + --ssh-host-keys=*) + CMD_SSH_HOST_KEYS="${*#*=}" + if ! isTrue "$(is_valid_ssh_host_keys_parameter_value "${CMD_SSH_HOST_KEYS}")" + then + echo "Error: --ssh-host-keys value '${CMD_SSH_HOST_KEYS}' is unsupported." + exit 1 + fi + print_info 3 "CMD_SSH_HOST_KEYS: ${CMD_SSH_HOST_KEYS}" + ;; diff --git a/features/strace/append_base_layout b/features/strace/append_base_layout new file mode 100644 index 00000000..7ca317d9 --- /dev/null +++ b/features/strace/append_base_layout @@ -0,0 +1 @@ + isTrue "${STRACE}" && build_parameters+=( --strace ) || build_parameters+=( --no-strace ) diff --git a/features/strace/create_initramfs b/features/strace/create_initramfs new file mode 100644 index 00000000..e4e4b524 --- /dev/null +++ b/features/strace/create_initramfs @@ -0,0 +1 @@ + append_data 'strace' "${STRACE}" diff --git a/features/strace/determine_real_args b/features/strace/determine_real_args new file mode 100644 index 00000000..1b7da192 --- /dev/null +++ b/features/strace/determine_real_args @@ -0,0 +1 @@ + set_config_with_override BOOL STRACE CMD_STRACE "no" diff --git a/features/strace/genkernel_conf b/features/strace/genkernel_conf new file mode 100644 index 00000000..98bd6716 --- /dev/null +++ b/features/strace/genkernel_conf @@ -0,0 +1,2 @@ +# Add strace support +#STRACE="no" diff --git a/features/strace/initramfs_append_func b/features/strace/initramfs_append_func new file mode 100644 index 00000000..cbaf7b64 --- /dev/null +++ b/features/strace/initramfs_append_func @@ -0,0 +1,25 @@ +append_strace() { + local PN=strace + local TDIR="${TEMP}/initramfs-${PN}-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi + + populate_binpkg ${PN} + + mkdir -p "${TDIR}" || gen_die "Failed to create '${TDIR}'!" + + unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append ${PN} to cpio!" + + cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" + if isTrue "${CLEANUP}" + then + rm -rf "${TDIR}" + fi +} diff --git a/features/strace/longusage b/features/strace/longusage new file mode 100644 index 00000000..cb299489 --- /dev/null +++ b/features/strace/longusage @@ -0,0 +1,2 @@ + echo " --strace Include strace support" + echo " --no-strace Exclude strace support" diff --git a/features/strace/man_genkernel_8 b/features/strace/man_genkernel_8 new file mode 100644 index 00000000..bd7e3a41 --- /dev/null +++ b/features/strace/man_genkernel_8 @@ -0,0 +1,2 @@ +*--*[*no-*]*multipath*:: + Includes or excludes strace support. diff --git a/features/strace/parse_cmdline b/features/strace/parse_cmdline new file mode 100644 index 00000000..8c9d08df --- /dev/null +++ b/features/strace/parse_cmdline @@ -0,0 +1,4 @@ + --strace|--no-strace) + CMD_STRACE=$(parse_optbool "$*") + print_info 3 "CMD_STRACE: ${CMD_STRACE}" + ;; diff --git a/features/unionfs/append_base_layout b/features/unionfs/append_base_layout new file mode 100644 index 00000000..9e7bbcb9 --- /dev/null +++ b/features/unionfs/append_base_layout @@ -0,0 +1 @@ + isTrue "${UNIONFS}" && build_parameters+=( --unionfs ) || build_parameters+=( --no-unionfs ) diff --git a/features/unionfs/create_initramfs b/features/unionfs/create_initramfs new file mode 100644 index 00000000..fdaa1d18 --- /dev/null +++ b/features/unionfs/create_initramfs @@ -0,0 +1 @@ + append_data 'unionfs_fuse' "${UNIONFS}" diff --git a/features/unionfs/determine_real_args b/features/unionfs/determine_real_args new file mode 100644 index 00000000..92f75f38 --- /dev/null +++ b/features/unionfs/determine_real_args @@ -0,0 +1 @@ + set_config_with_override BOOL UNIONFS CMD_UNIONFS "no" diff --git a/features/unionfs/genkernel_conf b/features/unionfs/genkernel_conf new file mode 100644 index 00000000..87728edd --- /dev/null +++ b/features/unionfs/genkernel_conf @@ -0,0 +1,2 @@ +# Include support for unionfs +#UNIONFS="no" diff --git a/features/unionfs/initramfs_append_func b/features/unionfs/initramfs_append_func new file mode 100644 index 00000000..8c9ab3b0 --- /dev/null +++ b/features/unionfs/initramfs_append_func @@ -0,0 +1,25 @@ +append_unionfs_fuse() { + local PN=unionfs-fuse + local TDIR="${TEMP}/initramfs-${PN}-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi + + populate_binpkg ${PN} + + mkdir -p "${TDIR}" || gen_die "Failed to create '${TDIR}'!" + + unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append ${PN} to cpio!" + + cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" + if isTrue "${CLEANUP}" + then + rm -rf "${TDIR}" + fi +} diff --git a/features/unionfs/longusage b/features/unionfs/longusage new file mode 100644 index 00000000..947f2b09 --- /dev/null +++ b/features/unionfs/longusage @@ -0,0 +1,2 @@ + echo " --unionfs Include support for unionfs" + echo " --no-unionfs Exclude support for unionfs" diff --git a/features/unionfs/man_genkernel_8 b/features/unionfs/man_genkernel_8 new file mode 100644 index 00000000..7d131da9 --- /dev/null +++ b/features/unionfs/man_genkernel_8 @@ -0,0 +1,3 @@ +*--*[*no-*]*unionfs*:: + Includes or excludes support for unionfs. + When enabled, this will compile unionfs-fuse for you. diff --git a/features/unionfs/parse_cmdline b/features/unionfs/parse_cmdline new file mode 100644 index 00000000..d36d1954 --- /dev/null +++ b/features/unionfs/parse_cmdline @@ -0,0 +1,4 @@ + --unionfs|--no-unionfs) + CMD_UNIONFS=$(parse_optbool "$*") + print_info 3 "CMD_UNIONFS: ${CMD_UNIONFS}" + ;; diff --git a/features/xfsprogs/append_base_layout b/features/xfsprogs/append_base_layout new file mode 100644 index 00000000..444a5687 --- /dev/null +++ b/features/xfsprogs/append_base_layout @@ -0,0 +1 @@ + isTrue "${XFSPROGS}" && build_parameters+=( --xfsprogs ) || build_parameters+=( --no-xfsprogs ) diff --git a/features/xfsprogs/create_initramfs b/features/xfsprogs/create_initramfs new file mode 100644 index 00000000..4151d557 --- /dev/null +++ b/features/xfsprogs/create_initramfs @@ -0,0 +1 @@ + append_data 'xfsprogs' "${XFSPROGS}" diff --git a/features/xfsprogs/determine_real_args b/features/xfsprogs/determine_real_args new file mode 100644 index 00000000..d0c8e4c6 --- /dev/null +++ b/features/xfsprogs/determine_real_args @@ -0,0 +1 @@ + set_config_with_override BOOL XFSPROGS CMD_XFSPROGS "no" diff --git a/features/xfsprogs/genkernel_conf b/features/xfsprogs/genkernel_conf new file mode 100644 index 00000000..56f7df71 --- /dev/null +++ b/features/xfsprogs/genkernel_conf @@ -0,0 +1,2 @@ +# Add xfsprogs support +#XFSPROGS="no" diff --git a/features/xfsprogs/initramfs_append_func b/features/xfsprogs/initramfs_append_func new file mode 100644 index 00000000..21d534ca --- /dev/null +++ b/features/xfsprogs/initramfs_append_func @@ -0,0 +1,25 @@ +append_xfsprogs() { + local PN=xfsprogs + local TDIR="${TEMP}/initramfs-${PN}-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi + + populate_binpkg ${PN} + + mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" + + unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append ${PN} to cpio!" + + cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" + if isTrue "${CLEANUP}" + then + rm -rf "${TDIR}" + fi +} diff --git a/features/xfsprogs/longusage b/features/xfsprogs/longusage new file mode 100644 index 00000000..3e2c0bd5 --- /dev/null +++ b/features/xfsprogs/longusage @@ -0,0 +1,2 @@ + echo " --xfsprogs Include xfsprogs" + echo " --no-xfsprogs Exclude xfsprogs" diff --git a/features/xfsprogs/man_genkernel_8 b/features/xfsprogs/man_genkernel_8 new file mode 100644 index 00000000..eef9fe75 --- /dev/null +++ b/features/xfsprogs/man_genkernel_8 @@ -0,0 +1,3 @@ +*--*[*no-*]*xfsprogs*:: + Includes or excludes xfsprogs. + When enabled, this will compile xfsprogs for you. diff --git a/features/xfsprogs/parse_cmdline b/features/xfsprogs/parse_cmdline new file mode 100644 index 00000000..b207b452 --- /dev/null +++ b/features/xfsprogs/parse_cmdline @@ -0,0 +1,4 @@ + --xfsprogs|--no-xfsprogs) + CMD_XFSPROGS=$(parse_optbool "$*") + print_info 3 "CMD_XFSPROGS: ${CMD_XFSPROGS}" + ;; diff --git a/features/zfs/append_base_layout b/features/zfs/append_base_layout new file mode 100644 index 00000000..c0794654 --- /dev/null +++ b/features/zfs/append_base_layout @@ -0,0 +1 @@ + isTrue "${ZFS}" && build_parameters+=( --zfs ) || build_parameters+=( --no-zfs ) diff --git a/features/zfs/create_initramfs b/features/zfs/create_initramfs new file mode 100644 index 00000000..1b420302 --- /dev/null +++ b/features/zfs/create_initramfs @@ -0,0 +1,5 @@ + append_data 'zfs' "${ZFS}" + if isTrue "${ZFS}" + then + append_data 'libgcc_s' + fi diff --git a/features/zfs/determine_real_args b/features/zfs/determine_real_args new file mode 100644 index 00000000..59b97e65 --- /dev/null +++ b/features/zfs/determine_real_args @@ -0,0 +1 @@ + set_config_with_override BOOL ZFS CMD_ZFS "$(rootfs_type_is zfs)" diff --git a/features/zfs/genkernel_conf b/features/zfs/genkernel_conf new file mode 100644 index 00000000..4674b045 --- /dev/null +++ b/features/zfs/genkernel_conf @@ -0,0 +1,3 @@ +# Include support for zfs volume management. If unset, genkernel will attempt +# to autodetect and enable this when rootfs is on zfs. +#ZFS="no" diff --git a/features/zfs/initramfs_append_func b/features/zfs/initramfs_append_func new file mode 100644 index 00000000..1467a7ce --- /dev/null +++ b/features/zfs/initramfs_append_func @@ -0,0 +1,80 @@ +append_zfs() { + local PN=zfs + local TDIR="${TEMP}/initramfs-${PN}-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi + + mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" + + mkdir -p "${TDIR}"/etc/zfs || gen_die "Failed to create '${TDIR}/etc/zfs'!" + + # Copy files to /etc/zfs + local i + for i in vdev_id.conf zdev.conf zpool.cache + do + if [ -f /etc/zfs/${i} ] + then + print_info 2 "$(get_indent 2)${PN}: >> Including ${i}" + cp -aL "/etc/zfs/${i}" "${TDIR}/etc/zfs/${i}" 2>/dev/null \ + || gen_die "Could not copy file '/etc/zfs/${i}' for ZFS" + fi + done + + if [ -f "/etc/hostid" ] + then + local _hostid=$(hostid 2>/dev/null) + print_info 2 "$(get_indent 2)${PN}: >> Embedding hostid '${_hostid}' into initramfs ..." + cp -aL /etc/hostid "${TDIR}"/etc/hostid 2>/dev/null \ + || gen_die "Failed to copy /etc/hostid" + + echo "${_hostid}" > "${TEMP}"/.embedded_hostid \ + || gen_die "Failed to record system's hostid!" + else + print_warning 1 "$(get_indent 2)${PN}: /etc/hostid not found; You must use 'spl_hostid' kernel command-line parameter!" + fi + + copy_binaries "${TDIR}" /sbin/{mount.zfs,zdb,zfs,zpool} + + local udevdir=$(get_udevdir) + local udevdir_initramfs="/usr/lib/udev" + local udev_files=( $(qlist -eC sys-fs/zfs:0 \ + | grep -E -- "^${udevdir}") + ) + + if [ ${#udev_files[@]} -eq 0 ] + then + gen_die "Something went wrong: Did not found any udev-related files for sys-fs/zfs!" + fi + + mkdir -p "${TDIR}"/usr/lib/udev/rules.d || gen_die "Failed to create '${TDIR}/usr/lib/udev/rules.d'!" + + local udev_files + for udev_file in "${udev_files[@]}" + do + local dest_file="${TDIR%/}${udev_file/${udevdir}/${udevdir_initramfs}}" + cp -aL "${udev_file}" "${dest_file}" \ + || gen_die "Failed to copy '${udev_file}' to '${dest_file}'" + + if [[ "${dest_file}" == *.rules ]] + then + print_info 5 "Updating UDEV dir in '${dest_file}' ..." + sed -i \ + -e "s|${udevdir}|${udevdir_initramfs}|g" \ + "${dest_file}" \ + || gen_die "Failed to update UDEV dir in '${dest_file}'" + fi + done + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append ${PN} to cpio!" + + cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" + if isTrue "${CLEANUP}" + then + rm -rf "${TDIR}" + fi +} diff --git a/features/zfs/longusage b/features/zfs/longusage new file mode 100644 index 00000000..16691daf --- /dev/null +++ b/features/zfs/longusage @@ -0,0 +1,2 @@ + echo " --zfs Include ZFS support (enabled by default if rootfs is ZFS)" + echo " --no-zfs Exclude ZFS support" diff --git a/features/zfs/man_genkernel_8 b/features/zfs/man_genkernel_8 new file mode 100644 index 00000000..2191e354 --- /dev/null +++ b/features/zfs/man_genkernel_8 @@ -0,0 +1,2 @@ +*--*[*no-*]*zfs*:: + Includes or excludes ZFS support. diff --git a/features/zfs/parse_cmdline b/features/zfs/parse_cmdline new file mode 100644 index 00000000..700ead75 --- /dev/null +++ b/features/zfs/parse_cmdline @@ -0,0 +1,4 @@ + --zfs|--no-zfs) + CMD_ZFS=$(parse_optbool "$*") + print_info 3 "CMD_ZFS: ${CMD_ZFS}" + ;; diff --git a/gen_cmdline.sh b/gen_cmdline.sh index 5857d48a..a84209b3 100755 --- a/gen_cmdline.sh +++ b/gen_cmdline.sh @@ -53,8 +53,6 @@ longusage() { echo " --no-mrproper Do not run 'make mrproper' before compilation" echo " --splash Install framebuffer splash support into initramfs" echo " --no-splash Do not install framebuffer splash" - echo " --plymouth Enable Plymouth support" - echo " --no-plymouth Do not enable Plymouth support" echo " --install Install the kernel after building" echo " --no-install Do not install the kernel after building" echo " --symlink Manage symlinks in /boot for installed images" @@ -128,51 +126,21 @@ longusage() { echo " --nice=<0-19> Run the kernel make at the selected nice level" echo " --no-nice Don't be nice while running the kernel make" echo " Initialization" - echo " --splash= Enable framebuffer splash using " - echo " --splash-res= Select splash theme resolutions to install" - echo " --splash= Enable framebuffer splash using " - echo " --splash-res= Select splash theme resolutions to install" - echo " --plymouth-theme= Embed the given Plymouth theme" - echo " --do-keymap-auto Forces keymap selection at boot" - echo " --keymap Enables keymap selection support" - echo " --no-keymap Disables keymap selection support" - echo " --bcache Include block layer cache (bcache) support" - echo " --no-bcache Exclude block layer cache (bcache) support" - echo " --lvm Include LVM support" - echo " --no-lvm Exclude LVM support" - echo " --mdadm Include MDADM/MDMON support" - echo " --no-mdadm Exclude MDADM/MDMON support" - echo " --mdadm-config= Use file as mdadm.conf in initramfs" + echo " --busybox Include busybox" + echo " --no-busybox Exclude busybox" + echo " --sandbox Enable sandbox-ing when building initramfs" + echo " --no-sandbox Disable sandbox-ing when building initramfs" echo " --microcode-initramfs Prepend early microcode to initramfs" echo " --no-microcode-initramfs" echo " Don't prepend early microcode to initramfs" echo " --nfs Include NFS support" echo " --no-nfs Exclude NFS support" - echo " --dmraid Include DMRAID support" - echo " --no-dmraid Exclude DMRAID support" - echo " --e2fsprogs Include e2fsprogs" - echo " --no-e2fsprogs Exclude e2fsprogs" - echo " --xfsprogs Include xfsprogs" - echo " --no-xfsprogs Exclude xfsprogs" - echo " --zfs Include ZFS support (enabled by default if rootfs is ZFS)" - echo " --no-zfs Exclude ZFS support" - echo " --btrfs Include Btrfs support (enabled by default if rootfs is Btrfs)" - echo " --no-btrfs Exclude Btrfs support" - echo " --multipath Include Multipath support" - echo " --no-multipath Exclude Multipath support" - echo " --iscsi Include iSCSI support" - echo " --no-iscsi Exclude iSCSI support" - echo " --sandbox Enable sandbox-ing when building initramfs" - echo " --no-sandbox Disable sandbox-ing when building initramfs" - echo " --ssh Include SSH (dropbear) support" - echo " --no-ssh Exclude SSH (dropbear) support" - echo " --ssh-authorized-keys-file=" - echo " Specifies a user created authorized_keys file" - echo " --ssh-host-keys=(create|create-from-host|runtime)" - echo " Use host keys from /etc/dropbear, but CREATE (default) new host key(s)" - echo " if missing, CREATE host key(s) FROM current HOST running genkernel" - echo " (not recommended) or don't embed any host key in initramfs and" - echo " generate at RUNTIME (dropbear -R)" + echo " --netboot Create a self-contained env in the initramfs" + echo " --no-netboot Exclude netboot env" + $(. load_features longusage) + echo " --do-keymap-auto Forces keymap selection at boot" + echo " --keymap Enables keymap selection support" + echo " --no-keymap Disables keymap selection support" echo " --boot-font=(current||none)" echo " Embed CURRENT active console font from host running genkernel" echo " or specified PSF font file into initramfs and activate early on boot." @@ -183,20 +151,6 @@ longusage() { echo " --linuxrc= Specifies a user created linuxrc" echo " --busybox-config= Specifies a user created busybox config" echo " --genzimage Make and install kernelz image (PowerPC)" - echo " --luks Include LUKS support" - echo " --no-luks Exclude LUKS support" - echo " --gpg Include GPG-armored LUKS key support" - echo " --no-gpg Exclude GPG-armored LUKS key support" - echo " --keyctl Include keyctl support for loading LUKS passphrase into a keyring" - echo " --no-keyctl Exclude keyctl support for loading LUKS passphrase into a keyring" - echo " --b2sum Include b2sum" - echo " --no-b2sum Exclude b2sum" - echo " --busybox Include busybox" - echo " --no-busybox Exclude busybox" - echo " --unionfs Include support for unionfs" - echo " --no-unionfs Exclude support for unionfs" - echo " --netboot Create a self-contained env in the initramfs" - echo " --no-netboot Exclude netboot env" echo " --real-root= Specify a default for real_root=" echo " Internals" echo " --cachedir= Override the default cache location" @@ -437,6 +391,10 @@ parse_cmdline() { CMD_BOOTDIR="${*#*=}" print_info 3 "CMD_BOOTDIR: ${CMD_BOOTDIR}" ;; + --real-root=*) + CMD_REAL_ROOT="${*#*=}" + print_info 3 "CMD_REAL_ROOT: ${CMD_REAL_ROOT}" + ;; --modprobedir=*) CMD_MODPROBEDIR="${*#*=}" print_info 3 "CMD_MODPROBEDIR: ${CMD_MODPROBEDIR}" @@ -450,32 +408,11 @@ parse_cmdline() { CMD_KEYMAP=$(parse_optbool "$*") print_info 3 "CMD_KEYMAP: ${CMD_KEYMAP}" ;; - --bcache|--no-bcache) - CMD_BCACHE=$(parse_optbool "$*") - print_info 3 "CMD_BCACHE: ${CMD_BCACHE}" - ;; - --lvm|--no-lvm) - CMD_LVM=$(parse_optbool "$*") - print_info 3 "CMD_LVM: ${CMD_LVM}" - ;; - --lvm2|--no-lvm2) - CMD_LVM=$(parse_optbool "$*") - print_info 3 "CMD_LVM: ${CMD_LVM}" - echo - print_warning 1 "Please use --lvm, as --lvm2 is deprecated." - ;; - --mdadm|--no-mdadm) - CMD_MDADM=$(parse_optbool "$*") - print_info 3 "CMD_MDADM: ${CMD_MDADM}" - ;; - --mdadm-config=*) - CMD_MDADM_CONFIG="${*#*=}" - print_info 3 "CMD_MDADM_CONFIG: ${CMD_MDADM_CONFIG}" - ;; - --b2sum|--no-b2sum) - CMD_B2SUM=$(parse_optbool "$*") - print_info 3 "CMD_B2SUM: ${CMD_B2SUM}" + --sandbox|--no-sandbox) + CMD_SANDBOX=$(parse_optbool "$*") + print_info 3 "CMD_SANDBOX: ${CMD_SANDBOX}" ;; + --busybox|--no-busybox) CMD_BUSYBOX=$(parse_optbool "$*") print_info 3 "CMD_BUSYBOX: ${CMD_BUSYBOX}" @@ -495,50 +432,6 @@ parse_cmdline() { CMD_MICROCODE_INITRAMFS=$(parse_optbool "$*") print_info 3 "CMD_MICROCODE_INITRAMFS: ${CMD_MICROCODE_INITRAMFS}" ;; - --nfs|--no-nfs) - CMD_NFS=$(parse_optbool "$*") - print_info 3 "CMD_NFS: ${CMD_NFS}" - ;; - --unionfs|--no-unionfs) - CMD_UNIONFS=$(parse_optbool "$*") - print_info 3 "CMD_UNIONFS: ${CMD_UNIONFS}" - ;; - --netboot|--no-netboot) - CMD_NETBOOT=$(parse_optbool "$*") - print_info 3 "CMD_NETBOOT: ${CMD_NETBOOT}" - ;; - --real-root=*) - CMD_REAL_ROOT="${*#*=}" - print_info 3 "CMD_REAL_ROOT: ${CMD_REAL_ROOT}" - ;; - --dmraid|--no-dmraid) - CMD_DMRAID=$(parse_optbool "$*") - print_info 3 "CMD_DMRAID: ${CMD_DMRAID}" - ;; - --e2fsprogs|--no-e2fsprogs) - CMD_E2FSPROGS=$(parse_optbool "$*") - print_info 3 "CMD_E2FSPROGS: ${CMD_E2FSPROGS}" - ;; - --xfsprogs|--no-xfsprogs) - CMD_XFSPROGS=$(parse_optbool "$*") - print_info 3 "CMD_XFSPROGS: ${CMD_XFSPROGS}" - ;; - --zfs|--no-zfs) - CMD_ZFS=$(parse_optbool "$*") - print_info 3 "CMD_ZFS: ${CMD_ZFS}" - ;; - --btrfs|--no-btrfs) - CMD_BTRFS=$(parse_optbool "$*") - print_info 3 "CMD_BTRFS: ${CMD_BTRFS}" - ;; - --virtio|--no-virtio) - CMD_VIRTIO=$(parse_optbool "$*") - print_info 3 "CMD_VIRTIO: ${CMD_VIRTIO}" - ;; - --multipath|--no-multipath) - CMD_MULTIPATH=$(parse_optbool "$*") - print_info 3 "CMD_MULTIPATH: ${CMD_MULTIPATH}" - ;; --boot-font=*) CMD_BOOTFONT="${*#*=}" [ -z "${CMD_BOOTFONT}" ] && CMD_BOOTFONT="none" @@ -553,39 +446,23 @@ parse_cmdline() { CMD_BOOTLOADER="no" print_info 3 "CMD_BOOTLOADER: ${CMD_BOOTLOADER}" ;; - --iscsi|--no-iscsi) - CMD_ISCSI=$(parse_optbool "$*") - print_info 3 "CMD_ISCSI: ${CMD_ISCSI}" + $(. load_features.sh parse_cmdline) + --nfs|--no-nfs) + CMD_NFS=$(parse_optbool "$*") + print_info 3 "CMD_NFS: ${CMD_NFS}" + ;; + --netboot|--no-netboot) + CMD_NETBOOT=$(parse_optbool "$*") + print_info 3 "CMD_NETBOOT: ${CMD_NETBOOT}" + ;; + --virtio|--no-virtio) + CMD_VIRTIO=$(parse_optbool "$*") + print_info 3 "CMD_VIRTIO: ${CMD_VIRTIO}" ;; --hyperv|--no-hyperv) CMD_HYPERV=$(parse_optbool "$*") print_info 3 "CMD_HYPERV: ${CMD_HYPERV}" ;; - --sandbox|--no-sandbox) - CMD_SANDBOX=$(parse_optbool "$*") - print_info 3 "CMD_SANDBOX: ${CMD_SANDBOX}" - ;; - --ssh|--no-ssh) - CMD_SSH=$(parse_optbool "$*") - print_info 3 "CMD_SSH: ${CMD_SSH}" - ;; - --ssh-authorized-keys-file=*) - CMD_SSH_AUTHORIZED_KEYS_FILE="${*#*=}" - print_info 3 "CMD_SSH_AUTHORIZED_KEYS_FILE: ${CMD_SSH_AUTHORIZED_KEYS_FILE}" - ;; - --ssh-host-keys=*) - CMD_SSH_HOST_KEYS="${*#*=}" - if ! isTrue "$(is_valid_ssh_host_keys_parameter_value "${CMD_SSH_HOST_KEYS}")" - then - echo "Error: --ssh-host-keys value '${CMD_SSH_HOST_KEYS}' is unsupported." - exit 1 - fi - print_info 3 "CMD_SSH_HOST_KEYS: ${CMD_SSH_HOST_KEYS}" - ;; - --strace|--no-strace) - CMD_STRACE=$(parse_optbool "$*") - print_info 3 "CMD_STRACE: ${CMD_STRACE}" - ;; --loglevel=*) CMD_LOGLEVEL="${*#*=}" LOGLEVEL="${CMD_LOGLEVEL}" @@ -649,53 +526,6 @@ parse_cmdline() { print_info 3 "CMD_CLEAN: ${CMD_CLEAN}" print_info 3 "CMD_OLDCONFIG: ${CMD_OLDCONFIG}" ;; - --gensplash=*) - CMD_SPLASH="yes" - SPLASH_THEME="${*#*=}" - print_info 3 "CMD_SPLASH: ${CMD_SPLASH}" - print_info 3 "SPLASH_THEME: ${SPLASH_THEME}" - echo - print_warning 1 "Please use --splash, as --gensplash is deprecated." - ;; - --gensplash|--no-gensplash) - CMD_SPLASH=$(parse_optbool "$*") - SPLASH_THEME='default' - print_info 3 "CMD_SPLASH: ${CMD_SPLASH}" - echo - print_warning 1 "Please use --splash, as --gensplash is deprecated." - ;; - --splash=*) - CMD_SPLASH="yes" - SPLASH_THEME="${*#*=}" - print_info 3 "CMD_SPLASH: ${CMD_SPLASH}" - print_info 3 "SPLASH_THEME: ${SPLASH_THEME}" - ;; - --splash|--no-splash) - CMD_SPLASH=$(parse_optbool "$*") - SPLASH_THEME='default' - print_info 3 "CMD_SPLASH: ${CMD_SPLASH}" - ;; - --gensplash-res=*) - SPLASH_RES="${*#*=}" - print_info 3 "SPLASH_RES: ${SPLASH_RES}" - echo - print_warning 1 "Please use --splash-res, as --gensplash-res is deprecated." - ;; - --splash-res=*) - SPLASH_RES="${*#*=}" - print_info 3 "SPLASH_RES: ${SPLASH_RES}" - ;; - --plymouth) - CMD_PLYMOUTH="yes" - PLYMOUTH_THEME='text' - print_info 3 "CMD_PLYMOUTH: ${CMD_PLYMOUTH}" - ;; - --plymouth-theme=*) - CMD_PLYMOUTH="yes" - PLYMOUTH_THEME="${*#*=}" - print_info 3 "CMD_PLYMOUTH: ${CMD_PLYMOUTH}" - print_info 3 "PLYMOUTH_THEME: ${PLYMOUTH_THEME}" - ;; --install|--no-install) CMD_INSTALL=$(parse_optbool "$*") print_info 3 "CMD_INSTALL: ${CMD_INSTALL}" @@ -855,18 +685,6 @@ parse_cmdline() { # ENABLE_PEGASOS_HACKS="yes" # print_info 3 "ENABLE_PEGASOS_HACKS: ${ENABLE_PEGASOS_HACKS}" ;; - --luks|--no-luks) - CMD_LUKS=$(parse_optbool "$*") - print_info 3 "CMD_LUKS: ${CMD_LUKS}" - ;; - --gpg|--no-gpg) - CMD_GPG=$(parse_optbool "$*") - print_info 3 "CMD_GPG: ${CMD_GPG}" - ;; - --keyctl|--no-keyctl) - CMD_KEYCTL=$(parse_optbool "$*") - print_info 3 "CMD_KEYCTL: ${CMD_KEYCTL}" - ;; --firmware|--no-firmware) CMD_FIRMWARE=$(parse_optbool "$*") print_info 3 "CMD_FIRMWARE: ${CMD_FIRMWARE}" diff --git a/gen_determineargs.sh b/gen_determineargs.sh index d29ad48a..16c62abe 100755 --- a/gen_determineargs.sh +++ b/gen_determineargs.sh @@ -387,8 +387,6 @@ determine_real_args() { set_config_with_override STRING KERNEL_LOCALVERSION CMD_KERNEL_LOCALVERSION "-%%ARCH%%" set_config_with_override STRING MODPROBEDIR CMD_MODPROBEDIR "/etc/modprobe.d" - set_config_with_override BOOL SPLASH CMD_SPLASH "no" - set_config_with_override BOOL PLYMOUTH CMD_PLYMOUTH "no" set_config_with_override BOOL CLEAR_CACHEDIR CMD_CLEAR_CACHEDIR "no" set_config_with_override BOOL POSTCLEAR CMD_POSTCLEAR "no" set_config_with_override BOOL MRPROPER CMD_MRPROPER "yes" @@ -412,44 +410,30 @@ determine_real_args() { set_config_with_override BOOL SAVE_CONFIG CMD_SAVE_CONFIG "yes" set_config_with_override BOOL SYMLINK CMD_SYMLINK "no" set_config_with_override BOOL OLDCONFIG CMD_OLDCONFIG "yes" - set_config_with_override BOOL SANDBOX CMD_SANDBOX "yes" - set_config_with_override BOOL SSH CMD_SSH "no" - set_config_with_override STRING SSH_AUTHORIZED_KEYS_FILE CMD_SSH_AUTHORIZED_KEYS_FILE "/etc/dropbear/authorized_keys" - set_config_with_override STRING SSH_HOST_KEYS CMD_SSH_HOST_KEYS "create" - set_config_with_override BOOL STRACE CMD_STRACE "no" - set_config_with_override BOOL BCACHE CMD_BCACHE "no" - set_config_with_override BOOL LVM CMD_LVM "no" - set_config_with_override BOOL DMRAID CMD_DMRAID "no" - set_config_with_override BOOL ISCSI CMD_ISCSI "no" - set_config_with_override BOOL HYPERV CMD_HYPERV "no" - set_config_with_override STRING BOOTFONT CMD_BOOTFONT "none" - set_config_with_override STRING BOOTLOADER CMD_BOOTLOADER "no" - set_config_with_override BOOL B2SUM CMD_B2SUM "no" + set_config_with_override STRING REAL_ROOT CMD_REAL_ROOT + set_config_with_override BOOL BUSYBOX CMD_BUSYBOX "yes" set_config_with_override STRING BUSYBOX_CONFIG CMD_BUSYBOX_CONFIG - set_config_with_override BOOL NFS CMD_NFS "yes" set_config_with_override STRING MICROCODE CMD_MICROCODE "all" set_config_with_override BOOL MICROCODE_INITRAMFS CMD_MICROCODE_INITRAMFS "no" - set_config_with_override BOOL UNIONFS CMD_UNIONFS "no" - set_config_with_override BOOL NETBOOT CMD_NETBOOT "no" - set_config_with_override STRING REAL_ROOT CMD_REAL_ROOT - set_config_with_override BOOL LUKS CMD_LUKS "no" - set_config_with_override BOOL GPG CMD_GPG "no" - set_config_with_override BOOL KEYCTL CMD_KEYCTL "no" - set_config_with_override BOOL MDADM CMD_MDADM "no" - set_config_with_override STRING MDADM_CONFIG CMD_MDADM_CONFIG - set_config_with_override BOOL E2FSPROGS CMD_E2FSPROGS "no" - set_config_with_override BOOL XFSPROGS CMD_XFSPROGS "no" - set_config_with_override BOOL ZFS CMD_ZFS "$(rootfs_type_is zfs)" - set_config_with_override BOOL BTRFS CMD_BTRFS "$(rootfs_type_is btrfs)" + set_config_with_override STRING BOOTLOADER CMD_BOOTLOADER "no" + set_config_with_override STRING BOOTFONT CMD_BOOTFONT "none" + set_config_with_override BOOL SANDBOX CMD_SANDBOX "yes" + set_config_with_override BOOL HYPERV CMD_HYPERV "no" set_config_with_override BOOL VIRTIO CMD_VIRTIO "no" - set_config_with_override BOOL MULTIPATH CMD_MULTIPATH "no" + set_config_with_override BOOL NETBOOT CMD_NETBOOT "no" + set_config_with_override BOOL NFS CMD_NFS "yes" + +#BEGIN FEATURES determine_real_args() +#END FEATURES determine_real_args() + set_config_with_override BOOL FIRMWARE CMD_FIRMWARE "no" set_config_with_override BOOL ALLFIRMWARE CMD_ALLFIRMWARE "no" set_config_with_override STRING FIRMWARE_DIR CMD_FIRMWARE_DIR "/lib/firmware" set_config_with_override STRING FIRMWARE_FILES CMD_FIRMWARE_FILES set_config_with_override BOOL FIRMWARE_INSTALL CMD_FIRMWARE_INSTALL "no" set_config_with_override BOOL INTEGRATED_INITRAMFS CMD_INTEGRATED_INITRAMFS "no" + set_config_with_override BOOL WRAP_INITRD CMD_WRAP_INITRD "no" set_config_with_override BOOL GENZIMAGE CMD_GENZIMAGE "no" set_config_with_override BOOL KEYMAP CMD_KEYMAP "yes" diff --git a/gen_funcs.sh b/gen_funcs.sh index 70a49695..e920ef1d 100755 --- a/gen_funcs.sh +++ b/gen_funcs.sh @@ -1981,7 +1981,7 @@ check_distfiles() { print_error 1 "Could not find source file '${source_file}'!" done - gen_die "Please add missing source file(s) or re-install genkernel!" + # gen_die "Please add missing source file(s) or re-install genkernel!" fi } diff --git a/gen_initramfs.sh b/gen_initramfs.sh index 87e51494..df7f7dde 100755 --- a/gen_initramfs.sh +++ b/gen_initramfs.sh @@ -472,28 +472,10 @@ append_base_layout() { isTrue "${MICROCODE_INITRAMFS}" && build_parameters+=( --microcode-initramfs ) || build_parameters+=( --no-microcode-initramfs ) isTrue "${RAMDISKMODULES}" && build_parameters+=( --ramdisk-modules ) || build_parameters+=( --no-ramdisk-modules ) isTrue "${BUSYBOX}" && build_parameters+=( --busybox ) || build_parameters+=( --no-busybox ) - isTrue "${BCACHE}" && build_parameters+=( --bcache ) || build_parameters+=( --no-bcache ) - isTrue "${B2SUM}" && build_parameters+=( --b2sum ) || build_parameters+=( --no-b2sum ) - isTrue "${BTRFS}" && build_parameters+=( --btrfs ) || build_parameters+=( --no-btrfs ) - isTrue "${ISCSI}" && build_parameters+=( --iscsi ) || build_parameters+=( --no-iscsi ) - isTrue "${MULTIPATH}" && build_parameters+=( --multipath ) || build_parameters+=( --no-multipath ) - isTrue "${DMRAID}" && build_parameters+=( --dmraid ) || build_parameters+=( --no-dmraid ) - isTrue "${MDADM}" && build_parameters+=( --mdadm ) || build_parameters+=( --no-mdadm ) - isTrue "${LVM}" && build_parameters+=( --lvm ) || build_parameters+=( --no-lvm ) - isTrue "${UNIONFS}" && build_parameters+=( --unionfs ) || build_parameters+=( --no-unionfs ) - isTrue "${ZFS}" && build_parameters+=( --zfs ) || build_parameters+=( --no-zfs ) - isTrue "${SPLASH}" && build_parameters+=( --splash ) || build_parameters+=( --no-splash ) - isTrue "${PLYMOUTH}" && build_parameters+=( --plymouth ) || build_parameters+=( --no-plymouth ) - isTrue "${STRACE}" && build_parameters+=( --strace ) || build_parameters+=( --no-strace ) - isTrue "${KEYCTL}" && build_parameters+=( --keyctl ) || build_parameters+=( --no-keyctl ) - isTrue "${GPG}" && build_parameters+=( --gpg ) || build_parameters+=( --no-gpg ) - isTrue "${LUKS}" && build_parameters+=( --luks ) || build_parameters+=( --no-luks ) + $(. load_features append_base_layout) isTrue "${FIRMWARE}" && build_parameters+=( --firmware ) || build_parameters+=( --no-firmware ) [ -n "${FIRMWARE_DIR}" ] && build_parameters+=( --firmware-dir="${FIRMWARE_DIR}" ) [ -n "${FIRMWARE_FILES}" ] && build_parameters+=( --firmware-files="${FIRMWARE_FILES}" ) - isTrue "${SSH}" && build_parameters+=( --ssh ) || build_parameters+=( --no-ssh ) - isTrue "${E2FSPROGS}" && build_parameters+=( --e2fsprogs ) || build_parameters+=( --no-e2fsprogs ) - isTrue "${XFSPROGS}" && build_parameters+=( --xfsprogs ) || build_parameters+=( --no-xfsprogs ) echo "${build_parameters[@]}" > "${TDIR}"/lib/dracut/build-parameter.txt \ || gen_die "Failed to create '${TDIR}/lib/dracut/build-parameter.txt'!" @@ -519,224 +501,36 @@ append_base_layout() { fi } -append_busybox() { - local PN=busybox - local TDIR="${TEMP}/initramfs-${PN}-temp" - if [ -d "${TDIR}" ] - then - rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" - fi - - populate_binpkg ${PN} - - mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" - - unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" - - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - - # Delete unneeded files - rm -rf configs/ - - mkdir -p "${TDIR}"/usr/share/udhcpc || gen_die "Failed to create '${TDIR}/usr/share/udhcpc'!" - - cp -a "${GK_SHARE}"/defaults/udhcpc.scripts usr/share/udhcpc/default.script 2>/dev/null \ - || gen_die "Failed to copy '${GK_SHARE}/defaults/udhcpc.scripts' to '${TDIR}/usr/share/udhcpc/default.script'!" - - local myfile= - for myfile in \ - bin/busybox \ - usr/share/udhcpc/default.script \ - ; do - chmod +x "${TDIR}"/${myfile} || gen_die "Failed to chmod of '${TDIR}/${myfile}'!" - done - - # Set up a few default symlinks - local required_applets='[ ash sh mkdir mknod mount uname echo chmod cut cat touch' - local required_applet= - for required_applet in ${required_applets} - do - ln -s busybox "${TDIR}"/bin/${required_applet} \ - || gen_die "Failed to create Busybox symlink for '${required_applet}' applet!" - done - - # allow for DNS resolution - if isTrue "$(is_glibc)" - then - local libdir=$(get_chost_libdir) - local libnss_dns="${libdir}/libnss_dns.so" - - # NSS dns module was moved into libc in >=glibc-2.34 - # but when this file exists we are probably dealing with older glibc - # and need to manually copy the module. - if [[ -f "${libnss_dns}" ]] - then - mkdir -p "${TDIR}"/lib || gen_die "Failed to create '${TDIR}/lib'!" - copy_system_binaries "${TDIR}"/lib "${libnss_dns}" - fi - fi - - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append ${PN} to cpio!" - - cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" - if isTrue "${CLEANUP}" - then - rm -rf "${TDIR}" - fi -} - -append_e2fsprogs() { - local PN=e2fsprogs - local TDIR="${TEMP}/initramfs-${PN}-temp" - if [ -d "${TDIR}" ] - then - rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" - fi - - populate_binpkg ${PN} - - mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" - - unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" - - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append ${PN} to cpio!" - - cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" - if isTrue "${CLEANUP}" - then - rm -rf "${TDIR}" - fi -} +#BEGIN FEATURES initramfs_append_func +#END FEATURES initramfs_append_func -append_eudev() { - local PN=eudev - local TDIR="${TEMP}/initramfs-${PN}-temp" +append_libgcc_s() { + local TDIR="${TEMP}/initramfs-libgcc_s-temp" if [ -d "${TDIR}" ] then rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" fi - populate_binpkg ${PN} - populate_binpkg hwids - mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" - - unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" - unpack "$(get_gkpkg_binpkg hwids)" "${TDIR}" - - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - - if isTrue "$(can_run_programs_compiled_by_genkernel)" - then - print_info 2 "$(get_indent 2)${PN}: >> Pre-generating initramfs' /etc/udev/hwdb.bin ..." - - local gen_hwdb_cmd=( "${TDIR}/usr/bin/udevadm" ) - gen_hwdb_cmd+=( hwdb --update --root "${TDIR}" ) - print_info 3 "COMMAND: ${gen_hwdb_cmd[*]}" 1 0 1 - eval "${gen_hwdb_cmd[@]}" 2>&1 | tee -a "${LOGFILE}" \ - || gen_die "Failed to pre-generate initramfs' /etc/udev/hwdb.bin!" - - # Now that we have a pre-generated hwdb in initramfs - # we can delete source files - rm -rf usr/lib/udev/hwdb.d/ - fi - - # Delete unneeded files - rm -rf usr/include \ - usr/lib/libu* \ - usr/lib/pkgconfig \ - usr/share - - # Disable predictable network interface names in initramfs - echo "" > usr/lib/udev/rules.d/80-net-name-slot.rules \ - || gen_die "Failed to disable predictable network interface naming rule" - - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append ${PN} to cpio!" - - cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" - if isTrue "${CLEANUP}" - then - rm -rf "${TDIR}" - fi -} - -append_b2sum() { - local PN="coreutils" - local TDIR="${TEMP}/initramfs-b2sum-temp" - if [ -d "${TDIR}" ] - then - rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" - fi - - populate_binpkg ${PN} - - mkdir -p "${TDIR}" || gen_die "Failed to create '${TDIR}'!" - - unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" - - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append b2sum to cpio!" - - cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" - if isTrue "${CLEANUP}" - then - rm -rf "${TDIR}" - fi -} - -append_bcache() { - local PN="bcache-tools" - local TDIR="${TEMP}/initramfs-bcache-temp" - if [ -d "${TDIR}" ] - then - rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" - fi - - populate_binpkg ${PN} - - mkdir -p "${TDIR}" || gen_die "Failed to create '${TDIR}'!" - - unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append bcache to cpio!" - cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" - if isTrue "${CLEANUP}" - then - rm -rf "${TDIR}" + # Include libgcc_s.so.1: + # - workaround for zfsonlinux/zfs#4749 + # - required for LUKS2 (libargon2 uses pthread_cancel) + local libgccpath + if type gcc-config 2>&1 1>/dev/null; then + libgccpath="/usr/lib/gcc/$(s=$(gcc-config -c); echo ${s%-*}/${s##*-})/libgcc_s.so.1" fi -} - -append_unionfs_fuse() { - local PN=unionfs-fuse - local TDIR="${TEMP}/initramfs-${PN}-temp" - if [ -d "${TDIR}" ] - then - rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + if [[ ! -f ${libgccpath} ]]; then + libgccpath="/usr/lib/gcc/*/*/libgcc_s.so.1" fi - populate_binpkg ${PN} - - mkdir -p "${TDIR}" || gen_die "Failed to create '${TDIR}'!" - - unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" + copy_binaries "${TDIR}" ${libgccpath} cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" log_future_cpio_content find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append ${PN} to cpio!" + || gen_die "Failed to append libgcc_s to cpio!" cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" if isTrue "${CLEANUP}" @@ -745,1103 +539,50 @@ append_unionfs_fuse() { fi } -append_util-linux() { - local PN="util-linux" - local TDIR="${TEMP}/initramfs-util-linux-temp" +append_linker() { + local TDIR="${TEMP}/initramfs-linker-temp" if [ -d "${TDIR}" ] then rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" fi - populate_binpkg ${PN} - - mkdir -p "${TDIR}" || gen_die "Failed to create '${TDIR}'!" - - unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" - + mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - # Delete unneeded files - rm -rf usr/ - - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append ${PN} to cpio!" - - cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" - if isTrue "${CLEANUP}" - then - rm -rf "${TDIR}" - fi -} - -append_multipath() { - local PN=multipath-tools - local TDIR="${TEMP}/initramfs-${PN}-temp" - if [ -d "${TDIR}" ] - then - rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" - fi - mkdir -p "${TDIR}"/etc || gen_die "Failed to create '${TDIR}/etc'!" - mkdir -p "${TDIR}"/usr/lib/udev/rules.d || gen_die "Failed to create '${TDIR}/usr/lib/udev/rules.d'!" - - local libdir=$(get_chost_libdir) - if [[ "${libdir}" =~ ^/usr ]] - then - libdir=${libdir/\/usr/} - fi - - copy_binaries \ - "${TDIR}" \ - /sbin/multipath \ - /sbin/kpartx \ - /sbin/mpathpersist \ - ${libdir}/multipath/lib*.so - - local udevdir=$(get_udevdir) - local udevdir_initramfs="/usr/lib/udev" - local udev_files=( $(qlist -eC sys-fs/multipath-tools:0 \ - | grep -E -- "^${udevdir}") - ) - - if [ ${#udev_files[@]} -eq 0 ] + if isTrue "$(tc-is-cross-compiler)" then - gen_die "Something went wrong: Did not found any udev-related files for sys-fs/multipath-tools!" - fi - - local udev_files - for udev_file in "${udev_files[@]}" - do - local dest_file="${TDIR%/}${udev_file/${udevdir}/${udevdir_initramfs}}" - cp -aL "${udev_file}" "${dest_file}" \ - || gen_die "Failed to copy '${udev_file}' to '${dest_file}'" - done - - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - - cp -aL /etc/multipath.conf "${TDIR}"/etc/multipath.conf 2>/dev/null \ - || gen_die "Failed to copy '/etc/multipath.conf'!" + # We cannot copy ld files from host because they could be + # incompatible with CHOST. Instead, add ldconfig to allow + # initramfs to regenerate on its own (default /etc/ld.so.conf + # for initramfs was added via append_base_layout()). + mkdir -p "${TDIR}"/sbin || gen_die "Failed to create '${TDIR}/sbin'!" - # /etc/scsi_id.config does not exist in newer udevs - # copy it optionally. - if [ -f /etc/scsi_id.config ] - then - cp -aL /etc/scsi_id.config "${TDIR}"/etc/scsi_id.config 2>/dev/null \ - || gen_die "Failed to copy '/etc/scsi_id.config'!" - fi - - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append ${PN} to cpio!" - - cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" - if isTrue "${CLEANUP}" - then - rm -rf "${TDIR}" - fi -} - -append_dmraid() { - local PN=dmraid - local TDIR="${TEMP}/initramfs-${PN}-temp" - if [ -d "${TDIR}" ] - then - rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" - fi - - populate_binpkg ${PN} - - mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" - - unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" - - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - - # Delete unneeded files - rm -rf \ - usr/lib \ - usr/share \ - usr/include - - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append dmraid to cpio!" - - cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" - if isTrue "${CLEANUP}" - then - rm -rf "${TDIR}" - fi -} - -append_iscsi() { - local PN=open-iscsi - local TDIR="${TEMP}/initramfs-${PN}-temp" - if [ -d "${TDIR}" ] - then - rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" - fi - - populate_binpkg ${PN} - - mkdir -p "${TDIR}" || gen_die "Failed to create '${TDIR}'!" - - unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" - - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append iscsi to cpio!" - - cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" - if isTrue "${CLEANUP}" - then - rm -rf "${TDIR}" - fi -} - -append_keyutils() { - local PN=keyutils - local TDIR="${TEMP}/initramfs-${PN}-temp" - if [ -d "${TDIR}" ] - then - rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" - fi - - populate_binpkg ${PN} - - mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" - - unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" - - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append ${PN} to cpio!" - - cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" - if isTrue "${CLEANUP}" - then - rm -rf "${TDIR}" - fi -} - -append_lvm() { - local PN=lvm - local TDIR="${TEMP}/initramfs-${PN}-temp" - if [ -d "${TDIR}" ] - then - rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" - fi - - populate_binpkg ${PN} - populate_binpkg thin-provisioning-tools - - mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" - - unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" - unpack "$(get_gkpkg_binpkg "thin-provisioning-tools")" "${TDIR}" - - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - - local mydir= - for mydir in \ - etc/lvm/cache \ - sbin \ - ; do - mkdir -p ${mydir} || gen_die "Failed to create '${TDIR}/${mydir}'!" - done - - # Delete unneeded files - rm -rf \ - usr/lib/device-mapper \ - usr/lib/pkgconfig \ - usr/lib/lib* \ - usr/sbin/dm* \ - usr/share \ - usr/include - - # Include the LVM config - if [ -x /sbin/lvm -o -x /bin/lvm ] - then - local ABORT_ON_ERRORS=$(kconfig_get_opt "/etc/lvm/lvm.conf" "abort_on_errors") - if isTrue "${ABORT_ON_ERRORS}" && [[ ${CBUILD} == ${CHOST} ]] - then - # Make sure the LVM binary we created is able to handle - # system's lvm.conf - "${TDIR}"/sbin/lvm dumpconfig 1>"${TDIR}"/etc/lvm/lvm.conf 2>/dev/null \ - || gen_die "Bundled LVM version does NOT support system's lvm.conf!" - - # Sanity check - if [ ! -s "${TDIR}/etc/lvm/lvm.conf" ] - then - gen_die "Sanity check failed: '${TDIR}/etc/lvm/lvm.conf' looks empty?!" - fi - else - cp -aL /etc/lvm/lvm.conf "${TDIR}"/etc/lvm/lvm.conf 2>/dev/null \ - || gen_die "Failed to copy '/etc/lvm/lvm.conf'!" - fi - - # Some LVM config options need changing, because the functionality is - # not compiled in: - sed -r -i \ - -e '/^[[:space:]]*obtain_device_list_from_udev/s,=.*,= 1,g' \ - -e '/^[[:space:]]*udev_sync/s,=.*,= 1,g' \ - -e '/^[[:space:]]*use_lvmetad/s,=.*,= 0,g' \ - -e '/^[[:space:]]*use_lvmlockd/s,=.*,= 0,g' \ - -e '/^[[:space:]]*use_lvmpolld/s,=.*,= 0,g' \ - -e '/^[[:space:]]*monitoring/s,=.*,= 0,g' \ - -e '/^[[:space:]]*external_device_info_source/s,=.*,= "none",g' \ - -e '/^[[:space:]]*units/s,=.*"r",= "h",g' \ - -e '/^[[:space:]]*thin_repair_executable/s,=.*,= /usr/sbin/thin_repair,g' \ - -e '/^[[:space:]]*thin_dump_executable/s,=.*,= /usr/sbin/thin_dump,g' \ - -e '/^[[:space:]]*thin_check_executable/s,=.*,= /usr/sbin/thin_check,g' \ - "${TDIR}"/etc/lvm/lvm.conf \ - || gen_die 'Could not sed lvm.conf!' - fi - - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append lvm to cpio!" - - cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" - if isTrue "${CLEANUP}" - then - rm -rf "${TDIR}" - fi -} - -append_mdadm() { - local PN=mdadm - local TDIR="${TEMP}/initramfs-${PN}-temp" - if [ -d "${TDIR}" ] - then - rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" - fi - - populate_binpkg ${PN} - - mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - - local mydir= - for mydir in \ - etc \ - sbin \ - ; do - mkdir -p "${TDIR}"/${mydir} || gen_die "Failed to create '${TDIR}/${mydir}'!" - done - - unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" - - if [ -n "${MDADM_CONFIG}" ] - then - print_info 2 "$(get_indent 2)${PN}: >> Adding '${MDADM_CONFIG}' ..." - - if [ -f "${MDADM_CONFIG}" ] - then - cp -aL "${MDADM_CONFIG}" "${TDIR}"/etc/mdadm.conf 2>/dev/null \ - || gen_die "Failed to copy '${MDADM_CONFIG}'!" - else - gen_die "Specified '${MDADM_CONFIG}' does not exist!" - fi - else - print_info 2 "$(get_indent 2)${PN}: >> --mdadm-config not set; Skipping inclusion of mdadm.conf ..." - fi - - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append ${PN} to cpio!" - - cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" - if isTrue "${CLEANUP}" - then - rm -rf "${TDIR}" - fi -} - -append_xfsprogs() { - local PN=xfsprogs - local TDIR="${TEMP}/initramfs-${PN}-temp" - if [ -d "${TDIR}" ] - then - rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" - fi - - populate_binpkg ${PN} - - mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" - - unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" - - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append ${PN} to cpio!" - - cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" - if isTrue "${CLEANUP}" - then - rm -rf "${TDIR}" - fi -} - -append_zfs() { - local PN=zfs - local TDIR="${TEMP}/initramfs-${PN}-temp" - if [ -d "${TDIR}" ] - then - rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" - fi - - mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" - - mkdir -p "${TDIR}"/etc/zfs || gen_die "Failed to create '${TDIR}/etc/zfs'!" - - # Copy files to /etc/zfs - local i - for i in vdev_id.conf zdev.conf zpool.cache - do - if [ -f /etc/zfs/${i} ] - then - print_info 2 "$(get_indent 2)${PN}: >> Including ${i}" - cp -aL "/etc/zfs/${i}" "${TDIR}/etc/zfs/${i}" 2>/dev/null \ - || gen_die "Could not copy file '/etc/zfs/${i}' for ZFS" - fi - done - - if [ -f "/etc/hostid" ] - then - local _hostid=$(hostid 2>/dev/null) - print_info 2 "$(get_indent 2)${PN}: >> Embedding hostid '${_hostid}' into initramfs ..." - cp -aL /etc/hostid "${TDIR}"/etc/hostid 2>/dev/null \ - || gen_die "Failed to copy /etc/hostid" - - echo "${_hostid}" > "${TEMP}"/.embedded_hostid \ - || gen_die "Failed to record system's hostid!" - else - print_warning 1 "$(get_indent 2)${PN}: /etc/hostid not found; You must use 'spl_hostid' kernel command-line parameter!" - fi - - copy_binaries "${TDIR}" /sbin/{mount.zfs,zdb,zfs,zpool} - - local udevdir=$(get_udevdir) - local udevdir_initramfs="/usr/lib/udev" - local udev_files=( $(qlist -eC sys-fs/zfs:0 \ - | grep -E -- "^${udevdir}") - ) - - if [ ${#udev_files[@]} -eq 0 ] - then - gen_die "Something went wrong: Did not found any udev-related files for sys-fs/zfs!" - fi - - mkdir -p "${TDIR}"/usr/lib/udev/rules.d || gen_die "Failed to create '${TDIR}/usr/lib/udev/rules.d'!" - - local udev_files - for udev_file in "${udev_files[@]}" - do - local dest_file="${TDIR%/}${udev_file/${udevdir}/${udevdir_initramfs}}" - cp -aL "${udev_file}" "${dest_file}" \ - || gen_die "Failed to copy '${udev_file}' to '${dest_file}'" - - if [[ "${dest_file}" == *.rules ]] - then - print_info 5 "Updating UDEV dir in '${dest_file}' ..." - sed -i \ - -e "s|${udevdir}|${udevdir_initramfs}|g" \ - "${dest_file}" \ - || gen_die "Failed to update UDEV dir in '${dest_file}'" - fi - done - - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append ${PN} to cpio!" - - cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" - if isTrue "${CLEANUP}" - then - rm -rf "${TDIR}" - fi -} - -append_btrfs() { - local PN=btrfs-progs - local TDIR="${TEMP}/initramfs-${PN}-temp" - if [ -d "${TDIR}" ] - then - rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" - fi - - populate_binpkg ${PN} - - mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" - - unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" - - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append ${PN} to cpio!" - - cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" - if isTrue "${CLEANUP}" - then - rm -rf "${TDIR}" - fi -} - -append_libgcc_s() { - local TDIR="${TEMP}/initramfs-libgcc_s-temp" - if [ -d "${TDIR}" ] - then - rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" - fi - - mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - - # Include libgcc_s.so.1: - # - workaround for zfsonlinux/zfs#4749 - # - required for LUKS2 (libargon2 uses pthread_cancel) - local libgccpath - if type gcc-config 2>&1 1>/dev/null; then - libgccpath="/usr/lib/gcc/$(s=$(gcc-config -c); echo ${s%-*}/${s##*-})/libgcc_s.so.1" - fi - if [[ ! -f ${libgccpath} ]]; then - libgccpath="/usr/lib/gcc/*/*/libgcc_s.so.1" - fi - - copy_binaries "${TDIR}" ${libgccpath} - - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append libgcc_s to cpio!" - - cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" - if isTrue "${CLEANUP}" - then - rm -rf "${TDIR}" - fi -} - -append_linker() { - local TDIR="${TEMP}/initramfs-linker-temp" - if [ -d "${TDIR}" ] - then - rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" - fi - - mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - - mkdir -p "${TDIR}"/etc || gen_die "Failed to create '${TDIR}/etc'!" - - if isTrue "$(tc-is-cross-compiler)" - then - # We cannot copy ld files from host because they could be - # incompatible with CHOST. Instead, add ldconfig to allow - # initramfs to regenerate on its own (default /etc/ld.so.conf - # for initramfs was added via append_base_layout()). - mkdir -p "${TDIR}"/sbin || gen_die "Failed to create '${TDIR}/sbin'!" - - local libdir=$(get_chost_libdir) - copy_system_binaries "${TDIR}/sbin" "${libdir%/usr\/*}/sbin/ldconfig" - else - # Only copy /etc/ld.so.conf.d -- /etc/ld.so.conf was already - # added to CPIO via append_base_layout() and because we only - # append to CPIO, that file wouldn't be used at all. - if [ -d "/etc/ld.so.conf.d" ] - then - mkdir -p "${TDIR}"/etc/ld.so.conf.d || gen_die "Failed to create '${TDIR}/etc/ld.so.conf.d'!" - cp -arL "/etc/ld.so.conf.d" "${TDIR}"/etc \ - || gen_die "Failed to copy '/etc/ld.so.conf.d'!" - fi - - if [ -e "/etc/ld.so.cache" ] - then - cp -aL "/etc/ld.so.cache" "${TDIR}"/etc/ld.so.cache \ - || gen_die "Failed to copy '/etc/ld.so.cache'!" - fi - fi - - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append linker to cpio!" - - cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" - if isTrue "${CLEANUP}" - then - rm -rf "${TDIR}" - fi -} - -append_splash() { - local TDIR="${TEMP}/initramfs-splash-temp" - if [ -d "${TDIR}" ] - then - rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" - fi - - mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - - if [ -z "${SPLASH_THEME}" -a -e /etc/conf.d/splash ] - then - source /etc/conf.d/splash &>/dev/null || gen_die "Failed to source '/etc/conf.d/splash'!" - fi - - if [ -z "${SPLASH_THEME}" ] - then - SPLASH_THEME=default - fi - - print_info 1 "$(get_indent 1)>> Installing splash [ using the ${SPLASH_THEME} theme ] ..." - - local res_param="" - [ -n "${SPLASH_RES}" ] && res_param="-r ${SPLASH_RES}" - splash_geninitramfs -c "${TDIR}" ${res_param} ${SPLASH_THEME} \ - || gen_die "Failed to build splash cpio archive" - - if [ -e "/usr/share/splashutils/initrd.splash" ] - then - mkdir -p "${TDIR}"/etc || gen_die "Failed to create '${TDIR}/etc'!" - cp -f /usr/share/splashutils/initrd.splash "${TDIR}"/etc/ 2>/dev/null \ - gen_die "Failed to copy '/usr/share/splashutils/initrd.splash'!" - fi - - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append splash to cpio!" - - cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" - if isTrue "${CLEANUP}" - then - rm -rf "${TDIR}" - fi -} - -append_plymouth() { - local PN=plymouth - local TDIR="${TEMP}/initramfs-${PN}-temp" - if [ -d "${TDIR}" ] - then - rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" - fi - - mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - - # set plymouth theme - if [ -n "${PLYMOUTH_THEME}" ] - then - plymouth-set-default-theme ${PLYMOUTH_THEME} || gen_die "Failed to set default plymouth theme!" - fi - if [ -z "${PLYMOUTH_THEME}" -a -e /etc/plymouth/plymouthd.conf ] - then - PLYMOUTH_THEME=$(plymouth-set-default-theme) || gen_die "Failed to set default plymouth theme!" - fi - if [ -z "${PLYMOUTH_THEME}" ] - then - PLYMOUTH_THEME=text - fi - - print_info 1 "$(get_indent 1)>> Installing plymouth [ using the '${PLYMOUTH_THEME}' theme ]..." - - /usr/libexec/plymouth/plymouth-populate-initrd -t "${TDIR}" \ - || gen_die "Failed to build plymouth cpio archive!" - - # can probably get rid of this; depends if plymouth was built with static libs - # rm -f "${TDIR}"/lib*/{ld*,libc*,libz*} \ - # || gen_die "Failed to clean up plymouth cpio archive!" - - ln -sf "${PLYMOUTH_THEME}/${PLYMOUTH_THEME}.plymouth" "${TDIR}/usr/share/plymouth/themes/default.plymouth" \ - || gen_die "Failed to set the default plymouth theme!" - - # include required udev rules - mkdir -p "${TDIR}"/usr/lib/udev/rules.d || gen_die "Failed to create '${TDIR}/usr/lib/udev/rules.d'!" - cp -aL /lib/udev/rules.d/70-uaccess.rules "${TDIR}/usr/lib/udev/rules.d" || gen_die "Failed to copy '70-uaccess.rules'!" - cp -aL /lib/udev/rules.d/71-seat.rules "${TDIR}/usr/lib/udev/rules.d" || gen_die "Failed to copy '71-seat.rules'!" - - # clean up - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append ${PN} to cpio!" - - cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" - if isTrue "${CLEANUP}" - then - rm -rf "${TDIR}" - fi -} - -append_strace() { - local PN=strace - local TDIR="${TEMP}/initramfs-${PN}-temp" - if [ -d "${TDIR}" ] - then - rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" - fi - - populate_binpkg ${PN} - - mkdir -p "${TDIR}" || gen_die "Failed to create '${TDIR}'!" - - unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" - - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append ${PN} to cpio!" - - cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" - if isTrue "${CLEANUP}" - then - rm -rf "${TDIR}" - fi -} - -append_overlay() { - cd "${INITRAMFS_OVERLAY}" || gen_die "Failed to chdir to '${INITRAMFS_OVERLAY}'!" - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append overlay to cpio!" -} - -append_luks() { - local PN=cryptsetup - local TDIR="${TEMP}/initramfs-luks-temp" - if [ -d "${TDIR}" ] - then - rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" - fi - - populate_binpkg ${PN} - - mkdir -p "${TDIR}" || gen_die "Failed to create '${TDIR}'!" - - unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" - - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - - # Delete unneeded files - rm -rf usr/ - - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append luks to cpio!" - - cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" - if isTrue "${CLEANUP}" - then - rm -rf "${TDIR}" - fi -} - -append_dropbear() { - local PN=dropbear - local TDIR="${TEMP}/initramfs-${PN}-temp" - if [ -d "${TDIR}" ] - then - rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" - fi - - local dropbear_command= - if ! isTrue "$(is_valid_ssh_host_keys_parameter_value "${SSH_HOST_KEYS}")" - then - gen_die "--ssh-host-keys value '${SSH_HOST_KEYS}' is unsupported!" - elif [[ "${SSH_HOST_KEYS}" == 'create' ]] - then - dropbear_command=dropbearkey - else - dropbear_command=dropbearconvert - fi - - if [ -z "${DROPBEAR_AUTHORIZED_KEYS_FILE}" ] - then - gen_die "Something went wrong: DROPBEAR_AUTHORIZED_KEYS_FILE should already been set but is missing!" - fi - - populate_binpkg ${PN} - - mkdir -p "${TDIR}" || gen_die "Failed to create '${TDIR}'!" - - unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" - - if [[ "${SSH_HOST_KEYS}" == 'runtime' ]] - then - print_info 2 "$(get_indent 2)${PN}: >> No SSH host key embedded due to --ssh-host-key=runtime; Dropbear will generate required host key(s) at runtime!" - else - if ! hash ssh-keygen &>/dev/null - then - gen_die "'ssh-keygen' program is required but missing!" - fi - - local initramfs_dropbear_dir="${TDIR}/etc/dropbear" - - if [[ "${SSH_HOST_KEYS}" == 'create-from-host' ]] - then - print_info 3 "$(get_indent 2)${PN}: >> Checking for existence of all SSH host keys ..." - local missing_ssh_host_keys=no - - if [ ! -f "/etc/ssh/ssh_host_rsa_key" ] - then - print_info 3 "$(get_indent 2)${PN}: >> SSH host key '/etc/ssh/ssh_host_rsa_key' is missing!" - missing_ssh_host_keys=yes - fi - - if [ ! -f "/etc/ssh/ssh_host_ecdsa_key" ] - then - print_info 3 "$(get_indent 2)${PN}: >> SSH host key '/etc/ssh/ssh_host_ecdsa_key' is missing!" - missing_ssh_host_keys=yes - fi - - if [ ! -f "/etc/ssh/ssh_host_ed25519_key" ] - then - print_info 3 "$(get_indent 2)${PN}: >> SSH host key '/etc/ssh/ssh_host_ed25519_key' is missing!" - missing_ssh_host_keys=yes - fi - - if isTrue "${missing_ssh_host_keys}" - then - # Should only happen when installing a new system ... - print_info 3 "$(get_indent 2)${PN}: >> Creating missing SSH host key(s) ..." - ssh-keygen -A || gen_die "Failed to generate host's SSH host key(s) using 'ssh-keygen -A'!" - fi - fi - - local -a required_dropbear_host_keys=( - /etc/dropbear/dropbear_ecdsa_host_key - /etc/dropbear/dropbear_ed25519_host_key - /etc/dropbear/dropbear_rsa_host_key - ) - - local i=0 - local n_required_dropbear_keys=${#required_dropbear_host_keys[@]} - local required_key= - while [[ ${i} < ${n_required_dropbear_keys} ]] - do - required_key=${required_dropbear_host_keys[${i}]} - print_info 3 "$(get_indent 2)${PN}: >> Checking for existence of dropbear host key '${required_key}' ..." - if [[ -f "${required_key}" ]] - then - if [[ ! -s "${required_key}" ]] - then - print_info 1 "$(get_indent 2)${PN}: >> Dropbear host key '${required_key}' exists but is empty; Removing ..." - rm "${required_key}" || gen_die "Failed to remove invalid '${required_key}' null byte file!" - elif [[ "${SSH_HOST_KEYS}" == 'create-from-host' ]] \ - && [[ "${required_key}" == *_rsa_* ]] \ - && [[ "${required_key}" -ot "/etc/ssh/ssh_host_rsa_key" ]] - then - print_info 1 "$(get_indent 2)${PN}: >> Dropbear host key '${required_key}' exists but is older than '/etc/ssh/ssh_host_rsa_key'; Removing to force update due to --ssh-host-key=create-from-host ..." - rm "${required_key}" || gen_die "Failed to remove outdated '${required_key}' file!" - elif [[ "${SSH_HOST_KEYS}" == 'create-from-host' ]] \ - && [[ "${required_key}" == *_ecdsa_* ]] \ - && [[ "${required_key}" -ot "/etc/ssh/ssh_host_ecdsa_key" ]] - then - print_info 1 "$(get_indent 2)${PN}: >> Dropbear host key '${required_key}' exists but is older than '/etc/ssh/ssh_host_ecdsa_key'; Removing to force update due to --ssh-host-key=create-from-host ..." - rm "${required_key}" || gen_die "Failed to remove outdated '${required_key}' file!" - elif [[ "${SSH_HOST_KEYS}" == 'create-from-host' ]] \ - && [[ "${required_key}" == *_ed25519_* ]] \ - && [[ "${required_key}" -ot "/etc/ssh/ssh_host_ed25519_key" ]] - then - print_info 1 "$(get_indent 2)${PN}: >> Dropbear host key '${required_key}' exists but is older than '/etc/ssh/ssh_host_ed25519_key'; Removing to force update due to --ssh-host-key=create-from-host ..." - rm "${required_key}" || gen_die "Failed to remove outdated '${required_key}' file!" - else - print_info 3 "$(get_indent 2)${PN}: >> Dropbear host key '${required_key}' exists!" - unset required_dropbear_host_keys[${i}] - fi - else - print_info 3 "$(get_indent 2)${PN}: >> Dropbear host key '${required_key}' is missing! Will create ..." - fi - - i=$((i + 1)) - done - - if [[ ${#required_dropbear_host_keys[@]} -gt 0 ]] - then - if isTrue "$(can_run_programs_compiled_by_genkernel)" - then - dropbear_command="${TDIR}/usr/bin/${dropbear_command}" - print_info 3 "$(get_indent 2)${PN}: >> Will use '${dropbear_command}' to create missing keys ..." - elif hash ${dropbear_command} &>/dev/null - then - print_info 3 "$(get_indent 2)${PN}: >> Will use existing '${dropbear_command}' program from path to create missing keys ..." - else - local error_msg="Need to generate '${required_dropbear_host_keys[*]}' but '${dropbear_command}'" - error_msg+=" program is missing. Please install net-misc/dropbear and re-run genkernel!" - gen_die "${error_msg}" - fi - - local missing_key= - for missing_key in ${required_dropbear_host_keys[@]} - do - dropbear_create_key "${missing_key}" "${dropbear_command}" - - # just in case ... - if [ -f "${missing_key}" ] - then - print_info 3 "$(get_indent 2)${PN}: >> Dropbear host key '${missing_key}' successfully created!" - else - gen_die "Sanity check failed: '${missing_key}' should exist at this stage but does NOT." - fi - done - else - print_info 2 "$(get_indent 2)${PN}: >> Using existing dropbear host keys from /etc/dropbear ..." - fi - - cp -aL --target-directory "${initramfs_dropbear_dir}" /etc/dropbear/dropbear_{rsa,ecdsa,ed25519}_host_key \ - || gen_die "Failed to copy '/etc/dropbear/dropbear_{rsa,ecdsa,ed25519}_host_key'" - - # Try to show embedded dropbear host key details for security reasons. - # We do it that complicated to get common used formats. - local -a key_info_files=() - local -a missing_key_info_files=() - - local host_key_file= host_key_file_checksum= host_key_info_file= - while IFS= read -r -u 3 -d $'\0' host_key_file - do - host_key_file_checksum=$(sha256sum "${host_key_file}" 2>/dev/null | awk '{print $1}') - if [ -z "${host_key_file_checksum}" ] - then - gen_die "Failed to generate SHA256 checksum of '${host_key_file}'!" - fi - - host_key_info_file="${GK_V_CACHEDIR}/$(basename "${host_key_file}").${host_key_file_checksum:0:10}.info" - - if [ ! -s "${host_key_info_file}" ] - then - missing_key_info_files+=( ${host_key_info_file} ) - else - key_info_files+=( ${host_key_info_file} ) - fi - done 3< <(find "${initramfs_dropbear_dir}" -type f -name '*_key' -print0 2>/dev/null) - unset host_key_file host_key_file_checksum host_key_info_file - IFS="${GK_DEFAULT_IFS}" - - if [[ ${#missing_key_info_files[@]} -ne 0 ]] - then - dropbear_command= - if isTrue "$(can_run_programs_compiled_by_genkernel)" - then - dropbear_command="${TDIR}/usr/bin/dropbearconvert" - print_info 3 "$(get_indent 2)${PN}: >> Will use '${dropbear_command}' to extract embedded host key information ..." - elif hash dropbearconvert &>/dev/null - then - dropbear_command=dropbearconvert - print_info 3 "$(get_indent 2)${PN}: >> Will use existing '${dropbear_command}' program to extract embedded host key information ..." - else - print_warning 2 "$(get_indent 2)${PN}: >> 'dropbearconvert' program not available; Cannot generate missing key information for ${#missing_key_info_files[@]} key(s)!" - fi - - if [[ -n "${dropbear_command}" ]] - then - # We are missing at least information for one embedded key - # but looks like we are able to generate the missing information ... - local missing_key_info_file= - for missing_key_info_file in "${missing_key_info_files[@]}" - do - dropbear_generate_key_info_file "${dropbear_command}" "${missing_key_info_file}" "${initramfs_dropbear_dir}" - key_info_files+=( ${missing_key_info_file} ) - done - unset missing_key_info_file - fi - fi - - if [[ ${#key_info_files[@]} -gt 0 ]] - then - # We have at least information about one embedded key ... - print_info 1 "=================================================================" 1 0 1 - print_info 1 "This initramfs' sshd will use the following host key(s):" 1 0 1 - - local key_info_file= - for key_info_file in "${key_info_files[@]}" - do - print_info 1 "$(cat "${key_info_file}")" 1 0 1 - done - unset key_info_file - - if [ ${LOGLEVEL} -lt 3 ] - then - # Don't clash with output from log_future_cpio_content - print_info 1 "=================================================================" 1 0 1 - fi - else - print_warning 2 "$(get_indent 2)${PN}: >> No information about embedded SSH host key(s) available." - fi - fi - - if isTrue "$(is_glibc)" - then local libdir=$(get_chost_libdir) - local libnss_files="${libdir}/libnss_files.so" - - # NSS files module was moved into libc in >=glibc-2.34 - # but when this file exists we are probably dealing with older glibc - # and need to manually copy the module. - if [[ -f "${libnss_files}" ]] - then - mkdir -p "${TDIR}"/lib || gen_die "Failed to create '${TDIR}/lib'!" - copy_system_binaries "${TDIR}"/lib "${libnss_files}" - fi - fi - - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - - cp -a "${GK_SHARE}"/defaults/login-remote.sh "${TDIR}"/usr/bin/ \ - || gen_die "Failed to copy '${GK_SHARE}/defaults/login-remote.sh'" - - cp -a "${GK_SHARE}"/defaults/resume-boot.sh "${TDIR}"/usr/sbin/resume-boot \ - || gen_die "Failed to copy '${GK_SHARE}/defaults/resume-boot.sh' to '${TDIR}/usr/sbin/resume-boot'" - - cp -a "${GK_SHARE}"/defaults/unlock-luks.sh "${TDIR}"/usr/sbin/unlock-luks \ - || gen_die "Failed to copy '${GK_SHARE}/defaults/unlock-luks.sh' to '${TDIR}/usr/sbin/unlock-luks'" - - cp -a "${GK_SHARE}"/defaults/unlock-zfs.sh "${TDIR}"/usr/sbin/unlock-zfs \ - || gen_die "Failed to copy '${GK_SHARE}/defaults/unlock-zfs.sh' to '${TDIR}/usr/sbin/unlock-zfs'" - - cp -aL "${DROPBEAR_AUTHORIZED_KEYS_FILE}" "${TDIR}"/root/.ssh/ \ - || gen_die "Failed to copy '${DROPBEAR_AUTHORIZED_KEYS_FILE}'!" - - cp -aL /etc/localtime "${TDIR}"/etc/ \ - || gen_die "Failed to copy '/etc/localtime'. Please set system's timezone!" - - - echo "/usr/bin/login-remote.sh" > "${TDIR}"/etc/shells \ - || gen_die "Failed to create '/etc/shells'!" - - chmod 0755 "${TDIR}"/usr/bin/login-remote.sh \ - || gen_die "Failed to chmod of '${TDIR}/usr/bin/login-remote.sh'!" - - chmod 0755 "${TDIR}"/usr/sbin/resume-boot \ - || gen_die "Failed to chmod of '${TDIR}/usr/sbin/resume-boot'!" - - chmod 0755 "${TDIR}"/usr/sbin/unlock-luks \ - || gen_die "Failed to chmod of '${TDIR}/usr/sbin/unlock-luks'!" - - chmod 0755 "${TDIR}"/usr/sbin/unlock-zfs \ - || gen_die "Failed to chmod of '${TDIR}/usr/sbin/unlock-zfs'!" - - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append ${PN} to cpio!" - - cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" - if isTrue "${CLEANUP}" - then - rm -rf "${TDIR}" - fi -} - -append_firmware() { - local TDIR="${TEMP}/initramfs-firmware-temp" - if [ -d "${TDIR}" ] - then - rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" - fi - - mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - - if [ ! -d "${FIRMWARE_DIR}" ] - then - gen_die "Specified firmware directory '${FIRMWARE_DIR}' does not exist!" - fi - - mkdir -p "${TDIR}"/lib/firmware || gen_die "Failed to create '${TDIR}/lib/firmware'!" - - local -a fwlist=() - - if isTrue "${ALLFIRMWARE}" - then - cp -a "${FIRMWARE_DIR}"/* "${TDIR}"/lib/firmware/ 2>/dev/null \ - || gen_die "Failed to copy firmware files to '${TDIR}/lib/firmware'!" - elif [ ${#FIRMWARE_FILES[@]} -gt 0 ] - then - fwlist=( "${FIRMWARE_FILES[@]}" ) + copy_system_binaries "${TDIR}/sbin" "${libdir%/usr\/*}/sbin/ldconfig" else - local myfw= - local -a myfw_f=() - while IFS= read -r -u 3 myfw - do - if [ -z "${myfw}" ] - then - gen_die "modinfo error!" - fi - - myfw_f=( $(compgen -G "${FIRMWARE_DIR}/${myfw}*") ) - - if [ ${#myfw_f[@]} -gt 1 ] - then - gen_die "excessive number of firmwares!" - fi - - if [ ${#myfw_f[@]} -lt 1 ] - then - print_warning 3 "$(get_indent 3) - ${myfw} is missing; Ignoring ..." - continue - fi - - fwlist+=( "${myfw_f#${FIRMWARE_DIR}/}" ) - done 3< <( ( - modinfo -b "${KERNEL_MODULES_PREFIX%/}" -k "${KV}" -F firmware $(mod_dep_list) 2>/dev/null || echo - ) | sort | uniq ) - fi - - if [ ${#fwlist[@]} -gt 0 ] - then - pushd "${FIRMWARE_DIR}" &>/dev/null || gen_die "Failed to chdir to '${FIRMWARE_DIR}'!" - cp -rL --parents --target-directory="${TDIR}/lib/firmware" "${fwlist[@]}" 2>/dev/null \ - || gen_die "Failed to copy firmware files to '${TDIR}/lib/firmware'!" - popd &>/dev/null || gen_die "Failed to chdir!" - - pushd "${TDIR}/lib/firmware" &>/dev/null || gen_die "Failed to chdir to '${TDIR}/lib/firmware'!" - find_and_unpack xz zstd - popd &>/dev/null || gen_die "Failed to chdir!" - fi - - cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" - log_future_cpio_content - find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append firmware to cpio!" - - cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" - if isTrue "${CLEANUP}" - then - rm -rf "${TDIR}" - fi -} - -append_gpg() { - local PN=gnupg - local TDIR="${TEMP}/initramfs-${PN}-temp" - if [ -d "${TDIR}" ] - then - rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" - fi - - populate_binpkg ${PN} - - mkdir -p "${TDIR}" || gen_die "Failed to create '${TDIR}'!" + # Only copy /etc/ld.so.conf.d -- /etc/ld.so.conf was already + # added to CPIO via append_base_layout() and because we only + # append to CPIO, that file wouldn't be used at all. + if [ -d "/etc/ld.so.conf.d" ] + then + mkdir -p "${TDIR}"/etc/ld.so.conf.d || gen_die "Failed to create '${TDIR}/etc/ld.so.conf.d'!" + cp -arL "/etc/ld.so.conf.d" "${TDIR}"/etc \ + || gen_die "Failed to copy '/etc/ld.so.conf.d'!" + fi - unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" + if [ -e "/etc/ld.so.cache" ] + then + cp -aL "/etc/ld.so.cache" "${TDIR}"/etc/ld.so.cache \ + || gen_die "Failed to copy '/etc/ld.so.cache'!" + fi + fi cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" log_future_cpio_content find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ - || gen_die "Failed to append ${PN} to cpio!" + || gen_die "Failed to append linker to cpio!" cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" if isTrue "${CLEANUP}" @@ -2141,6 +882,74 @@ append_auxiliary() { fi } +append_busybox() { + local PN=busybox + local TDIR="${TEMP}/initramfs-${PN}-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi + + populate_binpkg ${PN} + + mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" + + unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + + # Delete unneeded files + rm -rf configs/ + + mkdir -p "${TDIR}"/usr/share/udhcpc || gen_die "Failed to create '${TDIR}/usr/share/udhcpc'!" + + cp -a "${GK_SHARE}"/defaults/udhcpc.scripts usr/share/udhcpc/default.script 2>/dev/null \ + || gen_die "Failed to copy '${GK_SHARE}/defaults/udhcpc.scripts' to '${TDIR}/usr/share/udhcpc/default.script'!" + + local myfile= + for myfile in \ + bin/busybox \ + usr/share/udhcpc/default.script \ + ; do + chmod +x "${TDIR}"/${myfile} || gen_die "Failed to chmod of '${TDIR}/${myfile}'!" + done + + # Set up a few default symlinks + local required_applets='[ ash sh mkdir mknod mount uname echo chmod cut cat touch' + local required_applet= + for required_applet in ${required_applets} + do + ln -s busybox "${TDIR}"/bin/${required_applet} \ + || gen_die "Failed to create Busybox symlink for '${required_applet}' applet!" + done + + # allow for DNS resolution + if isTrue "$(is_glibc)" + then + local libdir=$(get_chost_libdir) + local libnss_dns="${libdir}/libnss_dns.so" + + # NSS dns module was moved into libc in >=glibc-2.34 + # but when this file exists we are probably dealing with older glibc + # and need to manually copy the module. + if [[ -f "${libnss_dns}" ]] + then + mkdir -p "${TDIR}"/lib || gen_die "Failed to create '${TDIR}/lib'!" + copy_system_binaries "${TDIR}"/lib "${libnss_dns}" + fi + fi + + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append ${PN} to cpio!" + + cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" + if isTrue "${CLEANUP}" + then + rm -rf "${TDIR}" + fi +} + append_data() { [ $# -eq 0 ] && gen_die "append_data() called with zero arguments" @@ -2156,6 +965,176 @@ append_data() { fi } +append_eudev() { + local PN=eudev + local TDIR="${TEMP}/initramfs-${PN}-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi + + populate_binpkg ${PN} + populate_binpkg hwids + + mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" + + unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" + unpack "$(get_gkpkg_binpkg hwids)" "${TDIR}" + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + + if isTrue "$(can_run_programs_compiled_by_genkernel)" + then + print_info 2 "$(get_indent 2)${PN}: >> Pre-generating initramfs' /etc/udev/hwdb.bin ..." + + local gen_hwdb_cmd=( "${TDIR}/usr/bin/udevadm" ) + gen_hwdb_cmd+=( hwdb --update --root "${TDIR}" ) + print_info 3 "COMMAND: ${gen_hwdb_cmd[*]}" 1 0 1 + eval "${gen_hwdb_cmd[@]}" 2>&1 | tee -a "${LOGFILE}" \ + || gen_die "Failed to pre-generate initramfs' /etc/udev/hwdb.bin!" + + # Now that we have a pre-generated hwdb in initramfs + # we can delete source files + rm -rf usr/lib/udev/hwdb.d/ + fi + + # Delete unneeded files + rm -rf usr/include \ + usr/lib/libu* \ + usr/lib/pkgconfig \ + usr/share + + # Disable predictable network interface names in initramfs + echo "" > usr/lib/udev/rules.d/80-net-name-slot.rules \ + || gen_die "Failed to disable predictable network interface naming rule" + + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append ${PN} to cpio!" + + cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" + if isTrue "${CLEANUP}" + then + rm -rf "${TDIR}" + fi +} + +append_firmware() { + local TDIR="${TEMP}/initramfs-firmware-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi + + mkdir "${TDIR}" || gen_die "Failed to create '${TDIR}'!" + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + + if [ ! -d "${FIRMWARE_DIR}" ] + then + gen_die "Specified firmware directory '${FIRMWARE_DIR}' does not exist!" + fi + + mkdir -p "${TDIR}"/lib/firmware || gen_die "Failed to create '${TDIR}/lib/firmware'!" + + local -a fwlist=() + + if isTrue "${ALLFIRMWARE}" + then + cp -a "${FIRMWARE_DIR}"/* "${TDIR}"/lib/firmware/ 2>/dev/null \ + || gen_die "Failed to copy firmware files to '${TDIR}/lib/firmware'!" + elif [ ${#FIRMWARE_FILES[@]} -gt 0 ] + then + fwlist=( "${FIRMWARE_FILES[@]}" ) + else + local myfw= + local -a myfw_f=() + while IFS= read -r -u 3 myfw + do + if [ -z "${myfw}" ] + then + gen_die "modinfo error!" + fi + + myfw_f=( $(compgen -G "${FIRMWARE_DIR}/${myfw}*") ) + + if [ ${#myfw_f[@]} -gt 1 ] + then + gen_die "excessive number of firmwares!" + fi + + if [ ${#myfw_f[@]} -lt 1 ] + then + print_warning 3 "$(get_indent 3) - ${myfw} is missing; Ignoring ..." + continue + fi + + fwlist+=( "${myfw_f#${FIRMWARE_DIR}/}" ) + done 3< <( ( + modinfo -b "${KERNEL_MODULES_PREFIX%/}" -k "${KV}" -F firmware $(mod_dep_list) 2>/dev/null || echo + ) | sort | uniq ) + fi + + if [ ${#fwlist[@]} -gt 0 ] + then + pushd "${FIRMWARE_DIR}" &>/dev/null || gen_die "Failed to chdir to '${FIRMWARE_DIR}'!" + cp -rL --parents --target-directory="${TDIR}/lib/firmware" "${fwlist[@]}" 2>/dev/null \ + || gen_die "Failed to copy firmware files to '${TDIR}/lib/firmware'!" + popd &>/dev/null || gen_die "Failed to chdir!" + + pushd "${TDIR}/lib/firmware" &>/dev/null || gen_die "Failed to chdir to '${TDIR}/lib/firmware'!" + find_and_unpack xz zstd + popd &>/dev/null || gen_die "Failed to chdir!" + fi + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append firmware to cpio!" + + cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" + if isTrue "${CLEANUP}" + then + rm -rf "${TDIR}" + fi +} + +append_util-linux() { + local PN="util-linux" + local TDIR="${TEMP}/initramfs-util-linux-temp" + if [ -d "${TDIR}" ] + then + rm -r "${TDIR}" || gen_die "Failed to clean out existing '${TDIR}'!" + fi + + populate_binpkg ${PN} + + mkdir -p "${TDIR}" || gen_die "Failed to create '${TDIR}'!" + + unpack "$(get_gkpkg_binpkg "${PN}")" "${TDIR}" + + cd "${TDIR}" || gen_die "Failed to chdir to '${TDIR}'!" + + # Delete unneeded files + rm -rf usr/ + + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append ${PN} to cpio!" + + cd "${TEMP}" || die "Failed to chdir to '${TEMP}'!" + if isTrue "${CLEANUP}" + then + rm -rf "${TDIR}" + fi +} + +append_overlay() { + cd "${INITRAMFS_OVERLAY}" || gen_die "Failed to chdir to '${INITRAMFS_OVERLAY}'!" + log_future_cpio_content + find . -print0 | "${CPIO_COMMAND}" ${CPIO_ARGS} --append -F "${CPIO_ARCHIVE}" \ + || gen_die "Failed to append overlay to cpio!" +} + create_initramfs() { print_info 1 "initramfs: >> Initializing ..." @@ -2165,34 +1144,9 @@ create_initramfs() { append_data 'base_layout' append_data 'util-linux' append_data 'eudev' - append_data 'devicemanager' "${DMRAID}" "${LVM}" "${LUKS}" "${MULTIPATH}" + append_data 'modprobed' append_data 'auxiliary' "${BUSYBOX}" append_data 'busybox' "${BUSYBOX}" - append_data 'b2sum' "${B2SUM}" - append_data 'btrfs' "${BTRFS}" - append_data 'dmraid' "${DMRAID}" - append_data 'dropbear' "${SSH}" - append_data 'e2fsprogs' "${E2FSPROGS}" - append_data 'gpg' "${GPG}" - append_data 'iscsi' "${ISCSI}" - append_data 'keyutils' "${KEYCTL}" - append_data 'luks' "${LUKS}" - append_data 'lvm' "${LVM}" - append_data 'bcache' "${BCACHE}" - append_data 'mdadm' "${MDADM}" - append_data 'modprobed' - append_data 'multipath' "${MULTIPATH}" - append_data 'splash' "${SPLASH}" - append_data 'plymouth' "${PLYMOUTH}" - append_data 'strace' "${STRACE}" - append_data 'unionfs_fuse' "${UNIONFS}" - append_data 'xfsprogs' "${XFSPROGS}" - append_data 'zfs' "${ZFS}" - - if isTrue "${ZFS}" - then - append_data 'libgcc_s' - fi if isTrue "${FIRMWARE}" && [ -n "${FIRMWARE_DIR}" ] then @@ -2206,6 +1160,11 @@ create_initramfs() { print_info 1 "$(get_indent 1)>> Not copying modules due to --no-ramdisk-modules ..." fi + append_data 'devicemanager' "${DMRAID}" "${LVM}" "${LUKS}" "${MULTIPATH}" + +#BEGIN FEATURES create_initramfs() +#END FEATURES create_initramfs() + # This should always be appended last if [ -n "${INITRAMFS_OVERLAY}" ] then diff --git a/genkernel.conf b/genkernel.conf index c4b44ea5..cd94dcd6 100644 --- a/genkernel.conf +++ b/genkernel.conf @@ -68,21 +68,6 @@ NOCOLOR="false" # Run the kernel make at the following NICE level #NICE=10 -# Add bcache support -#BCACHE="no" - -# Add LVM support -#LVM="no" - -# Add LUKS support -#LUKS="no" - -# Add GnuPG support -#GPG="no" - -# Add keyctl support for loading LUKS passphrase into a keyring -#KEYCTL="no" - # Add in early microcode support: this sets the kernel options for early microcode loading # Possible values: empty/"no", "all", "intel", "amd" #MICROCODE="all" @@ -94,52 +79,6 @@ NOCOLOR="false" # sys-kernel/linux-firmware[initramfs]. #MICROCODE_INITRAMFS="no" -# Add NFS support -#NFS="no" - -# Add DMRAID support -#DMRAID="no" - -# Add SSH support -#SSH="no" - -# Add b2sum support -#B2SUM="no" - -# Include busybox in the initramfs. If included, busybox is rebuilt -# if the cached copy is out of date. -#BUSYBOX="yes" - -# Add MDRAID support -#MDADM="no" - -# Specify a custom mdadm.conf. -# By default the initramfs will be built *without* an mdadm.conf and will auto-detect -# arrays during bootup. Usually, this should not be needed. -#MDADM_CONFIG="/etc/mdadm.conf" - -# Add Multipath support -#MULTIPATH="no" - -# Add iSCSI support -#ISCSI="no" - -# Add e2fsprogs support -#E2FSPROGS="no" - -# Include support for unionfs -#UNIONFS="no" - -# Include support for zfs volume management. If unset, genkernel will attempt -# to autodetect and enable this when rootfs is on zfs. -#ZFS="no" - -# Add BTRFS support -#BTRFS="no" - -# Add xfsprogs support -#XFSPROGS="no" - # Install firmware onto root filesystem # Will conflict with sys-kernel/linux-firmware package #FIRMWARE_INSTALL="no" @@ -170,21 +109,6 @@ NOCOLOR="false" # Possible values: empty/"none", "current", #BOOTFONT="none" -# Add boot splash using splashutils -#SPLASH="no" - -# Use this splash theme. If commented out - the "default" name theme is used. -# Also, SPLASH="yes" needs to be enabled for this one to work. -# This supersedes the "SPLASH_THEME" option in '/etc/conf.d/splash'. -#SPLASH_THEME="gentoo" - -# Includes or excludes Plymouth from the initramfs. If "splash" is -# passed at boot, Plymouth will be activated. -#PLYMOUTH="no" - -# Embeds the given plymouth theme in the initramfs. -#PLYMOUTH_THEME="text" - # Run "emerge @module-rebuild" automatically when possible and necessary # after kernel and modules have been compiled #MODULEREBUILD="yes" @@ -195,6 +119,18 @@ NOCOLOR="false" # files (use 'copy_image_with_preserve dtb path/to/dtb dtb ') #CMD_CALLBACK="" +# Include busybox in the initramfs. If included, busybox is rebuilt +# if the cached copy is out of date. +#BUSYBOX="yes" + +# Add NFS support +#NFS="no" + +# Create a self-contained env in the initramfs +#NETBOOT="no" + +#BEGIN FEATURES genkernel_conf +#END FEATURES genkernel_conf # =========KEYMAP SETTINGS========= # @@ -439,9 +375,6 @@ DEFAULT_KERNEL_SOURCE="/usr/src/linux" # wrap initramfs using mkimage for u-boot bootloader # WRAP_INITRD=no -# Create a self-contained env in the initramfs -#NETBOOT="no" - # =========MISC BOOT CONFIGURATION========= # diff --git a/load_features.sh b/load_features.sh new file mode 100644 index 00000000..02001668 --- /dev/null +++ b/load_features.sh @@ -0,0 +1 @@ +ls features/*/$1 > /dev/null 2>&1 && cat features/*/$1