凌云实验室推出的ARM Linux物联网网关开发板IGKBoard(IoT Gateway Kit Board)项目源码
guowenxue
2021-12-27 8944472dc440891bf7388889aeb06fca9a38b3f6
bsp/rootfs/build.sh
@@ -8,7 +8,7 @@
DRV_PATH=${PRJ_PATH}/driver
TAR_PATH=${PRJ_PATH}/../tarball
# rootfs should be buildroot/yocto or buster/bullseye for debian system
# rootfs should be buildroot/yocto or bullseye for debian system
ROOTFS=buildroot
ROOTFS_DIR=rootfs_${ROOTFS}
@@ -20,6 +20,7 @@
DEF_HOSTNAME=${BOARD}
APT_CONF=extra_apps.json
PATCH_PATH=${PRJ_PATH}/files
set -u
set -e
@@ -154,20 +155,52 @@
function do_modules()
{
    if [ ! -d ${DRV_PATH}/lib/modules ] ; then
    msg_banner " install linux firmware"
    if [ -s ${TAR_PATH}/firmware.tar.bz2 ] ; then
        tar -xjf ${TAR_PATH}/firmware.tar.bz2 -C ${ROOTFS_DIR}/lib/
    fi
    if [ ! -d ${DRV_PATH}/lib/ ] ; then
        return ;
    fi
    msg_banner " install kernel modules"
    if [ -d ${DRV_PATH}/lib/modules ] ; then
        msg_banner " install kernel modules"
        rm -rf ${ROOTFS_DIR}/lib/modules/
        cp -af ${DRV_PATH}/lib/modules  ${ROOTFS_DIR}/lib/
    fi
}
    rm -rf ${ROOTFS_DIR}/lib/modules/
    cp -af ${DRV_PATH}/lib/modules  ${ROOTFS_DIR}/lib/
function do_common()
{
    if [ -s ${PATCH_PATH}/expand_rootfs ] ; then
        cp ${PATCH_PATH}/expand_rootfs ${ROOTFS_DIR}/usr/sbin/
        chmod a+x ${ROOTFS_DIR}/usr/sbin/expand_rootfs
    fi
}
    if [ ! -d ${ROOTFS_DIR}/lib/firmware -a -s firmware.tar.bz2 ] ; then
        tar -xjf firmware.tar.bz2 -C ${ROOTFS_DIR}/lib/
function do_buildroot()
{
    if [ $ROOTFS != "buildroot" ] ; then
        return ;
    fi
    printf "\n\n -- install kernel modules done --\n\n"
    # add vim alias for vim
    grep "alias vim=" ${ROOTFS_DIR}/etc/profile > /dev/null 2>&1
    if [ $? != 0 ] ; then
       echo "alias vim='vi'" >> ${ROOTFS_DIR}/etc/profile
    fi
    if [ -s ${PATCH_PATH}/S30WpaSupplicant ] ; then
        cp ${PATCH_PATH}/S30WpaSupplicant ${ROOTFS_DIR}/etc/init.d/
        chmod a+x ${ROOTFS_DIR}/etc/init.d/S30WpaSupplicant
    fi
    if [ -s ${PATCH_PATH}/wpa_supplicant.conf ] ; then
        cp ${PATCH_PATH}/wpa_supplicant.conf ${ROOTFS_DIR}/etc/
    fi
    printf "\n\n -- modify buildroot rootfs done --\n\n"
}
function do_modify()
@@ -175,6 +208,12 @@
    msg_banner " modify rootfs environment"
    set +e
    # modify for buildroot rootfs
    do_buildroot
    # modify for all rootfs
    do_common
    # update hostnmae and issue
    echo "Welcome to LingYun IoT Gateway Kit Board GNU/Linux $ROOTFS system, default password '$DEF_PASSWD'." > ${ROOTFS_DIR}/etc/issue
@@ -194,7 +233,7 @@
    # add ls alias for display with color
    grep "color=auto" ${ROOTFS_DIR}/etc/profile > /dev/null 2>&1
    grep "^alias ls=" ${ROOTFS_DIR}/etc/profile > /dev/null 2>&1
    if [ $? != 0 ] ; then
       echo "alias ls='ls --color=auto'" >> ${ROOTFS_DIR}/etc/profile
    fi