Skip to content

Instantly share code, notes, and snippets.

@zlwu
Last active October 18, 2023 14:57
Show Gist options
  • Save zlwu/b8a83429d2618abfd935bcffaf7fa0fe to your computer and use it in GitHub Desktop.
Save zlwu/b8a83429d2618abfd935bcffaf7fa0fe to your computer and use it in GitHub Desktop.
OpenWrt官裁版

OpenWrt官裁版

$ ./slim.sh ssrp # 编译官方库里没有编译的包,只需要编译一次,编译完在./bin/packages目录下,不用删除以后复用
$ ./slim.sh image # 打包ROM,收工。各种格式的rom在./bin/targets下

⚠️注意

  • 构建过程需要下载包,注意网速
  • 构建环境依赖docker
  • 自行修改OWT_PACKAGES增删你需要的包
#!/bin/sh
# official docker images
TAG="x86-64-23.05.0"
OPENWRT_SDK="openwrt/sdk:$TAG"
OPENWRT_BUILDER="openwrt/imagebuilder:$TAG"
OPENWRT_HOME_DIR="/builder"
# builder targets
OWT_PROFILE="generic"
OWT_PACKAGES="lua qosify tc-full tc-mod-iptables zlib \
curl \
luci luci-ssl luci-base luci-i18n-base-zh-cn luci-app-firewall luci-i18n-firewall-zh-cn luci-app-opkg luci-i18n-opkg-zh-cn \
luci-mod-admin-full luci-mod-network luci-mod-status luci-mod-system \
luci-proto-ppp luci-proto-ipv6 \
luci-theme-bootstrap \
luci-app-mwan3 luci-i18n-mwan3-zh-cn \
ddns-scripts-cloudflare luci-app-ddns luci-i18n-ddns-zh-cn \
dnsmasq-full -dnsmasq luci-compat luci-lib-ipkg luci-app-ssr-plus luci-i18n-ssr-plus-zh-cn \
luci-app-upnp luci-i18n-upnp-zh-cn"
usage()
{
echo "Usage: $0 <ssrp|image|all>"
exit 0
}
pull_docker_image()
{
if [[ "$(docker image ls -q $1 2> /dev/null)" == "" ]]; then
echo "Fetching docker image $1 ..."
docker pull $1 || exit -1
fi
}
build_ssrp()
{
docker run --rm -v "$(pwd)"/bin/:$OPENWRT_HOME_DIR/bin -it $OPENWRT_SDK sh -c \
"echo src-git helloworld https://github.com/fw876/helloworld.git >> feeds.conf.default && ./scripts/feeds update -a && ./scripts/feeds install -a -f -p helloworld && make defconfig && make package/luci-app-ssr-plus/compile -j\$(nproc)"
}
build_image()
{
docker run --rm -v "$(pwd)"/bin/:$OPENWRT_HOME_DIR/bin -it $OPENWRT_BUILDER sh -c \
"cp -rf bin/packages/x86_64/helloworld/* ./packages/ && make PROFILE=$OWT_PROFILE PACKAGES=\"$OWT_PACKAGES\" image"
}
case "$1" in
ssrp)
pull_docker_image $OPENWRT_SDK
build_ssrp
;;
image)
pull_docker_image $OPENWRT_BUILDER
build_image
;;
all)
$0 ssrp
$0 image
;;
-h|--help|help)
usage
;;
*)
usage
;;
esac
@zlwu
Copy link
Author

zlwu commented Oct 18, 2023

full build

cat << EOF | tee helloworld.config
CONFIG_PACKAGE_luci-app-ssr-plus=m
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Shadowsocks_NONE_Client is not set
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Shadowsocks_Libev_Client=y
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Shadowsocks_Rust_Client is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Shadowsocks_NONE_Server is not set
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Shadowsocks_Libev_Server=y
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Shadowsocks_Rust_Server is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_NONE_V2RAY is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_V2ray is not set
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Xray=y
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_SagerNet_Core is not set
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_ChinaDNS_NG=y
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Hysteria=y
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_IPT2Socks=y
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Kcptun=y
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_NaiveProxy=y
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Redsocks2=y
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Shadowsocks_Simple_Obfs=y
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Shadowsocks_V2ray_Plugin=y
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_ShadowsocksR_Libev_Client=y
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_ShadowsocksR_Libev_Server=y
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Trojan=y
CONFIG_PACKAGE_luci-i18n-ssr-plus-zh-cn=m
EOF

light build

cat << EOF | tee helloworld.config
CONFIG_PACKAGE_luci-app-ssr-plus=m
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Shadowsocks_NONE_Client=y
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Shadowsocks_Libev_Client is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Shadowsocks_Rust_Client is not set
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Shadowsocks_NONE_Server=y
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Shadowsocks_Libev_Server is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Shadowsocks_Rust_Server is not set
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_NONE_V2RAY=y
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_V2ray is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Xray is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_SagerNet_Core is not set
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_ChinaDNS_NG=y
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Hysteria is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_IPT2Socks is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Kcptun is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_NaiveProxy is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Redsocks2 is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Shadowsocks_Simple_Obfs is not set
# CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Shadowsocks_V2ray_Plugin is not set
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_ShadowsocksR_Libev_Client=y
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_ShadowsocksR_Libev_Server=y
CONFIG_PACKAGE_luci-app-ssr-plus_INCLUDE_Trojan=y
CONFIG_PACKAGE_luci-i18n-ssr-plus-zh-cn=m
EOF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment