From 13d23a4b26f118814afa9230b6379f753271337a Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Fri, 26 Jan 2024 15:55:51 +0800
Subject: [PATCH] Build:Kernel:IGKBoard-All:Add SDK download from server support
---
kernel/build.sh | 80 ++++++++++++++++++++++++++++++++++-----
bootloader/build.sh | 2
2 files changed, 70 insertions(+), 12 deletions(-)
diff --git a/bootloader/build.sh b/bootloader/build.sh
index 4d2d2b4..d48c214 100755
--- a/bootloader/build.sh
+++ b/bootloader/build.sh
@@ -104,7 +104,7 @@
{
export BOARD=`jq -r ".bsp.board" $CONF_FILE | tr 'A-Z' 'a-z'`
export BSP_VER=`jq -r ".bsp.version" $CONF_FILE | tr 'A-Z' 'a-z'`
- export BSP_URL=`jq -r ".bsp.giturl" $CONF_FILE | tr 'A-Z' 'a-z'`
+ export BSP_URL=`jq -r ".bsp.giturl" $CONF_FILE`
export CROSS_COMPILE=`jq -r ".bsp.cortexAtool" $CONF_FILE`
export MCORE_COMPILE=`jq -r ".bsp.cortexMtool" $CONF_FILE`
diff --git a/kernel/build.sh b/kernel/build.sh
index e4a2093..a8ad919 100755
--- a/kernel/build.sh
+++ b/kernel/build.sh
@@ -12,6 +12,9 @@
# binaries finally install path if needed
#INST_PATH=/tftp
+# download taballs path
+TARBALL_PATH=$PRJ_PATH/tarballs
+
# config file path
CONF_FILE=$TOP_PATH/config.json
@@ -34,17 +37,62 @@
echo -e "\033[40;32m $1 \033[0m"
}
+# decompress a packet to destination path
+function do_unpack()
+{
+ tarball=$1
+ dstpath=`pwd`
+
+ if [[ $# == 2 ]] ; then
+ dstpath=$2
+ fi
+
+ pr_info "decompress $tarball => $dstpath"
+
+ mkdir -p $dstpath
+ case $tarball in
+ *.tar.gz)
+ tar -xzf $tarball -C $dstpath
+ ;;
+
+ *.tar.bz2)
+ tar -xjf $tarball -C $dstpath
+ ;;
+
+ *.tar.xz)
+ tar -xJf $tarball -C $dstpath
+ ;;
+
+ *.tar.zst)
+ tar -I zstd -xf $tarball -C $dstpath
+ ;;
+
+ *.tar)
+ tar -xf $tarball -C $dstpath
+ ;;
+
+ *.zip)
+ unzip -qo $tarball -d $dstpath
+ ;;
+
+ *)
+ pr_error "decompress Unsupport packet: $tarball"
+ return 1;
+ ;;
+ esac
+}
+
# parser configure file and export environment variable
function export_env()
{
export BOARD=`jq -r ".bsp.board" $CONF_FILE | tr 'A-Z' 'a-z'`
export BSP_VER=`jq -r ".bsp.version" $CONF_FILE | tr 'A-Z' 'a-z'`
- export GIT_URL=`jq -r ".bsp.giturl" $CONF_FILE | tr 'A-Z' 'a-z'`
- export CROSS_COMPILE=`jq -r ".bsp.cortexAtool" $CONF_FILE | tr 'A-Z' 'a-z'`
+ export BSP_URL=`jq -r ".bsp.giturl" $CONF_FILE`
+ export CROSS_COMPILE=`jq -r ".bsp.cortexAtool" $CONF_FILE`
- export SRCS="linux-imx"
export BRANCH=$BSP_VER
- export KER_PATH=$PRJ_PATH/linux-imx
+ export KER_SRC=linux-imx
+ export KER_PATH=$PRJ_PATH/$KER_SRC
export JOBS=`cat /proc/cpuinfo | grep processor | wc -l`
@@ -58,7 +106,7 @@
function build_kernel()
{
defconfig=${BOARD}_defconfig
- patch_file=$PRJ_PATH/patches/$BOARD/linux-imx-$BSP_VER.patch
+ patch_file=$PRJ_PATH/patches/$BOARD/${KER_SRC}-$BSP_VER.patch
cd $PRJ_PATH
@@ -66,7 +114,20 @@
pr_info "linux kernel source code fetched already"
else
pr_info "start fetch linux kernel source code"
- git clone $GIT_URL/linux-imx.git -b $BRANCH --depth=1
+
+ if [[ $BSP_URL =~ github.com ]] ; then
+ git clone $BSP_URL/$KER_SRC.git -b $BRANCH --depth=1
+ else
+ mkdir -p $TARBALL_PATH
+
+ # Download source code packet
+ if [ ! -s $TARBALL_PATH/$KER_SRC.tar.xz ] ; then
+ wget $BSP_URL/$BSP_VER/$KER_SRC.tar.xz -P $TARBALL_PATH
+ fi
+
+ # decompress source code packet
+ do_unpack $TARBALL_PATH/$KER_SRC.tar.xz
+ fi
fi
pr_info "Start build linux kernel source code"
@@ -140,11 +201,8 @@
{
cd $PRJ_PATH
- for d in $SRCS
- do
- rm -rf $PRJ_PATH/$d
- done
-
+ rm -rf $PRJ_PATH/$KER_SRC
+ rm -rf $PRJ_PATH/tarballs
rm -rf $PRFX_PATH
}
--
Gitblit v1.9.1