前言

我的J1900软路由从年初更换为Lean的OpenWrt固件(在谷歌云上自己编译的)后,一直使用到现在,最近发现ssr插件不稳定:一觉醒来设备总是fq不了,我得进去管理页面手动关闭插件后再开启才能正常使用 如此往复几天,受不了的我终于下定决心来更新下固件!

记得我在笔记本上第一次就编译成功,怎么我来二次编译就翻了好多趟车 ,翻车现场有:1.编译失败;2.编译“成功”将新固件刷入,软路由无限重启... 让我折腾了2天,终于修成正果,于是决定另开此文来记录下怎么在本地Ubuntu编译Lean的Openwrt固件。

镇楼:

懒得动手的话,这里下载我刚编译的吧~

一、跟着官方文档

https://github.com/coolsnowwolf/lede

0.装好 Ubuntu 18 LTS x64,我是直接安装到笔记本上,没用虚拟机。

1.以防万一网络环境不好,修改下软件源:

#备份源文档
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

#直接清空源文档后,增加国内源
sudo vim /etc/apt/sources.list
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse

2.更新Ubuntu系统:

sudo apt-get update #更新软件列表
sudo apt-get upgrade #更新软件包

3.安装编译工具:

sudo apt-get -y install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch python3.5 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

二、配置网络环境

要用root 用户 git 和编译!!!

国内用户编译前最好准备好梯子

敲黑板,前面我编译失败的原因之一就是梯子没有准备好:我以为在软路由设置了全局代理后,任何设备的终端都会走代理,然而事实不是这样子的... 为了避免编译失败,请务必重点配置好:让Ubuntu的终端走全局代理!

4.安装 v2ray GUI 客户端Qv2ray 或者 v2rayL,无论使用哪个都是:添加线路、修改 本地端口Socks(比如我这里设置/修改为了 Socks:1088)、到浏览器测试下能否fq、即可。

  • Qv2ray直接在Ubuntu软件商店搜索安装即可!
  • v2rayL安装方法如下:
