NanoPi r4s lede 固件编译
脚本来自 github action
编译的软件会有冲突, 参考
出现error: ext4_allocate_best_fit_partial: failed to allocate XXX blocks, out of space错误的解决办法: make menuconfig,找到菜单项"Target Images","Root filesystem partition size (in MB)",把值改大即可
脚本内容:
# 除了编译【openwrt】机型外,其他机型都直接打入了常用插件了,不需要自己再拉取插件,除非我的插件包跟源码自带的都没有,你就自己添加吧,说明的《各种命令的简单介绍》有教程。
# 选择编译【openwrt】纯天然不经任何修改的,增加插件可以在diy-1.sh增加,也可在settings.ini里修改成你想要编译的源码跟分支。
# 选择【Lede_phicomm_n1或Project_phicomm_n1】的机型文件夹编译的话,会自动编译出( N1、微加云、贝壳云、我家云、S9xxx )固件。
# [Lede_x86_64,Lede_gl_mt300n_v2,Lede_nanopi_r2s,Lede_nanopi_r4s,Lede_newifi_d2,p2w_r619ac_128m,Lede_phicomm_k2p,Lede_phicomm_n1,Lede_redmi_ac2100,Lede_wankeyun,Lede_wndr3800,Lede_wndr4300_v1,Lede_wr703n_v1,Lede_xiaomi_r3pro,Lede_xiaoyu_c5,Lede_Raspberry_Pi4]
# [Lienol_phicomm_k2p,Lienol_phicomm_k3,Lienol_x86_64]
# [Project_x86_64,Project_nanopi_r2s,Project_nanopi_r4s,Project_newifi_d2,Project_phicomm_k3,Project_phicomm_n1,Project_xiaomi_ac2100,Project_xiaomi_mir3g,Project_xiaoyu_c5]
# [openwrt]
REPO_URL="https://github.com/coolsnowwolf/lede" #编译固件源码链接(请勿修改)
REPO_BRANCH="master" #源码链接的分支(请勿修改)
CONFIG_FILE=".config" #配置文件(可SSH远程定制固件插件,也可在本地提取配置粘贴到此文件)(默认4GB内存的,要编译1GB内存的把 .config 修改成 1gb.config 就可以了)
WXFB_MESSAGE="Lede_nanopi_r4s" #微信通知跟发布要用到的名字,比如通知你XX开始编译,发布的时候显示XX固件
DIY_P1_SH="diy-1.sh" #自定义文件1
DIY_P2_SH="diy-2.sh" #自定义文件2
matrix_target="Lede_nanopi_r4s"
# 安装编译所需环境
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc
sudo -E apt-get -qq update -y
sudo -E apt-get -qq install -y build-essential asciidoc binutils bzip2 gawk gettext git libc6-dev-i386 libncurses5 libtinfo-dev libtinfo5 ncurses-doc libncurses5-dev libz-dev patch python3 python2.7 unzip zlib1g-dev lib32gcc1 subversion flex uglifyjs git-core gcc-multilib p7zip p7zip-full msmtp libssl-dev texinfo libglib2.0-dev xmlto qemu-utils upx libelf-dev autoconf automake libtool autopoint device-tree-compiler g++-multilib antlr3 gperf wget curl swig rsync
sudo -E apt-get -qq autoremove -y --purge
sudo -E apt-get -qq clean -y
sudo timedatectl set-timezone "$TZ"
sudo mkdir -p ~/workdir
sudo chown $USER:$GROUPS ~/workdir
# 下载编译的源码
cd ~/workdir
df -hT $PWD
git clone -b $REPO_BRANCH --single-branch $REPO_URL openwrt
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
git clone -b main --single-branch https://github.com/281677160/Custom openwrt/common
chmod +x openwrt/common/* ./
cd ~/workdir/openwrt
source common/common.sh && Diy_notice
# 加载源,patch补丁和自定义设置
cd ~/workdir
cp -Rf `find ./ -maxdepth 1 -type d ! -path './openwrt' ! -path './'` openwrt
cd openwrt
source common/common.sh && Diy_all
if [ ${matrix_target} != "openwrt" ]; then
if [ "${REPO_URL}" == "https://github.com/coolsnowwolf/lede" ]; then
source common/common.sh && Diy_lede
elif [ "${REPO_URL}" == "https://github.com/Lienol/openwrt" ]; then
source common/common.sh && Diy_lienol
elif [ "${REPO_URL}" == "https://github.com/immortalwrt/immortalwrt" ]; then
source common/common.sh && Diy_immortalwrt
fi
fi
if [ -f "build/${matrix_target}/$DIY_P1_SH" ]; then
chmod +x build/${matrix_target}/$DIY_P1_SH
/bin/bash "build/${matrix_target}/$DIY_P1_SH"
fi
./scripts/feeds clean && ./scripts/feeds update -a
./scripts/feeds install -a && ./scripts/feeds install -a
source common/common.sh && Diy_all2
if [ "${REPO_URL}" == "https://github.com/coolsnowwolf/lede" ]; then
source common/common.sh && Diy_lede2
echo "NAME2=Lede-" >> $GITHUB_ENV
echo "Source=Lede" >> $GITHUB_ENV
echo "ZUOZHE=lean" >> $GITHUB_ENV
elif [ "${REPO_URL}" == "https://github.com/Lienol/openwrt" ]; then
source common/common.sh && Diy_lienol2
echo "NAME2=Lienol-" >> $GITHUB_ENV
echo "Source=Lienol" >> $GITHUB_ENV
echo "ZUOZHE=lienol" >> $GITHUB_ENV
elif [ "${REPO_URL}" == "https://github.com/immortalwrt/immortalwrt" ]; then
source common/common.sh && Diy_immortalwrt2
echo "NAME2=Project-" >> $GITHUB_ENV
echo "Source=Project" >> $GITHUB_ENV
echo "ZUOZHE=CTCGFW" >> $GITHUB_ENV
fi
if [ -f "build/${matrix_target}/$DIY_P2_SH" ]; then
chmod +x build/${matrix_target}/$DIY_P2_SH
/bin/bash "build/${matrix_target}/$DIY_P2_SH"
fi
if [ -n "$(ls -A "build/${matrix_target}/patches" 2>/dev/null)" ]; then
find "build/${matrix_target}/patches" -type f -name '*.patch' -print0 | sort -z | xargs -I % -t -0 -n 1 sh -c "cat '%' | patch -d './' -p1 --forward --no-backup-if-mismatch"
fi
if [ -n "$(ls -A "build/${matrix_target}/files" 2>/dev/null)" ]; then
cp -rf build/${matrix_target}/files files
chmod -R 777 build/${matrix_target}/files/* ./
fi
if [ -n "$(ls -A "build/${matrix_target}/diy" 2>/dev/null)" ]; then
cp -Rf build/${matrix_target}/diy/* ./
fi
[ -e build/${matrix_target}/$CONFIG_FILE ] && mv build/${matrix_target}/$CONFIG_FILE .config
if [ ${matrix_target} != "openwrt" ]; then
if [ "${REGULAR_UPDATE}" == "true" ]; then
echo "Compile_Date=$(date +%Y%m%d-%H%M)" > $GITHUB_WORKSPACE/Openwrt.info
source common/upgrade.sh && Diy_Part1
fi
fi
# 下载软件包
cd ~/workdir/openwrt
make defconfig
make download -j8
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
# 编译固件
cd ~/workdir/openwrt
echo -e "$(($(nproc)+1)) thread compile"
make -j$(($(nproc)+5)) || make -j10 V=s
echo "::set-output name=status::success"
echo "date=$(date "+%y.%m.%d-%H%M")" >> $GITHUB_ENV
echo "date1=$(date "+%Y年%m月%d号-%H点%M分")" >> $GITHUB_ENV
echo "date2=$(date "+%Y%m%d%H%M%S")" >> $GITHUB_ENV
DEVICE="$(awk -F '[="]+' '/TARGET_BOARD/{print $2}' .config)"
SUBTARGET="$(awk -F '[="]+' '/TARGET_SUBTARGET/{print $2}' .config)"
if [ "${DEVICE}" == "x86" ]; then
echo "NAME1=x86-${SUBTARGET}" >> $GITHUB_ENV
elif [[ ${matrix_target} =~ (Lede_phicomm_n1|Project_phicomm_n1) ]]; then
echo "NAME1=n1,Vplus,Beikeyun,L1Pro,S9xxx" >> $GITHUB_ENV
elif [ "${DEVICE}" != "x86" ]; then
grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\1/' > NAME1
[ -s NAME1 ] && echo "NAME1=$(cat NAME1)" >> $GITHUB_ENV
fi
