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 <cevich@redhat.com>
This commit is contained in:
Chris Evich
2021-04-08 14:30:40 -04:00
parent a4686883b7
commit b6b0b6e8bd
6 changed files with 127 additions and 44 deletions

View File

@ -366,8 +366,7 @@ osx_alt_build_task:
script: script:
- brew install go - brew install go
- brew install go-md2man - brew install go-md2man
- make podman-remote-darwin - make podman-remote-release-darwin.zip
- make install-podman-remote-darwin-docs
always: *binary_artifacts always: *binary_artifacts

6
.gitignore vendored
View File

@ -17,10 +17,12 @@ coverprofile
*.o *.o
*.orig *.orig
/_output/ /_output/
/podman_tmp_*
/pause/pause.o /pause/pause.o
pkg/api/swagger.yaml pkg/api/swagger.yaml
podman-remote*.zip /podman-remote*.zip
podman*.tar.gz /podman*.tar.gz
/podman-*.msi
__pycache__ __pycache__
release.txt release.txt
.ropeproject .ropeproject

141
Makefile
View File

@ -147,6 +147,23 @@ CROSS_BUILD_TARGETS := \
# Dereference variable $(1), return value if non-empty, otherwise raise an error. # 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)) 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 define go-get
env GO111MODULE=off \ env GO111MODULE=off \
$(GO) get -u ${1} $(GO) get -u ${1}
@ -163,7 +180,7 @@ default: all
all: binaries docs all: binaries docs
.PHONY: binaries .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 # Extract text following double-# for targets, as their description for
# the `help` target. Otherwise These simple-substitutions are resolved # the `help` target. Otherwise These simple-substitutions are resolved
@ -272,6 +289,7 @@ ifeq (,$(findstring systemd,$(BUILDTAGS)))
Install libsystemd on Ubuntu or systemd-devel on rpm based \ Install libsystemd on Ubuntu or systemd-devel on rpm based \
distro for journald support." distro for journald support."
endif endif
CGO_ENABLED=$(CGO_ENABLED) \
$(GO) build \ $(GO) build \
$(BUILDFLAGS) \ $(BUILDFLAGS) \
-gcflags '$(GCFLAGS)' \ -gcflags '$(GCFLAGS)' \
@ -280,23 +298,62 @@ endif
-tags "$(BUILDTAGS)" \ -tags "$(BUILDTAGS)" \
-o $@ ./cmd/podman -o $@ ./cmd/podman
# Disambiguate Linux vs Darwin/Windows platform binaries under distinct "bin" dirs
$(SRCBINDIR):
mkdir -p $(SRCBINDIR)
$(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
$(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: podman .PHONY: podman
podman: bin/podman podman: bin/podman
.PHONY: podman-remote .PHONY: podman-remote
podman-remote: bin/podman-remote podman-remote: $(SRCBINDIR) $(SRCBINDIR)/podman$(BINSFX) ## Build podman-remote binary
bin/podman-remote: .gopathok $(SOURCES) go.mod go.sum ## Build with podman on remote environment # A wildcard podman-remote-% target incorrectly sets GOOS for release targets
$(GO) build $(BUILDFLAGS) -gcflags '$(GCFLAGS)' -asmflags '$(ASMFLAGS)' -ldflags '$(LDFLAGS_PODMAN)' -tags "${REMOTETAGS}" -o $@ ./cmd/podman .PHONY: podman-remote-linux
podman-remote-linux: ## Build podman-remote for Linux
$(MAKE) \
CGO_ENABLED=0 \
GOOS=linux \
bin/podman-remote
.PHONY: bin/podman-remote-static PHONY: podman-remote-static
podman-remote-static: bin/podman-remote-static podman-remote-static: $(SRCBINDIR)/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
# Most-specific, first-match wins: must appear _after_ podman-remote-static .PHONY: podman-remote-windows
podman-remote-%: .gopathok ## Build podman for a specific GOOS podman-remote-windows: ## Build podman-remote for Windows
$(eval BINSFX := $(shell test "$*" != "windows" || echo ".exe")) $(MAKE) \
CGO_ENABLED=0 GOOS=$* $(GO) build $(BUILDFLAGS) -gcflags '$(GCFLAGS)' -asmflags '$(ASMFLAGS)' -ldflags '$(LDFLAGS_PODMAN)' -tags "${REMOTETAGS}" -o bin/$@$(BINSFX) ./cmd/podman 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 ### Secondary binary-build targets
@ -304,15 +361,23 @@ podman-remote-%: .gopathok ## Build podman for a specific GOOS
.PHONY: generate-bindings .PHONY: generate-bindings
generate-bindings: generate-bindings:
ifneq ($(shell uname -s), Darwin) ifneq ($(GOOS),darwin)
GO111MODULE=off $(GO) generate ./pkg/bindings/... ; GO111MODULE=off $(GO) generate ./pkg/bindings/... ;
endif endif
# DO NOT USE: use local-cross instead
bin/podman.cross.%: .gopathok bin/podman.cross.%: .gopathok
TARGET="$*"; \ TARGET="$*"; \
GOOS="$${TARGET%%.*}" \ GOOS="$${TARGET%%.*}"; \
GOARCH="$${TARGET##*.}" \ GOARCH="$${TARGET##*.}"; \
CGO_ENABLED=0 $(GO) build $(BUILDFLAGS) -gcflags '$(GCFLAGS)' -asmflags '$(ASMFLAGS)' -ldflags '$(LDFLAGS_PODMAN)' -tags '$(BUILDTAGS_CROSS)' -o "$@" ./cmd/podman CGO_ENABLED=0 \
$(GO) build \
$(BUILDFLAGS) \
-gcflags '$(GCFLAGS)' \
-asmflags '$(ASMFLAGS)' \
-ldflags '$(LDFLAGS_PODMAN)' \
-tags '$(BUILDTAGS_CROSS)' \
-o "$@" ./cmd/podman
.PHONY: local-cross .PHONY: local-cross
local-cross: $(CROSS_BUILD_TARGETS) ## Cross compile podman binary for multiple architectures local-cross: $(CROSS_BUILD_TARGETS) ## Cross compile podman binary for multiple architectures
@ -371,7 +436,9 @@ docdir:
.PHONY: docs .PHONY: docs
docs: $(MANPAGES) ## Generate documentation 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 rm -rf docs/build/remote
mkdir -p docs/build/remote mkdir -p docs/build/remote
ln -sf $(CURDIR)/docs/source/markdown/links docs/build/man/ ln -sf $(CURDIR)/docs/source/markdown/links docs/build/man/
@ -399,7 +466,7 @@ docker-docs: docs
.PHONY: changelog .PHONY: changelog
changelog: ## Generate updated changelog.txt from git logs changelog: ## Generate updated changelog.txt from git logs
@echo "Creating changelog from $(CHANGELOG_BASE) to $(CHANGELOG_TARGET)" @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 cat changelog.txt > $(TMPFILE))
$(shell echo "- Changelog for $(CHANGELOG_TARGET) ($(ISODATE)):" > changelog.txt) $(shell echo "- Changelog for $(CHANGELOG_TARGET) ($(ISODATE)):" > changelog.txt)
$(shell git log --no-merges --format=" * %s" $(CHANGELOG_BASE)..$(CHANGELOG_TARGET) >> 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 .PHONY: run-docker-py-tests
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) " ./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 .PHONY: localunit
@ -480,7 +547,7 @@ remotesystem:
# podman server spews copious unhelpful output; ignore it. # podman server spews copious unhelpful output; ignore it.
rc=0;\ rc=0;\
if timeout -v 1 true; then \ 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; \ 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 & \ ./bin/podman system service --timeout=0 $$PODMAN_SOCKET > $(if $(PODMAN_SERVER_LOG),$(PODMAN_SERVER_LOG),/dev/null) 2>&1 & \
retry=5;\ retry=5;\
@ -529,7 +596,7 @@ tests-included:
### ###
podman-release.tar.gz: binaries docs ## Build all binaries, docs., and installation tree, into a tarball. 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)) $(eval SUBDIR := podman-v$(RELEASE_NUMBER))
mkdir -p "$(TMPDIR)/$(SUBDIR)" mkdir -p "$(TMPDIR)/$(SUBDIR)"
$(MAKE) install.bin install.man install.cni \ $(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)" tar -czvf $@ --xattrs -C "$(TMPDIR)" "./$(SUBDIR)"
-rm -rf "$(TMPDIR)" -rm -rf "$(TMPDIR)"
# Must call make in-line: Dependency-spec. w/ wild-card. podman-remote-release-%.zip: podman-remote-% install-podman-remote-%-docs ## Build podman-remote for GOOS=%, docs., and installation zip.
podman-remote-release-%.zip: $(eval TMPDIR := $(shell mktemp -d podman_tmp_XXXX))
$(MAKE) podman-remote-$* install-podman-remote-$*-docs \ $(eval SUBDIR := podman-$(RELEASE_NUMBER))
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)" 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 -r ./docs/build/remote/$* "$(TMPDIR)/$(SUBDIR)/docs/"
cp ./contrib/remote/containers.conf "$(TMPDIR)/$(SUBDIR)/" cp ./contrib/remote/containers.conf "$(TMPDIR)/$(SUBDIR)/"
cd "$(TMPDIR)/$(SUBDIR)" && \ cd "$(TMPDIR)" && \
zip --recurse-paths "$(CURDIR)/$@" "./" zip --recurse-paths "$(CURDIR)/$@" "./"
-rm -rf "$(TMPDIR)" -rm -rf "$(TMPDIR)"
.PHONY: podman.msi .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) $(eval DOCFILE := docs/build/remote/windows)
find $(DOCFILE) -print | \ find $(DOCFILE) -print | \
wixl-heat --var var.ManSourceDir --component-group ManFiles \ wixl-heat --var var.ManSourceDir --component-group ManFiles \
@ -593,8 +661,11 @@ install.catatonit:
.PHONY: install.remote-nobuild .PHONY: install.remote-nobuild
install.remote-nobuild: install.remote-nobuild:
install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(BINDIR) install ${SELINUXOPT} -d -m 755 $(DESTDIR)$(BINDIR)
install ${SELINUXOPT} -m 755 bin/podman-remote $(DESTDIR)$(BINDIR)/podman-remote install ${SELINUXOPT} -m 755 $(SRCBINDIR)/podman$(BINSFX) \
test -z "${SELINUXOPT}" || chcon --verbose --reference=$(DESTDIR)$(BINDIR)/podman-remote bin/podman-remote $(DESTDIR)$(BINDIR)/podman$(BINSFX)
test -z "${SELINUXOPT}" || \
chcon --verbose --reference=$(DESTDIR)$(BINDIR)/podman-remote \
bin/podman-remote
.PHONY: install.remote .PHONY: install.remote
install.remote: podman-remote install.remote-nobuild install.remote: podman-remote install.remote-nobuild
@ -746,11 +817,13 @@ uninstall:
rm -f ${DESTDIR}${USERSYSTEMDDIR}/podman.service rm -f ${DESTDIR}${USERSYSTEMDDIR}/podman.service
.PHONY: clean .PHONY: clean
clean: ## Clean artifacts clean: ## Clean all make artifacts
rm -rf \ rm -rf \
.gopathok \ .gopathok \
_output \ _output \
$(wildcard podman-*.msi) \
$(wildcard podman-remote*.zip) \ $(wildcard podman-remote*.zip) \
$(wildcard podman_tmp_*) \
$(wildcard podman*.tar.gz) \ $(wildcard podman*.tar.gz) \
bin \ bin \
build \ build \

