From e635e3e720f2cb443d5fa8baa498a9c6baffee8d Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Wed, 4 Dec 2024 22:06:12 +0100 Subject: [PATCH 1/6] test: Remove dead code --- test/test.mk | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/test.mk b/test/test.mk index 5ac14555..e5a43bdd 100644 --- a/test/test.mk +++ b/test/test.mk @@ -6,11 +6,6 @@ test-specification := $(O)/images/test-specification.pdf UNIT_TESTS ?= $(test-dir)/case/all-repo.yaml $(test-dir)/case/all-unit.yaml TESTS ?= $(test-dir)/case/all.yaml -ifeq ($INFIX_OEM_PATH), "") -GIT_PATH = $(INFIX_OEM_PATH) -else -GIT_PATH = $(BR2_EXTERNAL_INFIX_PATH) -endif GIT_VERSION = $(shell git -C $(GIT_PATH) describe --dirty --always --tags) base := -b $(base-dir) From d16ad7eedcfde824833f68055aa60b1fa1941aaf Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Wed, 4 Dec 2024 22:33:44 +0100 Subject: [PATCH 2/6] build: Define build id and version in one place Before this change, setting `GIT_VERSION` in `make`'s environment was intended to allow the user to specify a custom build id. As it turns out, `test/test.mk` had duplicated the logic from `board/common/post-build.sh` to unconditionally override any value set in it. Because of the way `make` handles variables, where assignments to variables inherited from the environment are exported back to it[^1], this would mean that `test.mk` would always clobber any value set by the user. Furthermore, there is also this file called `buildroot/package/git/git.mk`, which also (reasonably) has opinions about what the proper value of `GIT_VERSION` should be. In summary, this was a bit of a mess. Therefore: Make sure that there is one single place where we determine the build id and version, and make sure that those variables are scoped under the `INFIX_` prefix to avoid clashing with any other component. [^1]: https://www.gnu.org/software/make/manual/html_node/Environment.html --- board/common/mkrauc.sh | 4 +--- board/common/post-build.sh | 26 +++++--------------------- external.mk | 4 +--- infix.mk | 10 ++++++++++ test/test.mk | 3 +-- 5 files changed, 18 insertions(+), 29 deletions(-) diff --git a/board/common/mkrauc.sh b/board/common/mkrauc.sh index a528c7fa..6cb30c28 100755 --- a/board/common/mkrauc.sh +++ b/board/common/mkrauc.sh @@ -2,8 +2,6 @@ set -e -GIT_VERSION=$(git -C "$BR2_EXTERNAL_INFIX_PATH" describe --always --dirty --tags) - name=$1 compat=$2 sign=$3 @@ -26,7 +24,7 @@ cp -f "$BINARIES_DIR/rootfs.itbh" "$work/rootfs.itbh" cat >"$work/manifest.raucm" < "$TARGET_DIR/etc/os-release" -echo "$INFIX_TAGLINE $VERSION -- $(date +"%b %e %H:%M %Z %Y")" > "$TARGET_DIR/etc/version" +echo "$INFIX_TAGLINE $INFIX_VERSION -- $(date +"%b %e %H:%M %Z %Y")" > "$TARGET_DIR/etc/version" # In case of ambguities, this is what the image was built from cp "$BR2_CONFIG" "$TARGET_DIR/usr/share/infix/config" diff --git a/external.mk b/external.mk index 18c3c019..773e586f 100644 --- a/external.mk +++ b/external.mk @@ -1,9 +1,7 @@ -IXMSG = printf "\e[37;44m>>> $(call qstrip,$(1))\e[0m\n" - +include $(BR2_EXTERNAL_INFIX_PATH)/infix.mk include $(sort $(wildcard $(BR2_EXTERNAL_INFIX_PATH)/package/*/*.mk)) include $(BR2_EXTERNAL_INFIX_PATH)/board/common/common.mk -include $(BR2_EXTERNAL_INFIX_PATH)/board/$(patsubst "%",%,$(BR2_ARCH))/board.mk -include $(BR2_EXTERNAL_INFIX_PATH)/infix.mk include $(BR2_EXTERNAL_INFIX_PATH)/test/test.mk .PHONY: local.mk diff --git a/infix.mk b/infix.mk index d710f494..1a91fb28 100644 --- a/infix.mk +++ b/infix.mk @@ -1 +1,11 @@ +IXMSG = printf "\e[37;44m>>> $(call qstrip,$(1))\e[0m\n" + +INFIX_TOPDIR = $(if $(INFIX_OEM_PATH),$(INFIX_OEM_PATH),$(BR2_EXTERNAL_INFIX_PATH)) + +# Unless the user specifies an explicit build id, source it from git. +# The build id also becomes the image version, unless an official +# release is being built. +export INFIX_BUILD_ID ?= $(shell git -C $(INFIX_TOPDIR) describe --dirty --always --tags) +export INFIX_VERSION = $(if $(INFIX_RELEASE),$(INFIX_RELEASE),$(INFIX_BUILD_ID)) + INFIX_CFLAGS:=-Wall -Werror -Wextra -Wno-unused-parameter -Wformat=2 -Wformat-overflow=2 -Winit-self -Wstrict-overflow=4 -Wno-format-truncation -Wno-format-nonliteral diff --git a/test/test.mk b/test/test.mk index e5a43bdd..34901600 100644 --- a/test/test.mk +++ b/test/test.mk @@ -6,7 +6,6 @@ test-specification := $(O)/images/test-specification.pdf UNIT_TESTS ?= $(test-dir)/case/all-repo.yaml $(test-dir)/case/all-unit.yaml TESTS ?= $(test-dir)/case/all.yaml -GIT_VERSION = $(shell git -C $(GIT_PATH) describe --dirty --always --tags) base := -b $(base-dir) @@ -34,7 +33,7 @@ test-sh: test-spec: @esc_infix_name="$(echo $(INFIX_NAME) | sed 's/\//\\\//g')"; \ - sed 's/{REPLACE}/$(subst ",,$(esc_infix_name)) $(GIT_VERSION)/' $(spec-dir)/Readme.adoc.in > $(spec-dir)/Readme.adoc + sed 's/{REPLACE}/$(subst ",,$(esc_infix_name)) $(INFIX_VERSION)/' $(spec-dir)/Readme.adoc.in > $(spec-dir)/Readme.adoc @$(spec-dir)/generate_spec.py -d $(test-dir)/case -r $(BR2_EXTERNAL_INFIX_PATH) @asciidoctor-pdf --failure-level INFO --theme $(spec-dir)/theme.yml -a pdf-fontsdir=$(spec-dir)/fonts -o $(test-specification) $(spec-dir)/Readme.adoc From 3436cd68ac3f57b2deb4a200340cc673730a386d Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Thu, 5 Dec 2024 10:49:04 +0100 Subject: [PATCH 3/6] doc: branding: Update documentation around version variables --- doc/branding.md | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/doc/branding.md b/doc/branding.md index a73b2fe1..be3b5847 100644 --- a/doc/branding.md +++ b/doc/branding.md @@ -370,22 +370,30 @@ But you can of course use only two numbers, *major.minor*, as well. > with your own versioning scheme. -### `INFIX_RELEASE` +### Specifying Versioning Information -This global variable **must be** a lower-case string (no spaces or -other characters outside of 0–9, a–z, '.', '_' and '-') identifying -the operating system version, excluding any OS name information or -release code name, and suitable for processing by scripts or usage -in generated filenames. +Two optional environment variables control the version information +recorded in images. Both of these **must be** a lower-case string (no +spaces or other characters outside of 0–9, a–z, '.', '_' and '-') +identifying the operating system version, excluding any OS name +information or release code name, and suitable for processing by +scripts or usage in generated filenames. + +#### `INFIX_BUILD_ID` + +Used for `BUILD_ID` in `/etc/os-release`. + +**Default:** `$(git describe --always --dirty --tags)`, from the _top +directory_. By default, the top directory refers to the root of the +Infix source tree, but this can be changed by setting the branding +variable `INFIX_OEM_PATH`, e.g. in a `defconfig` file or via `make +menuconfig`, to the path of an enclosing br2-external. + +#### `INFIX_RELEASE` Used for `VERSION` and `VERSION_ID` in `/etc/os-release` and generated file names like disk images, etc. -**Default:** generated using `git describe --always --dirty --tags`, -with an additional `-C $infix_path`. This variable defaults to the -Infix tree and can be changed by setting the menuconfig branding -variable `INFIX_OEM_PATH` to that of the br2-external. It is also -possible to set the `GIT_VERSION` variable in your `post-build.sh` -script to change how the VCS version is extracted. +**Default:** `${INFIX_BUILD_ID}` [NanoPi R2S]: https://github.com/kernelkit/infix/blob/main/board/aarch64/r2s/rootfs/etc/factory-config.cfg From 89c5b67a1330166f000e80549fecf0c63da9cc3f Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Wed, 4 Dec 2024 14:54:22 +0100 Subject: [PATCH 4/6] .github: Set more informative build id on PR builds --- .github/workflows/build.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a562adf9..b71b1ebb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,6 +22,8 @@ jobs: matrix: target: [aarch64, x86_64] fail-fast: false + outputs: + build_id: ${{ steps.vars.outputs.INFIX_BUILD_ID }} steps: - name: Cleanup Build Folder run: | @@ -38,6 +40,16 @@ jobs: - name: Set Build Variables id: vars run: | + if [ -n "${{ github.event.pull_request.head.sha }}" ]; then + # Since PRs are built from an internally generated merge + # commit, reverse lookups of PRs and/or commits from + # image version information are cumbersome. Therefore: + # explicitly set a build id that references both the PR + # and the commit. + printf "INFIX_BUILD_ID=pr%d.%.7s\n" \ + "${{ github.event.number }}" "${{ github.event.pull_request.head.sha }}" \ + | tee -a $GITHUB_OUTPUT $GITHUB_ENV + fi if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then if [ "${{ github.event.inputs.minimal }}" == "true" ]; then flavor="_minimal" @@ -132,6 +144,11 @@ jobs: - name: Set Build Variables id: vars run: | + if [ -n "${{ needs.build.outputs.build_id }}" ]; then + echo "INFIX_BUILD_ID=${{ needs.build.outputs.build_id }}" \ + >>$GITHUB_ENV + fi + if [ "$GITHUB_REF_NAME" != "main" ]; then flavor="_minimal" else From 94cffd2c48c2d25545ea7a90086ba848fbcfa977 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Wed, 4 Dec 2024 22:55:01 +0100 Subject: [PATCH 5/6] doc: Mention kernel 6.12 update in the ChangeLog --- doc/ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/ChangeLog.md b/doc/ChangeLog.md index c661b668..969b8ced 100644 --- a/doc/ChangeLog.md +++ b/doc/ChangeLog.md @@ -12,6 +12,7 @@ All notable changes to the project are documented in this file. - Add support for more mDNS settings: allow/deny interfaces, acting as "reflector" and filtering of reflected services. Issue #678 - Review of default `sysctl` settings, issue #829 + - Upgrade Linux kernel to 6.12.1 (presumed LTS) ### Fixes From 967388395f9f861c745c91c5d5ef4c4bf726d122 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Thu, 5 Dec 2024 10:49:39 +0100 Subject: [PATCH 6/6] test: netns: Avoid infinite hangs on exceptions in `.call()`s If the callable threw an exception, then the process running inside the netns would exit before sending back a value on the tx pipe, which meant that `rx.recv()` would hang in the original process. Make sure that we catch any exceptions, and send that instead of the result over the pipe in those scenarios. Then in the original process, re-raise the exception. --- test/infamy/netns.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/infamy/netns.py b/test/infamy/netns.py index 8f3cbe11..daa970b7 100644 --- a/test/infamy/netns.py +++ b/test/infamy/netns.py @@ -139,6 +139,10 @@ class IsolatedMacVlans: f"{a[0]:02x}:{a[1]:02x}:{a[2]:02x}:" + \ f"{a[3]:02x}:{a[4]:02x}:{a[5]:02x}" + class CallException: + def __init__(self, inner): + self.inner = inner + def _ns_call(self, fn, tx): pid = self.sleeper.pid @@ -150,7 +154,12 @@ class IsolatedMacVlans: setns(nns, CLONE_NEWNET) os.close(nns) - tx.send(fn()) + try: + ret = fn() + except Exception as e: + ret = IsolatedMacVlans.CallException(e) + + tx.send(ret) tx.close() def call(self, fn): @@ -161,6 +170,9 @@ class IsolatedMacVlans: ret = rx.recv() rx.close() proc.join() + + if type(ret) == IsolatedMacVlans.CallException: + raise ret.inner return ret def _mangle_subprocess_args(self, args, kwargs):