pmaports/temp/akms/0002-Check-if-build-base-is-installed-by-checking-if-file.patch
Antoine Martin e927f76a7a
temp/akms: add with patches making sandboxing optional
AKMS builds modules in a sandbox using bubblewrap. Bubblewrap
unfortunately does not work in chroot environment, thus breaking
pmbootstrap. While a PR has been proposed upstream, history shows that
upstream takes a while to consider PRs. Thus, to unblock usage of AKMS,
this adds a patched version that allows disabling of sandbox using
`--no-sandbox` argument or by adding `use_sandbox=false` to
`/etc/akms.conf`. When building in chroot environment, sandboxing is
automatically disabled.

The aport handles conflicts with akms by setting `pkgver=9999$_pkgver`,
thus always overriding Alpine's package.

Upstream PR: https://github.com/jirutka/akms/pull/19

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6604
2025-06-16 08:46:13 -07:00

41 lines
1.6 KiB
Diff

From d35f03892032852742567e3443c1d4974d0ee813 Mon Sep 17 00:00:00 2001
From: Antoine Martin <dev@ayakael.net>
Date: Thu, 5 Jun 2025 14:18:21 -0400
Subject: [PATCH 2/2] Check if `build-base` is installed by checking if files
exist instead of apk
When building AKMS module without sandbox, and via kernel hooks, using
`apk` to check if `build-base` is installed won't work if it was added
via the same install transaction. Thus, following the approach of
`linux-*dev` package, we check if `build-base` is installed by looking
for key files (i.e gcc, patch, make). If those key files don't exist,
`build-base` is added to `makedepends` variable.
diff --git a/akms b/akms
index 95d66c8..e284ef1 100755
--- a/akms
+++ b/akms
@@ -124,7 +124,7 @@ MAKEFLAGS="-j$(nproc)"
readonly BUILD_USER=${build_user:-akms}
readonly BWRAP_OPTS=${bubblewrap_opts:-}
-readonly MAKEDEPENDS=${makedepends:-build-base}
+readonly MAKEDEPENDS=${makedepends:-}
readonly MAKEFLAGS
readonly MODULES_DEST_PATH=${modules_dest_path:-/kernel/extra/akms}
readonly MODULES_SRC_DIR=${modules_srcdir:-/usr/src}
@@ -526,6 +526,11 @@ install_makedepends() {
apk_opts="--root $build_root"
fi
+ # if any of these files are missing, it means `build-base` needs installing
+ if [ ! -f "/usr/bin/readelf" ] || [ ! -f "/usr/bin/file" ] || [ ! -f "/usr/bin/gcc" ] || [ ! -f "/usr/bin/g++" ] || [ ! -f "/usr/bin/make" ] || [ ! -f "/usr/bin/patch" ]; then
+ makedepends="$makedepends build-base"
+ fi
+
# If all $makedepends are installed, empty $makedepends.
[ "$makedepends" ] \
&& apk info $apk_opts -q --installed $makedepends \
--
2.49.0