Skip to content

Commit

Permalink
extract_tools should install and pull lfs no matter the ARCH
Browse files Browse the repository at this point in the history
  • Loading branch information
andiradulescu committed Jul 18, 2024
1 parent d506fc5 commit 03d7faf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
7 changes: 4 additions & 3 deletions build_kernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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"
38 changes: 20 additions & 18 deletions tools/extract_tools.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/bash -e

echo "Extracting tools..."

git lfs &> /dev/null || {
echo "ERROR: git lfs not installed"
exit 1
Expand All @@ -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..."
Expand All @@ -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

0 comments on commit 03d7faf

Please sign in to comment.