blob: ed6612592144a4df4c0b7c1586ea2329bab64e95 (
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
# Copyright 2020-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit shell-completion
BUN_PN="${PN//-bin/}"
DESCRIPTION="Incredibly fast JavaScript runtime, bundler, test runner, and package manager"
HOMEPAGE="https://bun.sh"
LICENSE="MIT"
SLOT="0"
KEYWORDS="-* amd64 ~arm64"
IUSE="bash-completion cpu_flags_x86_avx2 debug fish-completion zsh-completion"
DEPEND="
bash-completion? ( >=app-shells/bash-completion-2.0 )
fish-completion? ( app-shells/fish )
zsh-completion? ( app-shells/zsh )
"
bun_bin_filename_prefix() {
local -r arch=$1
local -r elibc=$2
local -ir avx2=$3
local -ir debug=$4
local -a specifier
# -- Add CPU architecture.
case "${arch}" in
amd64) specifier+=('x64') ;;
arm64) specifier+=('aarch64') ;;
* ) die "Unsupported arch: '${arch}'" ;;
esac
# -- Add libc type.
case "${elibc}" in
musl ) specifier+=('musl') ;;
glibc) : ;;
* ) die "Unsupported libc: '${elibc}'" ;;
esac
# -- Add CPU features.
(( avx2 == 0 )) &&
specifier+=('baseline')
# -- Add debug type.
(( debug != 0 )) &&
specifier+=('profile')
# -- Construct string.
suffix="$(IFS='-'; echo "${specifier[*]}")"
echo "bun-linux-${suffix}"
}
BASE_URI="https://github.com/oven-sh/${BUN_PN}/releases/download/${BUN_PN}-v${PV}"
SRC_URI="
amd64? (
elibc_musl? (
cpu_flags_x86_avx2? (
debug? (
${BASE_URI}/$(bun_bin_filename_prefix amd64 musl 1 1).zip
-> ${PN}-${PV}-amd64-musl-profile.zip
)
!debug? (
${BASE_URI}/$(bun_bin_filename_prefix amd64 musl 1 0).zip
-> ${PN}-${PV}-amd64-musl.zip
)
)
!cpu_flags_x86_avx2? (
debug? (
${BASE_URI}/$(bun_bin_filename_prefix amd64 musl 0 1).zip
-> ${PN}-${PV}-amd64-musl-baseline-profile.zip
)
!debug? (
${BASE_URI}/$(bun_bin_filename_prefix amd64 musl 0 0).zip
-> ${PN}-${PV}-amd64-musl-baseline.zip
)
)
)
!elibc_musl? (
cpu_flags_x86_avx2? (
debug? (
${BASE_URI}/$(bun_bin_filename_prefix amd64 glibc 1 1).zip
-> ${PN}-${PV}-amd64-profile.zip
)
!debug? (
${BASE_URI}/$(bun_bin_filename_prefix amd64 glibc 1 0).zip
-> ${PN}-${PV}-amd64.zip
)
)
!cpu_flags_x86_avx2? (
debug? (
${BASE_URI}/$(bun_bin_filename_prefix amd64 glibc 0 1).zip
-> ${PN}-${PV}-amd64-baseline-profile.zip
)
!debug? (
${BASE_URI}/$(bun_bin_filename_prefix amd64 glibc 0 0).zip
-> ${PN}-${PV}-amd64-baseline.zip
)
)
)
)
arm64? (
elibc_musl? (
debug? (
${BASE_URI}/$(bun_bin_filename_prefix arm64 musl 1 1).zip
-> ${PN}-${PV}-arm64-musl-profile.zip
)
!debug? (
${BASE_URI}/$(bun_bin_filename_prefix arm64 musl 1 0).zip
-> ${PN}-${PV}-arm64-musl.zip
)
)
!elibc_musl? (
debug? (
${BASE_URI}/$(bun_bin_filename_prefix arm64 glibc 1 1).zip
-> ${PN}-${PV}-arm64-profile.zip
)
!debug? (
${BASE_URI}/$(bun_bin_filename_prefix arm64 glibc 1 0).zip
-> ${PN}-${PV}-arm64.zip
)
)
)
"
BDEPEND="app-arch/unzip"
QA_PREBUILT="*"
bun_bin_dirname() {
local elibc
if use elibc_glibc; then
elibc='glibc'
elif use elibc_musl; then
elibc='musl'
else
die 'Unsupported libc'
fi
local -i avx2=0
if use cpu_flags_x86_avx2 \
|| [[ "${ARCH}" == 'arm64' ]]; then
(( avx2 = 1 ))
fi
local -i debug=0
use debug &&
(( debug = 1 ))
bun_bin_filename_prefix "${ARCH}" "${elibc}" "${avx2}" "${debug}"
}
src_unpack() {
unpack "${A}"
mv "$(bun_bin_dirname)" "${P}"
}
src_compile() {
local bun_bin='bun'
if use debug; then
bun_bin='bun-profile'
fi
if use bash-completion; then
SHELL=bash "./${bun_bin}" completions > bun.bash ||
die 'Unable to generate bash completions'
fi
if use fish-completion; then
SHELL=fish "./${bun_bin}" completions > bun.fish ||
die 'Unable to generate fish completions'
fi
if use zsh-completion; then
SHELL=zsh "./${bun_bin}" completions > bun.zsh ||
die 'Unable to generate zsh completions'
fi
}
src_install() {
exeinto /usr/bin
if use debug; then
doexe bun-profile
dosym /usr/bin/bun-profile /usr/bin/bun
dosym /usr/bin/bun-profile /usr/bin/bunx
else
doexe bun
dosym /usr/bin/bun /usr/bin/bunx
fi
use bash-completion &&
newbashcomp bun.bash "${BUN_PN}"
use fish-completion &&
newfishcomp bun.fish bun.fish
use zsh-completion &&
newzshcomp bun.zsh "_${BUN_PN}"
}
|