From 03d7faff06e70990c1cef3bae5c3142b8a51e572 Mon Sep 17 00:00:00 2001 From: Andrei Radulescu Date: Thu, 18 Jul 2024 12:47:21 +0300 Subject: [PATCH] extract_tools should install and pull lfs no matter the ARCH --- build_kernel.sh | 7 ++++--- tools/extract_tools.sh | 38 ++++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/build_kernel.sh b/build_kernel.sh index 994bf27d..19dcca9e 100755 --- a/build_kernel.sh +++ b/build_kernel.sh @@ -37,9 +37,12 @@ docker container rm -f $CONTAINER_ID" EXIT # Clone kernel if not done already if git submodule status --cached agnos-kernel-sdm845/ | grep "^-"; then + echo "Cloning agnos-kernel-sdm845" git submodule update --init agnos-kernel-sdm845 fi +$DIR/tools/extract_tools.sh + build_kernel() { cd agnos-kernel-sdm845 @@ -49,8 +52,6 @@ build_kernel() { export CROSS_COMPILE=$TOOLS/aarch64-linux-gnu-gcc/bin/aarch64-linux-gnu- export CC=$TOOLS/aarch64-linux-gnu-gcc/bin/aarch64-linux-gnu-gcc export LD=$TOOLS/aarch64-linux-gnu-gcc/bin/aarch64-linux-gnu-ld.bfd - - $DIR/tools/extract_tools.sh fi # Build arm64 arch @@ -105,4 +106,4 @@ USERNAME=$(whoami) docker exec $CONTAINER_ID bash -c "useradd --uid $(id -u) -U -m $USERNAME" # Run build_kernel in container -docker exec -u $USERNAME $CONTAINER_ID bash -c "export DEFCONFIG=$DEFCONFIG DIR=$DIR TOOLS=$TOOLS TMP_DIR=$TMP_DIR OUTPUT_DIR=$OUTPUT_DIR BOOT_IMG=$BOOT_IMG; $(declare -f build_kernel); build_kernel" +docker exec -u $USERNAME $CONTAINER_ID bash -c "set -e; export DEFCONFIG=$DEFCONFIG DIR=$DIR TOOLS=$TOOLS TMP_DIR=$TMP_DIR OUTPUT_DIR=$OUTPUT_DIR BOOT_IMG=$BOOT_IMG; $(declare -f build_kernel); build_kernel" diff --git a/tools/extract_tools.sh b/tools/extract_tools.sh index edfc28c7..ba86f790 100755 --- a/tools/extract_tools.sh +++ b/tools/extract_tools.sh @@ -1,7 +1,5 @@ #!/bin/bash -e -echo "Extracting tools..." - git lfs &> /dev/null || { echo "ERROR: git lfs not installed" exit 1 @@ -13,11 +11,6 @@ ROOT=$DIR/.. cd $DIR -LINARO_GCC=aarch64-linux-gnu-gcc -GOOGLE_GCC_4_9=aarch64-linux-android-4.9 -EDK2_LLVM=llvm-arm-toolchain-ship -SEC_IMAGE=SecImage - # grep for `-`, which stands for LFS pointer git lfs ls-files | awk '{print $2}' | grep "-" &>/dev/null && { echo "Pulling git lfs objects..." @@ -27,23 +20,32 @@ git lfs ls-files | awk '{print $2}' | grep "-" &>/dev/null && { cd $DIR } +LINARO_GCC=aarch64-linux-gnu-gcc +GOOGLE_GCC_4_9=aarch64-linux-android-4.9 +EDK2_LLVM=llvm-arm-toolchain-ship +SEC_IMAGE=SecImage + LINARO_GCC_TARBALL=$LINARO_GCC.tar.gz GOOGLE_GCC_4_9_TARBALL=$GOOGLE_GCC_4_9.tar.gz EDK2_LLVM_TARBALL=$EDK2_LLVM.tar.gz SEC_IMAGE_TARBALL=$SEC_IMAGE.tar.gz -if [ ! -d $LINARO_GCC ]; then - tar -xzf $LINARO_GCC_TARBALL &>/dev/null -fi +ARCH=$(uname -m) +if [ "$ARCH" != "arm64" ] && [ "$ARCH" != "aarch64" ]; then + echo "Extracting tools..." + if [ ! -d $LINARO_GCC ]; then + tar -xzf $LINARO_GCC_TARBALL &>/dev/null + fi -if [ ! -d $GOOGLE_GCC_4_9 ]; then - tar -xzf $GOOGLE_GCC_4_9_TARBALL &>/dev/null -fi + if [ ! -d $GOOGLE_GCC_4_9 ]; then + tar -xzf $GOOGLE_GCC_4_9_TARBALL &>/dev/null + fi -if [ ! -d $EDK2_LLVM ]; then - tar -xzf $EDK2_LLVM_TARBALL &>/dev/null -fi + if [ ! -d $EDK2_LLVM ]; then + tar -xzf $EDK2_LLVM_TARBALL &>/dev/null + fi -if [ ! -d $SEC_IMAGE ]; then - tar -xzf $SEC_IMAGE_TARBALL &>/dev/null + if [ ! -d $SEC_IMAGE ]; then + tar -xzf $SEC_IMAGE_TARBALL &>/dev/null + fi fi