-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathMakefile
137 lines (118 loc) · 3.95 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#
# Copyright (C) 2017 openwrt-ssr
# Copyright (C) 2017 yushi studio <[email protected]>
# Copyright (C) 2018 openwrt-brook-tproxy
#
# This is free software, licensed under the GNU General Public License v3.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=openwrt-brook-tproxy
PKG_VERSION:=1.0.1
PKG_RELEASE:=1
PKG_LICENSE:=GPLv3
PKG_LICENSE_FILES:=LICENSE
PKG_MAINTAINER:=WouldChar
PKG_BUILD_PARALLEL:=1
RELEASE_VERSION:=v20180401
ifeq ($(ARCH),mipsel)
BROOK_NAME:=brook_linux_mipsle
endif
ifeq ($(ARCH),mips)
BROOK_NAME:=brook_linux_mips
endif
ifeq ($(ARCH),i386)
BROOK_NAME:=brook_linux_386
endif
ifeq ($(ARCH),x86_64)
BROOK_NAME:=brook
endif
ifeq ($(ARCH),arm)
BROOK_NAME:=brook_linux_arm7
endif
ifeq ($(ARCH),aarch64)
BROOK_NAME:=brook_linux_arm64
endif
include $(INCLUDE_DIR)/package.mk
define Package/openwrt-brook-tproxy/Default
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=3. Applications
TITLE:=Brook LuCI interface
URL:=https://github.com/WouldChar/openwrt-brook-tproxy
DEPENDS:=$(1)
PKGARCH:=all
endef
Package/openwrt-brook-tproxy = $(call Package/openwrt-brook-tproxy/Default,+ipset +ip +iptables-mod-tproxy +dnsmasq-full +coreutils +coreutils-base64)
define Package/openwrt-brook-tproxy/description
LuCI Support for Brook.
endef
define Build/Prepare
$(foreach po,$(wildcard ${CURDIR}/files/luci/i18n/*.po), \
po2lmo $(po) $(PKG_BUILD_DIR)/$(patsubst %.po,%.lmo,$(notdir $(po)));)
wget -O $(PKG_BUILD_DIR)/brook https://github.com/txthinking/brook/releases/download/$(RELEASE_VERSION)/$(BROOK_NAME)
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/openwrt-brook-tproxy/prerm
#!/bin/sh
# check if we are on real system
if [ -z "$${IPKG_INSTROOT}" ]; then
echo "Removing rc.d symlink for brook"
/etc/init.d/brook disable
/etc/init.d/brook stop
echo "Removing firewall rule for brook"
uci -q batch <<-EOF >/dev/null
delete firewall.brook
commit firewall
EOF
sed -i '/conf-dir/d' /etc/dnsmasq.conf
/etc/init.d/dnsmasq restart
fi
exit 0
endef
define Package/openwrt-brook-tproxy/postinst
#!/bin/sh
if [ -z "$${IPKG_INSTROOT}" ]; then
uci -q batch <<-EOF >/dev/null
delete firewall.brook
set firewall.brook=include
set firewall.brook.type=script
set firewall.brook.path=/var/etc/brook.include
set firewall.brook.reload=1
commit firewall
EOF
( . /etc/uci-defaults/luci-brook ) && rm -f /etc/uci-defaults/luci-brook
chmod 755 /etc/init.d/brook >/dev/null 2>&1
/etc/init.d/brook enable >/dev/null 2>&1
fi
exit 0
endef
define Package/openwrt-brook-tproxy/install
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller
$(INSTALL_DATA) ./files/luci/controller/brook.lua $(1)/usr/lib/lua/luci/controller/brook.lua
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
$(INSTALL_DATA) $(PKG_BUILD_DIR)/brook.*.lmo $(1)/usr/lib/lua/luci/i18n
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/brook
$(INSTALL_DATA) ./files/luci/model/cbi/brook/*.lua $(1)/usr/lib/lua/luci/model/cbi/brook/
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/brook
$(INSTALL_DATA) ./files/luci/view/brook/*.htm $(1)/usr/lib/lua/luci/view/brook/
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) ./files/root/etc/uci-defaults/luci-brook $(1)/etc/uci-defaults/luci-brook
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DATA) ./files/root/etc/config/brook $(1)/etc/config/brook
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/root/etc/init.d/brook $(1)/etc/init.d/brook
$(INSTALL_DIR) $(1)/etc/dnsmasq.brook
$(INSTALL_DATA) ./files/root/etc/dnsmasq.brook/gfw_list.conf $(1)/etc/dnsmasq.brook/gfw_list.conf
$(INSTALL_DATA) ./files/root/etc/dnsmasq.brook/custom_list.conf $(1)/etc/dnsmasq.brook/custom_list.conf
$(INSTALL_DIR) $(1)/etc
$(INSTALL_DATA) ./files/root/etc/china_ip.txt $(1)/etc/china_ip.txt
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) ./files/root/usr/bin/brook-gfw $(1)/usr/bin/brook-gfw
$(INSTALL_BIN) ./files/root/usr/bin/brook-ad $(1)/usr/bin/brook-ad
$(INSTALL_BIN) $(PKG_BUILD_DIR)/brook $(1)/usr/bin/brook
endef
$(eval $(call BuildPackage,openwrt-brook-tproxy))