自己动手编译最新OpenWrt稳定版

登山则情满于山,观海则意溢于海。这篇文章主要讲述自己动手编译最新OpenWrt稳定版相关的知识,希望能为你提供帮助。
1.安装ubuntu 20.04.3
sudo apt-get update -y
?sudo apt-get -y install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch python3 python2.7 unzip zlib1g-dev lib32gcc1 libc6-dev-i386 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?
?2.下载源码:?
git clone https://github.com/coolsnowwolf/lede
git clone https://github.com/openwrt/openwrt
3.查看并切换到新的稳定版tag(分支):
【自己动手编译最新OpenWrt稳定版】cd openwrt
git tag

git checkout v21.02.2

4.?自定义要安装的包,修改openwrt的include/target.mk文件,在?
DEFAULT_PACKAGES:=\\
        base-files \\
        ca-bundle \\
        dropbear \\
        fstools \\
        libc \\
        libgcc \\
        libustream-wolfssl \\
        logd \\
        mtd \\
        netifd \\
        opkg \\
        uci \\
        uclient-fetch \\
        urandom-seed \\
        urngd
? 后面加上自己想要编译的内容:?
?DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg netifd fstools uclient-fetch logd default-settings luci luci-app-aliddns luci-app-upnp luci-app-adbyby-plus luci-app-autoreboot luci-app-ssr-plus ddns-scripts_aliyun luci-app-vlmcsd luci-app-ramfree luci-app-flowoffload?
Compile OpenWrt参考资料:



">">">https://github.com/openwrt/openwrt

">">">https://github.com/coolsnowwolf/lede





如何编译移植lean的固件到官方固件:https://www.bandwh.com/net/38.html

科学上网插件:

">">">https://github.com/kenzok8/small-package



编译Openwrt固件安装软件内核版本不一致问题解决:

">">">https://www.haiyun.me/archives/1075.html





esirplayground/Compile_OpenWrt_Tutorial:如何编译自己需要的 OpenWrt 固件:

">">">https://github.com/esirplayground/Compile_OpenWrt_Tutorial





sudo apt-get -y install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch python3 python2.7 unzip zlib1g-dev lib32gcc1 libc6-dev-i386 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







git clone https://github.com/coolsnowwolf/lede

git clone https://github.com/openwrt/openwrt



拷贝lede/packgage/lean文件夹到openwrt/package 里面,自定义要安装的包,修改openwrt的include/target.mk文件,在DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg netifd fstools uclient-fetch logd 后面加上自己想要编译的内容



下载源代码及切换目录





添加部分插件源,例如Helloword,(不需要的可跳过这步)

以下方式二选一



下载仓库方式:命令行输入以下命令"git clone https://github.com/fw876/helloworld.git package/lean/luci-app-ssr-plus"



添加feeds方式:命令行输入以下命令"echo src-git helloworld https://github.com/fw876/helloworld > > feeds.conf.default"



cd openwrt

git tag

git checkout v19.07.0



vi include/target.mk





./scripts/feeds update -a

./scripts/feeds install -a

make menuconfig



git clone https://github.com/fw876/helloworld.git package/lean/luci-app-ssr-plus



vi feeds.conf.default



src-git helloworld https://github.com/fw876/helloworld

src-git lienol https://github.com/xiaorouji/openwrt-passwall



首先装好 Ubuntu 64bit,推荐 Ubuntu 20.04 LTS x64



命令行输入 sudo apt-get update ,然后输入 sudo apt-get -y install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch python3 python2.7 unzip zlib1g-dev lib32gcc1 libc6-dev-i386 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



使用 git clone https://github.com/coolsnowwolf/lede 命令下载好源代码,然后 cd lede 进入目录



./scripts/feeds update -a

./scripts/feeds install -a

make menuconfig

make -j8 download V=s 下载dl库(国内请尽量全局科学上网)



输入 make -j1 V=s (-j1 后面是线程数。第一次编译推荐用单线程)即可开始编译你要的固件了。



git clone -b 19.07 https://github.com/kenzok8/small-package



wget https://downloads.openwrt.org/releases/19.07.8/targets/x86/64/openwrt-19.07.8-x86-64-generic.manifest



看看md5版本号是怎么生成的:



grep vermagic include/kernel-defaults.mk

$(SH_FUNC) grep =[ym] $(LINUX_DIR)/.config | LC_ALL=C sort | md5s > $(LINUX_DIR)/.vermagic



在编译前指定内核版本号:





#查看Openwrt官方源内核版本:



wget https://downloads.openwrt.org/releases/19.07.8/targets/x86/64/packages/Packages.gz

zgrep -m 1 "Depends: kernel (=.*)$" Packages.gz | sed -e s/.*-\\(.*\\))/\\1/ > .vermagic

#取而代之

sed -i -e s/^\\(.\\).*vermagic$/\\1cp $(TOPDIR)\\/.vermagic $(LINUX_DIR)\\/.vermagic/ include/kernel-defaults.mk





编译后指定内核版本:





sed -i s/eac88df3cb49b94d68ac3bc78be57f95/68143adfcb7fc62a239c4be112fe40de/ /usr/lib/opkg/status



    推荐阅读