diff --git a/Makefile b/Makefile index 88a7e107b1..7ab5fc7c5d 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,8 @@ help: ## show make targets .PHONY: clean-src clean-src: - [ ! -d src ] || $(CHOWN) -R $(shell id -u):$(shell id -g) src - $(RM) -r src + @[ ! -d src ] || $(CHOWN) -R $(shell id -u):$(shell id -g) src + @$(RM) -r src .PHONY: src src: src/github.com/docker/cli src/github.com/docker/docker src/github.com/docker/buildx src/github.com/docker/compose src/github.com/docker/scan-cli-plugin ## clone source @@ -50,22 +50,27 @@ src/github.com/docker/scan-cli-plugin: .PHONY: checkout-cli checkout-cli: src/github.com/docker/cli + $(call title,Checkout $(DOCKER_CLI_REPO)#$(DOCKER_CLI_REF)) ./scripts/checkout.sh src/github.com/docker/cli "$(DOCKER_CLI_REF)" .PHONY: checkout-docker checkout-docker: src/github.com/docker/docker + $(call title,Checkout $(DOCKER_ENGINE_REPO)#$(DOCKER_ENGINE_REF)) ./scripts/checkout.sh src/github.com/docker/docker "$(DOCKER_ENGINE_REF)" .PHONY: checkout-buildx checkout-buildx: src/github.com/docker/buildx + $(call title,Checkout $(DOCKER_BUILDX_REPO)#$(DOCKER_BUILDX_REF)) ./scripts/checkout.sh src/github.com/docker/buildx "$(DOCKER_BUILDX_REF)" .PHONY: checkout-compose checkout-compose: src/github.com/docker/compose + $(call title,Checkout $(DOCKER_COMPOSE_REPO)#$(DOCKER_COMPOSE_REF)) ./scripts/checkout.sh src/github.com/docker/compose "$(DOCKER_COMPOSE_REF)" .PHONY: checkout-scan-cli-plugin checkout-scan-cli-plugin: src/github.com/docker/scan-cli-plugin + $(call title,Checkout $(DOCKER_SCAN_REPO)#$(DOCKER_SCAN_REF)) ./scripts/checkout.sh src/github.com/docker/scan-cli-plugin "$(DOCKER_SCAN_REF)" .PHONY: checkout diff --git a/common.mk b/common.mk index 56794365d6..eeb77e2c7e 100644 --- a/common.mk +++ b/common.mk @@ -63,3 +63,17 @@ export DOCKER_ENGINE_REF export DOCKER_SCAN_REF export DOCKER_COMPOSE_REF export DOCKER_BUILDX_REF + +# utilities +BOLD := $(shell tput -T linux bold) +PURPLE := $(shell tput -T linux setaf 5) +GREEN := $(shell tput -T linux setaf 2) +CYAN := $(shell tput -T linux setaf 6) +RED := $(shell tput -T linux setaf 1) +RESET := $(shell tput -T linux sgr0) +TITLE := $(BOLD)$(PURPLE) +SUCCESS := $(BOLD)$(GREEN) + +define title + @printf '$(TITLE)$(1)$(RESET)\n' +endef diff --git a/scripts/checkout.sh b/scripts/checkout.sh index 6bc18479dd..91078c0252 100755 --- a/scripts/checkout.sh +++ b/scripts/checkout.sh @@ -15,7 +15,7 @@ # limitations under the License. checkout() ( - set -ex + set -e SRC="$1" REF="$2" REF_FETCH="$REF" @@ -27,11 +27,13 @@ checkout() ( else REF="FETCH_HEAD" fi - git -C "$SRC" fetch --update-head-ok --depth 1 origin "$REF_FETCH" - git -C "$SRC" checkout -q "$REF" + ( + set -x + git -C "$SRC" fetch --update-head-ok --depth 1 origin "$REF_FETCH" + git -C "$SRC" checkout -q "$REF" + ) ) - # Only execute checkout function above if this file is executed, not sourced from another script prog=checkout.sh # needs to be in sync with this file's name if [ "$(basename -- $0)" = "$prog" ]; then diff --git a/static/Makefile b/static/Makefile index f28d477b3c..5f7add7ee0 100644 --- a/static/Makefile +++ b/static/Makefile @@ -17,19 +17,21 @@ export CONTAINERD_VERSION export RUNC_VERSION .PHONY: help -help: - @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "$(BOLD)$(CYAN)%-25s$(RESET)%s\n", $$1, $$2}' +help: ## show make targets + @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) .PHONY: clean clean: ## remove build artifacts + $(call title,Removing build artifacts) @[ ! -d build ] || $(CHOWN) -R $(shell id -u):$(shell id -g) build @$(RM) -r build .PHONY: build build: ## build static package + $(call title,Building static package for $(TARGETPLATFORM)) ./build-static "$(CURDIR)" "$(TARGETPLATFORM)" .PHONY: hash_files hash_files: ## hash files - @echo "Hashing directory $(DIR_TO_HASH)" + $(call title,Hashing directory $(DIR_TO_HASH)) $(HASH_CMD) "$(DIR_TO_HASH)"