This repository was archived by the owner on Nov 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile
150 lines (120 loc) · 3.99 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
138
139
140
141
142
143
144
145
146
147
148
149
150
include $(TOPDIR)/rules.mk
PKG_NAME:=clash
PKG_VERSION:=1.17.0
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/Dreamacro/clash/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=cd30a27f801652151eea129e9cb00e4a3ee28d45982dad835f4546691796d9d7
PKG_MAINTAINER:=Chandelure Wang <[email protected]>
PKG_LICENSE:=GPL-3.0-only
PKG_LICENSE_FILES:=LICENSE
PKG_BUILD_DIR:=$(BUILD_DIR)/clash-$(PKG_VERSION)
PKG_BUILD_DEPENDS:=golang/host
PKG_BUILD_PARALLEL:=1
PKG_BUILD_FLAGS:=no-mips16
GO_PKG:=github.com/Dreamacro/clash
GO_PKG_BUILD_PKG:=$(GO_PKG)
GO_PKG_LDFLAGS_X:= \
$(GO_PKG)/constant.Version=$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/../feeds/packages/lang/golang/golang-package.mk
define Package/$(PKG_NAME)/template
SECTION:=net
CATEGORY:=Network
endef
define Package/$(PKG_NAME)
$(call Package/$(PKG_NAME)/template)
TITLE:=A rule-based tunnel in Go
URL:=https://github.com/dreamacro/clash
DEPENDS:=$(GO_ARCH_DEPENDS) \
+iptables \
+iptables-mod-tproxy \
+libuci-lua \
+lyaml \
+ca-bundle
endef
YACD_DASHBOARD_VER=0.3.8
define Package/clash-dashboard
$(call Package/$(PKG_NAME)/template)
TITLE:=Web Dashboard for Clash
URL:=https://github.com/dreamacro/clash-dashboard
DEPENDS:=$(PKG_NAME)
PKGARCH:=all
VERSION:=$(YACD_DASHBOARD_VER)
endef
define Package/$(PKG_NAME)/description
Clash, A rule based tunnel in Go, support VMess, Shadowsocks,
Trojan, Snell protocol for remote connections.
endef
define Package/clash-dashboard/description
Web Dashboard for Clash
endef
define Package/$(PKG_NAME)/config
menu "Clash Counfiguration"
depends on PACKAGE_$(PKG_NAME)
config PACKAGE_CLASH_INCLUDE_COUNTRY_MMDB
bool "Include Country.mmdb"
default y
endmenu
endef
define Package/$(PKG_NAME)/conffiles
/etc/clash/profiles/
/etc/config/clash
endef
COUNTRY_MMDB_VER=20230612
COUNTRY_MMDB_FILE:=Country.$(COUNTRY_MMDB_VER).mmdb
define Download/country_mmdb
URL:=https://github.com/Dreamacro/maxmind-geoip/releases/download/$(COUNTRY_MMDB_VER)/
URL_FILE:=Country.mmdb
FILE:=$(COUNTRY_MMDB_FILE)
HASH:=b83f94ccc8e942fb8d31c2319b88872e72708715ecb44dd6fb4c42b9ff63fe2f
endef
define Download/clash-dashboard
URL:=https://github.com/haishanh/yacd/releases/download/v$(YACD_DASHBOARD_VER)/
URL_FILE:=yacd.tar.xz
FILE:=yacd.tar.xz
HASH:=d5d7ecde91a708a79386116753e32a59f32c8cb8eec80ded56c3ab94e511ba50
endef
define Build/Prepare
$(call Build/Prepare/Default)
ifdef CONFIG_PACKAGE_CLASH_INCLUDE_COUNTRY_MMDB
$(call Download,country_mmdb)
endif
ifdef CONFIG_PACKAGE_clash-dashboard
$(call Download,clash-dashboard)
endif
endef
define Package/$(PKG_NAME)/install
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
$(INSTALL_DIR) $(1)/usr/bin/
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/clash $(1)/usr/bin/clash
$(INSTALL_DIR) $(1)/etc/init.d/
$(INSTALL_BIN) $(CURDIR)/files/clash.init $(1)/etc/init.d/clash
$(INSTALL_DIR) $(1)/etc/config/
$(INSTALL_CONF) $(CURDIR)/files/clash.conf $(1)/etc/config/clash
ifdef CONFIG_PACKAGE_CLASH_INCLUDE_COUNTRY_MMDB
$(INSTALL_DIR) $(1)/etc/clash/
$(INSTALL_DATA) $(DL_DIR)/$(COUNTRY_MMDB_FILE) $(1)/etc/clash/Country.mmdb
endif
$(INSTALL_DIR) $(1)/usr/lib/clash/
$(INSTALL_BIN) $(CURDIR)/files/create_rules.sh $(1)/usr/lib/clash/create_rules.sh
$(INSTALL_BIN) $(CURDIR)/files/clear_rules.sh $(1)/usr/lib/clash/clear_rules.sh
$(INSTALL_BIN) $(CURDIR)/files/build_conf.lua $(1)/usr/lib/clash/build_conf.lua
$(INSTALL_BIN) $(CURDIR)/files/update_profile.sh $(1)/usr/lib/clash/update_profile.sh
endef
define Package/clash-dashboard/install
$(INSTALL_DIR) $(1)/www/clash-dashboard/
$(TAR) -C $(DL_DIR) -Jxvf $(DL_DIR)/yacd.tar.xz
$(CP) \
$(DL_DIR)/public/assets \
$(DL_DIR)/public/index.html \
$(DL_DIR)/public/registerSW.js \
$(DL_DIR)/public/sw.js \
$(DL_DIR)/public/yacd-128.png \
$(DL_DIR)/public/yacd-64.png \
$(DL_DIR)/public/yacd.ico \
$(DL_DIR)/public/_headers \
$(1)/www/clash-dashboard/
endef
$(eval $(call BuildPackage,$(PKG_NAME)))
$(eval $(call BuildPackage,clash-dashboard))