xiaorouji / openwrt-passwall

7.15k stars 2.64k forks source link

教程:官方稳定版本SDK编译passwall相关ipk教程(Op21.02.1已经编译成功x86, rpi4b和 rpi3b相关ipk并且成功安装使用) #1557

Closed wazzx closed 2 years ago

wazzx commented 2 years ago

本人是菜鸟。这个是本人自己看网上教程和自己总结书写的一个教程。如果你是和我一样的菜鸟可以参考一下。本人在wsl的ubuntu18环境下编译成功了6次了。所以你使用应该也是没有问题的,当然也有很多可以改进的地方,希望得到大佬的支持和指点。谢谢。 授人以鱼不如授人以渔,希望墙外可以给你看到不一样的世界。 文章参考:来源 先安装运行环境。自己去看openwrt官网,所有编译环境全局科学上网,全局科学上网,全局科学上网

一.首次编译

#非root账号下载sdk
wget:....

解压sdk

进入SDK根目录
cd sdk

添加包含 passwall 的 feed (在SDK根目录)
echo "src-git passwall https://github.com/xiaorouji/openwrt-passwall" >> feeds.conf.default

因为部分软件包需要用到 upx,而官方 SDK 镜像中没有包含,所以自行安装 (在SDK根目录操作,只需要一次)
sudo apt-get update
sudo apt-get install upx -y
cp /usr/bin/upx staging_dir/host/bin
cp /usr/bin/upx-ucl staging_dir/host/bin

更新所有 feeds (在SDK根目录)
./scripts/feeds update -a

这里因为 Xray 使用的 golang 版本较新而 SDK 中依赖的 golang 版本较旧,所以替换了旧的,用了 21.02 的 golang 配置 (在SDK根目录进行,再次编译这一步可以不操作)
pushd feeds/packages/lang
rm -rf golang && svn co https://github.com/openwrt/packages/branches/openwrt-21.02/lang/golang
popd

在SDK根目录,下install
./scripts/feeds install luci-app-passwall

make defconfig

编译
#这个是清洁编译
make package/luci-app-passwall/{clean,compile} -j4
#这个是可以看到具体流程的可以看到错误
make package/luci-app-passwall/compile V=99

生成 index 和签名 (可以操作)
make package/index

二.更新以后再次编译
./scripts/feeds update -a

在SDK根目录,下install
./scripts/feeds install luci-app-passwall

make defconfig

编译
#这个是清洁编译
make package/luci-app-passwall/{clean,compile} -j4
#这个是可以看到具体流程的可以看到错误
make package/luci-app-passwall/compile V=99

有几个问题。 第一个编译都会有大量的其他无关ipk生成。可以只编译相关的ipk吗? 我以前编译trojan是这样操作的,但是还是有其他无关ipk生产

进入make menuconfig
make menuconfig
进入全局设置点掉前面三个的[*],如下面所示,然后保存,退出
[ ] Select all target specific packages by default                                                    
[ ] Select all kernel module packages by default                                                      
[ ] Select all userspace packages by default
[*] Cryptographically sign package lists (NEW) 
进入network———下拉找到[ ]trojan,然后选择[*] 退出保存
编译固件ipk
 make package/trojan/compile V=99

第二是如果源码更新以后,我这边再次编译有些ipk版本会改变,有些没有,那么在更新是不是需要把所有ipk都要重新上传还是只需要更新更新了版本的,好像 luci-app-passwall每次都会更新即使版本没有改变,还有问一下如果实际源码已经跟新了,但是软件版本好没有更新,重新安装配置文件会有改变或者重置吗! 第三是怎么优化一下编译。

二.安装 passwall软件

先更新软件源,移除dnsmasq,安装dnsmasq-full,luci-compat等依赖包

opkg update
opkg remove dnsmasq 
rm -rf /etc/config/dhcp
opkg install dnsmasq-full ipset iptables-mod-nat-extra openssl-util curl iptables-mod-tproxy iptables-mod-iprange ip-full luci-compat

