mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-05 20:40:16 -08:00
chore: update the install script (#9874)
Co-authored-by: Teppei Fukuda <knqyf263@gmail.com>
This commit is contained in:
@@ -11,6 +11,7 @@ $this: download go binaries for aquasecurity/trivy
|
|||||||
Usage: $this [-b] bindir [-d] [tag]
|
Usage: $this [-b] bindir [-d] [tag]
|
||||||
-b sets bindir or installation directory, Defaults to ./bin
|
-b sets bindir or installation directory, Defaults to ./bin
|
||||||
-d turns on debug logging
|
-d turns on debug logging
|
||||||
|
-x turns on verbose logging
|
||||||
[tag] is a tag from
|
[tag] is a tag from
|
||||||
https://github.com/aquasecurity/trivy/releases
|
https://github.com/aquasecurity/trivy/releases
|
||||||
If tag is missing, then the latest will be used.
|
If tag is missing, then the latest will be used.
|
||||||
@@ -51,42 +52,14 @@ execute() {
|
|||||||
srcdir="${tmpdir}"
|
srcdir="${tmpdir}"
|
||||||
(cd "${tmpdir}" && untar "${TARBALL}")
|
(cd "${tmpdir}" && untar "${TARBALL}")
|
||||||
test ! -d "${BINDIR}" && install -d "${BINDIR}"
|
test ! -d "${BINDIR}" && install -d "${BINDIR}"
|
||||||
for binexe in $BINARIES; do
|
binexe="trivy"
|
||||||
if [ "$OS" = "windows" ]; then
|
if [ "$OS" = "windows" ]; then
|
||||||
binexe="${binexe}.exe"
|
binexe="${binexe}.exe"
|
||||||
fi
|
fi
|
||||||
install "${srcdir}/${binexe}" "${BINDIR}/"
|
install "${srcdir}/${binexe}" "${BINDIR}/"
|
||||||
log_info "installed ${BINDIR}/${binexe}"
|
log_info "installed ${BINDIR}/${binexe}"
|
||||||
done
|
|
||||||
rm -rf "${tmpdir}"
|
rm -rf "${tmpdir}"
|
||||||
}
|
}
|
||||||
get_binaries() {
|
|
||||||
case "$PLATFORM" in
|
|
||||||
darwin/386) BINARIES="trivy" ;;
|
|
||||||
darwin/amd64) BINARIES="trivy" ;;
|
|
||||||
darwin/arm64) BINARIES="trivy" ;;
|
|
||||||
darwin/armv7) BINARIES="trivy" ;;
|
|
||||||
freebsd/386) BINARIES="trivy" ;;
|
|
||||||
freebsd/amd64) BINARIES="trivy" ;;
|
|
||||||
freebsd/arm64) BINARIES="trivy" ;;
|
|
||||||
freebsd/armv7) BINARIES="trivy" ;;
|
|
||||||
linux/386) BINARIES="trivy" ;;
|
|
||||||
linux/amd64) BINARIES="trivy" ;;
|
|
||||||
linux/ppc64le) BINARIES="trivy" ;;
|
|
||||||
linux/arm64) BINARIES="trivy" ;;
|
|
||||||
linux/armv7) BINARIES="trivy" ;;
|
|
||||||
linux/s390x) BINARIES="trivy" ;;
|
|
||||||
openbsd/386) BINARIES="trivy" ;;
|
|
||||||
openbsd/amd64) BINARIES="trivy" ;;
|
|
||||||
openbsd/arm64) BINARIES="trivy" ;;
|
|
||||||
openbsd/armv7) BINARIES="trivy" ;;
|
|
||||||
windows/amd64) BINARIES="trivy" ;;
|
|
||||||
*)
|
|
||||||
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"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
tag_to_version() {
|
tag_to_version() {
|
||||||
if [ -z "${TAG}" ]; then
|
if [ -z "${TAG}" ]; then
|
||||||
log_info "checking GitHub for latest tag"
|
log_info "checking GitHub for latest tag"
|
||||||
@@ -137,12 +110,6 @@ adjust_arch() {
|
|||||||
arm64) ARCH=ARM64 ;;
|
arm64) ARCH=ARM64 ;;
|
||||||
ppc64le) ARCH=PPC64LE ;;
|
ppc64le) ARCH=PPC64LE ;;
|
||||||
s390x) ARCH=s390x ;;
|
s390x) ARCH=s390x ;;
|
||||||
darwin) ARCH=macOS ;;
|
|
||||||
dragonfly) ARCH=DragonFlyBSD ;;
|
|
||||||
freebsd) ARCH=FreeBSD ;;
|
|
||||||
linux) ARCH=Linux ;;
|
|
||||||
netbsd) ARCH=NetBSD ;;
|
|
||||||
openbsd) ARCH=OpenBSD ;;
|
|
||||||
esac
|
esac
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
@@ -382,7 +349,6 @@ EOF
|
|||||||
PROJECT_NAME="trivy"
|
PROJECT_NAME="trivy"
|
||||||
OWNER=aquasecurity
|
OWNER=aquasecurity
|
||||||
REPO="trivy"
|
REPO="trivy"
|
||||||
BINARY=trivy
|
|
||||||
FORMAT=tar.gz
|
FORMAT=tar.gz
|
||||||
OS=$(uname_os)
|
OS=$(uname_os)
|
||||||
ARCH=$(uname_arch)
|
ARCH=$(uname_arch)
|
||||||
@@ -392,16 +358,15 @@ PREFIX="$OWNER/$REPO"
|
|||||||
log_prefix() {
|
log_prefix() {
|
||||||
echo "$PREFIX"
|
echo "$PREFIX"
|
||||||
}
|
}
|
||||||
PLATFORM="${OS}/${ARCH}"
|
|
||||||
GITHUB_DOWNLOAD=https://github.com/${OWNER}/${REPO}/releases/download
|
GITHUB_DOWNLOAD=https://github.com/${OWNER}/${REPO}/releases/download
|
||||||
|
GET_DOWNLOAD=https://get.trivy.dev/trivy
|
||||||
|
|
||||||
uname_os_check "$OS"
|
uname_os_check "$OS"
|
||||||
uname_arch_check "$ARCH"
|
uname_arch_check "$ARCH"
|
||||||
|
|
||||||
parse_args "$@"
|
parse_args "$@"
|
||||||
|
|
||||||
get_binaries
|
|
||||||
|
|
||||||
tag_to_version
|
tag_to_version
|
||||||
|
|
||||||
adjust_format
|
adjust_format
|
||||||
@@ -414,7 +379,7 @@ log_info "found version: ${VERSION} for ${TAG}/${OS}/${ARCH}"
|
|||||||
|
|
||||||
NAME=${PROJECT_NAME}_${VERSION}_${OS}-${ARCH}
|
NAME=${PROJECT_NAME}_${VERSION}_${OS}-${ARCH}
|
||||||
TARBALL=${NAME}.${FORMAT}
|
TARBALL=${NAME}.${FORMAT}
|
||||||
TARBALL_URL=${GITHUB_DOWNLOAD}/${TAG}/${TARBALL}
|
TARBALL_URL="${GET_DOWNLOAD}?os=${OS}&arch=${ARCH}&version=${VERSION}&type=${FORMAT}&client=install-script"
|
||||||
CHECKSUM=${PROJECT_NAME}_${VERSION}_checksums.txt
|
CHECKSUM=${PROJECT_NAME}_${VERSION}_checksums.txt
|
||||||
CHECKSUM_URL=${GITHUB_DOWNLOAD}/${TAG}/${CHECKSUM}
|
CHECKSUM_URL=${GITHUB_DOWNLOAD}/${TAG}/${CHECKSUM}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user