From 7dd6306b30547a02e7e78b3c4492c90b2baa40a7 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Fri, 19 Oct 2018 19:04:00 +0200 Subject: [PATCH] cleanup: derive LINUX_CPU from TARGET, merge linux packages Signed-off-by: David Oberhollenzer --- layer/bsp-alix/TOOLCHAIN | 1 - layer/bsp-qemu64/TOOLCHAIN | 1 - layer/bsp-rpi3/TOOLCHAIN | 3 +-- pkg/linux-rpi3/build | 41 +++----------------------------------- pkg/linux/build | 20 +++++++++++++++++++ pkg/linux_headers/build | 7 ++++--- 6 files changed, 28 insertions(+), 45 deletions(-) diff --git a/layer/bsp-alix/TOOLCHAIN b/layer/bsp-alix/TOOLCHAIN index e4f33ff..e29e100 100644 --- a/layer/bsp-alix/TOOLCHAIN +++ b/layer/bsp-alix/TOOLCHAIN @@ -7,7 +7,6 @@ CPU_IS_64BIT="no" GCC_EXTRACFG="--enable-libmpx" LINUXPKG="linux" -LINUX_CPU="x86" LINUX_TGT="bzImage modules" TC_HARDENING="no" diff --git a/layer/bsp-qemu64/TOOLCHAIN b/layer/bsp-qemu64/TOOLCHAIN index 8e14357..059a213 100644 --- a/layer/bsp-qemu64/TOOLCHAIN +++ b/layer/bsp-qemu64/TOOLCHAIN @@ -7,7 +7,6 @@ CPU_IS_64BIT="yes" GCC_EXTRACFG="--enable-libmpx" LINUXPKG="linux" -LINUX_CPU="x86_64" LINUX_TGT="bzImage" TC_HARDENING="no" diff --git a/layer/bsp-rpi3/TOOLCHAIN b/layer/bsp-rpi3/TOOLCHAIN index 400e316..851e3b2 100644 --- a/layer/bsp-rpi3/TOOLCHAIN +++ b/layer/bsp-rpi3/TOOLCHAIN @@ -7,7 +7,6 @@ CPU_IS_64BIT="no" GCC_EXTRACFG="--with-float=hard --with-fpu=neon-vfpv3" LINUXPKG="linux-rpi3" -LINUX_CPU="arm" -LINUX_TGT="zImage" +LINUX_TGT="zImage dtbs modules" TC_HARDENING="no" diff --git a/pkg/linux-rpi3/build b/pkg/linux-rpi3/build index 95d1e07..065ce4f 100755 --- a/pkg/linux-rpi3/build +++ b/pkg/linux-rpi3/build @@ -1,3 +1,6 @@ +# inherit functions from generic kernel package +source "$SCRIPTDIR/pkg/linux/build" + VERSION="1.20180919-1" SRCDIR="linux-raspberrypi-kernel_${VERSION}" TARBALL="raspberrypi-kernel_${VERSION}.tar.gz" @@ -5,44 +8,6 @@ URL="https://github.com/raspberrypi/linux/archive" SHA256SUM="b58a7a786b94957674ce3f64307ea7e7883ae2d1d871ea6ed5a5ce1b6846bdf4" DEPENDS="initrd" -prepare() { - return -} - -build() { - local INITRDLIST="$PKGDEPLOYDIR/initrd/initrd.list" - - export KBUILD_OUTPUT="$PKGBUILDDIR" - make -C "$1" O="$PKGBUILDDIR" ARCH="arm" CROSS_COMPILE="${TARGET}-" mrproper - - cat_file_override "linux.config" > "$PKGBUILDDIR/.config" - sed -i "$PKGBUILDDIR/.config" -e 's,^CONFIG_CROSS_COMPILE=.*,CONFIG_CROSS_COMPILE="'$TARGET'-",' - sed -i "$PKGBUILDDIR/.config" -e 's,^CONFIG_INITRAMFS_SOURCE=.*,CONFIG_INITRAMFS_SOURCE="'$INITRDLIST'",' - make -C "$1" O="$PKGBUILDDIR" ARCH="arm" CROSS_COMPILE="${TARGET}-" oldconfig - - sed -i "$PKGBUILDDIR/.config" -e 's,^CONFIG_CROSS_COMPILE=.*,CONFIG_CROSS_COMPILE="'$TARGET'-",' - sed -i "$PKGBUILDDIR/.config" -e 's,^CONFIG_INITRAMFS_SOURCE=.*,CONFIG_INITRAMFS_SOURCE="'$INITRDLIST'",' - sed -i "$PKGBUILDDIR/.config" -e 's,^CONFIG_LOCALVERSION=.*,CONFIG_LOCALVERSION="-'${OS_NAME}-${OS_RELEASE}'",' - make -C "$1" O="$PKGBUILDDIR" ARCH="arm" CROSS_COMPILE="${TARGET}-" -j $NUMJOBS zImage dtbs modules -} - -deploy() { - local SOURCE="$1" - local DEPLOY="$2" - - mkdir -p "$DEPLOY/boot" "$DEPLOY/lib/modules" - cp "arch/arm/boot/zImage" "$DEPLOY/boot/vmlinuz" - - export KBUILD_OUTPUT="$PKGBUILDDIR" - make -C "$SOURCE" O="$PKGBUILDDIR" ARCH="$LINUX_CPU" CROSS_COMPILE="${TARGET}-" INSTALL_MOD_PATH="$DEPLOY" modules_install - - echo "boot/vmlinuz m 555 0 0" > "$DEPLOY/rootfs_files.txt" - - find "$DEPLOY/lib" -exec stat {} --printf="%n m %a 0 0\\n" \; | \ - sed "s#^$DEPLOY/##g" | sed "s/644/444/g" | \ - sed "s/755/555/g" >> "$DEPLOY/rootfs_files.txt" -} - check_update() { local version=$(echo $VERSION | sed 's/-/./g') diff --git a/pkg/linux/build b/pkg/linux/build index df02bee..9d8e462 100755 --- a/pkg/linux/build +++ b/pkg/linux/build @@ -9,12 +9,31 @@ URL="https://www.kernel.org/pub/linux/kernel/v$MAJOR.x" SHA256SUM="70e69189fd7b2f96fa33833735c7bcf3281dc0172c3734e2c5819e9d57015c72" DEPENDS="initrd" +get_linux_cpu() { + case "$TARGET" in + i*86-*) + echo "x86" + ;; + x86_64-*) + echo "x86_64" + ;; + arm-*) + echo "arm" + ;; + *) + echo "don't know how to map $TARGET to Linux arch" >&2 + exit 1 + ;; + esac +} + prepare() { return } build() { local INITRDLIST="$PKGDEPLOYDIR/initrd/initrd.list" + local LINUX_CPU=$(get_linux_cpu) export KBUILD_OUTPUT="$PKGBUILDDIR" @@ -30,6 +49,7 @@ build() { deploy() { local SOURCE="$1" local DEPLOY="$2" + local LINUX_CPU=$(get_linux_cpu) mkdir -p "$DEPLOY/boot" "$DEPLOY/lib/modules" cp arch/${LINUX_CPU}/boot/*Image "$DEPLOY/boot/vmlinuz" diff --git a/pkg/linux_headers/build b/pkg/linux_headers/build index 63cce0a..6b77a65 100755 --- a/pkg/linux_headers/build +++ b/pkg/linux_headers/build @@ -3,14 +3,15 @@ source "$SCRIPTDIR/pkg/$LINUXPKG/build" DEPENDS="" build() { + local LINUX_CPU=$(get_linux_cpu) + make -C "$1" O="$PKGBUILDDIR" ARCH="$LINUX_CPU" mrproper make -C "$1" O="$PKGBUILDDIR" ARCH="$LINUX_CPU" headers_check } deploy() { - local INPUT="$1" - local DEPLOY="$2" + local LINUX_CPU=$(get_linux_cpu) export KBUILD_OUTPUT="$PKGBUILDDIR" - make -C "$INPUT" O="$PKGBUILDDIR" ARCH="$LINUX_CPU" INSTALL_HDR_PATH="$DEPLOY" headers_install + make -C "$1" O="$PKGBUILDDIR" ARCH="$LINUX_CPU" INSTALL_HDR_PATH="$2" headers_install }