blob: 9642c066836abf0a9f0adf9176c94f6291bf56db (
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
|
# Maintainer: iamawacko <iamawacko@protonmail.com>
# Contributor: 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
pkgver=24.11.21
pkgrel=1
pkgdesc='The best v2ray-core, with XTLS support'
url='https://github.com/XTLS/Xray-core'
license=('MPL2')
optdepends=('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}-v${pkgver}-@ARCH@.zip::${url}/releases/download/v${pkgver}/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=('8369d4ffc27640369646d860af9b2681319858ca3b3534409c875c1518acaa92'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955')
sha256sums_i686=('cb9ec14e2cdd9e4ccde00e699a244386b8dac85d79a45a0b7b07c45e235347bc'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955')
sha256sums_mips64el=('407ee7567752592ea3df5222b2721c810f4db70468509542671af4ea3fc5c461'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955')
sha256sums_ppc64le=('83b3ee09659b5ba022769c4583a11d42dd651f90a768b822f73ea578c3798ee0'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955')
sha256sums_riscv64=('5d1f9034434def10d7d1e390008b80d93a96bc7c0d755d0e87b0e85fa2470566'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955')
sha256sums_ppc64=('cc9bb958cd262b8145e40160de978d416106d16e5e8dc045f76296689a711114'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955')
sha256sums_mipsel=('431d7945ddafa67d4a09188b4e5cb909eca7b178df8a4b7e2e0ea8f59c62a987'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955')
sha256sums_mips64=('298bf6e62edf1daf8438fba6f96602c0515e759f57050b71a3c668f1b5d6665c'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955')
sha256sums_arm=('ead37c199daae58f0082fa51b161084af01741ed21520a2e8ed8f8e02d8db681'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955')
sha256sums_x86_64=('084bf895408cbd872f4973c73f6b9f84e8e4f819b9152edb19adf721446aee28'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955')
sha256sums_armv7h=('ead37c199daae58f0082fa51b161084af01741ed21520a2e8ed8f8e02d8db681'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955')
sha256sums_s390x=('85b7d54578ae2ba365e89dde588d203d5f4667fa1bd4f6c42766e971008703c8'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955')
sha256sums_mips=('b86cbebd5f59916373579699c50af6bfa78ca5fbb3479c75bf9458724d85c897'
'd7fed595af92cb516d995593e46e8d47f0eb94fc06304cd5d5c62075ace22d4b'
'7c51184d52d387509747abb8cd8f1c916c413a3562887a96de0e937c411d7ee8'
'b9a50932d2b14b6d494d5bba39ea1c15f15771f3514c425397e1be5f14617955')
|