arch: Fixed /usr/include/asm to build 32bit packages on 64bit Linux 04/227904/2 accepted/tizen/base/20200325.053342 submit/tizen_base/20200319.050442
authorGeunsik Lim <geunsik.lim@samsung.com>
Mon, 9 Mar 2020 11:36:01 +0000 (20:36 +0900)
committerDongkyun Son <dongkyun.s@samsung.com>
Thu, 19 Mar 2020 04:52:52 +0000 (04:52 +0000)
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 <geunsik.lim@samsung.com>
packaging/linux-glibc-devel.spec

index 392e794..921734a 100644 (file)
@@ -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 <geunsik.lim@samsung.com>
+- Replaced "uname -m" with "_arch" macro to build platform packages.