从compile.sh开始入手:

 SRC="$(dirname "$(realpath "${BASH_SOURCE}")")"
# fallback for Trusty
[[ -z "${SRC}" ]] && SRC="$(pwd)" # check for whitespace in $SRC and exit for safety reasons
grep -q "[[:space:]]" <<<"${SRC}" && { echo "\"${SRC}\" contains whitespace. Not supported. Aborting." >& ; exit ; } cd $SRC

如上主要是获取源代码的路径,并判断路径是否存在空格合法

在compile.sh

 if [[ -f $SRC/lib/general.sh && -L $SRC/main.sh ]]; then
source $SRC/lib/general.sh
else
echo "Error: missing build directory structure"
echo "Please clone the full repository https://github.com/armbian/build/"
exit -
fi

很明显在这一步里,我们可以进入general.sh看一下实际做了什么?

在lib/general.sh

定义了很多的shell 函数

Cleaning()

根据不同的参数做清除工作

Exit_with_error()

出错时用于显示错误调节的功能,文件,行号,是否高亮,及相关的出错描述

Get_package_list_hash()

打印新构建的文件系统安装包列表,以及文件系统的版本

Create_source_list()

更新apt source.list到新构建的文件系统当中

fetch_from_repo()

用于拉取git 仓库的代码

# fetch_from_repo <url> <directory> <ref> <ref_subdir>

# <url>: remote repository URL

# <directory>: local directory; subdir for branch/tag will be created

# <ref>:

#       branch:name

#       tag:name

#       head(*)

#       commit:hash@depth(**)

#

# *: Implies ref_subdir=no

# **: Not implemented yet

# <ref_subdir>: "yes" to create subdirectory for tag or branch name

#

display_alert()

根据不同的级别显示

fingerprint_image()

将编译信息生成至etc/armbian.txt,其中包含

Title:                  Armbian $REVISION ${BOARD^} $DISTRIBUTION $RELEASE $BRANCH

Kernel:                 Linux $VER

Build date:             $(date +'%d.%m.%Y')

Authors:                https://www.armbian.com/authors

Sources:                https://github.com/armbian/

Support:                https://forum.armbian.com/

Changelog:              https://www.armbian.com/logbook/

Documantation:          https://docs.armbian.com/

addtorepo()

用于创建本地的apt仓库,下载交叉编译工具链,下载etcher_cli工具。可定制自已的镜像打包脚本。

[[ ! -f $SRC/userpatches/customize-image.sh ]] && cp $SRC/config/templates/customize-image.sh.template $SRC/userpatches/customize-image.sh

download_toolchain()

用于下载工具链。

download_etcher_cli()

用于下载etcher_cli,该命令工具的功能相当于dd命令与校验功能的合体。

接来再次回到compile.sh脚本当中

 # copy default config from the template
[[ ! -f $SRC/config-default.conf ]] && cp $SRC/config/templates/config-example.conf $SRC/config-default.conf # source build configuration file
if [[ -n $ && -f $SRC/config-$.conf ]]; then
display_alert "Using config file" "config-$1.conf" "info"
source $SRC/config-$.conf
else
display_alert "Using config file" "config-default.conf" "info"
source $SRC/config-default.conf
fi

在默认的config-default.conf内容如下所示:

KERNEL_ONLY=""                          # leave empty to select each time, set to "yes" or "no" to skip dialog prompt
KERNEL_CONFIGURE="" # leave empty to select each time, set to "yes" or "no" to skip dialog prompt
CLEAN_LEVEL="make,debs,oldcache" # comma-separated list of clean targets: "make" = make clean for selected kernel and u-boot,
# "debs" = delete packages in "./output/debs" for current branch and family,
# "alldebs" = delete all packages in "./output/debs", "images" = delete "./output/images",
# "cache" = delete "./output/cache", "sources" = delete "./sources"
# "oldcache" = remove old cached rootfs except for the newest files DEST_LANG="en_US.UTF-8" # sl_SI.UTF-, en_US.UTF- # advanced
KERNEL_KEEP_CONFIG="no" # do not overwrite kernel config before compilation
EXTERNAL="yes" # build and install extra applications and drivers
EXTERNAL_NEW="prebuilt" # compile and install or install prebuilt additional packages
CREATE_PATCHES="no" # wait that you make changes to uboot and kernel source and creates patches
BUILD_ALL="no" # cycle through available boards and make images or kernel/u-boot packages.
# set KERNEL_ONLY to "yes" or "no" to build all packages/all images BSPFREEZE="" # freeze armbian packages (u-boot, kernel, dtb)
INSTALL_HEADERS="" # install kernel headers package
LIB_TAG="master" # change to "branchname" to use any branch currently available.
CARD_DEVICE="" # device name /dev/sdx of your SD card to burn directly to the card when done PROGRESS_LOG_TO_FILE="yes"
BUILD_KSRC="no"

在compile.sh当中允许传递 key=value, 比如./compile.sh  test_cmd=test_value

 # Script parameters handling
for i in "$@"; do
if [[ $i == *=* ]]; then
parameter=${i%%=*}
value=${i##*=}
display_alert "Command line: setting $parameter to" "${value:-(empty)}" "info"
eval $parameter=$value
fi
done

接下来我们继续看compile.sh

 if [[ $BUILD_ALL == yes || $BUILD_ALL == demo ]]; then
source $SRC/lib/build-all.sh
else
source $SRC/lib/main.sh
fi

由于默认的BUILD_ALL = “no” , 所以接下来会去执行$SRC/lib/main.sh.脚本。

总结一下compile.sh的功能:

1)    获取shell脚本相关的钩子函数,在lib/generate.sh当中

