<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>系统构建 on Laning's Blog</title><link>https://blog.laning.org/tags/%E7%B3%BB%E7%BB%9F%E6%9E%84%E5%BB%BA/</link><description>Recent content in 系统构建 on Laning's Blog</description><generator>Hugo</generator><language>zh-CN</language><lastBuildDate>Thu, 06 Jun 2024 13:45:50 +0800</lastBuildDate><atom:link href="https://blog.laning.org/tags/%E7%B3%BB%E7%BB%9F%E6%9E%84%E5%BB%BA/index.xml" rel="self" type="application/rss+xml"/><item><title>Armbian/build脚本分析</title><link>https://blog.laning.org/posts/wp-0380/</link><pubDate>Thu, 06 Jun 2024 13:44:10 +0800</pubDate><guid>https://blog.laning.org/posts/wp-0380/</guid><description>&lt;h2 id="1-脚本目录检测和代码健壮性保证"&gt;1. 脚本目录检测和代码健壮性保证&lt;/h2&gt;
&lt;h3 id="11-程序报错退出脚本"&gt;1.1 程序报错退出脚本&lt;/h3&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;#set -o pipefail # trace ERR through pipes - will be enabled &amp;#34;soon&amp;#34;
#set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled
set -e
set -o errtrace # trace ERR through - enabled
set -o errexit ## set -e : exit the script if any statement returns a non-true return value - enabled
# Important, go read http://mywiki.wooledge.org/BashFAQ/105 NOW!
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id="12-compilesh脚本目录检测"&gt;1.2. ./compile.sh脚本目录检测&lt;/h3&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;SRC=&amp;#34;$(dirname &amp;#34;$(realpath &amp;#34;${BASH_SOURCE[0]}&amp;#34;)&amp;#34;)&amp;#34;
cd &amp;#34;${SRC}&amp;#34; || exit
# check for whitespace in ${SRC} and exit for safety reasons
grep -q &amp;#34;[[:space:]]&amp;#34; &amp;lt;&amp;lt;&amp;lt; &amp;#34;${SRC}&amp;#34; &amp;amp;&amp;amp; {
echo &amp;#34;\&amp;#34;${SRC}\&amp;#34; contains whitespace. Not supported. Aborting.&amp;#34; &amp;gt;&amp;amp;2
exit 1
}
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="2-singlesh-文件加载位于lib"&gt;2. single.sh 文件加载（位于./lib）&lt;/h2&gt;
&lt;h3 id="21-检查bash版本是否高于5x"&gt;2.1 检查bash版本是否高于5.x&lt;/h3&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;# The Armbian functions require Bash 5.x.
if [[ &amp;#34;${BASH_VERSINFO:-0}&amp;#34; -lt 5 ]]; then
echo &amp;#34;Armbian build scripts require Bash 5.x. Go get it...&amp;#34; &amp;gt;&amp;amp;2
if [[ &amp;#34;${OSTYPE}&amp;#34; == &amp;#34;darwin&amp;#34;* ]]; then
echo &amp;#34;Armbian build scripts require brew to be installed and working on macOS. (old Bash version)&amp;#34; &amp;gt;&amp;amp;2
echo &amp;#34;Please install brew, *restart your terminal*.&amp;#34; &amp;gt;&amp;amp;2
echo &amp;#34;Then run &amp;#39;brew install bash coreutils git&amp;#39;, *restart your terminal* and then try again.&amp;#34; &amp;gt;&amp;amp;2
exit 51
fi
exit 50
fi
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id="22-macos系统检查"&gt;2.2 macOS系统检查&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;是否以root运行脚本&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Homebrew 包管理器已安装并正常工作&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;通过 Homebrew 的 &lt;code&gt;coreutils&lt;/code&gt; 安装的 &lt;code&gt;realpath&lt;/code&gt; 命令是否可用&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;更新 &lt;code&gt;PATH&lt;/code&gt; 环境变量以包含由 Homebrew 安装的 GNU &lt;code&gt;coreutils&lt;/code&gt; 二进制文件。&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;确保 &lt;code&gt;${SRC}&lt;/code&gt; 变量（应指向构建脚本的源目录）位于用户的主目录中。这对于 macOS 上的 Docker 兼容性很重要。&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;</description></item></channel></rss>