• freescale-sdk linux移植一搭建编译环境脚本host-prepare.sh分析


    接下来使用自己的课外歇息时间,对基于PowerPC架构freescale-sdk,进行linux移植和分析。主要參考官方文档freescale linux sdk START_HERE.html,首先对搭建编译环境脚本host-prepare.sh分析。在移植系统之前。须要搭建编译环境。安装必要的包。为后期编译系统做准备。

    非常多人看到脚本就头疼,以下是我的分析过程,分析不好的地方能够在以下留言。一起讨论。

    一.搭建编译环境脚本分析./scripts/host-prepare.sh

    freescale@freescale-sdk:~/SDK/QorIQ-SDK-V1.4-20130625-yocto$ ./scripts/host-prepare.sh -h
    Usage: ./scripts/host-prepare.sh [-h] [-f]
        -h: display help
        -f: force install all needed host pkgs, running non-interactively
    分析./scripts/host-prepare.sh脚本,输入命令./scripts/host-prepare.sh -h,显示帮助信息。
    SCRIPT_DIR=`readlink -f $(dirname $0)`#获取当前脚本所在文件夹
    usage_message() { #帮助子函数。输入-h或-?时调用该函数执行
        echo "Usage: $0 [-h] [-f]
        -h: display help
        -f: force install all needed host pkgs, running non-interactively
    "
    } #getopts options variable
    while getopts "fh" host_prepare_flag #每次运行循环。getopts 就检查下一个命令行參数,并推断它是否合法。

    即检查參数是否以 - 开头,后面跟一个包括在option中的字母
    do #假设是,就把匹配的选项字母存在指定的变量 variable 中,并返回退出状态0;
        case $host_prepare_flag in #假设 - 后面的字母没有包括在 options 中,就在 variable 中存入一个 ?。并返回退出状态0;
            f) force_update='true'; #假设命令行中已经没有參数,或者下一个參数不以 - 开头。就返回不为0的退出状态。
               ;;
            ?) usage_message;exit 1;
               ;;
        esac
    done
    # check host distribution #检查客服机系统类型,存在/etc/lsb-release文件,打开显示DISTRIB_ID=Ubuntu DISTRIB_RELEASE=10.04
    if [ -r /etc/lsb-release ] && grep Ubuntu /etc/lsb-release >/dev/null 2>&1 #1表示stdout标准输出,系统默认值是1。>/dev/null相当于1>/dev/null
    then #2表示stderr标准错误
        # Ubuntu-based system
        . /etc/lsb-release
        distro="Ubuntu"
        release=${DISTRIB_RELEASE}
        hostpkg="apt-get"
    elif [ -r /etc/debian_version ]
    then
        # Debian-based
        distro="Debian"
        release=`cat /etc/debian_version`
        hostpkg="apt-get"
    ......
    echo "Verifying sudo permission to execute $hostpkg command." #输出Verifying sudo permission to execute apt-get command.
    user=`whoami` || true #这里包含以下几句都是关于root权限推断的。以后分析??

    ?
    ......
    case "$distro" in #依据上面系统推断得出$distro="Ubuntu",故运行脚本script="$SCRIPT_DIR/host-prepare-ubuntu-mint-debian.sh";
        'Ubuntu' | 'Mint' | 'Debian' )
            script="$SCRIPT_DIR/host-prepare-ubuntu-mint-debian.sh";
            ;;
        'Redhat' | 'CentOS' | 'Fedora')
            script="$SCRIPT_DIR/host-prepare-rhel-centos-fedora.sh";
            ;;
        'SUSE' | 'openSUSE')
            script="$SCRIPT_DIR/host-prepare-suse.sh";
            ;;
    esac
    #紧接着上面分析$SCRIPT_DIR/host-prepare-ubuntu-mint-debian.sh,当中$SCRIPT_DIR=~/SDK/QorIQ-SDK-V1.4-20130625-yocto/scripts
    if test $force_update; then UPDATE_FLAG='-y --force-yes';fi #force_update='true'赋值 UPDATE_FLAG='-y --force-yes'
    PKGS="sed wget subversion git-core coreutils
         unzip texi2html texinfo libsdl1.2-dev docbook-utils fop gawk
         python-pysqlite2 diffstat make gcc build-essential xsltproc
         g++ desktop-file-utils chrpath libgl1-mesa-dev libglu1-mesa-dev
         autoconf automake groff libtool xterm libxml-parser-perl
    "
    # pkgs required for fsl use
    PKGS="$PKGS vim-common xz-utils cvs tofrodos libstring-crc32-perl"
    PKGS="$PKGS patch libbonobo2-common libncurses5-dev"
    if [ "`uname -m`" = "x86_64" ]; then
        PKGS="$PKGS ia32-libs lib32ncurses5-dev"
    fi #对PKGS赋值须要安装的包
    echo "Now we're going to install all the other development packages needed to build Yocto, please wait"
    sudo apt-get $UPDATE_FLAG install $PKGS #搭建编译环境,安装必要的包
    至此。已安装好必要的包,为后期系统正常编译搭建好环境。

  • 相关阅读:
    数组
    循环(二)
    循环——笔记
    C#基础(四)
    C#基础(三)
    安卓帮助文档
    增加线程异步发送消息的方法二(Runnable)
    增加线程异步发送消息的方法一(Thread)
    获取下拉框的值
    获取表中字段最大值,并且保存在前台页面中
  • 原文地址:https://www.cnblogs.com/slgkaifa/p/6853375.html
Copyright © 2020-2023  润新知