From fe3873a5423e587161941ba833bfbd266cc37f6a Mon Sep 17 00:00:00 2001 From: guowenxue <guowenxue@gmail.com> Date: Wed, 28 Jun 2023 22:08:51 +0800 Subject: [PATCH] update buildroot install build shell script --- tools/buildroot/buildroot.sh | 164 +++++++++++++++--------------------------------------- 1 files changed, 45 insertions(+), 119 deletions(-) diff --git a/tools/buildroot/buildroot.sh b/tools/buildroot/buildroot.sh index b936b17..da154b8 100755 --- a/tools/buildroot/buildroot.sh +++ b/tools/buildroot/buildroot.sh @@ -1,134 +1,60 @@ #!/bin/bash -LYFTP_PUB=http://weike-iot.com:2211/imx6ull/tools/lintools - -PRJ_PATH=`pwd` -WORK_SPACE=${HOME}/buildroot/ -INST_PATH=/opt/buildroot/cortexA7 - -BR_VER=buildroot-2021.02.7 -BR_PAK=${BR_VER}-packets -BR_TAR=${BR_PAK}.tar.bz2 - -BR_CONF=${BR_VER}-cortexA7.config -#BR_CONF=${BR_VER}-cortexA7-multimedia.config - -JOBS=`cat /proc/cpuinfo | grep processor | wc -l` - -set -u +# exit shell script when command get error set -e -if [ `id -u` == 0 ] ; then - echo "ERROR: This shell script shouldn't be excuted by root!" - exit ; +# crosstool name +BUILDROOT_NAME=gcc-10.4-cortexA7-2023.02 + +# crosstool download server URL +LYFTP_PUB=http://master.iot-yun.club:2211/imx/crosstool + +# install path defined in build shell script +INST_PATH=/opt/buildroot + +# buildroot version +BR_VER=buildroot-2023.02 + +# set workspace to build buildroot +WORK_SPACE=${HOME} + +if [ -d $INST_PATH/$BUILDROOT_NAME ] ; then + echo "crosstool $BUILDROOT_NAME already installed to \"$INST_PATH\"" + exit fi -STAGE=0 -function msg_banner() -{ - STAGE=`expr $STAGE + 1` - - echo "" - echo "+---------------------------------------------+" - printf " Stage $STAGE: $1\n" - echo "+---------------------------------------------+" - echo "" -} - -function do_fetch() -{ - msg_banner "Fetch ${BR_VER} packets" - - if [ -d $BR_VER ] ; then - printf "\n\n -- ${BR_VER} fetched already -- \n\n" - return ; - fi - - if [ ! -s $BR_TAR ] ; then - printf "\n\n -- fetch ${BR_VER} packet -- \n\n" - wget ${LYFTP_PUB}/$BR_TAR - fi - - if [ ! -d $BR_PAK ] ; then - printf "\n\n -- decompress ${BR_TAR} packet -- \n\n" - tar -xjf ${BR_TAR} - fi - - printf "\n\n -- decompress ${BR_VER} -- \n\n" - tar -xjf ${BR_PAK}/buildroot/${BR_VER}.tar.bz2 - - mv ${BR_PAK} ${BR_VER}/tarballs -} - -function do_patch() -{ - msg_banner "Patch for ${BR_VER} " - - cd $BR_VER - - cp tarballs/buildroot/$BR_CONF .config - cp tarballs/busybox/busybox.config package/busybox/ - sed -i "s|^BR2_HOST_DIR=.*|BR2_HOST_DIR=\"${INST_PATH}\"|g" .config - - cd - -} - -function do_build() -{ - msg_banner "Build ${BR_VER} " - cd $BR_VER - - make -j ${JOBS} - - cd - -} - -function do_install() -{ - msg_banner "Install ${BR_VER} " - - # Packet and install crosstool - cd `dirname $INST_PATH` - tar -cjf ${PRJ_PATH}/${BR_VER}-`basename $INST_PATH`.tar.bz2 `basename $INST_PATH` - - # Install rootfs tarball - cp $WORK_SPACE/$BR_VER/output/images/rootfs.tar.bz2 ${PRJ_PATH}/rootfs_buildroot.tar.bz2 - - echo "" - echo " -- 1. Crosstool already installed to \"$INST_PATH\"."; - echo " -- 2. Crosstool and rootfs packet installed to \"$PRJ_PATH\""; - echo " -- 3. Build workspace path is \"$WORK_SPACE\", you can remove it now."; - echo "" -} - -function do_prepare() -{ - INST_DIR=`dirname $INST_PATH` +# check install path is writable or not +if [ ! -w $INST_PATH ] ; then CUR_USER=`whoami` - if [ ! -w $INST_DIR ] ; then - echo "" - echo "ERROR: Crosstool install path \"$INST_DIR\" not writable, please solve it by follow command: " - echo " sudo sh -c 'mkdir -p $INST_DIR && chown $CUR_USER.$CUR_USER $INST_DIR' " - echo "" - exit ; - fi + echo "ERROR: Crosstool install path \"$INST_PATH\" not writable, please solve it by follow command: " + echo " sudo sh -c 'mkdir -p $INST_PATH && chown $CUR_USER.$CUR_USER $INST_PATH' " + exit +fi - echo "" - echo "" - echo " Switch work space to \"$WORK_SPACE\" " - echo "" - mkdir -p $WORK_SPACE - cd $WORK_SPACE -} -do_prepare +cd $WORK_SPACE -do_fetch +# Download source code pacakge, it's about 1.8GB +if [ ! -s ${BR_VER}-packets.tar.xz ] ; then + wget $LYFTP_PUB/${BR_VER}-packets.tar.xz +fi -do_patch +if [ ! -d ${BR_VER} ] ; then + tar -xJf ${BR_VER}-packets.tar.xz +fi -do_build +cd ${BR_VER} -do_install +chmod +x build.sh + +./build.sh + +echo "" +$INST_PATH/$BUILDROOT_NAME/bin/arm-linux-gcc -v + +echo "" +echo " -- crosstool already installed to \"$INST_PATH/$BUILDROOT_NAME\"."; +echo " -- build workspace path is \"$WORK_SPACE/$BR_VER\", you can remove it now."; +echo "" -- Gitblit v1.9.1