From 4aa0ab73b3b26b9e62f89e4fcde5982c61580715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Walstr=C3=B6m?= Date: Fri, 20 Feb 2026 16:24:48 +0100 Subject: [PATCH 1/2] init: Move all copy of files to before udev triger is run This since we may copy udev-rules dependeing on platforms, this fix #1357 Also remove all workaround scripts we have added for this purpose. --- .../etc/product/init.d/S01-trigger-udev.sh | 3 -- .../etc/product/init.d/S01-trigger-udev.sh | 3 -- .../etc/product/init.d/S01-trigger-udev.sh | 4 -- .../etc/product/init.d/S01-trigger-udev.sh | 4 -- .../usr/lib/finit/system/05-pre-udev.conf | 18 +++++++ .../usr/lib/finit/system/20-hw-wait.conf | 2 +- .../usr/libexec/infix/init.d/05-product | 30 +++--------- .../common/rootfs/usr/libexec/infix/pre-udev | 48 +++++++++++++++++++ 8 files changed, 73 insertions(+), 39 deletions(-) delete mode 100755 board/aarch64/bananapi-bpi-r3/rootfs/usr/share/product/bananapi,bpi-r3/etc/product/init.d/S01-trigger-udev.sh delete mode 100755 board/aarch64/friendlyarm-nanopi-r2s/rootfs/usr/share/product/friendlyarm,nanopi-r2s/etc/product/init.d/S01-trigger-udev.sh delete mode 100755 board/aarch64/raspberrypi-rpi64/rootfs/usr/share/product/raspberrypi,4-compute-module/etc/product/init.d/S01-trigger-udev.sh delete mode 100755 board/aarch64/raspberrypi-rpi64/rootfs/usr/share/product/raspberrypi,4-model-b/etc/product/init.d/S01-trigger-udev.sh create mode 100644 board/common/rootfs/usr/lib/finit/system/05-pre-udev.conf create mode 100755 board/common/rootfs/usr/libexec/infix/pre-udev diff --git a/board/aarch64/bananapi-bpi-r3/rootfs/usr/share/product/bananapi,bpi-r3/etc/product/init.d/S01-trigger-udev.sh b/board/aarch64/bananapi-bpi-r3/rootfs/usr/share/product/bananapi,bpi-r3/etc/product/init.d/S01-trigger-udev.sh deleted file mode 100755 index facaccd16..000000000 --- a/board/aarch64/bananapi-bpi-r3/rootfs/usr/share/product/bananapi,bpi-r3/etc/product/init.d/S01-trigger-udev.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -udevadm control --reload-rules -udevadm trigger --subsystem-match=net --action=add diff --git a/board/aarch64/friendlyarm-nanopi-r2s/rootfs/usr/share/product/friendlyarm,nanopi-r2s/etc/product/init.d/S01-trigger-udev.sh b/board/aarch64/friendlyarm-nanopi-r2s/rootfs/usr/share/product/friendlyarm,nanopi-r2s/etc/product/init.d/S01-trigger-udev.sh deleted file mode 100755 index facaccd16..000000000 --- a/board/aarch64/friendlyarm-nanopi-r2s/rootfs/usr/share/product/friendlyarm,nanopi-r2s/etc/product/init.d/S01-trigger-udev.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -udevadm control --reload-rules -udevadm trigger --subsystem-match=net --action=add diff --git a/board/aarch64/raspberrypi-rpi64/rootfs/usr/share/product/raspberrypi,4-compute-module/etc/product/init.d/S01-trigger-udev.sh b/board/aarch64/raspberrypi-rpi64/rootfs/usr/share/product/raspberrypi,4-compute-module/etc/product/init.d/S01-trigger-udev.sh deleted file mode 100755 index 94fdb56e7..000000000 --- a/board/aarch64/raspberrypi-rpi64/rootfs/usr/share/product/raspberrypi,4-compute-module/etc/product/init.d/S01-trigger-udev.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# Workaround for: https://github.com/kernelkit/infix/issues/1357 -udevadm control --reload-rules -udevadm trigger --subsystem-match=net --action=add diff --git a/board/aarch64/raspberrypi-rpi64/rootfs/usr/share/product/raspberrypi,4-model-b/etc/product/init.d/S01-trigger-udev.sh b/board/aarch64/raspberrypi-rpi64/rootfs/usr/share/product/raspberrypi,4-model-b/etc/product/init.d/S01-trigger-udev.sh deleted file mode 100755 index 94fdb56e7..000000000 --- a/board/aarch64/raspberrypi-rpi64/rootfs/usr/share/product/raspberrypi,4-model-b/etc/product/init.d/S01-trigger-udev.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# Workaround for: https://github.com/kernelkit/infix/issues/1357 -udevadm control --reload-rules -udevadm trigger --subsystem-match=net --action=add diff --git a/board/common/rootfs/usr/lib/finit/system/05-pre-udev.conf b/board/common/rootfs/usr/lib/finit/system/05-pre-udev.conf new file mode 100644 index 000000000..4dfe97c68 --- /dev/null +++ b/board/common/rootfs/usr/lib/finit/system/05-pre-udev.conf @@ -0,0 +1,18 @@ +# Copy product-specific files (udev rules, factory config, etc.) to / +# based on DT compatible strings, before udevd processes any events. +# +# fires after all filesystems are mounted but before +# finit enters runlevel S and starts any service, so the run task is +# guaranteed to start ahead of udevd. The +# condition below then blocks udevd until pre-udev has finished. +# +# Systems without a matching product directory exit immediately. +run name:preudev cgroup.init [S] log \ + /usr/libexec/infix/pre-udev -- Probing platform + +# Hold udevd back until pre-udev has had a chance to install any +# product-specific udev rules so that they are applied on first pass. +service nowarn cgroup.system name:udevd notify:none env:-/etc/default/udevd pid:udevd log \ + [S12345789] /lib/systemd/systemd-udevd $UDEVD_ARGS -- Device event daemon (udev) +service nowarn cgroup.system name:udevd notify:none env:-/etc/default/udevd pid:udevd log \ + [S12345789] udevd $UDEVD_ARGS -- Device event daemon (udev) diff --git a/board/common/rootfs/usr/lib/finit/system/20-hw-wait.conf b/board/common/rootfs/usr/lib/finit/system/20-hw-wait.conf index 5d6bc0c12..7b436fbbe 100644 --- a/board/common/rootfs/usr/lib/finit/system/20-hw-wait.conf +++ b/board/common/rootfs/usr/lib/finit/system/20-hw-wait.conf @@ -5,5 +5,5 @@ run nowarn if:udevd cgroup.init log \ # Now that everything should be probed, do a final pass over the # uevent queue before starting syslogd and everything else -run nowarn if:udevd cgroup.init :post log \ +run nowarn if:udevd cgroup.init :post log \ [S] udevadm settle -t 30 -- diff --git a/board/common/rootfs/usr/libexec/infix/init.d/05-product b/board/common/rootfs/usr/libexec/infix/init.d/05-product index 285ca5606..ea5a1af85 100755 --- a/board/common/rootfs/usr/libexec/infix/init.d/05-product +++ b/board/common/rootfs/usr/libexec/infix/init.d/05-product @@ -1,40 +1,22 @@ #!/bin/sh -# Find, install, and run product specific files and script in /etc -# before resuming bootstrap. +# Run product specific init scripts and set bootstrap conditions. +# +# Product-specific files (udev rules, factory config, etc.) are already +# copied to / by the pre-udev run task before udevd starts. This +# script handles the remaining product init: running custom scripts +# from /etc/product/init.d/ and setting finit conditions. # # Use /etc/product/init.d/S01-myscript for scripts, may be a symlink, it # will be called with `start` as its only argument. -# -# The compatible array is listed in the same order as the device tree, -# most significant to least. Hence the reverse.[], to ensure overrides -# are applied in order of significance. ident=$(basename "$0") PRODUCT_INIT=/etc/product/init.d -PREFIXD=/usr/share/product -COMPATIBLES=$(jq -r '.compatible | reverse.[] | ascii_downcase' /run/system.json) note() { logger -I $$ -k -p user.notice -t "$ident" "$1" } -found=false -for PRODUCT in $COMPATIBLES; do - DIR="$PREFIXD/$PRODUCT" - if [ -d "$DIR" ]; then - note "Using vendor/product-specific defaults for $PRODUCT." - for dir in "$DIR"/*; do - [ -d "$dir" ] && cp -a "$dir" / - done - found=true - fi -done - -if [ "$found" = false ]; then - note "No vendor/product-specific directory found, using built-in defaults." -fi - # Conditions for bootstrap services, this enables product specific # init scripts to prevent select services from starting. initctl -nbq cond set led diff --git a/board/common/rootfs/usr/libexec/infix/pre-udev b/board/common/rootfs/usr/libexec/infix/pre-udev new file mode 100755 index 000000000..2cbc4b1f1 --- /dev/null +++ b/board/common/rootfs/usr/libexec/infix/pre-udev @@ -0,0 +1,48 @@ +#!/bin/sh +# Copy product-specific files to / based on DT compatible strings. +# Designed to run before udevd, so that udev rules are in place when +# the kernel starts enumerating devices. No Python, no jq, no syslogd. +# +# Mirrors the platform detection from 00-probe and the copy logic from +# 05-product, but reads the DT directly instead of /run/system.json. + +PREFIXD=/usr/share/product +COMPAT=/sys/firmware/devicetree/base/compatible +IDENT=$(basename "$0") + +note() +{ + logger -I $$ -k -p user.notice -t "$IDENT" "$*" +} + +# Only DT-based systems have product-specific data keyed by compatible. +# QEMU and x86/DMI systems have no product dirs to copy. +[ -f "$COMPAT" ] || exit 0 + +# The DT compatible property is a null-separated list of strings, +# ordered most-specific first (e.g. "bananapi,bpi-r3\0mediatek,mt7986a"). +# Reverse the list so least-specific is applied first and more-specific +# overrides it, matching the behaviour of 05-product. +reversed="" +while IFS= read -r c; do + [ -n "$c" ] || continue + reversed="$c${reversed:+ $reversed}" +done < Date: Wed, 11 Feb 2026 08:28:15 +0100 Subject: [PATCH 2/2] test: Return fail if `make test` fails $? needs to be $$? inside a make rule to expand the bash variable. --- test/test.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test.mk b/test/test.mk index fe440d8c3..9ff8d4c54 100644 --- a/test/test.mk +++ b/test/test.mk @@ -30,7 +30,7 @@ endif test: $(test-dir)/env -r $(base) $(mode) $(binaries) $(pkg-$(ARCH)) \ - sh -c '$(ninepm) -v $(TESTS); rc=$?; \ + sh -c '$(ninepm) -v $(TESTS); rc=$$?; \ $(ninepm_report) github $(test-dir)/.log/last/result.json; \ $(ninepm_report) asciidoc $(test-dir)/.log/last/result.json; \ chmod -R 777 $(test-dir)/.log; \