根据luci-app-passwall需要的软件依此安装下面软件包

 * pkg_hash_check_unresolved: cannot find dependency **dns2socks** for luci-app-passwall
 * pkg_hash_check_unresolved: cannot find dependency **ipt2socks** for luci-app-passwall
 * pkg_hash_check_unresolved: cannot find dependency **microsocks** for luci-app-passwall
 * pkg_hash_check_unresolved: cannot find dependency **tcping** for luci-app-passwall
 * pkg_hash_check_unresolved: cannot find dependency **chinadns-ng** for luci-app-passwall
 * pkg_hash_check_unresolved: cannot find dependency **pdnsd-alt** for luci-app-passwall
 * pkg_hash_check_unresolved: cannot find dependency **shadowsocks-rust-sslocal** for luci-app-passwall
 * pkg_hash_check_unresolved: cannot find dependency **shadowsocksr-libev-ssr-local** for luci-app-passwall
 * pkg_hash_check_unresolved: cannot find dependency **shadowsocksr-libev-ssr-redir** for luci-app-passwall
 * pkg_hash_check_unresolved: cannot find dependency **simple-obfs** for luci-app-passwall
 * pkg_hash_check_unresolved: cannot find dependency **trojan-plus** for luci-app-passwall
 * pkg_hash_check_unresolved: cannot find dependency **v2ray-core** for luci-app-passwall
 * pkg_hash_check_unresolved: cannot find dependency **v2ray-plugin** for luci-app-passwall

