From fce744b0d9a648da5e2765af625c96370492f698 Mon Sep 17 00:00:00 2001
From: guowenxue <guowenxue@gmail.com>
Date: Mon, 13 Dec 2021 09:39:23 +0800
Subject: [PATCH] update images and rootfs build shell script
---
bsp/build.sh | 103 ++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 89 insertions(+), 14 deletions(-)
diff --git a/bsp/build.sh b/bsp/build.sh
index 461e261..c2ca941 100755
--- a/bsp/build.sh
+++ b/bsp/build.sh
@@ -7,11 +7,11 @@
#CROSS_TOOL=arm-linux-gnueabihf-
CROSS_TOOL=/opt/buildroot/cortexA7/bin/arm-linux-
-# bootloader, linux kernel tarball path and branch
+# bootloader, linux kernel tarball path and branch
TAR_PATH=${PRJ_PATH}/tarball
BSP_BRANCH="lf-5.10.52-2.1.0"
-# rootfs should be buildroot or stretch/buster/bullseye for debian system
+# rootfs should be buildroot/yocto or stretch/buster/bullseye for debian system
ROOTFS=buildroot
set -u
@@ -34,26 +34,101 @@
}
function do_modify()
-{
+{
do_modify_build tarball
do_modify_build bootloader
do_modify_build kernel
- do_modify_build rootfs
+ do_modify_build rootfs
do_modify_build images
}
-function do_build()
+function do_root()
{
- cd $PRJ_PATH/tarball && ./build.sh && cd -
-
- cd $PRJ_PATH/bootloader && ./build.sh && cd -
-
- cd $PRJ_PATH/kernel && ./build.sh && cd -
-
- cd $PRJ_PATH/rootfs && ./build.sh && cd -
+ echo ""
+ if [[ $1 == "yes" ]] && [ `id -u` != 0 ] ; then
+ echo "ERROR: This action must run as root!"
+ echo ""
+ exit;
+ elif [[ $1 != "yes" ]] && [ `id -u` == 0 ] ; then
+ echo "ERROR: This action cannot run as root!"
+ echo ""
+ exit;
+ fi
}
-do_modify
+function do_action()
+{
+ folder=$1
+ action=$2
-do_build
+ cd $PRJ_PATH/$folder
+
+ if [ $action == "build" ] ; then
+ ./build.sh -b
+ elif [ $action == "clean" ] ; then
+ ./build.sh -c
+ fi
+
+ cd $PRJ_PATH
+}
+
+
+function do_usage()
+{
+ echo ""
+ echo "Usage:"
+ echo " $0 [-b] [-c] [-h] bsp/image"
+ echo " -b bsp/image: build BSP or system image"
+ echo " -c bsp/image: clean BSP or system image"
+ echo " -h : show this help message"
+ echo ""
+ echo " WARNNING: build/clean image need run as sudo"
+ echo ""
+ echo " Example: $0 -b bsp && sudo $0 -b image"
+ echo ""
+ exit;
+}
+
+
+action="usage"
+
+while getopts "b:c:h" OPTNAME
+do
+ case "${OPTNAME}" in
+ "b")
+ action="build"
+ shift
+ ;;
+
+ "c")
+ action="clean"
+ shift
+ ;;
+
+ "*")
+ action="usage"
+ ;;
+ esac
+done
+
+if [ $action == "usage" ] ; then
+ do_usage
+fi
+
+if [ $action == "build" ] ; then
+ do_modify
+ cd tarball && ./build.sh && cd -
+fi
+
+if [ $1 == "bsp" ] ; then
+ if [ $action == "build" ] ; then
+ do_root "no"
+ fi
+ do_action bootloader $action
+ do_action kernel $action
+elif [ $1 == "image" ] ; then
+ do_root "yes"
+ do_action rootfs $action
+ do_action images $action
+fi
--
Gitblit v1.9.1