freescale-sdk linux移植一搭建编译环境脚本host-prepare.sh分析
来源:互联网 发布:python宝典 pdf下载 编辑:程序博客网 时间:2024/06/06 04:57
接下来使用自己的课外休息时间,对基于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 #搭建编译环境,安装必要的包
至此,已安装好必要的包,为后期系统正常编译搭建好环境。
- freescale-sdk linux移植一搭建编译环境脚本host-prepare.sh分析
- freescale自动编译分析
- ijkplayer编译脚本分析(一)——init-android.sh
- Linux-4.9.2内核在mini2440上的移植(一)——Ubuntu编译环境搭建(上)
- (一)linux系统移植过程和环境搭建
- 嵌入式Linux移植环境搭建
- Android 系统移植与调试(一)Android编译环境编译服务器搭建
- Linux环境移植编译SQLite3
- <QNX> Linux Host开发环境搭建
- ARM+LINUX移植攻略(一) U-boot-2009.08移植TE2440II开发板--环境搭建
- 在ubuntu12.04.1LTS上搭建freescale iMX6开发板sabresd_6dq编译环境
- Freescale I.mx 6 Android 4.2.2源码编译环境搭建(基于ubuntu12.04 LTS)
- 在ubuntu12.04.1LTS上搭建freescale iMX6开发板sabresd_6dq编译环境
- linux环境下java读取sh脚本并执行
- Freescale Linux SDK安装概要笔记
- ARM (FS_S5PC100)系统移植一 环境搭建
- 系统移植(一) 环境搭建
- linux crond 脚本.sh
- 在Linux上编译安装GCC-4.7.1
- 导入已有的Java Web项目时出现关于javax.servlet的异常时解决措施
- Java 序列化 与 反序列化
- 动感项目01
- 高效能人士的7个习惯
- freescale-sdk linux移植一搭建编译环境脚本host-prepare.sh分析
- 各种排序总结
- 《C++ Primer》习题9.20的问题
- ERROR: install CPQD ofsoftswitch13(2)
- Machine Learning in Python (Scikit-learn)-(转)
- 数论---泊松分布
- 32位64位操作系统基本数据类型字节大小
- 程序猿之---C语言细节25(数据类型取值范围、char细节、浮点数细节)
- NSCalendar获取未来一年