mkinitcpio MODULES and HOOKS

This commit is contained in:
Daniel Langbein 2021-05-03 13:26:54 +02:00
parent 075d9fe653
commit c6b7fb91e8
5 changed files with 97 additions and 5 deletions

View File

@ -277,6 +277,11 @@ ff02::2 ip6-allrouters" >> /mnt/etc/hosts || return $?
} }
function user_and_pwd() { function user_and_pwd() {
# @pre
# USERNAME
# USER_PWD
# ROOT_PWD (optional)
# -m: create home # -m: create home
# -U: Create a group with the same name as the user, and add the user to this group. # -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 $? 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 $? printf "%s:%s" "root" "${ROOT_PWD}" | chpasswd --root /mnt || return $?
} }
function gen_initramfs(){
# TODO
true
}
function main() { function main() {
# @pre # @pre
# bash libraries imported # bash libraries imported
@ -334,8 +344,10 @@ function main() {
# in: HOSTNAME, FQDN (optional), STATIC_IP (optional), IPV6_CAPABLE (optional) # in: HOSTNAME, FQDN (optional), STATIC_IP (optional), IPV6_CAPABLE (optional)
config_hostname_and_hosts || return $? config_hostname_and_hosts || return $?
# in: USERNAME, USER_PWD, ROOT_PWD (optional)
user_and_pwd || return $? user_and_pwd || return $?
gen_initramfs || return $?
} }
main "$@" main "$@"

View File

@ -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 ## arg 1: the new package version
post_install() { post_install() {
holo apply holo apply
mkinitcpio -P
} }
## arg 1: the new package version ## arg 1: the new package version
## arg 2: the old package version ## arg 2: the old package version
post_upgrade() { post_upgrade() {
holo apply holo apply
mkinitcpio -P
} }
## arg 1: the old package version ## arg 1: the old package version
post_remove() { post_remove() {
holo apply holo apply
mkinitcpio -P
} }

View File

@ -2,9 +2,9 @@
_pkgname=mkinitcpio _pkgname=mkinitcpio
_reponame=arch _reponame=arch
pkgname="de-p1st-$_pkgname" pkgname="de-p1st-$_pkgname"
pkgver=0.0.1 pkgver=0.0.2
pkgrel=1 pkgrel=1
pkgdesc="mkinitcpio with lz4 compression" pkgdesc="mkinitcpio configuration"
arch=('any') arch=('any')
url="https://codeberg.org/privacy1st/${_reponame}" url="https://codeberg.org/privacy1st/${_reponame}"
license=('MIT') license=('MIT')

View File

@ -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')
```

View File

@ -1,5 +1,25 @@
#!/bin/sh #!/bin/sh
# stdin: default config # stdin: default config
# stdout: modified 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"