Skip to content

Commit

Permalink
hack: cleanup buildx install
Browse files Browse the repository at this point in the history
This was useful when Buildx was not available but since
Docker 23 it should always be there.

Signed-off-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max committed Sep 15, 2023
1 parent 9f3c803 commit df408e7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 88 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
prefix=/usr/local
bindir=$(prefix)/bin

ifneq (, $(BUILDX_BIN))
export BUILDX_CMD = $(BUILDX_BIN)
else ifneq (, $(shell docker buildx version))
export BUILDX_CMD = docker buildx
else ifneq (, $(shell command -v buildx))
export BUILDX_CMD = $(command -v buildx)
endif

export BUILDX_CMD ?= docker buildx

.PHONY: binaries
Expand Down
19 changes: 0 additions & 19 deletions hack/bootstrap-buildx

This file was deleted.

50 changes: 0 additions & 50 deletions hack/install-buildx

This file was deleted.

23 changes: 4 additions & 19 deletions hack/util
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env sh

: "${BUILDX_CMD=docker buildx}"

: "${CI=}"
: "${GITHUB_ACTIONS=}"
: "${GITHUB_REPOSITORY=}"
Expand All @@ -15,32 +17,15 @@ if [ "$CI" = "true" ]; then
progressFlag="--progress=plain"
fi

buildxBin=""
builderName=""
if docker buildx version >/dev/null 2>&1; then
buildxBin="docker buildx"
elif buildx version >/dev/null 2>&1; then
buildxBin="buildx"
else
topdir="$(realpath $(dirname "$0")/..)"
if [ ! -x "${topdir}/bin/buildx" ]; then
set -x
"${topdir}/hack/install-buildx"
fi
buildxBin="${topdir}/bin/buildx"
builderName="moby-buildkit"
"${topdir}/hack/bootstrap-buildx" "${builderName}"
fi

buildxCmd() {
(
set -x
BUILDX_NO_DEFAULT_LOAD=true BUILDX_BUILDER="${builderName:-${BUILDX_BUILDER}}" $buildxBin "$@" $progressFlag
BUILDX_NO_DEFAULT_LOAD=true BUILDX_BUILDER="${BUILDX_BUILDER}" ${BUILDX_CMD} "$@" $progressFlag
)
}

buildAttestFlags() {
if $buildxBin build --help 2>&1 | grep -- '--attest' >/dev/null; then
if ${BUILDX_CMD} build --help 2>&1 | grep -- '--attest' >/dev/null; then
prvattrs="mode=max"
if [ "$GITHUB_ACTIONS" = "true" ]; then
prvattrs="$prvattrs,builder-id=https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
Expand Down

0 comments on commit df408e7

Please sign in to comment.