blob: 3ed9e6d526dd4abad8034a64635bc1316428bfb3 (
plain)
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
# Maintainer: koonix <me at koonix dot org>
# Contributor: chn <g897331845@gmail.com>
# Contributor: AkinoKaede <autmaple@protonmail.com>
# Contributor: DuckSoft <realducksoft@gmail.com>
# Contributor: Felix Yan <felixonmars@archlinux.org>
# Contributor: pandada8 <pandada8@gmail.com>
_name=xray
pkgname=${_name}-bin
pkgrel=1
_version=v1.8.6
pkgver=${_version//-/_}
pkgver=${pkgver#v}
pkgdesc='The best v2ray-core, with XTLS support'
url='https://github.com/XTLS/Xray-core'
license=('MPL2')
depends=('xray-assets-symlinks')
options=('!strip') # don't modify prebuilt binaries
provides=("${_name}")
conflicts=("${_name}")
# source array template
# @ARCH@ and @SRCARCH@ will be substituted per the _archmap array below
_source=(
"${_name}-${_version}-@ARCH@.zip::${url}/releases/download/${_version}/Xray-linux-@SRCARCH@.zip"
config.json
xray.service.tmpl
xray-sysusers.conf
)
# architectures and their counterparts used in the source URL
declare -Ag _archmap=(
# [ARCH]=SRCARCH
['i686']='32'
['x86_64']='64'
['arm']='arm32-v7a'
['armv7h']='arm32-v7a'
['aarch64']='arm64-v8a'
['mips']='mips32'
['mipsel']='mips32le'
['mips64']='mips64'
['mips64el']='mips64le'
['ppc64']='ppc64'
['ppc64le']='ppc64le'
['riscv64']='riscv64'
['s390x']='s390x'
)
# config file's path
_config="/etc/xray/config.json"
backup=("${_config#/}")
# generate systemd services from the template
prepare()
{
# regular service
TMPL_CONFIG_FILE_PATH="${_config}" \
_envsubst xray.service.tmpl xray.service
# multi-instance service (http://0pointer.net/blog/projects/instances.html)
TMPL_CONFIG_FILE_PATH="${_config%/*}/%i.${_config##*.}" \
_envsubst xray.service.tmpl xray@.service
}
package()
{
install -Dm644 xray.service -t "${pkgdir}/usr/lib/systemd/system/"
install -Dm644 xray@.service -t "${pkgdir}/usr/lib/systemd/system/"
install -Dm644 xray-sysusers.conf "${pkgdir}/usr/lib/sysusers.d/xray.conf"
install -Dm644 config.json "${pkgdir}${_config}"
install -Dm755 xray "${pkgdir}/usr/bin/xray"
install -Dm644 README.md "${pkgdir}/usr/share/doc/xray/USAGE.txt"
install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
# boilerplate for generating the "arch=()" and "source_<arch>=()" arrays
arch=("${!_archmap[@]}")
for _a in "${!_archmap[@]}"; do
_sa=${_archmap[$_a]}
_s=("${_source[@]//@ARCH@/$_a}")
_s=("${_s[@]//@SRCARCH@/$_sa}")
declare -ag "source_${_a}="'("${_s[@]}")'
done
# wrapper function for envsubst
_envsubst()
{
local in=$1 out=$2 vars=("${!TMPL_@}")
envsubst "${vars[*]/#/'$'}" < "$in" > "$out"
grep -q '\${\?TMPL_[A-Z_]\+' "$out" && {
echo "error: template file has unsubstituted references: '$in'" >&2
rm "$out"
return 1
} ||:
}
sha256sums_aarch64=(
'62149311cccbcc2791260fad5aa7655b91d4ccdb9fa4ca45f556e9637002e622'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955'
)
sha256sums_i686=(
'01488bf1a582d9ca03e34f16b515a8117420d7dbcf98b9375885c7d85d7c242d'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955'
)
sha256sums_mips64el=(
'05983a9e0f4aa72ebf2511d0637a6729f8f154f3bf64caac3a95f43dd11142a6'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955'
)
sha256sums_ppc64le=(
'272c3accdb64e5b8ba3712f7c07a39ff37c0ad05fa04f12da915b7bde0057cfb'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955'
)
sha256sums_riscv64=(
'70fecb6f4191e51824fb9466858365229a69efde29ebcdf5bc32854bbf1acc52'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955'
)
sha256sums_ppc64=(
'b9e2f55572c6f54ecc3bbb320d234c2235522c2f41bdd0ff5e65a0b940d147f2'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955'
)
sha256sums_mipsel=(
'0bba1e3a43bdf7028082af131a7af0c7ed48d22ca90398b47e2c5dbfe80cb93c'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955'
)
sha256sums_mips64=(
'a4a6ac9d9941bd79b42dfef746915177caf7694576367510cd1760318783c0f1'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955'
)
sha256sums_arm=(
'9d4716ac4c993e8d94ba6df4c4a67991cdc5f9c092eab33f12d76d4d37584432'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955'
)
sha256sums_x86_64=(
'515c0218a6c50ad1c026bec489425942a68a7231c183d3ed48503120cdb2a143'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955'
)
sha256sums_armv7h=(
'9d4716ac4c993e8d94ba6df4c4a67991cdc5f9c092eab33f12d76d4d37584432'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955'
)
sha256sums_s390x=(
'ab1a2cb668e78672495f36760b633a5d39bc3758f71e5dd8de40c33a1fc94a94'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955'
)
sha256sums_mips=(
'674a99e965c6de6947b35085906f2a03e5a73371445ebedbc14853901463b175'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955'
)
|