From 570c44ed57f1174accc3258ce0b1d2f7c515c726 Mon Sep 17 00:00:00 2001 From: Geunsik Lim Date: Mon, 9 Mar 2020 20:36:01 +0900 Subject: [PATCH] arch: Fixed /usr/include/asm to build 32bit packages on 64bit Linux This commit is to handle a different attribute of CPU architectures between kernel-space and user-space. For example, the Tizen platform 6.0 consists the ARM64-based Linux kernel and ARM32-based Tizen platform packages. When the developer want to compile the user-space software packages to support a ARM32 bit CPU architecture, they meet an unexpected issue because the 'linux-glibc-devel' package is installed based on CPU architecture of the Linux kernel on the real target board. Therefore, we need to improve the compatibility of the user-space software packages based on 32bit CPU architecture. Let's replace the criteria from "uname -m" command to "%_arch" macro. Let's assume that the Tizen 6.0 platform is based on ARM32, and the Tizen Linux kernel is based on ARM64 bit (arm64/aarch64). **Changelog** * Version 3: - Removed "BuildArch: noarch" statement to handle correctly different architecure attribute of /usr/include/asm (symlink) * Version 2: - Use '_arch' instead of tizen-release package to avoid a build issue (Note that this package does not use the Unified repository.) - Fixed typos - Added annotation for maintenance * Version 1: - Replaced "uname -m" with "/etc/tizen-release" **Self assessment** * Checking asm_link variable in the post section $ rpm -qp --scripts ./linux-glibc-devel-3.10-0.aarch64.rpm | grep asm_link asm_link=aarch64 $ rpm -qp --scripts ./linux-glibc-devel-3.10-0.armv7l.rpm | grep asm_link asm_link=arm * On Tizen 6.0 (32bit) after this commit: It's incorrect. sh-3.2# ls -al /usr/include/asm lrwxrwxrwx 1 root root 7 Mar 4 14:26 /usr/include/asm -> asm-arm64 * On Tizen 6.0 (32bit) after this commit: It's correct. sh-3.2# ls -al /usr/include/asm lrwxrwxrwx 1 root root 7 Mar 9 19:38 /usr/include/asm -> asm-arm Change-Id: I8c25d840d7558db16b6a92c728555ed1c6a24891 Signed-off-by: Geunsik Lim --- packaging/linux-glibc-devel.spec | 58 +++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/packaging/linux-glibc-devel.spec b/packaging/linux-glibc-devel.spec index 392e794..921734a 100644 --- a/packaging/linux-glibc-devel.spec +++ b/packaging/linux-glibc-devel.spec @@ -16,7 +16,6 @@ Requires(pre): coreutils Provides: kernel-headers Provides: linux-kernel-headers = %{version} Obsoletes: linux-kernel-headers < %{version} -BuildArch: noarch BuildRequires: fdupes %description @@ -102,18 +101,21 @@ fi exit 0 %post -asm_link= -case "$(uname -m)" in - alpha*) asm_link=alpha ;; - ppc*) asm_link=powerpc ;; - s390*) asm_link=s390 ;; - ia64) asm_link=ia64 ;; - *arm*) asm_link=arm ;; - *aarch64*) asm_link=arm64 ;; - parisc) asm_link=parisc ;; - *mips*) asm_link=mips ;; - sparc*) asm_link=sparc ;; - *) asm_link=x86 ;; +asm_link=%{_arch} +# Note that you must use the %{_arch} macro instead of "uname -m" +# to handle a software platform environment that consists of arm64-based Linux kernel +# and arm32-based Platform packages. +case "$asm_link" in + *alpha*) asm_link=alpha ;; + *ppc*) asm_link=powerpc ;; + *s390*) asm_link=s390 ;; + *ia64*) asm_link=ia64 ;; + *arm*) asm_link=arm ;; + *aarch64*) asm_link=arm64 ;; + *parisc*) asm_link=parisc ;; + *mips*) asm_link=mips ;; + *sparc* ) asm_link=sparc ;; + *) asm_link=x86 ;; esac if test -L usr/include/asm then @@ -134,18 +136,21 @@ ln -sfn asm-$asm_link usr/include/asm exit 0 %triggerpostun -- linux-kernel-headers, glibc-devel < 2.5, libc < 2.2 -asm_link= -case "$(uname -m)" in - alpha*) asm_link=alpha ;; - ppc*) asm_link=powerpc ;; - s390*) asm_link=s390 ;; - ia64) asm_link=ia64 ;; - *arm*) asm_link=arm ;; - *aarch64*) asm_link=arm64 ;; - parisc) asm_link=parisc ;; - *mips*) asm_link=mips ;; - sparc*) asm_link=sparc ;; - *) asm_link=x86 ;; +asm_link=%{_arch} +# Note that you must use the %{_arch} macro instead of "uname -m" +# to handle a software platform environment that consists of arm64-based Linux kernel +# and arm32-based Platform packages. +case "$asm_link" in + *alpha*) asm_link=alpha ;; + *ppc*) asm_link=powerpc ;; + *s390*) asm_link=s390 ;; + *ia64*) asm_link=ia64 ;; + *arm*) asm_link=arm ;; + *aarch64*) asm_link=arm64 ;; + *parisc*) asm_link=parisc ;; + *mips*) asm_link=mips ;; + *sparc* ) asm_link=sparc ;; + *) asm_link=x86 ;; esac ln -sfn asm-$asm_link usr/include/asm exit 0 @@ -157,3 +162,6 @@ exit 0 %ghost %{_includedir}/asm %changelog + +* Mon Mar 09 2020 Geunsik Lim +- Replaced "uname -m" with "_arch" macro to build platform packages. -- 2.7.4