#链接:https://github.com/jiangxufeng/v2rayL
bash <(curl -s -L http://dl.thinker.ink/install.sh)

5.安装 proxychains来协助Ubuntu的终端走代理:

sudo apt install -y proxychains
  • 修改配置文件:移动到文档最有一行、注释掉这行:socks4 127.0.0.1 9050、再新添加:socks5 127.0.0.1 1088(这个1088就是上边v2ray客户端设置的端口,可以是其他任意端口/数字,但是你需要确保它们对应上)
sudo vim /etc/proxychains.conf
  • 配置文件最后两行应该显示如下:
#socks4 127.0.0.1 9050
socks5 127.0.0.1 1088
  • 使用方法:哪条命令你想要它代理,就在最前面加上proxychains,比如我们在终端测试下:proxychains curl https://www.google.com,看到有OK的结果就ok了,如下:
sgq@ubuntu:~$ proxychains curl https://www.google.com
ProxyChains-3.1 (http://proxychains.sf.net)
|DNS-request| www.google.com 
|S-chain|-<>-127.0.0.1:1088-<><>-4.2.2.2:53-<><>-OK
|DNS-response| www.google.com is 172.217.163.164
|S-chain|-<>-127.0.0.1:1088-<><>-172.217.163.164:443-<><>-OK

三、接着编译命令

6.万事俱备,让我们回到官方文档的剩余步骤:需要联网下载的命令,我们就使用proxychains来使终端全局代理下载

#下载源码
proxychains git clone https://github.com/coolsnowwolf/lede`

#进入目录
cd lede

如果你是初次编译的话,那么你想要的 ssr-plus大概率会在feed里面被隐藏了的,此时你已进入lede目录,vim feeds.conf.default删除最后两行的 #即可解锁:

src-git luci https://github.com/coolsnowwolf/luci
src-git routing https://git.openwrt.org/feed/routing.git;openwrt-19.07
#src-git telephony https://git.openwrt.org/feed/telephony.git;openwrt-19.07
#src-git helloworld https://github.com/fw876/helloworld

修改并保存好 feeds.conf.default,继续:

#更新feed列表
proxychains ./scripts/feeds update -a && ./scripts/feeds install -a

#进入编译菜单勾一勾想要的功能
make menuconfig

#下载dl库
proxychains make download

#为了以防编译失败,建议使用单线程编译
proxychains make -j1 V=s

不出幺蛾子的话、最后应该能够修成正果、祝你好运 编译完成后的固件路径在这里:/lede/bin/targets

二次编译

cd lede
proxychains git pull
proxychains ./scripts/feeds update -a && ./scripts/feeds install -a

#如果需要重新配置:rm -rf ./tmp && rm -rf .config
make menuconfig

proxychains make download
proxychains make -j1 V=s

进阶:云编译openwrt

不想傻兮兮等电脑耗时几个小时还不一定百分比编译成功?本地编译还是很蛋疼?

那么 使用GitHub Actions云编译OpenWrt会是一个很棒的解决方案,详情请点击大佬项目:https://github.com/P3TERX/Actions-OpenWrt

记录下我的折腾过程:

1.本地制作 .config

在本地编译环境下:

make menuconfig #定制好需要的插件
make defconfig
./scripts/diffconfig.sh > seed.config #该脚本的作用在于把你定制的跟默认的差异部分写入seed.config这个文件

打开seed.config文档,全选复制里面所有的内容,

点击查看我20200731弄的配置

CONFIG_TARGET_x86=y
CONFIG_TARGET_x86_64=y
CONFIG_TARGET_x86_64_DEVICE_generic=y
CONFIG_ARIA2_BITTORRENT=y
CONFIG_ARIA2_NOXML=y
CONFIG_ARIA2_OPENSSL=y
CONFIG_ARIA2_WEBSOCKET=y
CONFIG_LIBCURL_COOKIES=y
CONFIG_LIBCURL_FILE=y
CONFIG_LIBCURL_FTP=y
CONFIG_LIBCURL_HTTP=y
CONFIG_LIBCURL_MBEDTLS=y
CONFIG_LIBCURL_NO_SMB="!"
CONFIG_LIBCURL_PROXY=y
CONFIG_PACKAGE_aria2=y
CONFIG_PACKAGE_ariang=y
CONFIG_PACKAGE_ca-bundle=y
CONFIG_PACKAGE_curl=y
CONFIG_PACKAGE_frpc=y
CONFIG_PACKAGE_gzip=y
CONFIG_PACKAGE_hd-idle=y
# CONFIG_PACKAGE_kmod-fast-classifier is not set
CONFIG_PACKAGE_kmod-ipt-offload=y
CONFIG_PACKAGE_kmod-nf-flow=y
# CONFIG_PACKAGE_kmod-shortcut-fe is not set
# CONFIG_PACKAGE_kmod-tun is not set
CONFIG_PACKAGE_libbz2=y
CONFIG_PACKAGE_libcap=y
CONFIG_PACKAGE_libcurl=y
CONFIG_PACKAGE_libdb47=y
CONFIG_PACKAGE_libffi=y
CONFIG_PACKAGE_libgdbm=y
CONFIG_PACKAGE_liblzma=y
CONFIG_PACKAGE_libsqlite3=y
CONFIG_PACKAGE_libwebsockets-full=y
CONFIG_PACKAGE_libxml2=y
CONFIG_PACKAGE_luci-app-aria2=y
CONFIG_PACKAGE_luci-app-flowoffload=y
CONFIG_PACKAGE_luci-app-frpc=y
CONFIG_PACKAGE_luci-app-hd-idle=y
CONFIG_PACKAGE_luci-app-netdata=y
# CONFIG_PACKAGE_luci-app-sfe is not set
CONFIG_PACKAGE_luci-app-transmission=y
CONFIG_PACKAGE_luci-app-ttyd=y
CONFIG_PACKAGE_luci-app-watchcat=y
# CONFIG_PACKAGE_luci-app-webadmin is not set
# CONFIG_PACKAGE_luci-app-xlnetacc is not set
# CONFIG_PACKAGE_luci-app-zerotier is not set
CONFIG_PACKAGE_luci-i18n-aria2-zh-cn=y
CONFIG_PACKAGE_luci-i18n-flowoffload-zh-cn=y
CONFIG_PACKAGE_luci-i18n-frpc-zh-cn=y
CONFIG_PACKAGE_luci-i18n-hd-idle-zh-cn=y
CONFIG_PACKAGE_luci-i18n-netdata-zh-cn=y
CONFIG_PACKAGE_luci-i18n-transmission-zh-cn=y
CONFIG_PACKAGE_luci-i18n-ttyd-zh-cn=y
CONFIG_PACKAGE_luci-i18n-watchcat-zh-cn=y
CONFIG_PACKAGE_luci-theme-freifunk-generic=y
CONFIG_PACKAGE_luci-theme-netgear=y
CONFIG_PACKAGE_netdata=y
CONFIG_PACKAGE_python3=y
CONFIG_PACKAGE_python3-asyncio=y
CONFIG_PACKAGE_python3-base=y
CONFIG_PACKAGE_python3-cgi=y
CONFIG_PACKAGE_python3-cgitb=y
CONFIG_PACKAGE_python3-codecs=y
CONFIG_PACKAGE_python3-ctypes=y
CONFIG_PACKAGE_python3-dbm=y
CONFIG_PACKAGE_python3-decimal=y
CONFIG_PACKAGE_python3-distutils=y
CONFIG_PACKAGE_python3-email=y
CONFIG_PACKAGE_python3-gdbm=y
CONFIG_PACKAGE_python3-light=y
CONFIG_PACKAGE_python3-logging=y
CONFIG_PACKAGE_python3-lzma=y
CONFIG_PACKAGE_python3-multiprocessing=y
CONFIG_PACKAGE_python3-ncurses=y
CONFIG_PACKAGE_python3-openssl=y
CONFIG_PACKAGE_python3-pkg-resources=y
CONFIG_PACKAGE_python3-pydoc=y
CONFIG_PACKAGE_python3-setuptools=y
CONFIG_PACKAGE_python3-sqlite3=y
CONFIG_PACKAGE_python3-unittest=y
CONFIG_PACKAGE_python3-urllib=y
CONFIG_PACKAGE_python3-xml=y
CONFIG_PACKAGE_screen=y
CONFIG_PACKAGE_transmission-daemon-openssl=y
CONFIG_PACKAGE_transmission-web-control=y
CONFIG_PACKAGE_ttyd=y
CONFIG_PACKAGE_unzip=y
CONFIG_PACKAGE_vim=y
CONFIG_PACKAGE_watchcat=y
CONFIG_PACKAGE_youtube-dl=y
CONFIG_PACKAGE_youtube-dl-src=y
# CONFIG_PACKAGE_zerotier is not set
CONFIG_PACKAGE_zsh=y
CONFIG_SQLITE3_DYNAMIC_EXTENSIONS=y
CONFIG_SQLITE3_FTS3=y
CONFIG_SQLITE3_FTS4=y
CONFIG_SQLITE3_FTS5=y
CONFIG_SQLITE3_JSON1=y
CONFIG_SQLITE3_RTREE=y
CONFIG_VDI_IMAGES=y

2.fork项目

  • 修改了diy-part1.sh:删除#开启ssr插件源:sed -i 's/^#\(.*helloworld\)/\1/' feeds.conf.default
  • 修改了work­flow文件.github/workflows/build-openwrt.yml激活了两个功能:点击 star 开始编译上传固件到奶牛快传

准备完毕后就可以触发初次云编译了:按照要求,在fork项目里新建 .config文档,把前面 seed.config的配置内容粘贴到里面保存即可!

最终耗时 3h 9m 24s编译完成:GitHub Actions.png

Last modification:December 16, 2020
如果觉得我的文章对你有用,请随意赞赏