View File

@ -202,8 +202,7 @@ function _run_build() {
# Ensure always start from clean-slate with all vendor modules downloaded # Ensure always start from clean-slate with all vendor modules downloaded
make clean make clean
make vendor make vendor
make podman-release make podman-release.tar.gz # includes podman, podman-remote, and docs
make podman-remote-linux-release
} }
function _run_altbuild() { function _run_altbuild() {
@ -219,7 +218,7 @@ function _run_altbuild() {
make build-all-new-commits GIT_BASE_BRANCH=origin/$DEST_BRANCH make build-all-new-commits GIT_BASE_BRANCH=origin/$DEST_BRANCH
;; ;;
*Windows*) *Windows*)
make podman-remote-windows-release make podman-remote-release-windows.zip
make podman.msi make podman.msi
;; ;;
*Without*) *Without*)

View File

@ -24,7 +24,7 @@
<CreateFolder/> <CreateFolder/>
</Component> </Component>
<Component Id="MainExecutable" Guid="73752F94-6589-4C7B-ABED-39D655A19714"> <Component Id="MainExecutable" Guid="73752F94-6589-4C7B-ABED-39D655A19714">
<File Id="520C6E17-77A2-4F41-9611-30FA763A0702" Name="podman.exe" Source="bin/podman-remote-windows.exe" KeyPath="yes"/> <File Id="520C6E17-77A2-4F41-9611-30FA763A0702" Name="podman.exe" Source="bin/windows/podman.exe" KeyPath="yes"/>
</Component> </Component>
</Directory> </Directory>
</Directory> </Directory>

View File

@ -6,7 +6,17 @@ PLATFORM=$1 ## linux, windows or darwin
TARGET=${2} ## where to output files TARGET=${2} ## where to output files
SOURCES=${@:3} ## directories to find markdown 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() { function usage() {
echo >&2 "$0 PLATFORM TARGET SOURCES..." echo >&2 "$0 PLATFORM TARGET SOURCES..."