Scripts can be run as `sh $script`. In this case `-e` on the shebang is
ignored.
So explicitly call `set -e` instead of specifying `-e` on the shebang.
blkid will exit with success if it can gather information about the
device, even if the device does not match the specified type.
This fixes the device type check by getting the type value and testing
it directly.
Signed-off-by: Jeffery To <jeffery.to@gmail.com>
[bwh: Keep checking that resolve_device and blkid are successful]
Signed-off-by: Ben Hutchings <benh@debian.org>
The kernel now looks for 'tmpfs' in the value of the rootfstype
parameter, and uses either ramfs or tmpfs for the initramfs depending
on that.
We should allow 'tmpfs' to appear, but not pass it down to the fsck
and mount commands. So filter it out of the value of $ROOTFSTYPE.
Signed-off-by: Ben Hutchings <benh@debian.org>
Various kernel parameters are comma-separated lists, and we don't
currently have any functions for manipulating them. Add the most
urgently needed list_filter_out which will filter out matching
items.
Signed-off-by: Ben Hutchings <benh@debian.org>
dracut-install can filter modules by symbol (`--mod-filter-symbol`) to
select modules more fine-grain. Harmonize the set of modules that
initramfs-tools and dracut install.
This change excludes wireless drivers (e. g. `drivers/net/ieee802154`
and `drivers/net/wwan`).
LP: #2031841
Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
Commit 9a297f56ba66 ("reduce number of dracut-install calls") requires
users of `manual_add_modules` to call `apply_add_modules` afterwards.
That breaks miniramfs. miniramfs 1.0.3 added the `apply_add_modules`
call.
Like other ARM64 Chromebooks, Qualcomm SC7180-based ones also suffer
from Google's boot firmware that does not provide a firmware-initialized
framebuffer to the OS. Add the "msm" module to the framebuffer modules
list to enable using the display from the initramfs for things like an
encryption passphrase prompt.
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
We add `pmic_glink_altmode` to the initramfs as a hidden dependency for
the `msm` module needed for display on Qualcomm devices. Following a
dependency chain of `pmic_glink` -> `pdr_interface` -> `qmi_helpers`,
modprobe also includes these along with it. Although the latter also has
a hidden dependency on `qrtr` that we handle, `qrtr` can end up missing
from the initramfs because we do not recursively handle hidden
dependencies of hidden dependencies.
Add `qrtr` also to the hidden dependency list of `msm` so it gets
properly included in this case.
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
unmkinitramfs unpacks each uncompressed section to directories 'early',
'early2', etc., which is confusing when compressed kernel modules were
put in uncompressed sections.
Use directory names 'cpio1', 'cpio2', etc. for both uncompressed and
compressed sections.
initramfs-tools decompresses kernel modules and firmware files before
putting them into the initramfs. This has several drawbacks:
* The compressed kernel modules and firmware files might be compressed
with a higher level. So recompressing them in the initramfs can
increase the size.
* Decompressing and compressing these files during mkinitramfs will take
time.
* The size of the decompressed initramfs will be bigger. That size is
needed in memory during boot.
So put compressed kernel modules and firmware files in an uncompressed
cpio instead. To make this change have an impact the files need to be
shipped compressed.
The benchmarks were done either on an AMD Ryzen 7 5700G with schroot and
overlay on tmpfs or on the hardware mentioned. All tests were running
the Ubuntu mantic development release in July 2023.
* minimal: schroot with linux-image-generic initramfs-tools zstd
* full: minimal + busybox-initramfs cryptsetup-initramfs
isc-dhcp-client kbd lvm2 mdadm ntfs-3g plymouth plymouth-theme-spinner
* nvidia: full + linux-headers-generic nvidia-driver-525
* nvidia fw: nvidia + compressed /lib/firmware/nvidia/525.125.06/
* VisionFive 2: VisionFive 2 RISC-V board
* RPi Zero 2: Raspberry Pi Zero 2 ARM board (running armhf)
"next" means using kernel and firmware packages from a PPA that ship the
files compressed with `zstd -19` plus initramfs-tools with this patch.
| | build | size | uncompressed size |
| test | time | in bytes | in MiB | in bytes | in MiB |
|----------------|---------|-----------|--------|--------------------|
| minimal | 4.30 s | 66701818 | 63.6 | 224087608 | 213.7 |
| minimal next | 4.54 s | 59935186 | 57.2 | 67738810 | 64.6 |
| full | 7.15 s | 118007038 | 112.5 | 387976843 | 370.0 |
| full next | 7.29 s | 106937908 | 102.0 | 128610985 | 122.7 |
| nvidia | 7.04 s | 209200523 | 199.5 | 513554279 | 489.8 |
| nvidia next | 7.21 s | 195246287 | 186.2 | 235288174 | 224.4 |
| nvidia fw next | 7.16 s | 191329102 | 182.5 | 213078234 | 203.2 |
| VisionFive 2 | 142.9 s | 121895035 | 116.2 | 411160836 | 392.1 |
| VF 2 next | 126.7 s | 111651453 | 106.5 | 134120804 | 127.9 |
| RPi Zero 2 | 109.5 s | 39803044 | 40.0 | 69592789 | 66.4 |
| RPi Zero 2 ² | 103.5 s | 39804499 | 40.0 | 69592789 | 66.4 |
| RPi Zero 2 next| 101.2 s | 31463352 | 30.0 | 41145762 | 39.2 |
² Updated initramfs-tools (but no compressed modules or firmware)
The build time was averaged over five runs.
| improvement | build time | size | uncompressed size |
|--------------|------------|--------|-------------------|
| minimal | 105.6 % | 89.9 % | 30.2 % |
| full | 102.0 % | 90.6 % | 33.1 % |
| nvidia | 101.7 % | 91.5 % | 41.5 % |
| VisionFive 2 | 88.7 % | 91.6 % | 32.6 % |
| RPi Zero 2 | 92.4 % | 79.0 % | 59.1 % |
See https://lists.ubuntu.com/archives/ubuntu-devel/2023-July/042707.html
LP: #2028567
Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
As the copy_file is quite complex and has had a number of bugs
found (and introduced) recently, add an autopkgtest test case that
exercises most of its functionality and the specific cases where
bugs were reported.
Signed-off-by: Ben Hutchings <benh@debian.org>
Currently if copy_file is invoked as:
copy_file binary /lib/package/command /bin/command
we will end up with:
src=/lib/package/command
target=/usr/bin/command
link_target=/usr/lib/package/command
and then we'll copy /lib/package/command to /usr/lib/package/command
and make /usr/bin/command a symlink to it. This is not what we used
to do and not the most sensible behaviour.
mkinitramfs already creates usr-merge symlinks in the initramfs so we
don't need to worry about creating duplicates when source files are
named via such symlinks on the host. So if the host system is
usr-merged, canonicalise source filenames that use the usr-merge
symlinks before doing symlink detection.
Fixes: b641a97705c1 ("hook_functions: Fix copy_file with source including a ...")
Signed-off-by: Ben Hutchings <benh@debian.org>
Until recently, copy_file would treat a target ending in a slash as a
target directory. This was not intended behaviour, but had worked
since at least v0.98.8. It broke when I started using 'realpath' to
canonicalise the target, which stripped the slash.
Add a specific check for a trailing slash, and document that
behaviour.
Fixes: 984bdc7d727f ("hook-functions: copy_file: Canonicalise target filename")
Closes: #1082647
Signed-off-by: Ben Hutchings <benh@debian.org>
The documentation is currently a bit vague and doesn't mention
creation of directories or symlinks at all. Expand it to describe the
current behaviour.
Signed-off-by: Ben Hutchings <benh@debian.org>
- qmi_helpers uses AF_QIPCRTR to communicate, but there is no dependency
on qrtr module, providing that address family
- panel-edp might require PWM backlight, but there is no corresponding
devlink / dependency
- drm/msm driver uses Type-C modules on DisplayPort-enabled platforms,
but devlinks can be missing because of the devlink loop resolution.
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Add ChromeOS platform driver modules for MODULES=most, based on dracut's
90kernel-modules script. These were added in dracut commit e69e41326241
("feat(kernel-modules): install platform/chrome modules on ARM/RISC-V")
by me, because they include drivers Chromebooks need to communicate with
their embedded controller, which in turn is necessary for functionality
like keyboard, USB, and display backlight.
The platform modules include cros_ec_spi that we already include, so we
no longer need to explicitly include that.
Link: e69e413262
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Add serial I/O driver modules for MODULES=most, based on dracut's
90kernel-modules script. These were added in dracut commit 180e9d78516f
("kernel-modules: install all HID drivers").
The serial I/O modules include hyperv-keyboard that we explicitly add,
so we can drop the explicit addition.
Link: 180e9d7851
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Add serial driver modules for MODULES=most, based on dracut's
90kernel-modules script. These were added in dracut commit c1699b59c6ec
("kernel-modules: add serial line drivers"). However, most of these have
already been enabled as built-in on the Debian kernel.
Link: c1699b59c6
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Add USB Type-C driver modules for MODULES=most, based on dracut's
90kernel-modules script. These were added in dracut commit a1287c627f28
("fix(90kernel-modules): add Type-C USB drivers for generic initrd"),
stating they can be necessary for input, external display and storage.
We already add the USB Type-C Port Controller drivers, which we can
replace with its parent directory.
Link: a1287c627f
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Add watchdog driver modules for MODULES=most, based on dracut's
90kernel-modules script. These were added in dracut commit 3a60c036db7c
("fix(90kernel-modules): add watchdog drivers for generic initrd"),
stating that we might not be able ping a hardware watchdog fast enough
if we wait until we mount the root filesystem.
Link: 3a60c036db
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Add Direct Memory Access drivers for MODULES=most, based on dracut's
90kernel-modules script. These were added in dracut commit 917e1b6b5b26
("Add check for aarch64 to the arm kernel module list"), stating that
they can add significant performance to storage drivers and often need
to be present when those are loaded.
The dma drivers include pl330 that is being added as a hidden dependency
for the rockchip-spi driver, but that relation is still necessary for
MODULES=dep.
Link: 917e1b6b5b
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Add Dynamic Voltage and Frequency Scaling drivers for MODULES=most,
based on dracut's 90kernel-modules script. These were added in dracut
commit 38ea7e821bce ("Include devfreq drivers in initrd"), stating that
some SoCs have drivers that need these in early init.
The devfreq modules include the respective governors. The panfrost
graphics driver is known to fail without one of these governors, which
led to PM_DEVFREQ and DEVFREQ_GOV_SIMPLE_ONDEMAND being built-in on
Debian (see kernel-team/linux!1066).
Link: 38ea7e821b
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Add the Qualcomm Inter-Processor Communication driver for MODULES=most,
based on dracut's 90kernel-modules script. This was added in dracut
commit dd9a4bc1b13a ("feat(kernel-modules): add Qualcomm IPC router to
enable USB") stating that it is necessary in order to use USB drives,
more specifically in the ARM ThinkPad X13s.
The driver is in the net directory, but apparently this is misleading
since it handles communication between different SoC parts in general,
including those unrelated to networking in the common sense.
Link: dd9a4bc1b1
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Add System Power Management Interface drivers for MODULES=most, based on
dracut's 90kernel-modules script. These were added in dracut commit
9491c2852501 ("feat(kernel-modules): Install SPMI modules on
ARM/RISC-V"), stating the Mediatek PCIe and PHY drivers depend on
spmi-mtk-pmif (although the latter is built-in on Debian).
Link: 9491c28525
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Add power-related drivers for MODULES=most, based on dracut's
90kernel-modules script. These were added in dracut commit e752d42de9c3
("modules: kernel: add phy and power modules to generic initrd"), which
states they are needed for the NextThing C.H.I.P. and some Exynos
devices. The commit also adds PHY drivers, which we already add.
The power drivers include the axp20x_usb_power we already explicitly
add, so we can fold that into the general case now.
Link: e752d42de9
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Add non-volatile memory drivers for MODULES=most, based on dracut's
90kernel-modules script. These were added in dracut commit bc965cd88900
("fix(kernel-modules): always include nvmem driver on nvmem_on_arm"),
stating they are needed to boot on SoCs like NXP i.MX.
The nvmem drivers include nvmem_mtk-efuse that is being added as a
hidden dependency for a display-related PHY on MediaTek devices, though
that relation is still necessary for MODULES=dep. They also include
nvmem-imx-ocotp that we explicitly add in the net section, so we can fold
the latter into the general case.
Link: bc965cd889
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Add external memory controller drivers, based on dracut's
90kernel-modules script. These were added in dracut commit commit
07c671cc51efc ("feat(kernel-modules): add driver memory"), stating that
tegra_drm depends on tegra*_emc drivers (although those default to being
built-in).
The memory drivers also include mtk-smi, which is already transitively
included by display-related modules for MediaTek devices as a fw_devlink
dependency.
Link: 07c671cc51
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Add hardware mailbox drivers for MODULES=most, based on dracut's
90kernel-modules script. These were added in dracut commit 0e80ff72e01d
("fix(kernel-modules): add mailbox drivers for arm") which states these
might be needed by other devices used in the initrd, with the example
that sdhci-iproc requires bcm2835-mailbox on Raspberry Pi 4 (although
the latter is built-in on Debian).
The mailbox drivers also include mtk-cmdq-mailbox, which is already
transitively included by display-related modules for MediaTek devices as
a fw_devlink dependency.
Link: 0e80ff72e0
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Add on-chip interconnect management driver modules for MODULES=most,
based on dracut's 90kernel-modules script. These were added in dracut
commit afb5717e6772 ("fix(kernel-modules): add interconnect drivers"),
stating that many device-tree based systems require them.
The interconnect modules include imx8mq-interconnect that we have in
framebuffer-specific modules, so we can remove it from that list. They
also include qnoc-sc8280xp which is known to be necessary for the ARM
ThinkPad X13s.
Link: afb5717e67
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Add remote processor messaging and hardware spinlock drivers for
MODULES=most, based on dracut's 90kernel-modules script. These were
added in dracut commit 82651e9ef3c4 ("Add rpmsg, hwspinlock and usb/misc
for ARM") without much discussion beyond stating that more complex
devices now need them in the early boot process.
The dracut commit also includes miscellaneous USB drivers, but there are
too many unnecessary drivers there, so let's not include the whole
directory and instead only add necessary ones as we find out.
Link: 82651e9ef3
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Add SoC and external connector driver modules for MODULES=most, based on
dracut's 90kernel-modules script. These were added in dracut commit
39018c93c2bc ("arm: add soc/extcon/mfd as they're often needed for USB
and core memory/soc drivers"). We already include multi-function device
drivers that commit also adds.
The SoC modules include rockchip-io-domain and mtk-pmic-wrap that are
being added as hidden dependencies, though that relation is still
necessary for MODULES=dep. The external connector modules include
extcon-cros-ec and extcon-usb-gpio that we explicitly add, so we can
delist those two.
Link: 39018c93c2
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
When updating copy_file I have assumed that expected the target
argument is an absolute file (or directory) name. This was not
previously required, and is even our own example hook does not include
a leading "/".
This is a longstanding bug, but apparently didn't have much of an
effect until commit b641a97705c1 ("hook_functions: Fix copy_file with
source including a directory symlink").
The reiserfsprogs hook runs:
copy_exec /sbin/reiserfsck sbin/reiserfsck
which now results in:
src=/sbin/reiserfsck
target=sbin/reiserfsck # did not match usr-merge patterns
link_target=/usr/sbin/reiserfsck # host is usr-merged
We make a symlink from ${DESTDIR}//usr/sbin/reiserfsck to
${DESTDIR}/sbin/reiserfsck, i.e. a self-link, and try to copy
/usr/sbin/reiserfsck to ${DESTDIR}/sbin/reiserfsck, which fails.
Prepend a "/" to the target and canonicalise it with "realpath -ms"
before doing any filename comparisons.
Fixes: e5476bff04c0 ("copy_file: Skip duplicating symlink if it points to ...")
Fixes: 4807ede18d88 ("hook-functions: Avoid symlinks that conflict with ...")
Closes: #1079276
Signed-off-by: Ben Hutchings <benh@debian.org>
mkinitramfs etc. are normally run as root, so it probably makes sense
to run the tests as root. Additionally, on Debian armhf we now need
to run as root in order to create dummy files under /lib/firmware.
Add "Restrictions: needs-root" to all tests.
Since modifying /lib/firmware is potentially breaking, also add
"Restrictions: breaks-testbed".
Signed-off-by: Ben Hutchings <benh@debian.org>
dracut-install was briefly broken (due to Debian bug #1079022) and
mkinitramfs did not treat this as a fatal error.
There are many cases where we fail to check for errors, and it will
take a lot of effort to fix them all. But we can at least start by
catching this particular failure and not building a broken initramfs:
- In apply_add_modules in hook-functions, return early if
_call_dracut_install fails
- In mkinitramfs, exit if apply_add_modules fails
Closes: #1079066
Signed-off-by: Ben Hutchings <benh@debian.org>