Skip to content

Commit

Permalink
don't re-bootstrap when bindown already installed
Browse files Browse the repository at this point in the history
  • Loading branch information
WillAbides committed Aug 8, 2023
1 parent 432f30e commit c4d80e1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/build-bootstrapper/assets/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ execute() {
rm -rf "${tmpdir}"
}

already_installed() {
VERSION="$1"
[ -f "${BINDIR}/$(bindown_name)" ] &&
"${BINDIR}/$(bindown_name)" version 2> /dev/null | grep -q "$VERSION"
}

OS=$(uname_os)
ARCH=$(uname_arch)

Expand All @@ -59,6 +65,12 @@ uname_arch_check "$ARCH"
parse_args "$@"

VERSION=${TAG#v}

if already_installed "$VERSION"; then
log_debug "bindown ${VERSION} is already installed"
exit 0
fi

NAME=bindown_${VERSION}_${OS}_${ARCH}
TARBALL=${NAME}.${FORMAT}
TARBALL_URL=${GITHUB_DOWNLOAD}/${TAG}/${TARBALL}
Expand Down
12 changes: 12 additions & 0 deletions internal/build-bootstrapper/testdata/want.txt
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,12 @@ execute() {
rm -rf "${tmpdir}"
}

already_installed() {
VERSION="$1"
[ -f "${BINDIR}/$(bindown_name)" ] &&
"${BINDIR}/$(bindown_name)" version 2> /dev/null | grep -q "$VERSION"
}

OS=$(uname_os)
ARCH=$(uname_arch)

Expand All @@ -296,6 +302,12 @@ uname_arch_check "$ARCH"
parse_args "$@"

VERSION=${TAG#v}

if already_installed "$VERSION"; then
log_debug "bindown ${VERSION} is already installed"
exit 0
fi

NAME=bindown_${VERSION}_${OS}_${ARCH}
TARBALL=${NAME}.${FORMAT}
TARBALL_URL=${GITHUB_DOWNLOAD}/${TAG}/${TARBALL}
Expand Down

0 comments on commit c4d80e1

Please sign in to comment.