将编译好的passwall文件夹内的ipk(除去luci-app-passwall和luci-i18n-passwall-zh-cn)上传到路由器的tmp文件夹内,然后安装 opkg install /tmp/*.ipk 最后上传和安装 luci-app-passwall和luci-i18n-passwall-zh-cn

****注意一点开启passwall后要在访问控制内部把路由器本身的UDP 代理模式设置成不代理**

azim0044 commented 2 years ago

Hi.. how to install the compiled Ipk? Does I have to upload the Ipk on /tmp or /root folder ? opkg update and opkg install *.ipk on that folder.. is it right ?

azim0044 commented 2 years ago

I do all of the step above but when i installed it give me an error like this :

the other ipk can be installed. I used offical sdk openwrt 21.02.1 for my Rpi4 from openwrt website. can you give me a quick guide how to overcome this such error and sorry for not asking in chineese.. Thanks in advance

wazzx commented 2 years ago

I do all of the step above but when i installed it give me an error like this :

  • pkg_hash_fetch_best_installation_candidate: Packages for luci-app-passwall found, but incompatible with the architectures configured
  • opkg_install_cmd: Cannot install package luci-app-passwall.

the other ipk can be installed. I used offical sdk openwrt 21.02.1 for my Rpi4 from openwrt website. can you give me a quick guide how to overcome this such error and sorry for not asking in chineese.. Thanks in advance

bad thing my english is bad so u cna give me a email i seed it to u

azim0044 commented 2 years ago

I do all of the step above but when i installed it give me an error like this :

  • pkg_hash_fetch_best_installation_candidate: Packages for luci-app-passwall found, but incompatible with the architectures configured
  • opkg_install_cmd: Cannot install package luci-app-passwall.

the other ipk can be installed. I used offical sdk openwrt 21.02.1 for my Rpi4 from openwrt website. can you give me a quick guide how to overcome this such error and sorry for not asking in chineese.. Thanks in advance

bad thing my english is bad so u cna give me a email i seed it to u

You can reply in chineese sir.. because I can translate it.. sorry for the inconvinience.. where to find your email sir ?

azim0044 commented 2 years ago

I do all of the step above but when i installed it give me an error like this :

  • pkg_hash_fetch_best_installation_candidate: Packages for luci-app-passwall found, but incompatible with the architectures configured
  • opkg_install_cmd: Cannot install package luci-app-passwall.

the other ipk can be installed. I used offical sdk openwrt 21.02.1 for my Rpi4 from openwrt website. can you give me a quick guide how to overcome this such error and sorry for not asking in chineese.. Thanks in advance

bad thing my english is bad so u cna give me a email i seed it to u

This is my email ... azimm0044@gmail.com

osnosn commented 2 years ago

补充:

  1. 全局当然方便,不是全局也可以。
    make 过程会用到 curl wget git go 这四个东西下载依赖组件。
    事先设置好它们的代理就可以了。

    • curl 设置 ~/.curlrc 优先用 curl
    • wget 设置 ~/.wgetrccurl, 就用不到wget
    • git 设置 ~/.gitconfig
    • go 用 GOPROXY 环境变量。
  2. 加入feeds.conf.default
    对于最新,应该是 src-git passwall https://github.com/xiaorouji/openwrt-passwall.git
    如果只想要luci:4.43
    src-git passwall https://github.com/xiaorouji/openwrt-passwall.git^ca993f3ea6b355b9f4d918cbd7de0e31a584b2d2

  3. 只需要ln -s /usr/bin/upx staging_dir/host/bin/ ,不需要upx-ucl
    如果编译x86, 用/usr/bin/upx, 即upx-3.96.
    如果编译mipsel, 要用 upx-3.93
    如果编译其他平台的, 自己试。

  4. 不需要替换golang的目录。
    对于 op-21.02-SDK 用的就是go-1.17.2, 无需修改。
    对于 op-19.07-SDK 只需要修改。
    feeds/packages/lang/golang/golang/Makefile

    PKG_HASH:=705c64251e5b25d5d55ede1039c6aa22bea40a7a931d14c370339853643c3df0

    feeds/packages/lang/golang/golang-version.mk

    GO_VERSION_MAJOR_MINOR:=1.17 GO_VERSION_PATCH:=3

  5. 最后的安装,还缺了一个包 luci-compat 需要安装。否则也用不了。

  6. 如果用 WSL , 建议关掉win防毒的"进程防护"(有的话),否则极慢。

wazzx commented 2 years ago

补充:

  1. 全局当然方便,不是全局也可以。 make 过程会用到 curl wget git go 这四个东西下载依赖组件。 事先设置好它们的代理就可以了。

    • curl 设置 ~/.curlrc
    • wget 设置 ~/.wgetrc 其实有 curl, 就用不到wget
    • git 设置 ~/.gitconfig
    • go 用 GOPROXY 环境变量。
  2. 加入feeds.conf.default 应该是 src-git passwall https://github.com/xiaorouji/openwrt-passwall.git 如果只想要luci:4.43 src-git passwall https://github.com/xiaorouji/openwrt-passwall.git^ca993f3ea6b355b9f4d918cbd7de0e31a584b2d2
  3. 只需要cp /usr/bin/upx staging_dir/host/bin ,不需要copy /usr/bin/upx-ucl
  4. 不需要替换golang的目录,只需要修改,对于 op-19.07 的 SDK, feeds/packages/lang/golang/golang/Makefile

    PKG_HASH:=705c64251e5b25d5d55ede1039c6aa22bea40a7a931d14c370339853643c3df0

    feeds/packages/lang/golang/golang-version.mk

    GO_VERSION_MAJOR_MINOR:=1.17 GO_VERSION_PATCH:=3

  5. 最后的安装,还缺了一个包 luci-compat 需要安装。否则也用不了。
  6. 如果用 WSL , 建议关掉win防毒的"进程防护",否则极慢。

谢谢大佬答疑,上面部分已经修改,但是我想问一个问题杀毒的进程防护是什么

osnosn commented 2 years ago

win 自己的 defender,似乎还好。 如果装了 360,它的 "进程防护" 影响就很大了。 编译耗时,相差十倍。