From de8243453d47648df0fa290592c9f1b33b384dd9 Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Thu, 8 Apr 2021 16:19:39 -0400 Subject: Exclude .gitignore from test req. Also sort the explicit files by name, since the list is growing. Signed-off-by: Chris Evich --- contrib/cirrus/pr-should-include-tests | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/cirrus/pr-should-include-tests b/contrib/cirrus/pr-should-include-tests index 2bc06df50..9ccac17a3 100755 --- a/contrib/cirrus/pr-should-include-tests +++ b/contrib/cirrus/pr-should-include-tests @@ -32,8 +32,9 @@ fi # This is OK if the only files being touched are "safe" ones. filtered_changes=$(git diff --name-status $base $head | awk '{print $2}' | - fgrep -vx Makefile | fgrep -vx .cirrus.yml | + fgrep -vx .gitignore | + fgrep -vx Makefile | fgrep -vx changelog.txt | fgrep -vx go.mod | fgrep -vx go.sum | -- cgit v1.2.3-54-g00ecf From e296b6023ec6b02747943a9c3e1a5935e1f2e705 Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Thu, 18 Feb 2021 15:16:48 -0500 Subject: Fix incorrect version number output Signed-off-by: Chris Evich --- hack/get_release_info.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hack/get_release_info.sh b/hack/get_release_info.sh index 69cf8cd57..40c473246 100755 --- a/hack/get_release_info.sh +++ b/hack/get_release_info.sh @@ -14,11 +14,19 @@ valid_args() { cut -d '*' -f 1 } +# `git describe` does not reliably produce a useful version number. +scrape_version() { + local versionfile='version/version.go' + local version_line=$(grep -m 1 'var Version =' $versionfile) + local version_string=$(cut -d '"' -f 2 <<<"$version_line") + echo "$version_string" | tr -d '[:space:]' +} + unset OUTPUT case "$1" in # Wild-card suffix needed by valid_args() e.g. possible bad grep of "$(echo $FOO)" VERSION*) - OUTPUT="${CIRRUS_TAG:-$(git fetch --tags && git describe HEAD 2> /dev/null)}" + OUTPUT="${CIRRUS_TAG:-$(scrape_version)}" ;; NUMBER*) OUTPUT="$($0 VERSION | sed 's/-.*//')" -- cgit v1.2.3-54-g00ecf From 837bb9f492da57c15fbd4f14f4aa53c3bd7132ea Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Thu, 18 Feb 2021 16:08:01 -0500 Subject: Remove unnecessary/not-needed release.txt target Previously this was needed for an automated release process. That automation has long since been removed. Simplify the Makefile by removing the target and references. Signed-off-by: Chris Evich --- Makefile | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index 55e15d049..666c27b7d 100644 --- a/Makefile +++ b/Makefile @@ -260,7 +260,7 @@ run-docker-py-tests: $(eval testLogs=$(shell mktemp)) ./bin/podman run --rm --security-opt label=disable --privileged -v $(testLogs):/testLogs --net=host -e DOCKER_HOST=tcp://localhost:8080 $(DOCKERPY_IMAGE) sh -c "pytest $(DOCKERPY_TEST) " -pkg/api/swagger.yaml: .gopathok release.txt +pkg/api/swagger.yaml: .gopathok make -C pkg/api .PHONY: swagger @@ -271,7 +271,6 @@ clean: ## Clean artifacts rm -rf \ .gopathok \ _output \ - release.txt \ $(wildcard podman-remote*.zip) \ $(wildcard podman*.tar.gz) \ bin \ @@ -425,54 +424,30 @@ tests-included: codespell: codespell -S bin,vendor,.git,go.sum,changelog.txt,.cirrus.yml,"RELEASE_NOTES.md,*.xz,*.gz,*.tar,*.tgz,bin2img,*ico,*.png,*.1,*.5,copyimg,*.orig,apidoc.go" -L uint,iff,od,seeked,splitted,marge,ERRO,hist -w -# When publishing releases include critical build-time details -.PHONY: release.txt -release.txt: - # X-RELEASE-INFO format depended upon by automated tooling - echo -n "X-RELEASE-INFO:" > "$@" - for field in "$(RELEASE_BASENAME)" "$(RELEASE_VERSION)" \ - "$(RELEASE_DIST)" "$(RELEASE_DIST_VER)" "$(RELEASE_ARCH)"; do \ - echo -n " $$field"; done >> "$@" - echo "" >> "$@" - -podman-release.tar.gz: binaries docs release.txt +podman-release.tar.gz: binaries docs $(eval TMPDIR := $(shell mktemp -d -p '' podman_XXXX)) $(eval SUBDIR := podman-v$(RELEASE_NUMBER)) mkdir -p "$(TMPDIR)/$(SUBDIR)" $(MAKE) install.bin install.man install.cni install.systemd "DESTDIR=$(TMPDIR)/$(SUBDIR)" "PREFIX=/usr" - # release.txt location and content depended upon by automated tooling - cp release.txt "$(TMPDIR)/" - tar -czvf $@ --xattrs -C "$(TMPDIR)" "./release.txt" "./$(SUBDIR)" + tar -czvf $@ --xattrs -C "$(TMPDIR)" "./$(SUBDIR)" -rm -rf "$(TMPDIR)" # Must call make in-line: Dependency-spec. w/ wild-card. podman-remote-release-%.zip: - $(MAKE) podman-remote-$* install-podman-remote-$*-docs release.txt \ + $(MAKE) podman-remote-$* install-podman-remote-$*-docs \ RELEASE_BASENAME=$(shell hack/get_release_info.sh REMOTENAME) \ RELEASE_DIST=$* RELEASE_DIST_VER="-" $(eval TMPDIR := $(shell mktemp -d -p '' $podman_remote_XXXX)) $(eval SUBDIR := podman-$(RELEASE_VERSION)) $(eval BINSFX := $(shell test "$*" != "windows" || echo ".exe")) mkdir -p "$(TMPDIR)/$(SUBDIR)" - # release.txt location and content depended upon by automated tooling - cp release.txt "$(TMPDIR)/" cp ./bin/podman-remote-$*$(BINSFX) "$(TMPDIR)/$(SUBDIR)/podman$(BINSFX)" cp -r ./docs/build/remote/$* "$(TMPDIR)/$(SUBDIR)/docs/" cp ./contrib/remote/containers.conf "$(TMPDIR)/$(SUBDIR)/" cd "$(TMPDIR)/$(SUBDIR)" && \ - zip --recurse-paths "$(CURDIR)/$@" "./release.txt" "./" + zip --recurse-paths "$(CURDIR)/$@" "./" -rm -rf "$(TMPDIR)" -.PHONY: podman-release -podman-release: - rm -f release.txt - $(MAKE) podman-release.tar.gz - -.PHONY: podman-remote-%-release -podman-remote-%-release: - rm -f release.txt - $(MAKE) podman-remote-release-$*.zip - .PHONY: generate-bindings generate-bindings: ifneq ($(shell uname -s), Darwin) -- cgit v1.2.3-54-g00ecf From 5a703bbf7a73ef4ab3ee99db885c206abf773a49 Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Thu, 8 Apr 2021 08:47:19 -0400 Subject: Don't shell to obtain current directory Instead of shelling out frequently to resolve the current directory, use the Makefile built-in `$(CURDIR)`. It has the exact same meaning w/in the context of a `Makefile`. Ref.: https://www.gnu.org/software/make/manual/html_node/Quick-Reference.html Signed-off-by: Chris Evich --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 666c27b7d..0511a17f2 100644 --- a/Makefile +++ b/Makefile @@ -64,8 +64,8 @@ else ISODATE ?= $(shell date --iso-8601) endif LIBPOD := ${PROJECT}/v3/libpod -GCFLAGS ?= all=-trimpath=${PWD} -ASMFLAGS ?= all=-trimpath=${PWD} +GCFLAGS ?= all=-trimpath=$(CURDIR) +ASMFLAGS ?= all=-trimpath=$(CURDIR) LDFLAGS_PODMAN ?= \ -X $(LIBPOD)/define.gitCommit=$(GIT_COMMIT) \ -X $(LIBPOD)/define.buildInfo=$(BUILD_INFO) \ @@ -329,7 +329,7 @@ remoteintegration: test-binaries ginkgo-remote localsystem: # Wipe existing config, database, and cache: start with clean slate. $(RM) -rf ${HOME}/.local/share/containers ${HOME}/.config/containers - if timeout -v 1 true; then PODMAN=$(shell pwd)/bin/podman bats test/system/; else echo "Skipping $@: 'timeout -v' unavailable'"; fi + if timeout -v 1 true; then PODMAN=$(CURDIR)/bin/podman bats test/system/; else echo "Skipping $@: 'timeout -v' unavailable'"; fi .PHONY: remotesystem remotesystem: @@ -354,7 +354,7 @@ remotesystem: echo "Error: ./bin/podman system service did not come up on $$SOCK_FILE" >&2;\ exit 1;\ fi;\ - env PODMAN="$(shell pwd)/bin/podman-remote --url $$PODMAN_SOCKET" bats test/system/ ;\ + env PODMAN="$(CURDIR)/bin/podman-remote --url $$PODMAN_SOCKET" bats test/system/ ;\ rc=$$?;\ kill %1;\ rm -f $$SOCK_FILE;\ @@ -404,7 +404,7 @@ docs: $(MANPAGES) ## Generate documentation install-podman-remote-%-docs: podman-remote docs $(MANPAGES) rm -rf docs/build/remote mkdir -p docs/build/remote - ln -sf $(shell pwd)/docs/source/markdown/links docs/build/man/ + ln -sf $(CURDIR)/docs/source/markdown/links docs/build/man/ docs/remote-docs.sh $* docs/build/remote/$* $(if $(findstring windows,$*),docs/source/markdown,docs/build/man) .PHONY: man-page-check @@ -678,7 +678,7 @@ vendor: .PHONY: vendor-in-container vendor-in-container: - podman run --privileged --rm --env HOME=/root -v `pwd`:/src -w /src docker.io/library/golang:1.16 make vendor + podman run --privileged --rm --env HOME=/root -v $(CURDIR):/src -w /src docker.io/library/golang:1.16 make vendor .PHONY: package package: ## Build rpm packages -- cgit v1.2.3-54-g00ecf From 0e83851f080f67a7008f43136e46195a0a658819 Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Thu, 8 Apr 2021 08:55:56 -0400 Subject: Simplify Makefile help target An in-line Python script, while flexible, is arguably more complex and less stable than the long-lived `grep`, `awk`, and `printf`. Make use of these simple tools to display a column-aligned table of target and description help output. Also, the first target that appears in a Makefile is considered the default (when no target is specified on the command-line). However, despite it's name, the `default` target was not listed first. Fix this, and redefine "default" target to "all" as intended, instead of "help". Lastly, add a small workaround for a vim syntax-hilighting bug. Signed-off-by: Chris Evich --- Makefile | 43 ++++++++++++++++++------------------------- hack/get_release_info.sh | 18 +++++++++++++----- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/Makefile b/Makefile index 0511a17f2..0cbe7eb09 100644 --- a/Makefile +++ b/Makefile @@ -118,38 +118,29 @@ CROSS_BUILD_TARGETS := \ bin/podman.cross.linux.mips64 \ bin/podman.cross.linux.mips64le +.PHONY: default +default: all + .PHONY: all all: binaries docs -.PHONY: default -default: help - -define PRINT_HELP_PYSCRIPT -import re, sys - -print("Usage: make ") -cmds = {} -for line in sys.stdin: - match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) - if match: - target, help = match.groups() - cmds.update({target: help}) -for cmd in sorted(cmds): - print(" * '%s' - %s" % (cmd, cmds[cmd])) -endef -export PRINT_HELP_PYSCRIPT - # Dereference variable $(1), return value if non-empty, otherwise raise an error. err_if_empty = $(if $(strip $($(1))),$(strip $($(1))),$(error Required variable $(1) value is undefined, whitespace, or empty)) +# Extract text following double-# for targets, as their description for +# the `help` target. Otherwise These simple-substitutions are resolved +# at reference-time (due to `=` and not `=:`). +_HLP_TGTS_RX = '^[[:print:]]+:.*?\#\# .*$$' +_HLP_TGTS_CMD = grep -E $(_HLP_TGTS_RX) $(MAKEFILE_LIST) +_HLP_TGTS_LEN = $(shell $(_HLP_TGTS_CMD) | cut -d : -f 1 | wc -L) +_HLPFMT = "%-$(_HLP_TGTS_LEN)s %s\n" .PHONY: help -ifneq (, ${PYTHON}) -help: - @$(PYTHON) -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) -else -help: - $(error python required for 'make help', executable not found) -endif +help: ## (Default) Print listing of key targets with their descriptions + @printf $(_HLPFMT) "Target:" "Description:" + @printf $(_HLPFMT) "--------------" "--------------------" + @$(_HLP_TGTS_CMD) | sort | \ + awk 'BEGIN {FS = ":(.*)?## "}; \ + {printf $(_HLPFMT), $$1, $$2}' .gopathok: ifeq ("$(wildcard $(GOPKGDIR))","") @@ -469,6 +460,8 @@ changelog: ## Generate changelog $(shell cat $(TMPFILE) >> changelog.txt) $(shell rm $(TMPFILE)) +# Workaround vim syntax highlighting bug: " + .PHONY: install install: .gopathok install.bin install.remote install.man install.cni install.systemd ## Install binaries to system locations diff --git a/hack/get_release_info.sh b/hack/get_release_info.sh index 40c473246..b3e208ac9 100755 --- a/hack/get_release_info.sh +++ b/hack/get_release_info.sh @@ -14,12 +14,20 @@ valid_args() { cut -d '*' -f 1 } -# `git describe` does not reliably produce a useful version number. +# `git describe` will never produce a useful version number under all +# branches. This is because the podman release process (see `RELEASE_PROCESS.md`) +# tags release versions only on release-branches (i.e. never on master). +# Scraping the version number directly from the source, is the only way +# to reliably obtain the number from all the various contexts supported by +# the `Makefile`. scrape_version() { - local versionfile='version/version.go' - local version_line=$(grep -m 1 'var Version =' $versionfile) - local version_string=$(cut -d '"' -f 2 <<<"$version_line") - echo "$version_string" | tr -d '[:space:]' + local v + # extract the value of 'var Version' + v=$(sed -ne 's/^var\s\+Version\s\+=\s.*("\(.*\)").*/\1/p' Date: Thu, 8 Apr 2021 10:38:16 -0400 Subject: Reorganize Makefile with sections and guide Over several years the podman Makefile has become a bloated complex mess. This impedes both debugging and maintenance, besides causing general eye-strain. Fix this by adding a simple navigation/layout guide, to help developers quickly find what's needed. Re-organize the entire file according to the new layout guide. Add section headers that call out the purpose of the encompassed content, and are easy to locate with search-tools. Note: No recipes or definitions have been altered by this commit, only re-arranged. Signed-off-by: Chris Evich --- Makefile | 452 +++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 264 insertions(+), 188 deletions(-) diff --git a/Makefile b/Makefile index 0cbe7eb09..896013b77 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,25 @@ +### +### Makefile Navigation +### +# +# This file is organized based on approximate end-to-end workflow: +# +# 1. Variables and common definitions are located at the top +# to make finding them quicker. +# 2. Main entry-point targets, like "default", "all", and "help" +# 3. Targets for code formatting and validation +# 4. Primary build targets, like podman and podman-remote +# 5. Secondary build targets, shell completions, static and multi-arch. +# 6. Targets that format and build documentation +# 7. Testing targets +# 8. Release and package-building targets +# 9. Targets that install tools, utilities, binaries and packages +# 10. Uninstall / Cleanup targets +# +### +### Variables & Definitions +### + export GOPROXY=https://proxy.golang.org GO ?= go @@ -47,6 +69,10 @@ BUILDTAGS_CROSS ?= containers_image_openpgp exclude_graphdriver_btrfs exclude_gr CONTAINER_RUNTIME := $(shell command -v podman 2> /dev/null || echo docker) OCI_RUNTIME ?= "" +MANPAGES_MD ?= $(wildcard docs/source/markdown/*.md pkg/*/docs/*.md) +MANPAGES ?= $(MANPAGES_MD:%.md=%) +MANPAGES_DEST ?= $(subst markdown,man, $(subst source,build,$(MANPAGES))) + BASHINSTALLDIR=${PREFIX}/share/bash-completion/completions ZSHINSTALLDIR=${PREFIX}/share/zsh/site-functions FISHINSTALLDIR=${PREFIX}/share/fish/vendor_completions.d @@ -118,14 +144,26 @@ CROSS_BUILD_TARGETS := \ bin/podman.cross.linux.mips64 \ bin/podman.cross.linux.mips64le +# Dereference variable $(1), return value if non-empty, otherwise raise an error. +err_if_empty = $(if $(strip $($(1))),$(strip $($(1))),$(error Required variable $(1) value is undefined, whitespace, or empty)) + +define go-get + env GO111MODULE=off \ + $(GO) get -u ${1} +endef + +### +### Primary entry-point targets +### + .PHONY: default default: all .PHONY: all all: binaries docs -# Dereference variable $(1), return value if non-empty, otherwise raise an error. -err_if_empty = $(if $(strip $($(1))),$(strip $($(1))),$(error Required variable $(1) value is undefined, whitespace, or empty)) +.PHONY: binaries +binaries: podman podman-remote ## Build podman # Extract text following double-# for targets, as their description for # the `help` target. Otherwise These simple-substitutions are resolved @@ -142,6 +180,10 @@ help: ## (Default) Print listing of key targets with their descriptions awk 'BEGIN {FS = ":(.*)?## "}; \ {printf $(_HLPFMT), $$1, $$2}' +### +### Linting/Formatting/Code Validation targets +### + .gopathok: ifeq ("$(wildcard $(GOPKGDIR))","") mkdir -p "$(GOPKGBASEDIR)" @@ -149,6 +191,11 @@ ifeq ("$(wildcard $(GOPKGDIR))","") endif touch $@ +.PHONY: .gitvalidation +.gitvalidation: .gopathok + @echo "Validating vs commit '$(call err_if_empty,EPOCH_TEST_COMMIT)'" + GIT_CHECK_EXCLUDE="./vendor:docs/make.bat" $(GOBIN)/git-validation -run DCO,short-subject,dangling-whitespace -range $(EPOCH_TEST_COMMIT)..$(HEAD) + .PHONY: lint lint: golangci-lint @echo "Linting vs commit '$(call err_if_empty,EPOCH_TEST_COMMIT)'" @@ -189,18 +236,56 @@ volume-plugin-test-img: test/goecho/goecho: .gopathok $(wildcard test/goecho/*.go) $(GO) build $(BUILDFLAGS) -ldflags '$(LDFLAGS_PODMAN)' -o $@ ./test/goecho +.PHONY: codespell +codespell: + codespell -S bin,vendor,.git,go.sum,changelog.txt,.cirrus.yml,"RELEASE_NOTES.md,*.xz,*.gz,*.tar,*.tgz,bin2img,*ico,*.png,*.1,*.5,copyimg,*.orig,apidoc.go" -L uint,iff,od,seeked,splitted,marge,ERRO,hist -w + +.PHONY: validate +validate: gofmt lint .gitvalidation validate.completions man-page-check swagger-check tests-included + +.PHONY: build-all-new-commits +build-all-new-commits: + # Validate that all the commits build on top of $(GIT_BASE_BRANCH) + git rebase $(GIT_BASE_BRANCH) -x make + +.PHONY: vendor +vendor: + GO111MODULE=on $(GO) mod tidy + GO111MODULE=on $(GO) mod vendor + GO111MODULE=on $(GO) mod verify + +.PHONY: vendor-in-container +vendor-in-container: + podman run --privileged --rm --env HOME=/root \ + -v $(CURDIR):/src -w /src \ + docker.io/library/golang:1.16 \ + make vendor + +### +### Primary binary-build targets +### -bin/podman: .gopathok $(SOURCES) go.mod go.sum ## Build with podman # Make sure to warn in case we're building without the systemd buildtag. +bin/podman: .gopathok $(SOURCES) go.mod go.sum ifeq (,$(findstring systemd,$(BUILDTAGS))) - @echo "Podman is being compiled without the systemd build tag. Install libsystemd on \ - Ubuntu or systemd-devel on rpm based distro for journald support." + @echo "Podman is being compiled without the systemd build tag. \ + Install libsystemd on Ubuntu or systemd-devel on rpm based \ + distro for journald support." endif - $(GO) build $(BUILDFLAGS) -gcflags '$(GCFLAGS)' -asmflags '$(ASMFLAGS)' -ldflags '$(LDFLAGS_PODMAN)' -tags "$(BUILDTAGS)" -o $@ ./cmd/podman + $(GO) build \ + $(BUILDFLAGS) \ + -gcflags '$(GCFLAGS)' \ + -asmflags '$(ASMFLAGS)' \ + -ldflags '$(LDFLAGS_PODMAN)' \ + -tags "$(BUILDTAGS)" \ + -o $@ ./cmd/podman .PHONY: podman podman: bin/podman +.PHONY: podman-remote +podman-remote: bin/podman-remote + bin/podman-remote: .gopathok $(SOURCES) go.mod go.sum ## Build with podman on remote environment $(GO) build $(BUILDFLAGS) -gcflags '$(GCFLAGS)' -asmflags '$(ASMFLAGS)' -ldflags '$(LDFLAGS_PODMAN)' -tags "${REMOTETAGS}" -o $@ ./cmd/podman @@ -208,21 +293,20 @@ bin/podman-remote: .gopathok $(SOURCES) go.mod go.sum ## Build with podman on re podman-remote-static: bin/podman-remote-static CGO_ENABLED=0 $(GO) build $(BUILDFLAGS) -gcflags '$(GCFLAGS)' -asmflags '$(ASMFLAGS)' -ldflags '$(LDFLAGS_PODMAN_STATIC)' -tags "${REMOTETAGS}" -o bin/podman-remote-static ./cmd/podman -.PHONY: podman-remote -podman-remote: bin/podman-remote - -.PHONY: podman.msi -podman.msi: podman-remote podman-remote-windows install-podman-remote-windows-docs ## Will always rebuild exe as there is no podman-remote-windows.exe target to verify timestamp - $(eval DOCFILE := docs/build/remote/windows) - find $(DOCFILE) -print \ - |wixl-heat --var var.ManSourceDir --component-group ManFiles --directory-ref INSTALLDIR --prefix $(DOCFILE)/ >$(DOCFILE)/pages.wsx - wixl -D VERSION=$(RELEASE_NUMBER) -D ManSourceDir=$(DOCFILE) -o podman-v$(RELEASE_NUMBER).msi contrib/msi/podman.wxs $(DOCFILE)/pages.wsx - +# Most-specific, first-match wins: must appear _after_ podman-remote-static podman-remote-%: .gopathok ## Build podman for a specific GOOS $(eval BINSFX := $(shell test "$*" != "windows" || echo ".exe")) CGO_ENABLED=0 GOOS=$* $(GO) build $(BUILDFLAGS) -gcflags '$(GCFLAGS)' -asmflags '$(ASMFLAGS)' -ldflags '$(LDFLAGS_PODMAN)' -tags "${REMOTETAGS}" -o bin/$@$(BINSFX) ./cmd/podman -local-cross: $(CROSS_BUILD_TARGETS) ## Cross local compilation +### +### Secondary binary-build targets +### + +.PHONY: generate-bindings +generate-bindings: +ifneq ($(shell uname -s), Darwin) + GO111MODULE=off $(GO) generate ./pkg/bindings/... ; +endif bin/podman.cross.%: .gopathok TARGET="$*"; \ @@ -230,6 +314,9 @@ bin/podman.cross.%: .gopathok GOARCH="$${TARGET##*.}" \ CGO_ENABLED=0 $(GO) build $(BUILDFLAGS) -gcflags '$(GCFLAGS)' -asmflags '$(ASMFLAGS)' -ldflags '$(LDFLAGS_PODMAN)' -tags '$(BUILDTAGS_CROSS)' -o "$@" ./cmd/podman +.PHONY: local-cross +local-cross: $(CROSS_BUILD_TARGETS) ## Cross compile podman binary for multiple architectures + # Update nix/nixpkgs.json its latest stable commit .PHONY: nixpkgs nixpkgs: @@ -246,36 +333,98 @@ static: mkdir -p ./bin cp -rfp ./result/bin/* ./bin/ -.PHONY: run-docker-py-tests -run-docker-py-tests: - $(eval testLogs=$(shell mktemp)) - ./bin/podman run --rm --security-opt label=disable --privileged -v $(testLogs):/testLogs --net=host -e DOCKER_HOST=tcp://localhost:8080 $(DOCKERPY_IMAGE) sh -c "pytest $(DOCKERPY_TEST) " +.PHONY: build-no-cgo +build-no-cgo: + BUILDTAGS="containers_image_openpgp exclude_graphdriver_btrfs \ + exclude_graphdriver_devicemapper exclude_disk_quota" \ + CGO_ENABLED=0 \ + $(MAKE) all + +.PHONY: completions +completions: podman podman-remote + # key = shell, value = completion filename + declare -A outfiles=([bash]=%s [zsh]=_%s [fish]=%s.fish [powershell]=%s.ps1);\ + for shell in $${!outfiles[*]}; do \ + for remote in "" "-remote"; do \ + podman="podman$$remote"; \ + outfile=$$(printf "completions/$$shell/$${outfiles[$$shell]}" $$podman); \ + ./bin/$$podman completion $$shell >| $$outfile; \ + done;\ + done + +### +### Documentation targets +### pkg/api/swagger.yaml: .gopathok make -C pkg/api +$(MANPAGES): %: %.md .install.md2man docdir + @sed -e 's/\((podman.*\.md)\)//' -e 's/\[\(podman.*\)\]/\1/' \ + -e 's;<\(/\)\?\(a[^>]*\|sup\)>;;g' $< | \ + $(GOMD2MAN) -in /dev/stdin -out $(subst source/markdown,build/man,$@) + +.PHONY: docdir +docdir: + mkdir -p docs/build/man + +.PHONY: docs +docs: $(MANPAGES) ## Generate documentation + +install-podman-remote-%-docs: podman-remote docs $(MANPAGES) + rm -rf docs/build/remote + mkdir -p docs/build/remote + ln -sf $(CURDIR)/docs/source/markdown/links docs/build/man/ + docs/remote-docs.sh \ + $* \ + docs/build/remote/$* \ + $(if $(findstring windows,$*),docs/source/markdown,docs/build/man) + +.PHONY: man-page-check +man-page-check: bin/podman + hack/man-page-checker + hack/xref-helpmsgs-manpages + +.PHONY: swagger-check +swagger-check: + hack/swagger-check + .PHONY: swagger swagger: pkg/api/swagger.yaml -.PHONY: clean -clean: ## Clean artifacts - rm -rf \ - .gopathok \ - _output \ - $(wildcard podman-remote*.zip) \ - $(wildcard podman*.tar.gz) \ - bin \ - build \ - test/checkseccomp/checkseccomp \ - test/goecho/goecho \ - test/testdata/redis-image \ - libpod/container_ffjson.go \ - libpod/pod_ffjson.go \ - libpod/container_easyjson.go \ - libpod/pod_easyjson.go \ - .install.goimports \ - docs/build - make -C docs clean +.PHONY: docker-docs +docker-docs: docs + (cd docs; ./dckrman.sh ./build/man/*.1) + +.PHONY: changelog +changelog: ## Generate updated changelog.txt from git logs + @echo "Creating changelog from $(CHANGELOG_BASE) to $(CHANGELOG_TARGET)" + $(eval TMPFILE := $(shell mktemp)) + $(shell cat changelog.txt > $(TMPFILE)) + $(shell echo "- Changelog for $(CHANGELOG_TARGET) ($(ISODATE)):" > changelog.txt) + $(shell git log --no-merges --format=" * %s" $(CHANGELOG_BASE)..$(CHANGELOG_TARGET) >> changelog.txt) + $(shell echo "" >> changelog.txt) + $(shell cat $(TMPFILE) >> changelog.txt) + $(shell rm $(TMPFILE)) + +# Workaround vim syntax highlighting bug: " + +### +### Utility and Testing targets +### + +.PHONY: validate.completions +validate.completions: SHELL:=/usr/bin/env bash # Set shell to bash for this target +validate.completions: + # Check if the files can be loaded by the shell + . completions/bash/podman + if [ -x /bin/zsh ]; then /bin/zsh completions/zsh/_podman; fi + if [ -x /bin/fish ]; then /bin/fish completions/fish/podman.fish; fi + +.PHONY: run-docker-py-tests +run-docker-py-tests: + $(eval testLogs=$(shell mktemp)) + ./bin/podman run --rm --security-opt label=disable --privileged -v $(testLogs):/testLogs --net=host -e DOCKER_HOST=tcp://localhost:8080 $(DOCKERPY_IMAGE) sh -c "pytest $(DOCKERPY_TEST) " .PHONY: localunit localunit: test/goecho/goecho @@ -368,58 +517,23 @@ remoteapiv2: system.test-binary: .install.ginkgo $(GO) test -c ./test/system -.PHONY: binaries -binaries: podman podman-remote ## Build podman - -.PHONY: install.catatonit -install.catatonit: - ./hack/install_catatonit.sh - .PHONY: test-binaries test-binaries: test/checkseccomp/checkseccomp test/goecho/goecho install.catatonit -MANPAGES_MD ?= $(wildcard docs/source/markdown/*.md pkg/*/docs/*.md) -MANPAGES ?= $(MANPAGES_MD:%.md=%) -MANPAGES_DEST ?= $(subst markdown,man, $(subst source,build,$(MANPAGES))) - -$(MANPAGES): %: %.md .install.md2man docdir - @sed -e 's/\((podman.*\.md)\)//' -e 's/\[\(podman.*\)\]/\1/' -e 's;<\(/\)\?\(a[^>]*\|sup\)>;;g' $< | $(GOMD2MAN) -in /dev/stdin -out $(subst source/markdown,build/man,$@) - -.PHONY: docdir -docdir: - mkdir -p docs/build/man - -.PHONY: docs -docs: $(MANPAGES) ## Generate documentation - -install-podman-remote-%-docs: podman-remote docs $(MANPAGES) - rm -rf docs/build/remote - mkdir -p docs/build/remote - ln -sf $(CURDIR)/docs/source/markdown/links docs/build/man/ - docs/remote-docs.sh $* docs/build/remote/$* $(if $(findstring windows,$*),docs/source/markdown,docs/build/man) - -.PHONY: man-page-check -man-page-check: bin/podman - hack/man-page-checker - hack/xref-helpmsgs-manpages - -.PHONY: swagger-check -swagger-check: - hack/swagger-check - .PHONY: tests-included tests-included: contrib/cirrus/pr-should-include-tests -.PHONY: codespell -codespell: - codespell -S bin,vendor,.git,go.sum,changelog.txt,.cirrus.yml,"RELEASE_NOTES.md,*.xz,*.gz,*.tar,*.tgz,bin2img,*ico,*.png,*.1,*.5,copyimg,*.orig,apidoc.go" -L uint,iff,od,seeked,splitted,marge,ERRO,hist -w +### +### Release/Packaging targets +### -podman-release.tar.gz: binaries docs +podman-release.tar.gz: binaries docs ## Build all binaries, docs., and installation tree, into a tarball. $(eval TMPDIR := $(shell mktemp -d -p '' podman_XXXX)) $(eval SUBDIR := podman-v$(RELEASE_NUMBER)) mkdir -p "$(TMPDIR)/$(SUBDIR)" - $(MAKE) install.bin install.man install.cni install.systemd "DESTDIR=$(TMPDIR)/$(SUBDIR)" "PREFIX=/usr" + $(MAKE) install.bin install.man install.cni \ + install.systemd "DESTDIR=$(TMPDIR)/$(SUBDIR)" "PREFIX=/usr" tar -czvf $@ --xattrs -C "$(TMPDIR)" "./$(SUBDIR)" -rm -rf "$(TMPDIR)" @@ -439,32 +553,43 @@ podman-remote-release-%.zip: zip --recurse-paths "$(CURDIR)/$@" "./" -rm -rf "$(TMPDIR)" -.PHONY: generate-bindings -generate-bindings: -ifneq ($(shell uname -s), Darwin) - GO111MODULE=off $(GO) generate ./pkg/bindings/... ; -endif +.PHONY: podman.msi +podman.msi: podman-remote podman-remote-windows install-podman-remote-windows-docs ## Will always rebuild exe as there is no podman-remote-windows.exe target to verify timestamp + $(eval DOCFILE := docs/build/remote/windows) + find $(DOCFILE) -print | \ + wixl-heat --var var.ManSourceDir --component-group ManFiles \ + --directory-ref INSTALLDIR --prefix $(DOCFILE)/ > \ + $(DOCFILE)/pages.wsx + wixl -D VERSION=$(RELEASE_VERSION) -D ManSourceDir=$(DOCFILE) \ + -o $@ contrib/msi/podman.wxs $(DOCFILE)/pages.wsx -.PHONY: docker-docs -docker-docs: docs - (cd docs; ./dckrman.sh ./build/man/*.1) +.PHONY: package +package: ## Build rpm packages + ## TODO(ssbarnea): make version number predictable, it should not change + ## on each execution, producing duplicates. + rm -rf build/* *.src.rpm ~/rpmbuild/RPMS/* + ./contrib/build_rpm.sh -.PHONY: changelog -changelog: ## Generate changelog - @echo "Creating changelog from $(CHANGELOG_BASE) to $(CHANGELOG_TARGET)" - $(eval TMPFILE := $(shell mktemp)) - $(shell cat changelog.txt > $(TMPFILE)) - $(shell echo "- Changelog for $(CHANGELOG_TARGET) ($(ISODATE)):" > changelog.txt) - $(shell git log --no-merges --format=" * %s" $(CHANGELOG_BASE)..$(CHANGELOG_TARGET) >> changelog.txt) - $(shell echo "" >> changelog.txt) - $(shell cat $(TMPFILE) >> changelog.txt) - $(shell rm $(TMPFILE)) +### +### Installation targets +### -# Workaround vim syntax highlighting bug: " +# Remember that rpms install exec to /usr/bin/podman while a `make install` +# installs them to /usr/local/bin/podman which is likely before. Always use +# a full path to test installed podman or you risk to call another executable. +.PHONY: package-install +package-install: package ## Install rpm packages + sudo ${PKG_MANAGER} -y install ${HOME}/rpmbuild/RPMS/*/*.rpm + /usr/bin/podman version + /usr/bin/podman info # will catch a broken conmon .PHONY: install install: .gopathok install.bin install.remote install.man install.cni install.systemd ## Install binaries to system locations +.PHONY: install.catatonit +install.catatonit: + ./hack/install_catatonit.sh + .PHONY: install.remote-nobuild install.remote-nobuild: install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(BINDIR) @@ -550,41 +675,9 @@ else install.systemd: endif -.PHONY: uninstall -uninstall: - for i in $(filter %.1,$(MANPAGES_DEST)); do \ - rm -f $(DESTDIR)$(MANDIR)/man1/$$(basename $${i}); \ - done; \ - for i in $(filter %.5,$(MANPAGES_DEST)); do \ - rm -f $(DESTDIR)$(MANDIR)/man5/$$(basename $${i}); \ - done - # Remove podman and remote bin - rm -f $(DESTDIR)$(BINDIR)/podman - rm -f $(DESTDIR)$(BINDIR)/podman-remote - # Remove related config files - rm -f ${DESTDIR}${ETCDIR}/cni/net.d/87-podman-bridge.conflist - rm -f ${DESTDIR}${TMPFILESDIR}/podman.conf - rm -f ${DESTDIR}${SYSTEMDDIR}/io.podman.socket - rm -f ${DESTDIR}${USERSYSTEMDDIR}/io.podman.socket - rm -f ${DESTDIR}${SYSTEMDDIR}/io.podman.service - rm -f ${DESTDIR}${SYSTEMDDIR}/podman.service - rm -f ${DESTDIR}${SYSTEMDDIR}/podman.socket - rm -f ${DESTDIR}${USERSYSTEMDDIR}/podman.socket - rm -f ${DESTDIR}${USERSYSTEMDDIR}/podman.service - -.PHONY: .gitvalidation -.gitvalidation: .gopathok - @echo "Validating vs commit '$(call err_if_empty,EPOCH_TEST_COMMIT)'" - GIT_CHECK_EXCLUDE="./vendor:docs/make.bat" $(GOBIN)/git-validation -run DCO,short-subject,dangling-whitespace -range $(EPOCH_TEST_COMMIT)..$(HEAD) - .PHONY: install.tools install.tools: .install.goimports .install.gitvalidation .install.md2man .install.ginkgo .install.golangci-lint .install.bats ## Install needed tools -define go-get - env GO111MODULE=off \ - $(GO) get -u ${1} -endef - .install.goimports: .gopathok if [ ! -x "$(GOBIN)/goimports" ]; then \ $(call go-get,golang.org/x/tools/cmd/goimports); \ @@ -630,61 +723,44 @@ install.libseccomp.sudo: git clone https://github.com/seccomp/libseccomp ../../seccomp/libseccomp cd ../../seccomp/libseccomp && git checkout --detach $(LIBSECCOMP_COMMIT) && ./autogen.sh && ./configure --prefix=/usr && make all && make install - -.PHONY: completions -completions: podman podman-remote - # key = shell, value = completion filename - declare -A outfiles=([bash]=%s [zsh]=_%s [fish]=%s.fish [powershell]=%s.ps1);\ - for shell in $${!outfiles[*]}; do \ - for remote in "" "-remote"; do \ - podman="podman$$remote"; \ - outfile=$$(printf "completions/$$shell/$${outfiles[$$shell]}" $$podman); \ - ./bin/$$podman completion $$shell >| $$outfile; \ - done;\ +.PHONY: uninstall +uninstall: + for i in $(filter %.1,$(MANPAGES_DEST)); do \ + rm -f $(DESTDIR)$(MANDIR)/man1/$$(basename $${i}); \ + done; \ + for i in $(filter %.5,$(MANPAGES_DEST)); do \ + rm -f $(DESTDIR)$(MANDIR)/man5/$$(basename $${i}); \ done + # Remove podman and remote bin + rm -f $(DESTDIR)$(BINDIR)/podman + rm -f $(DESTDIR)$(BINDIR)/podman-remote + # Remove related config files + rm -f ${DESTDIR}${ETCDIR}/cni/net.d/87-podman-bridge.conflist + rm -f ${DESTDIR}${TMPFILESDIR}/podman.conf + rm -f ${DESTDIR}${SYSTEMDDIR}/io.podman.socket + rm -f ${DESTDIR}${USERSYSTEMDDIR}/io.podman.socket + rm -f ${DESTDIR}${SYSTEMDDIR}/io.podman.service + rm -f ${DESTDIR}${SYSTEMDDIR}/podman.service + rm -f ${DESTDIR}${SYSTEMDDIR}/podman.socket + rm -f ${DESTDIR}${USERSYSTEMDDIR}/podman.socket + rm -f ${DESTDIR}${USERSYSTEMDDIR}/podman.service -.PHONY: validate.completions -validate.completions: SHELL:=/usr/bin/env bash # Set shell to bash for this target -validate.completions: - # Check if the files can be loaded by the shell - . completions/bash/podman - if [ -x /bin/zsh ]; then /bin/zsh completions/zsh/_podman; fi - if [ -x /bin/fish ]; then /bin/fish completions/fish/podman.fish; fi - -.PHONY: validate -validate: gofmt lint .gitvalidation validate.completions man-page-check swagger-check tests-included - -.PHONY: build-all-new-commits -build-all-new-commits: - # Validate that all the commits build on top of $(GIT_BASE_BRANCH) - git rebase $(GIT_BASE_BRANCH) -x make - -.PHONY: build-no-cgo -build-no-cgo: - env BUILDTAGS="containers_image_openpgp exclude_graphdriver_btrfs exclude_graphdriver_devicemapper exclude_disk_quota" CGO_ENABLED=0 $(MAKE) - -.PHONY: vendor -vendor: - GO111MODULE=on $(GO) mod tidy - GO111MODULE=on $(GO) mod vendor - GO111MODULE=on $(GO) mod verify - -.PHONY: vendor-in-container -vendor-in-container: - podman run --privileged --rm --env HOME=/root -v $(CURDIR):/src -w /src docker.io/library/golang:1.16 make vendor - -.PHONY: package -package: ## Build rpm packages - ## TODO(ssbarnea): make version number predictable, it should not change - ## on each execution, producing duplicates. - rm -rf build/* *.src.rpm ~/rpmbuild/RPMS/* - ./contrib/build_rpm.sh - -# Remember that rpms install exec to /usr/bin/podman while a `make install` -# installs them to /usr/local/bin/podman which is likely before. Always use -# a full path to test installed podman or you risk to call another executable. -.PHONY: package-install -package-install: package ## Install rpm packages - sudo ${PKG_MANAGER} -y install ${HOME}/rpmbuild/RPMS/*/*.rpm - /usr/bin/podman version - /usr/bin/podman info # will catch a broken conmon +.PHONY: clean +clean: ## Clean artifacts + rm -rf \ + .gopathok \ + _output \ + $(wildcard podman-remote*.zip) \ + $(wildcard podman*.tar.gz) \ + bin \ + build \ + test/checkseccomp/checkseccomp \ + test/goecho/goecho \ + test/testdata/redis-image \ + libpod/container_ffjson.go \ + libpod/pod_ffjson.go \ + libpod/container_easyjson.go \ + libpod/pod_easyjson.go \ + .install.goimports \ + docs/build + make -C docs clean -- cgit v1.2.3-54-g00ecf From b6b0b6e8bd0f8c75fe9411f722a43f9305c6137a Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Thu, 8 Apr 2021 14:30:40 -0400 Subject: Overhaul Makefile binary and release worflows * Incorporate changes from abandoned #9918: Use dedicated `bin` sub-directories for `windows` and `darwin` when building `podman-remote`. The linux flavor remains under `bin` as before. * Fix MacOS Documentation-generation for release-packaging. The `install-podman-remote-%-docs` target requires local execution of `podman-remote`, but it was assuming GOOS=linux. Fix this by dynamically discovering the local OS/architecture type while still permitting cross-building of MacOS binaries under Linux. * Unify temporary directory/file behavior to use a common template. In case of left-over temporary items left in the repository, update the `clean` target accordingly to remove them. * Fix broken podman-remote-static and MacOS release archive targets mismatching the `podman-remote-%` target. Disambiguate this target for all platforms by spelling each out in full, instead of using a wild-card recipe. * Fix Windows-installer target to properly recognize existing output files and not constantly rebuild every time. * Include the podman version number in the Windows-installer target in case a user downloads multiple releases. * Include a subdirectory containing the podman version number for both `tar.gz` and `zip` targets. This prevents users clobbering existing directories when un-archiving from releases. Signed-off-by: Chris Evich --- .cirrus.yml | 3 +- .gitignore | 6 +- Makefile | 149 +++++++++++++++++++++++++++++++++++------------ contrib/cirrus/runner.sh | 5 +- contrib/msi/podman.wxs | 2 +- docs/remote-docs.sh | 12 +++- 6 files changed, 130 insertions(+), 47 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 194bcae52..f044b98ab 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -366,8 +366,7 @@ osx_alt_build_task: script: - brew install go - brew install go-md2man - - make podman-remote-darwin - - make install-podman-remote-darwin-docs + - make podman-remote-release-darwin.zip always: *binary_artifacts diff --git a/.gitignore b/.gitignore index 6a5ae509c..0a3caf8ca 100644 --- a/.gitignore +++ b/.gitignore @@ -17,10 +17,12 @@ coverprofile *.o *.orig /_output/ +/podman_tmp_* /pause/pause.o pkg/api/swagger.yaml -podman-remote*.zip -podman*.tar.gz +/podman-remote*.zip +/podman*.tar.gz +/podman-*.msi __pycache__ release.txt .ropeproject diff --git a/Makefile b/Makefile index 896013b77..01d25a856 100644 --- a/Makefile +++ b/Makefile @@ -147,6 +147,23 @@ CROSS_BUILD_TARGETS := \ # Dereference variable $(1), return value if non-empty, otherwise raise an error. err_if_empty = $(if $(strip $($(1))),$(strip $($(1))),$(error Required variable $(1) value is undefined, whitespace, or empty)) +# Podman does not work w/o CGO_ENABLED, except in some very specific cases +CGO_ENABLED ?= 1 +# Default to the native OS type and archetecture unless otherwise specified +GOOS ?= $(shell $(GO) env GOOS) +ifeq ($(call err_if_empty,GOOS),windows) +BINSFX := .exe +SRCBINDIR := bin/windows +else ifeq ($(GOOS),darwin) +BINSFX := +SRCBINDIR := bin/darwin +else +BINSFX := -remote +SRCBINDIR := bin +endif +# Necessary for nested-$(MAKE) calls and docs/remote-docs.sh +export GOOS CGO_ENABLED BINSFX SRCBINDIR + define go-get env GO111MODULE=off \ $(GO) get -u ${1} @@ -163,7 +180,7 @@ default: all all: binaries docs .PHONY: binaries -binaries: podman podman-remote ## Build podman +binaries: podman podman-remote ## Build podman and podman-remote binaries # Extract text following double-# for targets, as their description for # the `help` target. Otherwise These simple-substitutions are resolved @@ -272,7 +289,8 @@ ifeq (,$(findstring systemd,$(BUILDTAGS))) Install libsystemd on Ubuntu or systemd-devel on rpm based \ distro for journald support." endif - $(GO) build \ + CGO_ENABLED=$(CGO_ENABLED) \ + $(GO) build \ $(BUILDFLAGS) \ -gcflags '$(GCFLAGS)' \ -asmflags '$(ASMFLAGS)' \ @@ -280,23 +298,62 @@ endif -tags "$(BUILDTAGS)" \ -o $@ ./cmd/podman -.PHONY: podman -podman: bin/podman +# Disambiguate Linux vs Darwin/Windows platform binaries under distinct "bin" dirs +$(SRCBINDIR): + mkdir -p $(SRCBINDIR) -.PHONY: podman-remote -podman-remote: bin/podman-remote +$(SRCBINDIR)/podman$(BINSFX): $(SRCBINDIR) .gopathok $(SOURCES) go.mod go.sum + CGO_ENABLED=$(CGO_ENABLED) \ + GOOS=$(GOOS) \ + $(GO) build \ + $(BUILDFLAGS) \ + -gcflags '$(GCFLAGS)' \ + -asmflags '$(ASMFLAGS)' \ + -ldflags '$(LDFLAGS_PODMAN)' \ + -tags "${REMOTETAGS}" \ + -o $@ ./cmd/podman -bin/podman-remote: .gopathok $(SOURCES) go.mod go.sum ## Build with podman on remote environment - $(GO) build $(BUILDFLAGS) -gcflags '$(GCFLAGS)' -asmflags '$(ASMFLAGS)' -ldflags '$(LDFLAGS_PODMAN)' -tags "${REMOTETAGS}" -o $@ ./cmd/podman +$(SRCBINDIR)/podman-remote-static: $(SRCBINDIR) .gopathok $(SOURCES) go.mod go.sum + CGO_ENABLED=$(CGO_ENABLED) \ + GOOS=$(GOOS) \ + $(GO) build \ + $(BUILDFLAGS) \ + -gcflags '$(GCFLAGS)' \ + -asmflags '$(ASMFLAGS)' \ + -ldflags '$(LDFLAGS_PODMAN_STATIC)' \ + -tags "${REMOTETAGS}" \ + -o $@ ./cmd/podman -.PHONY: bin/podman-remote-static -podman-remote-static: bin/podman-remote-static - CGO_ENABLED=0 $(GO) build $(BUILDFLAGS) -gcflags '$(GCFLAGS)' -asmflags '$(ASMFLAGS)' -ldflags '$(LDFLAGS_PODMAN_STATIC)' -tags "${REMOTETAGS}" -o bin/podman-remote-static ./cmd/podman +.PHONY: podman +podman: bin/podman -# Most-specific, first-match wins: must appear _after_ podman-remote-static -podman-remote-%: .gopathok ## Build podman for a specific GOOS - $(eval BINSFX := $(shell test "$*" != "windows" || echo ".exe")) - CGO_ENABLED=0 GOOS=$* $(GO) build $(BUILDFLAGS) -gcflags '$(GCFLAGS)' -asmflags '$(ASMFLAGS)' -ldflags '$(LDFLAGS_PODMAN)' -tags "${REMOTETAGS}" -o bin/$@$(BINSFX) ./cmd/podman +.PHONY: podman-remote +podman-remote: $(SRCBINDIR) $(SRCBINDIR)/podman$(BINSFX) ## Build podman-remote binary + +# A wildcard podman-remote-% target incorrectly sets GOOS for release targets +.PHONY: podman-remote-linux +podman-remote-linux: ## Build podman-remote for Linux + $(MAKE) \ + CGO_ENABLED=0 \ + GOOS=linux \ + bin/podman-remote + +PHONY: podman-remote-static +podman-remote-static: $(SRCBINDIR)/podman-remote-static + +.PHONY: podman-remote-windows +podman-remote-windows: ## Build podman-remote for Windows + $(MAKE) \ + CGO_ENABLED=0 \ + GOOS=windows \ + bin/windows/podman.exe + +.PHONY: podman-remote-darwin +podman-remote-darwin: ## Build podman-remote for MacOS + $(MAKE) \ + CGO_ENABLED=0 \ + GOOS=darwin \ + bin/darwin/podman ### ### Secondary binary-build targets @@ -304,15 +361,23 @@ podman-remote-%: .gopathok ## Build podman for a specific GOOS .PHONY: generate-bindings generate-bindings: -ifneq ($(shell uname -s), Darwin) +ifneq ($(GOOS),darwin) GO111MODULE=off $(GO) generate ./pkg/bindings/... ; endif +# DO NOT USE: use local-cross instead bin/podman.cross.%: .gopathok TARGET="$*"; \ - GOOS="$${TARGET%%.*}" \ - GOARCH="$${TARGET##*.}" \ - CGO_ENABLED=0 $(GO) build $(BUILDFLAGS) -gcflags '$(GCFLAGS)' -asmflags '$(ASMFLAGS)' -ldflags '$(LDFLAGS_PODMAN)' -tags '$(BUILDTAGS_CROSS)' -o "$@" ./cmd/podman + GOOS="$${TARGET%%.*}"; \ + GOARCH="$${TARGET##*.}"; \ + CGO_ENABLED=0 \ + $(GO) build \ + $(BUILDFLAGS) \ + -gcflags '$(GCFLAGS)' \ + -asmflags '$(ASMFLAGS)' \ + -ldflags '$(LDFLAGS_PODMAN)' \ + -tags '$(BUILDTAGS_CROSS)' \ + -o "$@" ./cmd/podman .PHONY: local-cross local-cross: $(CROSS_BUILD_TARGETS) ## Cross compile podman binary for multiple architectures @@ -371,7 +436,9 @@ docdir: .PHONY: docs docs: $(MANPAGES) ## Generate documentation -install-podman-remote-%-docs: podman-remote docs $(MANPAGES) +# docs/remote-docs.sh requires a locally executable 'podman-remote' binary +# in addition to the target-archetecture binary (if any). +install-podman-remote-%-docs: podman-remote-$(shell env -i HOME=$$HOME PATH=$$PATH go env GOOS) docs $(MANPAGES) rm -rf docs/build/remote mkdir -p docs/build/remote ln -sf $(CURDIR)/docs/source/markdown/links docs/build/man/ @@ -399,7 +466,7 @@ docker-docs: docs .PHONY: changelog changelog: ## Generate updated changelog.txt from git logs @echo "Creating changelog from $(CHANGELOG_BASE) to $(CHANGELOG_TARGET)" - $(eval TMPFILE := $(shell mktemp)) + $(eval TMPFILE := $(shell mktemp podman_tmp_XXXX)) $(shell cat changelog.txt > $(TMPFILE)) $(shell echo "- Changelog for $(CHANGELOG_TARGET) ($(ISODATE)):" > changelog.txt) $(shell git log --no-merges --format=" * %s" $(CHANGELOG_BASE)..$(CHANGELOG_TARGET) >> changelog.txt) @@ -423,7 +490,7 @@ validate.completions: .PHONY: run-docker-py-tests run-docker-py-tests: - $(eval testLogs=$(shell mktemp)) + $(eval testLogs=$(shell mktemp podman_tmp_XXXX)) ./bin/podman run --rm --security-opt label=disable --privileged -v $(testLogs):/testLogs --net=host -e DOCKER_HOST=tcp://localhost:8080 $(DOCKERPY_IMAGE) sh -c "pytest $(DOCKERPY_TEST) " .PHONY: localunit @@ -480,7 +547,7 @@ remotesystem: # podman server spews copious unhelpful output; ignore it. rc=0;\ if timeout -v 1 true; then \ - SOCK_FILE=$(shell mktemp --dry-run --tmpdir podman.XXXXXX);\ + SOCK_FILE=$(shell mktemp --dry-run --tmpdir podman_tmp_XXXX);\ export PODMAN_SOCKET=unix:$$SOCK_FILE; \ ./bin/podman system service --timeout=0 $$PODMAN_SOCKET > $(if $(PODMAN_SERVER_LOG),$(PODMAN_SERVER_LOG),/dev/null) 2>&1 & \ retry=5;\ @@ -529,7 +596,7 @@ tests-included: ### podman-release.tar.gz: binaries docs ## Build all binaries, docs., and installation tree, into a tarball. - $(eval TMPDIR := $(shell mktemp -d -p '' podman_XXXX)) + $(eval TMPDIR := $(shell mktemp -d podman_tmp_XXXX)) $(eval SUBDIR := podman-v$(RELEASE_NUMBER)) mkdir -p "$(TMPDIR)/$(SUBDIR)" $(MAKE) install.bin install.man install.cni \ @@ -537,24 +604,25 @@ podman-release.tar.gz: binaries docs ## Build all binaries, docs., and installa tar -czvf $@ --xattrs -C "$(TMPDIR)" "./$(SUBDIR)" -rm -rf "$(TMPDIR)" -# Must call make in-line: Dependency-spec. w/ wild-card. -podman-remote-release-%.zip: - $(MAKE) podman-remote-$* install-podman-remote-$*-docs \ - RELEASE_BASENAME=$(shell hack/get_release_info.sh REMOTENAME) \ - RELEASE_DIST=$* RELEASE_DIST_VER="-" - $(eval TMPDIR := $(shell mktemp -d -p '' $podman_remote_XXXX)) - $(eval SUBDIR := podman-$(RELEASE_VERSION)) - $(eval BINSFX := $(shell test "$*" != "windows" || echo ".exe")) +podman-remote-release-%.zip: podman-remote-% install-podman-remote-%-docs ## Build podman-remote for GOOS=%, docs., and installation zip. + $(eval TMPDIR := $(shell mktemp -d podman_tmp_XXXX)) + $(eval SUBDIR := podman-$(RELEASE_NUMBER)) mkdir -p "$(TMPDIR)/$(SUBDIR)" - cp ./bin/podman-remote-$*$(BINSFX) "$(TMPDIR)/$(SUBDIR)/podman$(BINSFX)" + $(MAKE) \ + GOOS=$* \ + DESTDIR=$(TMPDIR)/ \ + BINDIR=$(SUBDIR) \ + SELINUXOPT="" \ + install.remote-nobuild cp -r ./docs/build/remote/$* "$(TMPDIR)/$(SUBDIR)/docs/" cp ./contrib/remote/containers.conf "$(TMPDIR)/$(SUBDIR)/" - cd "$(TMPDIR)/$(SUBDIR)" && \ + cd "$(TMPDIR)" && \ zip --recurse-paths "$(CURDIR)/$@" "./" -rm -rf "$(TMPDIR)" .PHONY: podman.msi -podman.msi: podman-remote podman-remote-windows install-podman-remote-windows-docs ## Will always rebuild exe as there is no podman-remote-windows.exe target to verify timestamp +podman.msi: podman-v$(RELEASE_NUMBER).msi ## Build podman-remote, package for installation on Windows +podman-v$(RELEASE_NUMBER).msi: podman-remote-windows install-podman-remote-windows-docs $(eval DOCFILE := docs/build/remote/windows) find $(DOCFILE) -print | \ wixl-heat --var var.ManSourceDir --component-group ManFiles \ @@ -593,8 +661,11 @@ install.catatonit: .PHONY: install.remote-nobuild install.remote-nobuild: install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(BINDIR) - install ${SELINUXOPT} -m 755 bin/podman-remote $(DESTDIR)$(BINDIR)/podman-remote - test -z "${SELINUXOPT}" || chcon --verbose --reference=$(DESTDIR)$(BINDIR)/podman-remote bin/podman-remote + install ${SELINUXOPT} -m 755 $(SRCBINDIR)/podman$(BINSFX) \ + $(DESTDIR)$(BINDIR)/podman$(BINSFX) + test -z "${SELINUXOPT}" || \ + chcon --verbose --reference=$(DESTDIR)$(BINDIR)/podman-remote \ + bin/podman-remote .PHONY: install.remote install.remote: podman-remote install.remote-nobuild @@ -746,11 +817,13 @@ uninstall: rm -f ${DESTDIR}${USERSYSTEMDDIR}/podman.service .PHONY: clean -clean: ## Clean artifacts +clean: ## Clean all make artifacts rm -rf \ .gopathok \ _output \ + $(wildcard podman-*.msi) \ $(wildcard podman-remote*.zip) \ + $(wildcard podman_tmp_*) \ $(wildcard podman*.tar.gz) \ bin \ build \ diff --git a/contrib/cirrus/runner.sh b/contrib/cirrus/runner.sh index 8d3a6b987..b463745d1 100755 --- a/contrib/cirrus/runner.sh +++ b/contrib/cirrus/runner.sh @@ -202,8 +202,7 @@ function _run_build() { # Ensure always start from clean-slate with all vendor modules downloaded make clean make vendor - make podman-release - make podman-remote-linux-release + make podman-release.tar.gz # includes podman, podman-remote, and docs } function _run_altbuild() { @@ -219,7 +218,7 @@ function _run_altbuild() { make build-all-new-commits GIT_BASE_BRANCH=origin/$DEST_BRANCH ;; *Windows*) - make podman-remote-windows-release + make podman-remote-release-windows.zip make podman.msi ;; *Without*) diff --git a/contrib/msi/podman.wxs b/contrib/msi/podman.wxs index ff8160a53..451dd565d 100644 --- a/contrib/msi/podman.wxs +++ b/contrib/msi/podman.wxs @@ -24,7 +24,7 @@ - + diff --git a/docs/remote-docs.sh b/docs/remote-docs.sh index 67c731e75..2b7d73cd3 100755 --- a/docs/remote-docs.sh +++ b/docs/remote-docs.sh @@ -6,7 +6,17 @@ PLATFORM=$1 ## linux, windows or darwin TARGET=${2} ## where to output files SOURCES=${@:3} ## directories to find markdown files -PODMAN=${PODMAN:-bin/podman-remote} ## location overridden for testing +# Overriden for testing. Native podman-remote binary expected filepaths +if [[ -z "$PODMAN" ]]; then + case $(env -i HOME=$HOME PATH=$PATH go env GOOS) in + windows) + PODMAN=bin/windows/podman.exe ;; + darwin) + PODMAN=bin/darwin/podman ;; + *) # Assume "linux" + PODMAN=bin/podman-remote ;; + esac +fi function usage() { echo >&2 "$0 PLATFORM TARGET SOURCES..." -- cgit v1.2.3-54-g00ecf