WSL的安装参见Windows10 玩SmartDNS告别污染
最好别装在默认的C盘,编译文件量巨大(占用空间近6G)
环境准备
# 命令
sudo nano /etc/apt/sources.list
# 文件开头处插入
deb http://mirrors.163.com/debian/ stretch main non-free contrib
deb http://mirrors.163.com/debian/ stretch-updates main non-free contrib
deb http://mirrors.163.com/debian/ stretch-backports main non-free contrib
deb-src http://mirrors.163.com/debian/ stretch main non-free contrib
deb-src http://mirrors.163.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.163.com/debian/ stretch-backports main non-free contrib
deb http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib
deb-src http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib
更新环境软件包 命令:sudo sh -c "apt update && apt upgrade -y"
安装依赖包:
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 rsync
取消WSL PATH 与windows PATH关联
#在Debian中修改/etc/wsl.conf
sudo nano /etc/wsl.conf
#加入内容
[interop]
appendWindowsPath=false
[automount]
enable=false
#管理员身份cmd运行以下命令重启wsl
net stop LxssManager
net start LxssManager
#查验环境变量看效果
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
#上面看不到Windows环境路径就对了
将Debian目录设置为大小写敏感路径 参考
fsutil.exe file setCaseSensitiveInfo <Debian Path> enable
加速连接
前面的参考文都采用的系统代理的方式加速,我这里代理效果不佳,常常TimeOut
,所以采用了镜像连接的方法
# 原GitHub
https://github.com/coolsnowwolf/lede.git
# 镜像连接
https://gitclone.com/github.com/coolsnowwolf/lede.git # 杭州
https://hub.fastgit.org/coolsnowwolf/lede.git # 香港
https://github.com.cnpmjs.org/coolsnowwolf/lede.git # 新加坡
# 切换至用户目录 (必须)
cd /home/UserName
# 克隆镜像
git clone https://github.com.cnpmjs.org/coolsnowwolf/lede.git
cd lede
# 添加 feed 源
sed -i '$a src-git lienol https://github.com/Lienol/openwrt-package' feeds.conf.default
sed -i '$a src-git kenzok8 https://github.com/kenzok8/openwrt-packages' feeds.conf.default
sed -i '$a src-git small https://github.com/kenzok8/small' feeds.conf.default
# 替换镜像连接
sed -i 's/github.com/&.cnpmjs.org/g' ./feeds.conf.default
sed -i 's/github.com\//github.com.cnpmjs.org\//g' `grep -l -e github.com/.*/.*\.git ./package/lean/*/Makefile`
./scripts/feeds clean
./scripts/feeds update -a #最好多执行几次, 放置下载失败
./scripts/feeds install -a
编译
以编译极路由B70硬改SPI版为例:
# 修改默认网址
sed -i 's/192.168.1.1/192.168.77.1/g' ./package/base-files/files/bin/config_generate
# 下载dts配置文件
wget -P ./target/linux/ramips/dts/ https://raw.sevencdn.com/lon91ong/OpenWRT_B70_SPI_16M/master/mt7621_hiwifi_hc5962-spi.dts
sed -i 's/hc5962/&|\\\n\thiwifi,hc5962-spi/g' ./target/linux/ramips/mt7621/base-files/etc/board.d/02_network
# 添加设备信息
cat >> ./target/linux/ramips/image/mt7621.mk <<EOF
define Device/hiwifi_hc5962-spi
IMAGE_SIZE := 16064k
DEVICE_VENDOR := HiWiFi
DEVICE_MODEL := HC5962
DEVICE_PACKAGES := kmod-mt7603 kmod-mt76x2 kmod-usb3 wpad-openssl
endef
TARGET_DEVICES += hiwifi_hc5962-spi
EOF
# 下面两条适配32M闪存
sed -i 's/<0x50000 0xfb0000>/<0x50000 0x1fb0000>/g' ./target/linux/ramips/dts/mt7621_hiwifi_hc5962-spi.dts
sed -i 's/16064/32128/g' ./target/linux/ramips/image/mt7621.mk
# 修改默认主题
sed -i 's/luci-theme-bootstrap/luci-theme-argon/g' ./feeds/luci/collections/luci/Makefile
rm -f ./.config*
touch ./.config
# ===========固件定制部分=============
# 编译极路由B70固件:
cat >> .config <<EOF
CONFIG_TARGET_ramips=y
CONFIG_TARGET_ramips_mt7621=y
CONFIG_TARGET_ramips_mt7621_DEVICE_hiwifi_hc5962-spi=y
# 常用LuCI插件选择: 添加外面的主题和应用
CONFIG_PACKAGE_luci-app-aria2=y
CONFIG_PACKAGE_webui-aria2=y
CONFIG_PACKAGE_aria2=y
CONFIG_PACKAGE_luci-app-wol=n
CONFIG_PACKAGE_luci-app-upnp=y
CONFIG_PACKAGE_luci-app-accesscontrol=n
CONFIG_PACKAGE_luci-app-filetransfer=y
CONFIG_PACKAGE_luci-app-unblockmusic=n
CONFIG_PACKAGE_luci-app-unblockneteasemusic-mini=n
CONFIG_PACKAGE_luci-app-vsftpd=y
CONFIG_PACKAGE_luci-app-cifs-mount=y
CONFIG_PACKAGE_luci-app-vlmcsd=n
CONFIG_PACKAGE_luci-app-zerotier=n
CONFIG_PACKAGE_luci-theme-argon=y
CONFIG_PACKAGE_luci-theme-bootstrap=n
# passwall Configuration 16M固件取 n, 32M固件取 y
CONFIG_PACKAGE_luci-app-ssr-plus=n
CONFIG_PACKAGE_luci-app-passwall=y
CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Shadowsocks=y
CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Shadowsocks_Server=y
CONFIG_PACKAGE_luci-app-passwall_INCLUDE_ShadowsocksR=y
CONFIG_PACKAGE_luci-app-passwall_INCLUDE_ShadowsocksR_Server=y
CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Xray=y
CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Trojan_Plus=y
CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Trojan_GO=y
CONFIG_PACKAGE_luci-app-passwall_INCLUDE_haproxy=y
CONFIG_PACKAGE_luci-app-passwall_INCLUDE_dns2socks=y
CONFIG_PACKAGE_luci-app-passwall_INCLUDE_v2ray-plugin=y
CONFIG_PACKAGE_luci-app-passwall_INCLUDE_simple-obfs=y
CONFIG_PACKAGE_shadowsocks-libev-ss-server=y
CONFIG_PACKAGE_shadowsocks-libev-ss-redir=y
CONFIG_PACKAGE_shadowsocks-libev-ss-local=y
CONFIG_PACKAGE_shadowsocksr-libev-server=y
# 常用软件包:
CONFIG_PACKAGE_mount-utils=n
CONFIG_PACKAGE_automount=y
CONFIG_PACKAGE_coreutils-nohup=y
CONFIG_PACKAGE_kmod-fs-ext4=y
CONFIG_PACKAGE_curl=y
CONFIG_PACKAGE_htop=y
CONFIG_PACKAGE_libmbedtls=y
CONFIG_PACKAGE_ipt2socks=y
CONFIG_PACKAGE_ssocks=y
CONFIG_PACKAGE_screen=y
CONFIG_PACKAGE_trojan-go=y
CONFIG_PACKAGE_tree=y
CONFIG_PACKAGE_unzip=y
CONFIG_PACKAGE_vim-fuller=y
CONFIG_PACKAGE_wget=y
EOF
# ===================固件定制部分结束===================
sed -i 's/^[ \t]*//g' ./.config
make defconfig
配置结束,编译预备:
# 最后下载dl库, 多执行几次, 实在下不动的用工具下之后复制过来
make -j8 download V=s
# 手动复制过来的需要添加权限644
sudo chmod 644 ./dl/*
# 开始编译, (-j 后面是线程数。第一次编译推荐用单线程)
make -j1 V=s
第一次编译耗时大约1小时左右, 具体看电脑配置。
以后编译可以使用多线程,速度更快:参考
make dirclean //清除上一次编译产生的垃圾
make download -j8 V=s
make -j6 V=s
编译好的固件位置:
编译工作目录(/home/UserName/lede)./bin/targets/(CPU架构)..openwrt-*-squashfs-sysupgrade.bin
网友评论