2)    获取并解析默认的参数。

3)    最后的主要功能还是在/lib/main.sh脚本当中,接下来我们会来解析main.sh脚本的功能。

 

learning armbian steps(7) ----- armbian 源码分析(二)的更多相关文章

  1. Fresco 源码分析(二) Fresco客户端与服务端交互(1) 解决遗留的Q1问题

    4.2 Fresco客户端与服务端的交互(一) 解决Q1问题 从这篇博客开始,我们开始讨论客户端与服务端是如何交互的,这个交互的入口,我们从Q1问题入手(博客按照这样的问题入手,是因为当时我也是从这里 ...

  2. 框架-springmvc源码分析(二)

    框架-springmvc源码分析(二) 参考: http://www.cnblogs.com/leftthen/p/5207787.html http://www.cnblogs.com/leftth ...

  3. Tomcat源码分析二:先看看Tomcat的整体架构

    Tomcat源码分析二:先看看Tomcat的整体架构 Tomcat架构图 我们先来看一张比较经典的Tomcat架构图: 从这张图中,我们可以看出Tomcat中含有Server.Service.Conn ...

  4. 十、Spring之BeanFactory源码分析(二)

    Spring之BeanFactory源码分析(二) 前言 在前面我们简单的分析了BeanFactory的结构,ListableBeanFactory,HierarchicalBeanFactory,A ...

  5. Vue源码分析(二) : Vue实例挂载

    Vue源码分析(二) : Vue实例挂载 author: @TiffanysBear 实例挂载主要是 $mount 方法的实现,在 src/platforms/web/entry-runtime-wi ...

  6. 多线程之美8一 AbstractQueuedSynchronizer源码分析<二>

    目录 AQS的源码分析 该篇主要分析AQS的ConditionObject,是AQS的内部类,实现等待通知机制. 1.条件队列 条件队列与AQS中的同步队列有所不同,结构图如下: 两者区别: 1.链表 ...

  7. ABP源码分析二:ABP中配置的注册和初始化

    一般来说,ASP.NET Web应用程序的第一个执行的方法是Global.asax下定义的Start方法.执行这个方法前HttpApplication 实例必须存在,也就是说其构造函数的执行必然是完成 ...

  8. ABP源码分析二十:ApplicationService

    IApplicationService : 空接口,起标识作用.所有实现了IApplicationService 的类都会被自动注入到容器中.同时所有IApplicationService对象都会被注 ...

  9. ABP源码分析二十一:Feature

    Feature是什么?Feature就是对function的分类方法,其与function的关系就比如Role和User的关系一样. ABP中Feature具有以下属性: 其中最重要的属性是name, ...

  10. ABP源码分析二十二:Navigation

    MenuDefinition:封装了导航栏上的主菜单的属性. MenuItemDefinition:封装了主菜单的子菜单的属性.子菜单可以引用其他子菜单构成一个菜单树 UserMenu/UserMen ...

随机推荐

  1. Education Reform(CodeForces-119C)【DP】

    题意:从m门课选出n个排到n天,每天一门,难度须递增,每门课对应着一个作业量Xi,且Xi = Xi-1 + k or Xi - Xi-1 * k,总作业量要尽可能大,问能否排布,若能排布,求方案. 思 ...

  2. hadoop 》》 django 简单操作hdfs 语句

    >> from django.shortcuts import render # Create your views here. from hdfs.client import Clien ...

  3. 计算机网络(TCP/IP)

    概述:网络协议通常分不同的层次进行开发,每一层分别不同的通信功能.TCP/IP通常分为4层协议系统. 1.链路层,有时也称为数据链路层或者网络接口层,通常包括操作系统中的设备驱动程序和计算机中对应的网 ...

  4. HeidiSQL 导入Excel数据

    一 前言 原文出处:http://blog.csdn.net/qq_27727681/article/details/53944744 二 效果演示: 2000多条数据,顺利导入成功. 三  实现方法 ...

  5. k8s之网络插件flannel及基于Calico的网络策略

    1.k8s网络通信 a.容器间通信:同一个pod内的多个容器间的通信,通过lo即可实现; b.pod之间的通信:pod ip <---> pod ip,pod和pod之间不经过任何转换即可 ...

  6. docker 入门1 - 方向 【翻译】

    开始,第 1 部分:方向和设置 欢迎!我们很高兴您想学习 Docker.Docker 入门教程将教您如何: 设置 Docker 环境(当前步骤) 生成映像并将其作为一个容器运行 缩放应用以运行多个容器 ...

  7. centos中拉取postgre

    新搭建好的linux服务器环境,docker也配置好了. 第一步,下载postgre docker pull postgres:11 这里的版本号自己按照自己的需要来获取. 然而实际上没那么顺利,直接 ...

  8. css鼠标悬浮控制元素隐藏与显示

    在网页开发中经常有需求是鼠标移动到一个元素A身上时,另外一个元素B显示. 如下图 当鼠标移到图片上时,相关的描述从下方显示出来. css实现原理与情景: A 是 B 的父元素 B 默认隐藏 B{opa ...

  9. iview-admin部署linux nginx报500错误的问题记录

    遇到个新服务器部署iview-admin之后 在nginx配置文件有个user配置项 这里需要配置为root或者可以读取本地文件的用户 站点配置如下 server { listen ; server_ ...

  10. 如何在Marketing Cloud里创建extension field扩展字段

    首先在Marketing Cloud里找到创建扩展字段的tile入口,搜索关键字extension: 这会进入Fiori应用"Custom fields",能看到系统里所有创建好的 ...