archboot/usr/lib/initcpio/install/archboot_base_common

243 lines
11 KiB
Text
Raw Normal View History

2022-01-31 10:49:49 +01:00
#!/usr/bin/env bash
# SPDX-License-Identifier: GPL-2.0-only
2022-01-31 10:49:49 +01:00
# Created by Tobias Powalowski <tpowa@archlinux.org>
build ()
{
### setting up base structure
2023-02-14 07:06:43 +01:00
map add_dir "/root" "/mnt" "/sysroot" "/install" "/var/log" "/home" "/var/tmp"
2022-01-31 10:49:49 +01:00
add_symlink /var/run ../run
add_symlink /var/lock ../run/lock
2022-05-01 22:14:25 +02:00
2022-01-31 10:49:49 +01:00
### add basic apps
2023-02-15 21:25:41 +01:00
map add_binary init agetty basename mount umount clear env printf gawk tty bash rbash \
partprobe cp dir du ls mv rm sed grep kill killall more ps pwd rmdir true cat \
mkdir echo false sleep kmod pidof touch chmod find wc uname yes awk halt \
2023-02-15 21:25:41 +01:00
shutdown reboot poweroff insmod modprobe sh dd sort zstd date tee mktemp \
install pgrep mkfs.btrfs rmmod mountpoint gzip ldconfig nscd ln top df cut \
2023-06-18 16:46:01 +02:00
stat tr passwd od tar bsdtar
### add nano
add_binary nano
add_full_dir /usr/share/nano
add_file /etc/nanorc
# add syntax highlighting
2023-04-17 14:52:21 +02:00
echo "include \"/usr/share/nano/*.nanorc\"" >> "${BUILDROOT}/etc/nanorc"
2022-09-19 10:37:09 +02:00
2022-12-26 09:50:38 +01:00
### add machine-id
2023-04-17 14:55:06 +02:00
: > "${BUILDROOT}/etc/machine-id"
2022-12-26 09:50:38 +01:00
2022-09-19 10:37:09 +02:00
### add file magic file
add_file /usr/share/file/misc/magic.mgc
2022-01-31 10:49:49 +01:00
add_file "/usr/lib/libkmod.so"
add_symlink "/init" "/usr/lib/systemd/systemd"
### adding needed files from running system
2022-04-04 07:43:15 +02:00
map add_full_dir "/etc/profile.d" "/usr/share/terminfo"
2023-02-06 20:51:50 +01:00
add_symlink /usr/lib/terminfo ../share/terminfo
2023-02-06 20:48:35 +01:00
2023-02-13 06:55:17 +01:00
systemfiles="bash.bash_logout bash.bashrc crypttab fstab host.conf hosts \
inputrc mke2fs.conf nscd.conf nsswitch.conf protocols \
request-key.conf securetty services"
2022-01-31 10:49:49 +01:00
for i in $systemfiles; do
add_file "/etc/$i"
done
### adding config files of installation system
2023-01-30 16:45:09 +01:00
map add_file "/etc/profile" "/etc/shells"
2023-06-25 15:50:31 +02:00
basic_config="hostname issue modprobe.d/modprobe.conf os-release tmpfiles.d/var.conf"
2022-01-31 15:03:27 +01:00
for i in $basic_config; do
add_file "/usr/share/archboot/base/etc/${i}" "/etc/${i}"
2022-01-31 15:03:27 +01:00
done
2023-02-06 19:29:37 +01:00
### add coreutils,cryptsetup,terminfo libs and charmaps
2023-02-07 07:37:34 +01:00
map add_full_dir /usr/lib/coreutils /usr/lib/cryptsetup \
2023-02-08 07:36:39 +01:00
/usr/lib/gconv /usr/share/readline
2023-03-01 12:18:09 +01:00
### add locale support
2023-03-01 12:50:54 +01:00
map add_binary locale-gen localedef
add_file /etc/locale.gen
2023-03-05 14:05:51 +01:00
_LANG="be bg cs da de en el es fi fr hu it lt lv mk nl nn pl pt ro ru sk sr sv uk"
2023-03-01 12:18:09 +01:00
for i in ${_LANG}; do
add_full_dir /usr/share/locale/${i}
done
2023-03-02 07:20:13 +01:00
add_file /usr/share/locale/locale.alias
2023-03-01 14:28:43 +01:00
add_full_dir /usr/share/i18n/locales
2023-03-02 07:20:13 +01:00
# only support UTF-8
2023-03-01 12:18:09 +01:00
add_file /usr/share/i18n/charmaps/UTF-8.gz
2023-03-02 07:20:13 +01:00
# remove conflicting files from not installed packages: binutils, grub and gdbm
2023-04-17 14:52:21 +02:00
find ${BUILDROOT}/usr/share/locale/ -type f \( -name 'grub*' -o -name 'binutils*' -o -name 'gdbm*' -o -name 'bfd*' \
2023-03-01 16:00:42 +01:00
-o -name 'gettext*' -o -name 'gas*' -o -name 'gold*' -o -name 'gprof*' -o -name 'ld*' \
-o -name 'opcodes*' \) -delete
2023-01-29 10:22:42 +01:00
### add bash configuration
2023-01-27 10:41:30 +01:00
# add bash-completion
add_full_dir /usr/share/bash-completion
2023-01-29 10:22:42 +01:00
# use color bash prompt
2023-01-27 10:41:30 +01:00
# unlock and delete root password, if not set by user!
# use color grep and ls output
for i in custom-bash-options.sh archboot-reset-root-password.sh; do
add_file "/usr/share/archboot/base/etc/profile.d/${i}" "/etc/profile.d/${i}"
done
# add default bash setup
2023-02-01 15:44:28 +01:00
for i in .bashrc .bash_profile .bash_logout; do
add_file "/etc/skel/${i}" "/root/${i}"
done
# add custom bash options
2023-04-17 14:52:21 +02:00
echo ". /etc/profile.d/custom-bash-options.sh" >> "${BUILDROOT}/root/.bashrc"
# add /etc/skel
add_full_dir /etc/skel
2022-01-31 10:49:49 +01:00
### add kmod related config file(s)
add_file "/usr/lib/depmod.d/search.conf"
2022-01-31 15:45:56 +01:00
### fixing network support from glibc
2022-03-14 21:32:33 +01:00
map add_file "/lib/libnss_files.so.2" "/lib/libnss_dns.so.2"
2022-01-31 10:49:49 +01:00
2022-09-12 08:24:29 +02:00
### add hwdata
add_full_dir /usr/share/hwdata
2022-01-31 10:49:49 +01:00
### add pam
2022-03-14 21:32:33 +01:00
map add_binary mkhomedir_helper pam_timestamp_check unix_chkpwd unix_update
map add_full_dir "/etc/security" "/etc/default" "/etc/pam.d" "/usr/lib/security"
2022-01-31 10:49:49 +01:00
add_file "/etc/environment"
2022-03-14 21:32:33 +01:00
2022-01-31 10:49:49 +01:00
### add shadow
2022-03-14 21:32:33 +01:00
map add_binary login nologin
2022-01-31 10:49:49 +01:00
add_file "/etc/login.defs"
### add systemd
# add systemd kernel modules
2023-02-17 21:37:58 +01:00
add_all_modules 'nfs|autofs4|loop'
2022-03-14 21:32:33 +01:00
map add_binary mount.nfs4 umount.nfs umount.nfs4 mount.nfs setfont loadkeys
2022-01-31 10:49:49 +01:00
#dbus files
2022-03-14 21:32:33 +01:00
map add_binary dbus-cleanup-sockets dbus-daemon dbus-launch dbus-monitor dbus-run-session dbus-send dbus-test-tool \
dbus-update-activation-environment dbus-uuidgen /usr/lib/dbus-1.0/dbus-daemon-launch-helper
2022-01-31 10:49:49 +01:00
add_dir "/var/lib/dbus"
2022-03-14 21:32:33 +01:00
map add_full_dir "/etc/dbus-1" "/usr/share/dbus-1"
# tpm2-tss files
2023-02-02 22:16:29 +01:00
map add_binary secret-tool pinentry pinentry-curses gpgme-tool gpgme-json
map add_full_dir /etc/tpm2-tss /etc/pinentry
2022-01-31 10:49:49 +01:00
#systemd files
map add_binary systemd-umount busctl bootctl coredumpctl hostnamectl journalctl kernel-install localectl \
2022-01-31 10:49:49 +01:00
loginctl machinectl networkctl systemctl systemd-analyze systemd-ask-password \
systemd-cat systemd-cgls systemd-cgtop \
systemd-delta systemd-detect-virt systemd-escape systemd-firstboot systemd-hwdb systemd-inhibit systemd-machine-id-setup \
systemd-mount systemd-notify systemd-nspawn systemd-path systemd-resolve \
systemd-run systemd-socket-activate systemd-stdio-bridge systemd-sysusers \
2022-01-31 10:49:49 +01:00
systemd-tty-ask-password-agent timedatectl systemd-repart userdbctl homectl oomctl portablectl systemd-creds \
systemd-cryptenroll systemd-dissect systemd-id128 systemd-sysext
2022-03-14 21:32:33 +01:00
map add_dir "/etc/tmpfiles.d" "/etc/modules-load.d" "/etc/binfmt.d/" "/var/lib/systemd"
map add_full_dir "/etc/sysctl.d/" "/etc/systemd" "/etc/xdg" "/usr/lib/systemd" "/usr/share/systemd" "/usr/share/factory" \
2022-04-17 21:47:39 +02:00
"/usr/share/polkit-1" "/usr/lib/tmpfiles.d" "/usr/lib/modules-load.d" "/usr/lib/sysusers.d" "/usr/lib/sysctl.d"
2022-01-31 10:49:49 +01:00
add_file "/usr/share/archboot/base/etc/locale.conf" "/etc/locale.conf"
add_file "/usr/share/archboot/base/etc/vconsole.conf" "/etc/vconsole.conf"
add_file "/usr/share/archboot/base/etc/systemd/system/getty@.service" "/etc/systemd/system/getty@.service"
add_file "/usr/share/archboot/base/etc/systemd/system/serial-getty@.service" "/etc/systemd/system/serial-getty@.service"
add_file "/usr/share/archboot/base/etc/systemd/system/systemd-sysusers.service" "/etc/systemd/system/systemd-sysusers.service"
### disable systemd mounts:
# disable configfs, debugfs, fuse and tracefs
for i in sys-kernel-debug sys-kernel-tracing sys-kernel-config sys-fs-fuse-connections tmp; do
add_symlink "/etc/systemd/system/${i}.mount" "/dev/null"
done
### disable systemd targets:
# swap cryptsetup integritysetup veritysetup
2023-06-21 12:08:31 +02:00
for i in cryptsetup first-boot-complete integritysetup swap veritysetup; do
add_symlink "/etc/systemd/system/${i}.target" "/dev/null"
done
### disable systemd services:
2023-06-21 12:08:31 +02:00
# hwdb-update firstboot machine-id-commit pcrmachine binfmt
# boot-random-seed repart pcrphase pcrphase-sysinit
for i in hwdb-update firstboot machine-id-commit pcrmachine binfmt boot-random-seed repart pcrphase pcrphase-sysinit; do
add_symlink "/etc/systemd/system/systemd-${i}.service" "/dev/null"
done
2023-06-20 21:33:20 +02:00
# remove multi-user.target.wants
rm -rf ${BUILDROOT}/etc/systemd/system/multi-user.target.wants
# disable lastlog
add_symlink "/var/log/lastlog" "/dev/null"
add_file "/usr/share/archboot/base/etc/tmpfiles.d/var.conf" "/etc/tmpfiles.d/var.conf"
2022-01-31 10:49:49 +01:00
### add missing libsystemd files
2022-03-14 21:32:33 +01:00
map add_file "/usr/lib/libnss_myhostname.so.2" "/usr/lib/libnss_mymachines.so.2" \
"/usr/lib/libnss_resolve.so.2" "/usr/lib/libnss_systemd.so.2"
2022-01-31 10:49:49 +01:00
### fix tmpfiles startup
2022-03-14 21:32:33 +01:00
map add_file "/usr/lib/libnss_compat.so.2" "/usr/lib/libnsl.so.1"
## fix for systemd >=245 set default.target
# remove initrd-release to allow normal systemd boot without initrd.target
2023-04-17 14:52:21 +02:00
rm -f ${BUILDROOT}/etc/initrd-release
# mask systemd-gpt-auto-generator, errors out on initramfs usage
add_symlink "/etc/systemd/system-generators/systemd-gpt-auto-generator" "/dev/null"
### add udev
map add_binary /usr/lib/systemd/systemd-udevd udevadm systemd-tmpfiles logger
2022-01-31 10:49:49 +01:00
# add rule files
add_full_dir "/usr/lib/udev"
# add schedule rules file
add_file "/usr/share/archboot/base/etc/udev/rules.d/60-ioschedulers.rules" "/etc/udev/rules.d/60-ioschedulers.rules"
# add swapiness sysctl config file
add_file "/usr/share/archboot/base/etc/sysctl.d/99-sysctl.conf" "/etc/sysctl.d/99-sysctl.conf"
### add pacman
2022-03-14 21:32:33 +01:00
map add_binary pacman pacman-conf pacman-key pacman-db-upgrade makepkg \
repo-add repo-elephant testpkg vercmp curl gpg-agent gpg \
2022-09-07 13:02:02 +02:00
gpgconf gpg-connect-agent repo-remove archlinux-keyring-wkd-sync
2022-03-14 21:32:33 +01:00
map add_dir "/var/cache/pacman/pkg" "/var/lib/pacman"
map add_file "/etc/pacman.conf" "/etc/makepkg.conf" "/etc/pacman.d/mirrorlist"
2022-01-31 10:49:49 +01:00
# add pacman initialisation of gpg keys
add_dir "/etc/pacman.d/gnupg"
2022-04-28 20:14:49 +02:00
add_file "/usr/share/archboot/base/etc/systemd/system/pacman-init.service" "/etc/systemd/system/pacman-init.service"
2022-03-14 21:32:33 +01:00
map add_full_dir "/usr/share/pacman/keyrings" "/usr/share/makepkg"
2022-01-31 10:49:49 +01:00
# add local installed pacman database in container mode
if [[ -e "/etc/hostname" ]]; then
[[ "$(cat /etc/hostname )" == "archboot" ]] && add_full_dir "/var/lib/pacman/local"
else
add_full_dir "/var/lib/pacman/local"
fi
2022-05-02 13:01:41 +02:00
### add nss p11-kit and ca certificates
map add_binary p11-kit trust certutil cmsutil crlutil modutil nss-config pk12util \
shlibsign signtool signver ssltap symkeyutil update-ca-trust
2022-01-31 10:49:49 +01:00
cafile="tls-ca-bundle.pem"
cert="cert.pem"
cert2="ca-certificates.crt"
ca_dir="/etc/ca-certificates/extracted"
cert_dir="/etc/ssl"
cert2_dir="/etc/ssl/certs"
map add_full_dir "$ca_dir" "$cert2_dir" /usr/lib/p11-kit /usr/lib/pkcs11
2022-01-31 10:49:49 +01:00
add_symlink "${cert_dir}/${cert}" "../ca-certificates/extracted/$cafile"
add_symlink "${cert2_dir}/${cert2}" "../../ca-certificates/extracted/$cafile"
2022-05-02 13:01:41 +02:00
add_file /usr/share/ca-certificates/trust-source/mozilla.trust.p11-kit
2022-09-19 22:03:28 +02:00
add_file /usr/share/p11-kit/modules/p11-kit-trust.module
2022-05-02 13:01:41 +02:00
2022-06-16 16:51:02 +02:00
### add secure boot MOK
add_full_dir /usr/share/archboot/keys
2023-02-09 12:39:11 +01:00
### remove conflicting mkinitcpio files and grub
2023-02-13 14:26:17 +01:00
rm ${BUILDROOT}/usr/lib/systemd/system/mkinitcpio-generate-shutdown-ramfs.service \
2023-02-07 07:41:20 +01:00
${BUILDROOT}/usr/lib/systemd/system/shutdown.target.wants/mkinitcpio-generate-shutdown-ramfs.service \
2023-03-18 21:03:48 +01:00
${BUILDROOT}/usr/lib/systemd/ukify \
2023-02-07 07:41:20 +01:00
${BUILDROOT}/usr/lib/tmpfiles.d/mkinitcpio.conf \
${BUILDROOT}/usr/share/bash-completion/completions/lsinitcpio \
2023-02-09 12:39:11 +01:00
${BUILDROOT}/usr/share/bash-completion/completions/mkinitcpio \
2023-02-24 21:10:03 +01:00
${BUILDROOT}/usr/share/bash-completion/completions/grub \
${BUILDROOT}/usr/lib/modules-load.d/cdrecord.conf
2023-02-07 07:41:20 +01:00
2022-01-31 10:49:49 +01:00
### fix licenses
map add_file /usr/share/licenses/shadow/COPYING /usr/share/licenses/iana-etc/LICENSE \
/usr/share/licenses/dbus/COPYING /usr/share/licenses/p11-kit/COPYING
2022-05-02 13:01:41 +02:00
2022-01-31 10:49:49 +01:00
}
help ()
{
cat <<HELPEOF
This hook sets up all common initial directories and installs base, kmod,
pam, pacman, shadow, systemd, udev utilities and libraries
for a archboot image.
DO NOT remove this one unless you know what you're doing.
HELPEOF
}
# vim: set ft=sh ts=4 sw=4 et: