diff --git a/.gitignore b/.gitignore index c62ec20cd..f9a44140f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ **/__pycache__ .vscode +_test* diff --git a/extra-files/local-clone.sh b/extra-files/local-clone.sh new file mode 100755 index 000000000..690f77419 --- /dev/null +++ b/extra-files/local-clone.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash +# Use for testing in local environment +# Run this script in a blank directory + +STDIR=$(dirname $(realpath $0)) +. $STDIR/tools/color.sh + +# download base code +echo "Start to download the base code..." + +CODE_DIR=$PWD/${1:-_test_code} +CODE_URL=https://git.openwrt.org/openwrt/openwrt.git +CODE_BRANCH=openwrt-23.05 +SWITCH_LATEST_TAG=false + +if [ -d "$CODE_DIR" ]; then + echo "Updating base code from $(cyan $CODE_URL@$CODE_BRANCH)" + cd $CODE_DIR + git pull + cd - > /dev/null +else + echo "Cloning base code from $(cyan $CODE_URL@$CODE_BRANCH)" + git clone --single-branch -b $CODE_BRANCH $CODE_URL $CODE_DIR +fi + +if $SWITCH_LATEST_TAG; then + cd $CODE_DIR + LATEST_TAG_HASH=$(git rev-list --tags --max-count=1) + if [ -z "$LATEST_TAG_HASH" ]; then + red "No tag to switch, keep the latest commit" + else + git checkout $LATEST_TAG_HASH + LATEST_TAG=$(git describe --tags $LATEST_TAG_HASH) + green "The code has been switched to the latest stable version $LATEST_TAG" + fi + cd - > /dev/null +fi + +cd $CODE_DIR + +# download app codes +echo "Start to download app codes..." + +SUPPLY_DIR=$PWD/_supply_packages +bdir=$PWD/._b_supply_packages + +if ! grep -q "src-link supply $SUPPLY_DIR" feeds.conf.default; then + echo "src-link supply $SUPPLY_DIR" >> feeds.conf.default +fi +mkdir -p $SUPPLY_DIR +cd $SUPPLY_DIR + +declare -A REPOS=( + ["https://github.com/jerrykuku/luci-theme-argon.git"]="" + ["https://github.com/jerrykuku/luci-app-argon-config.git"]="" + ["https://github.com/sbwml/luci-app-alist.git"]="" + ["https://github.com/yichya/luci-app-xray.git"]=":$bdir/luci-app-xray" + ["https://github.com/xiaorouji/openwrt-passwall-packages.git"]=":pw-dependencies" + ["https://github.com/xiaorouji/openwrt-passwall.git"]=":$bdir/openwrt-passwall" + ["https://github.com/xiaorouji/openwrt-passwall2.git"]=":$bdir/openwrt-passwall2" + ["https://github.com/vernesong/OpenClash.git"]=":$bdir/openclash" +) + +for REPO_URL in "${!REPOS[@]}"; do + IFS=":" read -r BRANCH LOCAL_PATH <<< "${REPOS[$REPO_URL]}" + REPO_NAME=$(basename "$REPO_URL" .git) + LOCAL_PATH=${LOCAL_PATH:-$REPO_NAME} + + if [ -d "$LOCAL_PATH" ]; then + echo "Updating $REPO_NAME from $(cyan $REPO_URL)" + cd $LOCAL_PATH + git pull + cd - > /dev/null + else + if [ -z "$BRANCH" ]; then + echo "Cloning code from $(cyan $REPO_URL)" + git clone --depth 1 $REPO_URL $LOCAL_PATH + else + echo "Cloning code from $(cyan $REPO_URL@$BRANCH)" + git clone -b $BRANCH --depth 1 $REPO_URL $LOCAL_PATH + fi + fi +done + +rsync -a --delete $bdir/luci-app-xray/core/ luci-app-xray-core/ +rsync -a --delete $bdir/luci-app-xray/status/ luci-app-xray-status/ +rsync -a --delete $bdir/openwrt-passwall/luci-app-passwall/ luci-app-passwall/ +rsync -a --delete $bdir/openwrt-passwall2/luci-app-passwall2/ luci-app-passwall2/ +rsync -a --delete $bdir/openclash/luci-app-openclash/ luci-app-openclash/ + +cd $CODE_DIR + +./scripts/feeds update -a +./scripts/feeds install -a + +$STDIR/../preset-openwrt/1.modify.sh diff --git a/extra-files/simplify.py b/extra-files/simplify.py new file mode 100755 index 000000000..6b515e411 --- /dev/null +++ b/extra-files/simplify.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python3 +import sys + +from tools.process_text import simplify_config + +if __name__ == '__main__': + simplify_config(sys.argv[1]) + print('Done') diff --git a/preset-openwrt/README.md b/preset-openwrt/README.md new file mode 100644 index 000000000..193b91fd5 --- /dev/null +++ b/preset-openwrt/README.md @@ -0,0 +1,45 @@ +## 本地测试生成.config文件 + +> 以生成other.config为例,编译流程`build openwrt`中`other`机型对应当前的other.config。 + +1. 使用Codespace或本地环境,克隆本仓库,并进入仓库根目录。 + + 建议使用Codespace,只需要一个浏览器即可,且不会存在网络问题。 + + +1. 运行以下命令,克隆openwrt源码。 + + ```shell + chmod +x extra-files/local-clone.sh + chmod +x extra-files/simplify.py + ./extra-files/local-clone.sh + cd _test_code + ``` + +1. (可选)从已有的.config修改。 + + ```shell + cp ../preset-openwrt/other.config .config + ``` + +1. 运行以下命令,开始配置。 + + ```shell + make menuconfig + ``` + +1. 配置完成后,_test_code目录里,也就是现在所在的目录下已生成.config文件。 + +1. (可选)简化一下.config文件,只保留常用的配置项,运行以下命令。 + + ```shell + ../extra-files/simplify.py .config + ``` + +1. 将.config文件复制到本仓库的preset-openwrt目录下,运行以下命令。 + + ```shell + mv .config ../preset-openwrt/other.config + ``` + +1. 提交到远程仓库,开始运行编译流程`build openwrt`,选择机型`other`。 diff --git a/preset-openwrt/other.config b/preset-openwrt/other.config new file mode 100644 index 000000000..63709bf40 --- /dev/null +++ b/preset-openwrt/other.config @@ -0,0 +1,171 @@ +# Target +CONFIG_TARGET_ramips=y +CONFIG_TARGET_ramips_mt7621=y +CONFIG_TARGET_ramips_mt7621_DEVICE_xiaomi_mi-router-ac2100=y + +# Collections +CONFIG_PACKAGE_luci=y +CONFIG_PACKAGE_luci-light=y + +# Modules +CONFIG_PACKAGE_luci-base=y +CONFIG_LUCI_SRCDIET=y +CONFIG_LUCI_JSMIN=y +CONFIG_LUCI_CSSTIDY=y +CONFIG_LUCI_LANG_zh_Hans=y +CONFIG_PACKAGE_luci-compat=y +CONFIG_PACKAGE_luci-lua-runtime=y +CONFIG_PACKAGE_luci-mod-admin-full=y +CONFIG_PACKAGE_luci-mod-network=y +CONFIG_PACKAGE_luci-mod-status=y +CONFIG_PACKAGE_luci-mod-system=y + +# Applications +# CONFIG_PACKAGE_luci-app-acl is not set +# CONFIG_PACKAGE_luci-app-acme is not set +# CONFIG_PACKAGE_luci-app-adblock is not set +# CONFIG_PACKAGE_luci-app-adblock-fast is not set +# CONFIG_PACKAGE_luci-app-advanced-reboot is not set +# CONFIG_PACKAGE_luci-app-ahcp is not set +CONFIG_PACKAGE_luci-app-alist=y +# CONFIG_PACKAGE_luci-app-apinger is not set +CONFIG_PACKAGE_luci-app-argon-config=y +# CONFIG_PACKAGE_luci-app-aria2 is not set +# CONFIG_PACKAGE_luci-app-attendedsysupgrade is not set +# CONFIG_PACKAGE_luci-app-babeld is not set +# CONFIG_PACKAGE_luci-app-banip is not set +# CONFIG_PACKAGE_luci-app-bcp38 is not set +# CONFIG_PACKAGE_luci-app-bird1-ipv4 is not set +# CONFIG_PACKAGE_luci-app-bird1-ipv6 is not set +# CONFIG_PACKAGE_luci-app-bmx7 is not set +# CONFIG_PACKAGE_luci-app-cjdns is not set +# CONFIG_PACKAGE_luci-app-clamav is not set +# CONFIG_PACKAGE_luci-app-commands is not set +# CONFIG_PACKAGE_luci-app-crowdsec-firewall-bouncer is not set +# CONFIG_PACKAGE_luci-app-cshark is not set +# CONFIG_PACKAGE_luci-app-dawn is not set +# CONFIG_PACKAGE_luci-app-dcwapd is not set +CONFIG_PACKAGE_luci-app-ddns=y +# CONFIG_PACKAGE_luci-app-diag-core is not set +# CONFIG_PACKAGE_luci-app-dnscrypt-proxy is not set +# CONFIG_PACKAGE_luci-app-dump1090 is not set +# CONFIG_PACKAGE_luci-app-dynapoint is not set +# CONFIG_PACKAGE_luci-app-eoip is not set +# CONFIG_PACKAGE_luci-app-example is not set +CONFIG_PACKAGE_luci-app-firewall=y +# CONFIG_PACKAGE_luci-app-frpc is not set +# CONFIG_PACKAGE_luci-app-frps is not set +# CONFIG_PACKAGE_luci-app-fwknopd is not set +# CONFIG_PACKAGE_luci-app-hd-idle is not set +# CONFIG_PACKAGE_luci-app-hnet is not set +# CONFIG_PACKAGE_luci-app-https-dns-proxy is not set +# CONFIG_PACKAGE_luci-app-keepalived is not set +# CONFIG_PACKAGE_luci-app-ksmbd is not set +# CONFIG_PACKAGE_luci-app-ledtrig-rssi is not set +# CONFIG_PACKAGE_luci-app-ledtrig-switch is not set +# CONFIG_PACKAGE_luci-app-ledtrig-usbport is not set +# CONFIG_PACKAGE_luci-app-lorawan-basicstation is not set +# CONFIG_PACKAGE_luci-app-lxc is not set +# CONFIG_PACKAGE_luci-app-minidlna is not set +# CONFIG_PACKAGE_luci-app-mjpg-streamer is not set +# CONFIG_PACKAGE_luci-app-mwan3 is not set +# CONFIG_PACKAGE_luci-app-natmap is not set +# CONFIG_PACKAGE_luci-app-nextdns is not set +# CONFIG_PACKAGE_luci-app-nft-qos is not set +CONFIG_PACKAGE_luci-app-nlbwmon=y +# CONFIG_PACKAGE_luci-app-ntpc is not set +# CONFIG_PACKAGE_luci-app-nut is not set +# CONFIG_PACKAGE_luci-app-ocserv is not set +# CONFIG_PACKAGE_luci-app-olsr is not set +# CONFIG_PACKAGE_luci-app-olsr-services is not set +# CONFIG_PACKAGE_luci-app-olsr-viz is not set +# CONFIG_PACKAGE_luci-app-olsrd2 is not set +# CONFIG_PACKAGE_luci-app-omcproxy is not set +CONFIG_PACKAGE_luci-app-openclash=y +# CONFIG_PACKAGE_iptables-mod-tproxy is not set +# CONFIG_PACKAGE_iptables-mod-extra is not set +# CONFIG_PACKAGE_luci-app-openvpn is not set +# CONFIG_PACKAGE_luci-app-openwisp is not set +CONFIG_PACKAGE_luci-app-opkg=y +# CONFIG_PACKAGE_luci-app-p910nd is not set +# CONFIG_PACKAGE_luci-app-pagekitec is not set +# CONFIG_PACKAGE_luci-app-passwall is not set +# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Brook is not set +# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Haproxy is not set +# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Hysteria is not set +# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_NaiveProxy is not set +# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Shadowsocks_Libev_Client is not set +# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Shadowsocks_Libev_Server is not set +# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Shadowsocks_Rust_Client is not set +# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Shadowsocks_Rust_Server is not set +# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_ShadowsocksR_Libev_Client is not set +# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_ShadowsocksR_Libev_Server is not set +# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Simple_Obfs is not set +# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_SingBox is not set +# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Trojan_GO is not set +# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Trojan_Plus is not set +# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_V2ray_Geodata is not set +# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_V2ray_Plugin is not set +# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Xray is not set +# CONFIG_PACKAGE_luci-app-passwall_INCLUDE_Xray_Plugin is not set +CONFIG_PACKAGE_luci-app-passwall2=y +# CONFIG_PACKAGE_luci-app-passwall2_Iptables_Transparent_Proxy is not set +CONFIG_PACKAGE_luci-app-passwall2_Nftables_Transparent_Proxy=y +# CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_Brook is not set +# CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_Haproxy is not set +# CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_Hysteria is not set +# CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_NaiveProxy is not set +# CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_Shadowsocks_Libev_Client is not set +# CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_Shadowsocks_Libev_Server is not set +# CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_Shadowsocks_Rust_Client is not set +# CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_Shadowsocks_Rust_Server is not set +# CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_ShadowsocksR_Libev_Client is not set +# CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_ShadowsocksR_Libev_Server is not set +# CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_Simple_Obfs is not set +# CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_SingBox is not set +# CONFIG_PACKAGE_luci-app-passwall2_INCLUDE_V2ray_Plugin is not set +# CONFIG_PACKAGE_luci-app-pbr is not set +# CONFIG_PACKAGE_luci-app-polipo is not set +# CONFIG_PACKAGE_luci-app-privoxy is not set +# CONFIG_PACKAGE_luci-app-qos is not set +# CONFIG_PACKAGE_luci-app-radicale is not set +# CONFIG_PACKAGE_luci-app-radicale2 is not set +# CONFIG_PACKAGE_luci-app-rp-pppoe-server is not set +# CONFIG_PACKAGE_luci-app-samba4 is not set +# CONFIG_PACKAGE_luci-app-ser2net is not set +# CONFIG_PACKAGE_luci-app-shadowsocks-libev is not set +# CONFIG_PACKAGE_luci-app-shairplay is not set +# CONFIG_PACKAGE_luci-app-siitwizard is not set +# CONFIG_PACKAGE_luci-app-smartdns is not set +# CONFIG_PACKAGE_luci-app-snmpd is not set +# CONFIG_PACKAGE_luci-app-softether is not set +# CONFIG_PACKAGE_luci-app-splash is not set +# CONFIG_PACKAGE_luci-app-sqm is not set +# CONFIG_PACKAGE_luci-app-squid is not set +# CONFIG_PACKAGE_luci-app-sshtunnel is not set +# CONFIG_PACKAGE_luci-app-statistics is not set +# CONFIG_PACKAGE_luci-app-tinyproxy is not set +# CONFIG_PACKAGE_luci-app-tor is not set +# CONFIG_PACKAGE_luci-app-transmission is not set +# CONFIG_PACKAGE_luci-app-travelmate is not set +# CONFIG_PACKAGE_luci-app-ttyd is not set +# CONFIG_PACKAGE_luci-app-udpxy is not set +# CONFIG_PACKAGE_luci-app-uhttpd is not set +# CONFIG_PACKAGE_luci-app-unbound is not set +CONFIG_PACKAGE_luci-app-upnp=y +# CONFIG_PACKAGE_luci-app-usteer is not set +# CONFIG_PACKAGE_luci-app-vnstat is not set +# CONFIG_PACKAGE_luci-app-vnstat2 is not set +# CONFIG_PACKAGE_luci-app-watchcat is not set +# CONFIG_PACKAGE_luci-app-wifischedule is not set +# CONFIG_PACKAGE_luci-app-wol is not set +# CONFIG_PACKAGE_luci-app-xfrpc is not set +# CONFIG_PACKAGE_luci-app-xinetd is not set +# CONFIG_PACKAGE_luci-app-xray is not set + +# Themes +CONFIG_PACKAGE_luci-theme-argon=y +CONFIG_PACKAGE_luci-theme-bootstrap=y +# CONFIG_PACKAGE_luci-theme-material is not set +# CONFIG_PACKAGE_luci-theme-openwrt is not set +# CONFIG_PACKAGE_luci-theme-openwrt-2020 is not set