Compare commits

...
Author SHA1 Message Date
Caleb Connolly 95a9508b8b copy all modules if available
For development it can be helpful to include all kernel modules in the
initramfs and copy them to the rootfs during boot. Add support for this
directly in the initramfs.

This relies on the fact that development kernels include the git tag and
build number (incrementing) so 'uname -r' changes every time.

It's up to the user to manage deleting their old modules.

Opt-in to this behaviour by setting
deviceinfo_dev_kernel_copy_all_modules="true" in your deviceinfo file.

Signed-off-by: Caleb Connolly <caleb@postmarketos.org>
2024-06-19 02:22:18 +02:00
3 changed files with 34 additions and 4 deletions

No files matched your search

+4 -4
View File
@@ -1,8 +1,8 @@
# Maintainer: Oliver Smith <ollieparanoid@postmarketos.org>
# Co-Maintainer: Clayton Craft <clayton@craftyguy.net>
pkgname=postmarketos-initramfs
pkgver=3.1.0
pkgrel=1
pkgver=3.2.0
pkgrel=0
pkgdesc="Base files for the postmarketOS initramfs / initramfs-extra"
url="https://postmarketos.org"
options="!check" # no tests
@@ -89,7 +89,7 @@ sha512sums="
9c0e8f6f61d5da191e03a1aa9d5d0ceb5baf1eae6dbb9bfb0af59817783525119ac8394b135f303f7b6434a3eab0b49185fb90379e06823db847a4999c75ce33 00-initramfs-base.dirs
1c64d2da2013213467dfaa40e984e3a7c7e8a885d3327fe164f1e1c091eb9c9f2dfadcc7e1e1ef8a0e7fa36513b2216b4bde97d58c2528a637821a31800ccd34 00-initramfs-base.files
8a4adad3785af474b36a09a05f6a3b2c4b4f43aac331a53b903abfa51ea12be1e3d1d807b7a6e66a1346815f3b0044daf8cd62e21e2dc75d2db13ee265a72985 00-initramfs-extra-base.files
749865c52a229569c0cd346dd97fe10d49361124eba95bd0dbb25d0737d1efc139c8e2e31f4b7654747ffecfa77403886f1e1fe7d548d47aee03ced43d8ef2eb init.sh
1d3337ace7611853579945dc6563556ced66f386a7f906835425bac9e45c7734682b85b381656dfd5d3b0a727a39e5718e77f0d19af42562c199df25ea9fda59 init_functions.sh
9a9e422252836ed1594be9c307ea787042ff0d52390e222bb6d3ed557916fbe67902516536ba8cdcbe8eef6dc9e2712029bd539878deb4c24e9de954efd2c6ac init.sh
498d2a4973033026581fbb434953b6693de0f6d15a63baced328ab650842a4e34802e60d5f26dd70dbcca246d2bcbbd7abf90894af4d0b3f6bba43cefce5ae4b init_functions.sh
ba3275a9af788c7c782322a22a0f144d5e50e3498ea6886486a29331f23ae89cd32d500a3635cfa7cab369afba92edc18aeca64ccbf0cd589061cce23d15b46c unudhcpd.conf
"
+2
View File
@@ -81,6 +81,8 @@ unlock_root_partition
resize_root_filesystem
mount_root_partition
copy_kernel_modules
# Mount boot partition into sysroot, so we do not depend on /etc/fstab, as
# not all old installations have a proper /etc/fstab file. See #2800
umount /boot
@@ -12,6 +12,7 @@ HOST_IP="${unudhcpd_host_ip:-172.16.42.1}"
deviceinfo_getty=""
deviceinfo_name=""
deviceinfo_codename=""
deviceinfo_dev_kernel_copy_all_modules=""
# Redirect stdout and stderr to logfile
setup_log() {
@@ -602,6 +603,33 @@ mount_root_partition() {
fi
}
# For development or CI we might be booting with a different kernel
# to what we have in the rootfs. Usually this means we also have all
# kernel modules available in the initramfs, so we copy them over
# to make them available in the rootfs.
copy_kernel_modules() {
local reason
reason="they were missing from rootfs"
if [ "$deviceinfo_dev_kernel_copy_all_modules" != "true" ]; then
# Copying kernel modules is disabled
return
elif grep -q "pmos.force-copy-modules" /proc/cmdline; then
reason="pmos.force-copy-modules was specified on the cmdline"
elif [ -e "/sysroot/lib/modules/$(uname -r)" ]; then
# Kernel modules already present
return
fi
remount -o rw /sysroot
echo "Copying kernel modules for $(uname -sr) to rootfs"
cp -af /lib/modules/"$(uname -r)" /sysroot/lib/modules/
remount -o ro /sysroot
echo "Updated kernel modules in rootfs because $reason"
}
# $1: path to the hooks dir
run_hooks() {
scriptsdir="$1"