From c6b7fb91e8fb925e6a36faaccebd852b04e7982f Mon Sep 17 00:00:00 2001 From: langfingaz Date: Mon, 3 May 2021 13:26:54 +0200 Subject: [PATCH] mkinitcpio MODULES and HOOKS --- pkg/de-p1st-installer/de-p1st-installer.sh | 14 +++++- pkg/de-p1st-mkinitcpio/.install | 10 ++++ pkg/de-p1st-mkinitcpio/PKGBUILD | 4 +- pkg/de-p1st-mkinitcpio/README.md | 50 +++++++++++++++++++ .../mkinitcpio.conf.holoscript | 24 ++++++++- 5 files changed, 97 insertions(+), 5 deletions(-) create mode 100644 pkg/de-p1st-mkinitcpio/README.md diff --git a/pkg/de-p1st-installer/de-p1st-installer.sh b/pkg/de-p1st-installer/de-p1st-installer.sh index 709d628..0eb848c 100755 --- a/pkg/de-p1st-installer/de-p1st-installer.sh +++ b/pkg/de-p1st-installer/de-p1st-installer.sh @@ -277,6 +277,11 @@ ff02::2 ip6-allrouters" >> /mnt/etc/hosts || return $? } function user_and_pwd() { + # @pre + # USERNAME + # USER_PWD + # ROOT_PWD (optional) + # -m: create home # -U: Create a group with the same name as the user, and add the user to this group. arch-chroot /mnt useradd -m -s /usr/bin/zsh -g wheel "${USERNAME}" || return $? @@ -289,6 +294,11 @@ function user_and_pwd() { printf "%s:%s" "root" "${ROOT_PWD}" | chpasswd --root /mnt || return $? } +function gen_initramfs(){ + # TODO + true +} + function main() { # @pre # bash libraries imported @@ -334,8 +344,10 @@ function main() { # in: HOSTNAME, FQDN (optional), STATIC_IP (optional), IPV6_CAPABLE (optional) config_hostname_and_hosts || return $? - + # in: USERNAME, USER_PWD, ROOT_PWD (optional) user_and_pwd || return $? + + gen_initramfs || return $? } main "$@" diff --git a/pkg/de-p1st-mkinitcpio/.install b/pkg/de-p1st-mkinitcpio/.install index b754ef5..d8f272c 100644 --- a/pkg/de-p1st-mkinitcpio/.install +++ b/pkg/de-p1st-mkinitcpio/.install @@ -1,15 +1,25 @@ +## arg 1: the new package version +pre_install() { + # Check if system is SSE4.2 capable + # lscpu is part of util-linux which is a dependency of mkinitcpio + lscpu | grep sse4_2 >/dev/null 2>&1 +} + ## arg 1: the new package version post_install() { holo apply + mkinitcpio -P } ## arg 1: the new package version ## arg 2: the old package version post_upgrade() { holo apply + mkinitcpio -P } ## arg 1: the old package version post_remove() { holo apply + mkinitcpio -P } diff --git a/pkg/de-p1st-mkinitcpio/PKGBUILD b/pkg/de-p1st-mkinitcpio/PKGBUILD index 2884eda..59d7922 100644 --- a/pkg/de-p1st-mkinitcpio/PKGBUILD +++ b/pkg/de-p1st-mkinitcpio/PKGBUILD @@ -2,9 +2,9 @@ _pkgname=mkinitcpio _reponame=arch pkgname="de-p1st-$_pkgname" -pkgver=0.0.1 +pkgver=0.0.2 pkgrel=1 -pkgdesc="mkinitcpio with lz4 compression" +pkgdesc="mkinitcpio configuration" arch=('any') url="https://codeberg.org/privacy1st/${_reponame}" license=('MIT') diff --git a/pkg/de-p1st-mkinitcpio/README.md b/pkg/de-p1st-mkinitcpio/README.md new file mode 100644 index 0000000..5cf1e8a --- /dev/null +++ b/pkg/de-p1st-mkinitcpio/README.md @@ -0,0 +1,50 @@ +# mkinitcpio.conf + +After changing the global configuration, +one should execute: + +```shell +mkinitcpio -P +``` + +## compression + +Can be enabled with: + +```shell +COMPRESSION='lz4' +``` + +## hooks + +Hooks to for + +1) resuming +2) BTRFS +3) encryption +4) keymap + +```shell +HOOKS=(base udev resume modconf block keyboard keymap encrypt lvm2 btrfs fsck filesystems) +``` + +## crc32c_intel + +* Archwiki (Ext4#Enabling_metadata_checksums)[https://wiki.archlinux.org/title/Ext4#Enabling_metadata_checksums] + > If the CPU supports SSE 4.2, make sure the crc32c_intel + > kernel module is loaded in order to enable the hardware + > accelerated CRC32C algorithm +* https://en.wikipedia.org/wiki/SSE4#SSE4.2 +* https://bugzilla.redhat.com/show_bug.cgi?id=1874808 + +On a SSE4.2 capable system, `crc32c-intel` should be used, not `crc32c-generic`. + +Check your CPU (see the `.install` script): +```shell +lscpu | grep sse4_2 +``` + +Can be enabled with: +```shell +MODULES=('crc32c-intel') +``` diff --git a/pkg/de-p1st-mkinitcpio/mkinitcpio.conf.holoscript b/pkg/de-p1st-mkinitcpio/mkinitcpio.conf.holoscript index 5e064c5..ff26cfb 100644 --- a/pkg/de-p1st-mkinitcpio/mkinitcpio.conf.holoscript +++ b/pkg/de-p1st-mkinitcpio/mkinitcpio.conf.holoscript @@ -1,5 +1,25 @@ #!/bin/sh # stdin: default config # stdout: modified config -cat -echo 'COMPRESSION="lz4"' + +# save stdin (content of /etc/mkinitcpio.conf) in variable +stdin=$(cat) + +# MODULES is empty +echo "$stdin" | grep '^MODULES=()' + +# assert HOOKS is as expected +echo "$stdin" | grep '^HOOKS=(base udev autodetect modconf block filesystems keyboard fsck)' + +# assert no COMPRESSION option is enabled yet +! echo "$stdin" | grep '^COMPRESSION=' + +# assert lz4 COMPRESSION is uncommented +echo "$stdin" | grep '^#COMPRESSION="lz4"' + +# 1) add to MODULES; 2 replace HOOKS; 3) uncomment lz4 COMPRESSION +sed ' + s|^MODULES=(|MODULES=(crc32c-intel |; + s|^#COMPRESSION="lz4".*$|COMPRESSION="lz4"|; + s|^HOOKS=(.*$|HOOKS=(base udev resume modconf block keyboard keymap encrypt lvm2 btrfs fsck filesystems)| + ' <<< "$stdin"