Skip to content

Commit

Permalink
Upgraded patch for Mender package builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
lueschem committed Dec 6, 2024
1 parent c7ee67f commit d1062b2
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 231 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
From 5dd05921a17a02366a0624cd233c2179f63ba4de Mon Sep 17 00:00:00 2001
From 1813d0dee11b077df0d34de26e47168909b65757 Mon Sep 17 00:00:00 2001
From: Matthias Luescher <[email protected]>
Date: Fri, 28 Jun 2024 13:50:26 +0200
Subject: [PATCH] Removed Raspbian specific setup, allow cross compilation on
arm64.
Date: Fri, 6 Dec 2024 14:36:20 +0100
Subject: [PATCH] Allow cross compilation on arm64, use podman.

---
docker-build-package | 26 ++++++++--------
mender-deb-package | 70 +++++++++++++++++++++++++-------------------
2 files changed, 52 insertions(+), 44 deletions(-)
docker-build-package | 22 +++++++++---------
mender-deb-package | 53 +++++++++++++++++++++++++++++++-------------
2 files changed, 49 insertions(+), 26 deletions(-)

diff --git a/docker-build-package b/docker-build-package
index eafb1a4..01f22fb 100755
index 600b6db..7b916a2 100755
--- a/docker-build-package
+++ b/docker-build-package
@@ -16,7 +16,7 @@
Expand All @@ -22,7 +21,7 @@ index eafb1a4..01f22fb 100755

