Merge pull request #16430 from LecrisUT/improve-gandi
[feed/packages.git] / net / xray-core / Makefile
1 include $(TOPDIR)/rules.mk
2
3 PKG_NAME:=xray-core
4 PKG_VERSION:=1.4.2
5 PKG_RELEASE:=$(AUTORELEASE)
6
7 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
8 PKG_SOURCE_URL:=https://codeload.github.com/XTLS/Xray-core/tar.gz/v$(PKG_VERSION)?
9 PKG_HASH:=565255d8c67b254f403d498b9152fa7bc097d649c50cb318d278c2be644e92cc
10
11 PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
12 PKG_LICENSE:=MPL-2.0
13 PKG_LICENSE_FILES:=LICENSE
14
15 PKG_BUILD_DIR:=$(BUILD_DIR)/Xray-core-$(PKG_VERSION)
16 PKG_BUILD_DEPENDS:=golang/host
17 PKG_BUILD_PARALLEL:=1
18 PKG_USE_MIPS16:=0
19
20 GO_PKG:=github.com/xtls/xray-core
21 GO_PKG_BUILD_PKG:=github.com/xtls/xray-core/main
22 GO_PKG_LDFLAGS_X:= \
23 $(GO_PKG)/core.build=OpenWrt \
24 $(GO_PKG)/core.version=$(PKG_VERSION)
25
26 include $(INCLUDE_DIR)/package.mk
27 include ../../lang/golang/golang-package.mk
28
29 define Package/xray/template
30 TITLE:=A platform for building proxies to bypass network restrictions
31 SECTION:=net
32 CATEGORY:=Network
33 URL:=https://xtls.github.io
34 endef
35
36 define Package/xray-core
37 $(call Package/xray/template)
38 DEPENDS:=$(GO_ARCH_DEPENDS) +ca-bundle
39 endef
40
41 define Package/xray-example
42 $(call Package/xray/template)
43 TITLE+= (example configs)
44 DEPENDS:=xray-core
45 PKGARCH:=all
46 endef
47
48 define Package/xray-geodata
49 $(call Package/xray/template)
50 TITLE+= (geodata files)
51 DEPENDS:=xray-core
52 PKGARCH:=all
53 endef
54
55 define Package/xray/description
56 Xray, Penetrates Everything. It helps you to build your own computer network.
57 It secures your network connections and thus protects your privacy.
58 endef
59
60 define Package/xray-core/description
61 $(call Package/xray/description)
62 endef
63
64 define Package/xray-example/description
65 $(call Package/xray/description)
66
67 This includes example configuration files for xray-core.
68 endef
69
70 define Package/xray-geodata/description
71 $(call Package/xray/description)
72
73 This includes GEO datas used for xray-core.
74 endef
75
76 define Package/xray-core/conffiles
77 /etc/xray/
78 /etc/config/xray
79 endef
80
81 GEOIP_VER:=202106030115
82 GEOIP_FILE:=geoip.dat.$(GEOIP_VER)
83
84 define Download/geoip
85 URL:=https://github.com/v2fly/geoip/releases/download/$(GEOIP_VER)/
86 URL_FILE:=geoip.dat
87 FILE:=$(GEOIP_FILE)
88 HASH:=acf231d7c6461d088ae479fe0c1cb143b5ee3cf7048a897c5a9b7807ab7005df
89 endef
90
91 GEOSITE_VER:=20210531212831
92 GEOSITE_FILE:=dlc.dat.$(GEOSITE_VER)
93
94 define Download/geosite
95 URL:=https://github.com/v2fly/domain-list-community/releases/download/$(GEOSITE_VER)/
96 URL_FILE:=dlc.dat
97 FILE:=$(GEOSITE_FILE)
98 HASH:=332bbe53af49582dbf89bda04ee5e60e474f9293fc368ab55b517fdcd4a78ed2
99 endef
100
101 define Build/Prepare
102 $(call Build/Prepare/Default)
103 ifneq ($(CONFIG_PACKAGE_xray-geodata),)
104 $(call Download,geoip)
105 $(call Download,geosite)
106 endif
107 endef
108
109 define Package/xray-core/install
110 $(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
111 $(INSTALL_DIR) $(1)/usr/bin/
112 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/main $(1)/usr/bin/xray
113
114 $(INSTALL_DIR) $(1)/etc/xray/
115 $(INSTALL_DATA) $(CURDIR)/files/config.json.example $(1)/etc/xray/
116
117 $(INSTALL_DIR) $(1)/etc/config/
118 $(INSTALL_CONF) $(CURDIR)/files/xray.conf $(1)/etc/config/xray
119 $(INSTALL_DIR) $(1)/etc/init.d/
120 $(INSTALL_BIN) $(CURDIR)/files/xray.init $(1)/etc/init.d/xray
121
122 $(INSTALL_DIR) $(1)/etc/capabilities/
123 $(INSTALL_DATA) $(CURDIR)/files/xray.capabilities $(1)/etc/capabilities/xray.json
124 endef
125
126 define Package/xray-example/install
127 $(INSTALL_DIR) $(1)/etc/xray/
128 $(INSTALL_DATA) $(CURDIR)/files/vpoint_socks_vmess.json $(1)/etc/xray/
129 $(INSTALL_DATA) $(CURDIR)/files/vpoint_vmess_freedom.json $(1)/etc/xray/
130 endef
131
132 define Package/xray-geodata/install
133 $(INSTALL_DIR) $(1)/usr/share/xray/
134 $(INSTALL_DATA) $(DL_DIR)/$(GEOIP_FILE) $(1)/usr/share/xray/geoip.dat
135 $(INSTALL_DATA) $(DL_DIR)/$(GEOSITE_FILE) $(1)/usr/share/xray/geosite.dat
136 endef
137
138 $(eval $(call BuildPackage,xray-core))
139 $(eval $(call BuildPackage,xray-example))
140 $(eval $(call BuildPackage,xray-geodata))