Update architecture detection
cover Update architecture detection
This series cleans up the set_debarch function in scripts/package/mkdebian and adds support for several additional Debian architectures.
Ben.
Ben Hutchings (12):
builddeb: Skip architecture detection when KBUILD_DEBARCH is set
builddeb: Change architecture detection fallback to use
dpkg-architecture
builddeb: Drop check for 32-bit s390
builddeb: Introduce functions to simplify kconfig tests in set_debarch
builddeb: Add automatic support for ppc64 and powerpcspe architectures
builddeb: Add automatic support for mips64el architecture
builddeb: Add automatic support for mips46{,64}{,el} architectures
builddeb: Add automatic support for sparc64 architecture
builddeb: Add automatic support for or1k architecture
builddeb: Add automatic support for m68k architecture
builddeb: Add automatic support for riscv* architectures
builddeb: Add automatic support for sh{3,4}{,eb} architectures
scripts/package/mkdebian | 68 +++++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 18 deletions(-)
PATCH 1/12 builddeb: Skip architecture detection when KBUILD_DEBARCH is set
If KBUILD_DEBARCH is set then we will not use the result of architecture detection, and we may also warn unnecessarily. Move the check for KBUILD_DEBARCH further up to avoid this.
--- scripts/package/mkdebian | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
scripts/package/mkdebian +6 -3
@@ -7,6 +7,11 @@ set -e set_debarch() { + if [ -n "$KBUILD_DEBARCH" ] ; then + debarch="$KBUILD_DEBARCH" + return + fi + # Attempt to find the correct Debian architecture case "$UTS_MACHINE" in i386|ia64|alpha)
@@ -46,10 +51,8 @@ set_debarch() { echo "Falling back to using your current userspace instead!" >&2 echo "Please add support for $UTS_MACHINE to ${0} ..." >&2 echo "" >&2 + ;; esac - if [ -n "$KBUILD_DEBARCH" ] ; then - debarch="$KBUILD_DEBARCH" - fi } # Some variables and settings used throughout the script
PATCH 2/12 builddeb: Change architecture detection fallback to use dpkg-architecture
In reply to Ben HutchingsWe currently use dpkg --print-architecture, which reports the architecture of the build machine. We can make a better guess than this by asking dpkg-architecture what the host architecture, i.e. the default architecture for building packages, is. This is sensitive to environment variables such as CC and DEB_HOST_ARCH, which should already be set in a cross-build environment.
--- scripts/package/mkdebian | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/package/mkdebian +2 -2
@@ -42,13 +42,13 @@ set_debarch() { fi ;; *) - debarch=$(dpkg --print-architecture) + debarch=$(dpkg-architecture -qDEB_HOST_ARCH) echo "" >&2 echo "** ** ** WARNING ** ** **" >&2 echo "" >&2 echo "Your architecture doesn't have its equivalent" >&2 echo "Debian userspace architecture defined!" >&2 - echo "Falling back to using your current userspace instead!" >&2 + echo "Falling back to the current host architecture ($debarch)." >&2 echo "Please add support for $UTS_MACHINE to ${0} ..." >&2 echo "" >&2 ;;
PATCH 3/12 builddeb: Drop check for 32-bit s390
In reply to Ben Hutchingss390 now only supports 64-bit configurations.
--- scripts/package/mkdebian | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/package/mkdebian +1 -1
@@ -21,7 +21,7 @@ set_debarch() { sparc*) debarch=sparc ;; s390*) - debarch=s390$(grep -q CONFIG_64BIT=y $KCONFIG_CONFIG && echo x || true) ;; + debarch=s390x ;; ppc*) debarch=$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo ppc64el || echo powerpc) ;; parisc*)
PATCH 4/12 builddeb: Introduce functions to simplify kconfig tests in set_debarch
In reply to Ben HutchingsWe now have many repetitive greps over the kernel config. Refactor them into functions.
--- scripts/package/mkdebian | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-)
scripts/package/mkdebian +17 -9
@@ -6,6 +6,18 @@ set -e +is_enabled() { + grep -q "^CONFIG_$1=y" $KCONFIG_CONFIG +} + +if_enabled_echo() { + if is_enabled "$1"; then + echo -n "$2" + elif [ $# -ge 3 ]; then + echo -n "$3" + fi +} + set_debarch() { if [ -n "$KBUILD_DEBARCH" ] ; then debarch="$KBUILD_DEBARCH"
@@ -23,22 +35,18 @@ set_debarch() { s390*) debarch=s390x ;; ppc*) - debarch=$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo ppc64el || echo powerpc) ;; + debarch=$(if_enabled_echo CPU_LITTLE_ENDIAN ppc64el powerpc) ;; parisc*) debarch=hppa ;; mips*) - debarch=mips$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo el || true) ;; + debarch=mips$(if_enabled_echo CPU_LITTLE_ENDIAN el) ;; aarch64|arm64) debarch=arm64 ;; arm*) - if grep -q CONFIG_AEABI=y $KCONFIG_CONFIG; then - if grep -q CONFIG_VFP=y $KCONFIG_CONFIG; then - debarch=armhf - else - debarch=armel - fi + if is_enabled AEABI; then + debarch=arm$(if_enabled_echo VFP hf el) else - debarch=arm + debarch=arm fi ;; *)
PATCH 5/12 builddeb: Add automatic support for ppc64 and powerpcspe architectures
In reply to Ben HutchingsWe currently label 64-bit big-endian kernel packages as powerpc (32-bit), mostly because it was officially supported while ppc64 (64-bit big-endian) was not. Now neither is officially supported, so label these packages as ppc64.
Debian also has a powerpcspe (32-bit with SPE) architecture. Label packages with a suitable configuration as powerpcspe.
--- scripts/package/mkdebian | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
scripts/package/mkdebian +6 -1
@@ -35,7 +35,12 @@ set_debarch() { s390*) debarch=s390x ;; ppc*) - debarch=$(if_enabled_echo CPU_LITTLE_ENDIAN ppc64el powerpc) ;; + if is_enabled 64BIT; then + debarch=ppc64$(if_enabled_echo CPU_LITTLE_ENDIAN el) + else + debarch=powerpc$(if_enabled_echo SPE spe) + fi + ;; parisc*) debarch=hppa ;; mips*)
PATCH 6/12 builddeb: Add automatic support for mips64el architecture
In reply to Ben HutchingsWe currently label 64-bit little-endian kernel packages as mipsel (32-bit little-endian), mostly it was officially supported while mips64el (64-bit little-endian) was not. Now both are officially supported, so label these packages as mips64el.
--- scripts/package/mkdebian | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
scripts/package/mkdebian +6 -1
@@ -44,7 +44,12 @@ set_debarch() { parisc*) debarch=hppa ;; mips*) - debarch=mips$(if_enabled_echo CPU_LITTLE_ENDIAN el) ;; + if is_enabled CPU_LITTLE_ENDIAN; then + debarch=mips$(if_enabled_echo 64BIT 64)el + else + debarch=mips + fi + ;; aarch64|arm64) debarch=arm64 ;; arm*)
PATCH 7/12 builddeb: Add automatic support for mips{,64}r6{,el} architectures
In reply to Ben HutchingsMIPS R6 is not fully backward-compatible, so Debian has separate architecture names for userland built for R6. Label kernel packages accordingly.
--- scripts/package/mkdebian | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/package/mkdebian +3 -1
@@ -45,7 +45,9 @@ set_debarch() { debarch=hppa ;; mips*) if is_enabled CPU_LITTLE_ENDIAN; then - debarch=mips$(if_enabled_echo 64BIT 64)el + debarch=mips$(if_enabled_echo 64BIT 64)$(if_enabled_echo CPU_MIPSR6 r6)el + elif is_enabled CPU_MIPSR6; then + debarch=mips$(if_enabled_echo 64BIT 64)r6 else debarch=mips fi
PATCH 8/12 builddeb: Add automatic support for sparc64 architecture
In reply to Ben HutchingsWe currently label 64-bit kernel packages as sparc (32-bit), mostly because it was officially supported while sparc64 was not. Now neither is officially supported, so label these packages as sparc64.
--- scripts/package/mkdebian | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/package/mkdebian +1 -1
@@ -31,7 +31,7 @@ set_debarch() { x86_64) debarch=amd64 ;; sparc*) - debarch=sparc ;; + debarch=sparc$(if_enabled_echo 64BIT 64) ;; s390*) debarch=s390x ;; ppc*)
PATCH 9/12 builddeb: Add automatic support for or1k architecture
In reply to Ben Hutchings--- scripts/package/mkdebian | 2 ++ 1 file changed, 2 insertions(+)
scripts/package/mkdebian +2 -0
@@ -61,6 +61,8 @@ set_debarch() { debarch=arm fi ;; + openrisc) + debarch=or1k ;; *) debarch=$(dpkg-architecture -qDEB_HOST_ARCH) echo "" >&2
PATCH 10/12 builddeb: Add automatic support for m68k architecture
In reply to Ben Hutchings--- scripts/package/mkdebian | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/package/mkdebian +1 -1
@@ -26,7 +26,7 @@ set_debarch() { # Attempt to find the correct Debian architecture case "$UTS_MACHINE" in - i386|ia64|alpha) + i386|ia64|alpha|m68k) debarch="$UTS_MACHINE" ;; x86_64) debarch=amd64 ;;
PATCH 11/12 builddeb: Add automatic support for riscv* architectures
In reply to Ben HutchingsDebian currently only defines "riscv64", but it seems safe to assume that any 32-bit port will now be called "riscv32", also matching $UTS_MACHINE.
--- scripts/package/mkdebian | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/package/mkdebian +1 -1
@@ -26,7 +26,7 @@ set_debarch() { # Attempt to find the correct Debian architecture case "$UTS_MACHINE" in - i386|ia64|alpha|m68k) + i386|ia64|alpha|m68k|riscv*) debarch="$UTS_MACHINE" ;; x86_64) debarch=amd64 ;;
PATCH 12/12 builddeb: Add automatic support for sh{3,4}{,eb} architectures
In reply to Ben HutchingsDifferent generations of the SH architecture are not very compatible, so there are/were separate Debian ports for SH3 and SH4.
Move the fallback out of the "case" statement, so that it will also be used in case we find some SH architecture version without a known mapping.
--- scripts/package/mkdebian | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
scripts/package/mkdebian +10 -3
@@ -63,7 +63,15 @@ set_debarch() { ;; openrisc) debarch=or1k ;; - *) + sh) + if is_enabled CPU_SH3; then + debarch=sh3$(if_enabled_echo CPU_BIG_ENDIAN eb) + elif is_enabled CPU_SH4; then + debarch=sh4$(if_enabled_echo CPU_BIG_ENDIAN eb) + fi + ;; + esac + if [ -z "$debarch" ]; then debarch=$(dpkg-architecture -qDEB_HOST_ARCH) echo "" >&2 echo "** ** ** WARNING ** ** **" >&2
@@ -73,8 +81,7 @@ set_debarch() { echo "Falling back to the current host architecture ($debarch)." >&2 echo "Please add support for $UTS_MACHINE to ${0} ..." >&2 echo "" >&2 - ;; - esac + fi } # Some variables and settings used throughout the script
Masahiro Yamada
Applied2018-07-26 19:19 GMT+09:00 Ben Hutchings <[email protected]>:
Quoted 21 lines
This series cleans up the
set_debarchfunction inscripts/package/mkdebianand adds support for several additional Debian architectures.Ben.
Ben Hutchings (12):
builddeb: Skip architecture detection whenKBUILD_DEBARCHis set
builddeb: Change architecture detection fallback to use
dpkg-architecture
builddeb: Drop check for 32-bit s390
builddeb: Introduce functions to simplify kconfig tests inset_debarch
builddeb: Add automatic support for ppc64 and powerpcspe architectures
builddeb: Add automatic support for mips64el architecture
builddeb: Add automatic support for mips46{,64}{,el} architectures
builddeb: Add automatic support for sparc64 architecture
builddeb: Add automatic support for or1k architecture
builddeb: Add automatic support for m68k architecture
builddeb: Add automatic support for riscv* architectures
builddeb: Add automatic support for sh{3,4}{,eb} architectures
Quoted 3 lines
scripts/package/mkdebian | 68 +++++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 18 deletions(-)
Applied. Thanks!
Signature · 2 lines
Best Regards Masahiro Yamada