declare -A mender_client_props=(
[recipe_name]="mender-client"
@@ -138,8 +138,10 @@ if [ $commercial = "true" -a -z "${MENDER_PRIVATE_REPO_ACCESS_TOKEN}" ]; then
@@ -139,8 +139,10 @@ if [ $commercial = "true" -a -z "${MENDER_PRIVATE_REPO_ACCESS_TOKEN}" ]; then
exit 1
fi

Expand All @@ -35,7 +34,7 @@ index eafb1a4..01f22fb 100755
echo "Not building arch independent package $recipe_name on architecture $ARCH"
exit 0
fi
@@ -155,31 +157,27 @@ orig_dir="output/orig"
@@ -156,18 +158,18 @@ orig_dir="output/orig"

mkdir -p "${output_dir}" "${orig_dir}"

Expand All @@ -59,47 +58,38 @@ index eafb1a4..01f22fb 100755
echo "Including source packages in the build."
BUILD_TYPE="source,${BUILD_TYPE}"
fi
@@ -180,7 +182,7 @@ fi

PLATFORM=""

-if [ "$ARCH" = "armhf" -a "$DISTRO" = "debian" ]; then
- PLATFORM="--platform=linux/arm/v6"
-fi
-
echo

-docker run --rm \
+podman run --rm \
--volume $(pwd)/recipes:/recipes \
--volume $(pwd)/${output_dir}:/output \
--volume $(pwd)/${orig_dir}:/orig \
@@ -188,7 +186,7 @@ docker run --rm \
@@ -189,7 +191,7 @@ docker run --rm \
--env MENDER_PRIVATE_GPG_KEY_BUILD \
--env OVERRIDE_DEBIAN_SUFFIX \
${PLATFORM} \
- ${IMAGE_NAME_PREFIX}-${DISTRO}-${RELEASE}-${ARCH}-${IMAGE_VERSION:-master} \
- ${IMAGE_NAME_PREFIX}-${BUILD}-${DISTRO}-${RELEASE}-${ARCH}-${IMAGE_VERSION:-master} \
+ ${IMAGE_NAME_PREFIX}-${DISTRO}-${RELEASE} \
/script \
${recipe_name} \
${BUILD_TYPE} \
diff --git a/mender-deb-package b/mender-deb-package
index 291de2c..d410429 100755
index 42d5f7d..f8cfb4e 100755
--- a/mender-deb-package
+++ b/mender-deb-package
@@ -61,11 +61,8 @@ checkout_repo() {
@@ -61,7 +61,7 @@ checkout_repo() {

install_go() {
local GOLANG_VERSION=1.21.1
- local GOLANG_ARCH=amd64
+ local GOLANG_ARCH=${HOST_ARCHITECTURE}
local golang_version_set
- if [ $ARCH = "armhf" -a $OS_DISTRO = "debian" ]; then
- local GOLANG_ARCH=armv6l
- fi

golang_version_set=$(sed -n '/[^ ]*GOLANG_VERSION:[ "0-9]/{s/.*GOLANG_VERSION:[ ]*\(["0-9\.]*\).*/\1/p;q}' .gitlab-ci.yml)
golang_version_set=${golang_version_set//\"/}
@@ -232,46 +229,57 @@ build_packages() {
if [ $ARCH = "armhf" -a $OS_DISTRO = "raspbian" ]; then
local GOLANG_ARCH=armv6l
@@ -234,11 +234,23 @@ build_packages() {

case "$ARCH" in
amd64)
Expand All @@ -108,60 +98,40 @@ index 291de2c..d410429 100755
- ${sign_flags} \
- ${dpkg_build_ignore_flag} \
- --build=$DEB_BUILD_TYPE
- ;;
-
- armhf)
- if [ "$OS_DISTRO" = "debian" ]; then
- # Native build (emulated ARM v6)
- dpkg-buildpackage \
- ${sign_flags} \
- ${dpkg_build_ignore_flag} \
- --build=$DEB_BUILD_TYPE
- else
- # Debian ARM 32bit toolchain
- CROSS_COMPILE="arm-linux-gnueabihf" \
+ if [ "$ARCH" != "${HOST_ARCHITECTURE}" ]; then
+ CROSS_COMPILE="x86_64-linux-gnu" \
CC="$CROSS_COMPILE-gcc" \
- PKG_CONFIG_PATH="/usr/lib/arm-linux-gnueabihf/pkgconfig/" \
- GOARCH=arm \
+ CC="$CROSS_COMPILE-gcc" \
+ PKG_CONFIG_PATH="/usr/lib/x86_64-linux-gnu/pkgconfig/" \
+ GOARCH=amd64 \
dpkg-buildpackage \
- --target-arch armhf \
+ dpkg-buildpackage \
+ --target-arch amd64 \
${sign_flags} \
${dpkg_build_ignore_flag} \
--build=$DEB_BUILD_TYPE
+ ${sign_flags} \
+ ${dpkg_build_ignore_flag} \
+ --build=$DEB_BUILD_TYPE
+ else
+ # Native build (amd64)
+ dpkg-buildpackage \
+ ${sign_flags} \
+ ${dpkg_build_ignore_flag} \
+ --build=$DEB_BUILD_TYPE
fi
+ fi
;;

armhf)
@@ -263,16 +275,23 @@ build_packages() {
;;

- arm64)
arm64)
- # Debian ARM 64bit toolchain
- CROSS_COMPILE="aarch64-linux-gnu" \
+ armhf)
+ # Debian ARM 32bit toolchain
+ CROSS_COMPILE="arm-linux-gnueabihf" \
CC="$CROSS_COMPILE-gcc" \
- CC="$CROSS_COMPILE-gcc" \
- PKG_CONFIG_PATH="/usr/lib/aarch64-linux-gnu/pkgconfig/" \
- GOARCH=arm64 \
+ PKG_CONFIG_PATH="/usr/lib/arm-linux-gnueabihf/pkgconfig/" \
+ GOARCH=arm \
dpkg-buildpackage \
- dpkg-buildpackage \
- --target-arch arm64 \
+ --target-arch armhf \
${sign_flags} \
${dpkg_build_ignore_flag} \
--build=$DEB_BUILD_TYPE
;;
+
+ arm64)
- ${sign_flags} \
- ${dpkg_build_ignore_flag} \
- --build=$DEB_BUILD_TYPE
+ if [ "$ARCH" != "${HOST_ARCHITECTURE}" ]; then
+ # Debian ARM 64bit toolchain
+ CROSS_COMPILE="aarch64-linux-gnu" \
Expand All @@ -179,11 +149,10 @@ index 291de2c..d410429 100755
+ ${dpkg_build_ignore_flag} \
+ --build=$DEB_BUILD_TYPE
+ fi
+ ;;
;;
esac
}

@@ -298,6 +306,8 @@ copy_deb_packages() {
@@ -300,6 +319,8 @@ copy_deb_packages() {
# Run script #
##############

Expand Down
117 changes: 0 additions & 117 deletions .github/patches/mender/Dockerfile.patch

This file was deleted.

47 changes: 0 additions & 47 deletions .github/patches/mender/mender-deb-package.patch

This file was deleted.

2 changes: 1 addition & 1 deletion .github/scripts/build-mender-packages
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fi
cd "${SCRIPT_DIR}/../../mender-dist-packages"

# Make sure we have a pure Debian armhf environment and add flexiblity to build on arm64 host:
git apply "${SCRIPT_DIR}/../patches/mender/0001-Removed-Raspbian-specific-setup-allow-cross-compilat.patch"
git apply "${SCRIPT_DIR}/../patches/mender/0001-Allow-cross-compilation-on-arm64-use-podman.patch"

declare -a architectures=("amd64" "armhf" "arm64")

Expand Down

0 comments on commit d1062b2

Please sign in to comment.