Skip to content

Commit 32f3df1

Browse files
owenrumneyknqyf263
andauthored
chore: update the install script (#9874)
Co-authored-by: Teppei Fukuda <[email protected]>
1 parent 96290ae commit 32f3df1

File tree

1 file changed

+10
-45
lines changed

1 file changed

+10
-45
lines changed

contrib/install.sh

Lines changed: 10 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ $this: download go binaries for aquasecurity/trivy
1111
Usage: $this [-b] bindir [-d] [tag]
1212
-b sets bindir or installation directory, Defaults to ./bin
1313
-d turns on debug logging
14+
-x turns on verbose logging
1415
[tag] is a tag from
1516
https://github.com/aquasecurity/trivy/releases
1617
If tag is missing, then the latest will be used.
@@ -51,42 +52,14 @@ execute() {
5152
srcdir="${tmpdir}"
5253
(cd "${tmpdir}" && untar "${TARBALL}")
5354
test ! -d "${BINDIR}" && install -d "${BINDIR}"
54-
for binexe in $BINARIES; do
55-
if [ "$OS" = "windows" ]; then
56-
binexe="${binexe}.exe"
57-
fi
58-
install "${srcdir}/${binexe}" "${BINDIR}/"
59-
log_info "installed ${BINDIR}/${binexe}"
60-
done
55+
binexe="trivy"
56+
if [ "$OS" = "windows" ]; then
57+
binexe="${binexe}.exe"
58+
fi
59+
install "${srcdir}/${binexe}" "${BINDIR}/"
60+
log_info "installed ${BINDIR}/${binexe}"
6161
rm -rf "${tmpdir}"
6262
}
63-
get_binaries() {
64-
case "$PLATFORM" in
65-
darwin/386) BINARIES="trivy" ;;
66-
darwin/amd64) BINARIES="trivy" ;;
67-
darwin/arm64) BINARIES="trivy" ;;
68-
darwin/armv7) BINARIES="trivy" ;;
69-
freebsd/386) BINARIES="trivy" ;;
70-
freebsd/amd64) BINARIES="trivy" ;;
71-
freebsd/arm64) BINARIES="trivy" ;;
72-
freebsd/armv7) BINARIES="trivy" ;;
73-
linux/386) BINARIES="trivy" ;;
74-
linux/amd64) BINARIES="trivy" ;;
75-
linux/ppc64le) BINARIES="trivy" ;;
76-
linux/arm64) BINARIES="trivy" ;;
77-
linux/armv7) BINARIES="trivy" ;;
78-
linux/s390x) BINARIES="trivy" ;;
79-
openbsd/386) BINARIES="trivy" ;;
80-
openbsd/amd64) BINARIES="trivy" ;;
81-
openbsd/arm64) BINARIES="trivy" ;;
82-
openbsd/armv7) BINARIES="trivy" ;;
83-
windows/amd64) BINARIES="trivy" ;;
84-
*)
85-
log_crit "platform $PLATFORM is not supported. Make sure this script is up-to-date and file request at https://github.com/${PREFIX}/issues/new"
86-
exit 1
87-
;;
88-
esac
89-
}
9063
tag_to_version() {
9164
if [ -z "${TAG}" ]; then
9265
log_info "checking GitHub for latest tag"
@@ -137,12 +110,6 @@ adjust_arch() {
137110
arm64) ARCH=ARM64 ;;
138111
ppc64le) ARCH=PPC64LE ;;
139112
s390x) ARCH=s390x ;;
140-
darwin) ARCH=macOS ;;
141-
dragonfly) ARCH=DragonFlyBSD ;;
142-
freebsd) ARCH=FreeBSD ;;
143-
linux) ARCH=Linux ;;
144-
netbsd) ARCH=NetBSD ;;
145-
openbsd) ARCH=OpenBSD ;;
146113
esac
147114
true
148115
}
@@ -382,7 +349,6 @@ EOF
382349
PROJECT_NAME="trivy"
383350
OWNER=aquasecurity
384351
REPO="trivy"
385-
BINARY=trivy
386352
FORMAT=tar.gz
387353
OS=$(uname_os)
388354
ARCH=$(uname_arch)
@@ -392,16 +358,15 @@ PREFIX="$OWNER/$REPO"
392358
log_prefix() {
393359
echo "$PREFIX"
394360
}
395-
PLATFORM="${OS}/${ARCH}"
361+
396362
GITHUB_DOWNLOAD=https://github.com/${OWNER}/${REPO}/releases/download
363+
GET_DOWNLOAD=https://get.trivy.dev/trivy
397364

398365
uname_os_check "$OS"
399366
uname_arch_check "$ARCH"
400367

401368
parse_args "$@"
402369

403-
get_binaries
404-
405370
tag_to_version
406371

407372
adjust_format
@@ -414,7 +379,7 @@ log_info "found version: ${VERSION} for ${TAG}/${OS}/${ARCH}"
414379

415380
NAME=${PROJECT_NAME}_${VERSION}_${OS}-${ARCH}
416381
TARBALL=${NAME}.${FORMAT}
417-
TARBALL_URL=${GITHUB_DOWNLOAD}/${TAG}/${TARBALL}
382+
TARBALL_URL="${GET_DOWNLOAD}?os=${OS}&arch=${ARCH}&version=${VERSION}&type=${FORMAT}&client=install-script"
418383
CHECKSUM=${PROJECT_NAME}_${VERSION}_checksums.txt
419384
CHECKSUM_URL=${GITHUB_DOWNLOAD}/${TAG}/${CHECKSUM}
420385

0 commit comments

Comments
 (0)