From 1fb379a3e959c319805e9ff258da0fc94fadd522 Mon Sep 17 00:00:00 2001
From: Martyn Welch <martyn.welch@collabora.com>
Date: Thu, 10 Nov 2022 14:36:12 +0000
Subject: [PATCH] Tweak packaging to build only on arm64, single package for
 binaries

At the moment we are only building for a single arm64 target, so mark
this as arm64 only (we may in the future build for arm32 as well, but
we're not at the moment). Also we'll produce a single package of
binaries for all supported boards. This package is used as a build time
dependency of U-Boot rather than being installed directly on a target.

Signed-off-by: Martyn Welch <martyn.welch@collabora.com>
---
 debian/control                                   |  6 ++----
 debian/{optee-os-k3.install => optee-os.install} |  0
 debian/rules                                     | 15 ++++++++++-----
 3 files changed, 12 insertions(+), 9 deletions(-)
 rename debian/{optee-os-k3.install => optee-os.install} (100%)

diff --git a/debian/control b/debian/control
index c46f7f1..0c578bb 100644
--- a/debian/control
+++ b/debian/control
@@ -5,8 +5,6 @@ Maintainer: Apertis package maintainers <packagers@lists.apertis.org>
 Standards-Version: 4.6.1
 Build-Depends: debhelper-compat (= 13),
                dh-sequence-python3,
-               crossbuild-essential-armhf,
-               crossbuild-essential-arm64,
                python3,
                python3-cryptography,
                python3-pyelftools
@@ -15,8 +13,8 @@ Vcs-Git: https://gitlab.apertis.org/pkg/optee-os.git
 Homepage: http://optee.readthedocs.io/
 Rules-Requires-Root: no
 
-Package: optee-os-k3
-Architecture: any
+Package: optee-os
+Architecture: arm64
 Depends: ${misc:Depends},
          ${shlibs:Depends}
 Description: OP-TEE Trusted OS
diff --git a/debian/optee-os-k3.install b/debian/optee-os.install
similarity index 100%
rename from debian/optee-os-k3.install
rename to debian/optee-os.install
diff --git a/debian/rules b/debian/rules
index 14e0ce2..e870745 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,10 +1,16 @@
 #!/usr/bin/make -f
 
-COMPILE=arm-linux-gnueabihf-
-COMPILE64=aarch64-linux-gnu-
+export COMPILE = aarch64-linux-gnu-
 
-PLATFORM = k3-am62x
-CFG_ARM64_core = y
+export PLATFORM = k3-am62x
+
+export CFG_ARM64_core = y
+
+# hardening -> relro breaks compilation with error "'-Wl,-z,relro' unknown"
+export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-relro
+
+# Build only 64-bit TAs
+export CFG_USER_TA_TARGETS = ta_arm64
 
 %:
 	dh $@
@@ -12,6 +18,5 @@ CFG_ARM64_core = y
 override_dh_auto_build:
 	make \
 	    CROSS_COMPILE=${COMPILE32} \
-	    CROSS_COMPILE64=${COMPILE64} \
             PLATFORM=${PLATFORM} \
             CFG_ARM64_core=${CFG_ARM64_core}
-- 
GitLab