From bfceb172fbac401c760473a4ee7c159940253d9b Mon Sep 17 00:00:00 2001 From: guowenxue <guowenxue@gmail.com> Date: Fri, 26 Nov 2021 21:43:31 +0800 Subject: [PATCH] remove space in the end of a line --- bsp/images/build.sh | 93 +++++++++++++++++++++++++++++++++++++++------- 1 files changed, 79 insertions(+), 14 deletions(-) diff --git a/bsp/images/build.sh b/bsp/images/build.sh index 22b15ca..e8b2a0a 100755 --- a/bsp/images/build.sh +++ b/bsp/images/build.sh @@ -18,12 +18,14 @@ # PRJ_PATH=`pwd` +PRJ_NAME=`basename ${PRJ_PATH}` + IMAGE_PATH=${PRJ_PATH}/boot/ BOARD=imx6ull # rootfs should be buildroot or stretch/buster/bullseye for debian system -ROOTFS=buildroot +ROOTFS=buster # linux kernel tarball path and branch TAR_PATH=${PRJ_PATH}/../tarball @@ -59,12 +61,6 @@ set -u set -e -if [ `id -u` != 0 ] ; then - echo "ERROR: This shell script must run as root" - exit 0; -fi - -trap 'exit_handler' EXIT function exit_handler() { echo "Shell script exit now, do some clean work" @@ -168,17 +164,86 @@ umount ${MNT_POINT} } -mkdir -p ${MNT_POINT} +function do_distclean() +{ + printf "\n\n -- do distclean in `basename ${PRJ_PATH}` --\n\n" -generate_image + rm -f *${BOARD}* + rm -rf boot/*Image* + rm -rf boot/overlays/ + rm -rf boot/*${BOARD}* + exit 0; +} -format_partition +function do_image() +{ + mkdir -p ${MNT_POINT} -install_sysimg + generate_image -install_rootfs + format_partition -bzip2 ${IMAGE_NAME} + install_sysimg -rm -rf ${MNT_POINT} + install_rootfs + + msg_banner " bzip2 compress system image " + bzip2 ${IMAGE_NAME} + + rm -rf ${MNT_POINT} + + printf "\n\n -- generate system image done --\n\n" +} + + +function do_root() +{ + 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 +} + +function do_usage() +{ + echo "" + echo "Usage:" + echo " $0 [-b] [-c] [-h]" + echo " -b: download and build $PRJ_NAME" + echo " -c: clean all the source code" + echo " -h: show this help message" + echo "" + echo " WARNNING: This shell script must run as sudo" + echo "" + exit; +} + +trap 'exit_handler' EXIT + +while getopts "bch" OPTNAME +do + case "${OPTNAME}" in + "b") + break; + ;; + + "c") + do_root "yes" + do_distclean + ;; + + "*") + do_usage + ;; + esac +done + +do_root "yes" +do_image -- Gitblit v1.9.1