#!/bin/bash build() { local mod crypttab map add_module 'dm-crypt' 'dm-integrity' 'hid-generic?' if [[ -n "$CRYPTO_MODULES" ]]; then for mod in $CRYPTO_MODULES; do add_module "$mod" done else add_all_modules '/crypto/' fi add_checked_modules '/drivers/char/tpm/' map add_udev_rule \ '10-dm.rules' \ '13-dm-disk.rules' \ '60-fido-id.rules' \ '95-dm-notify.rules' map add_systemd_unit 'cryptsetup.target' \ 'systemd-ask-password-console.path' \ 'systemd-ask-password-console.service' map add_binary \ '/usr/lib/systemd/system-generators/systemd-cryptsetup-generator' \ '/usr/lib/systemd/systemd-cryptsetup' \ '/usr/lib/systemd/systemd-makefs' \ '/usr/lib/cryptsetup/libcryptsetup-token-systemd-fido2.so' \ '/usr/lib/cryptsetup/libcryptsetup-token-systemd-tpm2.so' # cryptsetup calls pthread_create(), which dlopen()s libgcc_s.so.1 add_binary '/usr/lib/libgcc_s.so.1' # cryptsetup loads the legacy provider which is required for whirlpool add_binary '/usr/lib/ossl-modules/legacy.so' # add libraries dlopen()ed by systemd-cryptsetup for LIB in fido2 cryptsetup; do LC_ALL=C.UTF-8 find /usr/lib/ -maxdepth 1 -name "lib${LIB}.so*" | while read -r FILE; do if [[ -L "${FILE}" ]]; then add_symlink "${FILE}" else add_binary "${FILE}" fi done done # add mkswap for creating swap space on the fly (see 'swap' in crypttab(5)) add_binary 'mkswap' # add NVPCR definition files map add_file /usr/lib/nvpcr/*.nvpcr if [[ -f /etc/crypttab.initramfs ]]; then add_file '/etc/crypttab.initramfs' '/etc/crypttab' 600 warning '/etc/crypttab.initramfs is deprecated. Merge it into /etc/crypttab and add a x-initrd.attach option to the devices that need to be unlocked in the initramfs.' elif crypttab="$(awk '!/^\s*($|#)/ && $4 ~ /x-initrd\.attach/' /etc/crypttab 2>/dev/null)" && [[ -n "$crypttab" ]]; then printf '%s\n' "$crypttab" | add_file - '/etc/crypttab' 600 fi } help() { cat <