aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile33
-rwxr-xr-xhack/get_release_info.sh70
-rw-r--r--test/version/main.go11
4 files changed, 30 insertions, 85 deletions
diff --git a/.gitignore b/.gitignore
index 08e5309ee..d54013bfd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,7 @@ release.txt
/test/checkseccomp/checkseccomp
/test/copyimg/copyimg
/test/goecho/goecho
+/test/version/version
/test/testvol/testvol
.vscode*
tags
diff --git a/Makefile b/Makefile
index cf796ed3c..12889c1c5 100644
--- a/Makefile
+++ b/Makefile
@@ -107,12 +107,9 @@ LIBSECCOMP_COMMIT := v2.3.3
# caller may override in special circumstances if needed.
GINKGOTIMEOUT ?= -timeout=90m
-RELEASE_VERSION ?= $(shell hack/get_release_info.sh VERSION)
-RELEASE_NUMBER ?= $(shell hack/get_release_info.sh NUMBER|sed -e 's/^v\(.*\)/\1/')
-RELEASE_DIST ?= $(shell hack/get_release_info.sh DIST)
-RELEASE_DIST_VER ?= $(shell hack/get_release_info.sh DIST_VER)
-RELEASE_ARCH ?= $(shell hack/get_release_info.sh ARCH)
-RELEASE_BASENAME := $(shell hack/get_release_info.sh BASENAME)
+# Conditional required to produce empty-output if binary not built yet.
+RELEASE_VERSION = $(shell if test -x test/version/version; then test/version/version; fi)
+RELEASE_NUMBER = $(shell echo "$(RELEASE_VERSION)" | sed -e 's/^v\(.*\)/\1/')
# If non-empty, logs all output from server during remote system testing
PODMAN_SERVER_LOG ?=
@@ -256,6 +253,9 @@ volume-plugin-test-img:
test/goecho/goecho: .gopathok $(wildcard test/goecho/*.go)
$(GO) build $(BUILDFLAGS) -ldflags '$(LDFLAGS_PODMAN)' -o $@ ./test/goecho
+test/version/version: .gopathok version/version.go
+ $(GO) build -o $@ ./test/version/
+
.PHONY: codespell
codespell:
codespell -S bin,vendor,.git,go.sum,.cirrus.yml,"RELEASE_NOTES.md,*.xz,*.gz,*.ps1,*.tar,*.tgz,bin2img,*ico,*.png,*.1,*.5,copyimg,*.orig,apidoc.go" -L uint,iff,od,seeked,splitted,marge,ERRO,hist,ether -w
@@ -491,7 +491,7 @@ run-docker-py-tests:
-rm test/__init__.py
.PHONY: localunit
-localunit: test/goecho/goecho
+localunit: test/goecho/goecho test/version/version
rm -rf ${COVERAGE_PATH} && mkdir -p ${COVERAGE_PATH}
$(GOBIN)/ginkgo \
-r \
@@ -581,7 +581,8 @@ system.test-binary: .install.ginkgo
$(GO) test -c ./test/system
.PHONY: test-binaries
-test-binaries: test/checkseccomp/checkseccomp test/goecho/goecho install.catatonit
+test-binaries: test/checkseccomp/checkseccomp test/goecho/goecho install.catatonit test/version/version
+ @echo "Canonical source version: $(call err_if_empty,RELEASE_VERSION)"
.PHONY: tests-included
tests-included:
@@ -601,18 +602,18 @@ tests-expect-exit:
### Release/Packaging targets
###
-podman-release.tar.gz: binaries docs ## Build all binaries, docs., and installation tree, into a tarball.
+podman-release.tar.gz: test/version/version binaries docs ## Build all binaries, docs., and installation tree, into a tarball.
$(eval TMPDIR := $(shell mktemp -d podman_tmp_XXXX))
- $(eval SUBDIR := podman-v$(RELEASE_NUMBER))
+ $(eval SUBDIR := podman-v$(call err_if_empty,RELEASE_NUMBER))
mkdir -p "$(TMPDIR)/$(SUBDIR)"
- $(MAKE) install.bin install.man \
+ $(MAKE) install.bin install.remote install.man \
install.systemd "DESTDIR=$(TMPDIR)/$(SUBDIR)" "PREFIX=/usr"
tar -czvf $@ --xattrs -C "$(TMPDIR)" "./$(SUBDIR)"
-rm -rf "$(TMPDIR)"
-podman-remote-release-%.zip: podman-remote-% install-podman-remote-%-docs ## Build podman-remote for GOOS=%, docs., and installation zip.
+podman-remote-release-%.zip: test/version/version 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))
+ $(eval SUBDIR := podman-$(call err_if_empty,RELEASE_NUMBER))
mkdir -p "$(TMPDIR)/$(SUBDIR)"
$(MAKE) \
GOOS=$* \
@@ -627,14 +628,15 @@ podman-remote-release-%.zip: podman-remote-% install-podman-remote-%-docs ## Bu
-rm -rf "$(TMPDIR)"
.PHONY: podman.msi
-podman.msi: podman-v$(RELEASE_NUMBER).msi ## Build podman-remote, package for installation on Windows
+podman.msi: test/version/version ## Build podman-remote, package for installation on Windows
+ $(MAKE) podman-v$(RELEASE_NUMBER).msi
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 \
--directory-ref INSTALLDIR --prefix $(DOCFILE)/ > \
$(DOCFILE)/pages.wsx
- wixl -D VERSION=$(RELEASE_VERSION) -D ManSourceDir=$(DOCFILE) \
+ wixl -D VERSION=$(call err_if_empty,RELEASE_VERSION) -D ManSourceDir=$(DOCFILE) \
-o $@ contrib/msi/podman.wxs $(DOCFILE)/pages.wsx
.PHONY: package
@@ -832,6 +834,7 @@ clean: ## Clean all make artifacts
build \
test/checkseccomp/checkseccomp \
test/goecho/goecho \
+ test/version/version \
test/__init__.py \
test/testdata/redis-image \
libpod/container_ffjson.go \
diff --git a/hack/get_release_info.sh b/hack/get_release_info.sh
deleted file mode 100755
index e1020e677..000000000
--- a/hack/get_release_info.sh
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/env bash
-
-# This script produces various bits of metadata needed by Makefile. Using
-# a script allows uniform behavior across multiple environments and
-# distributions. The script expects a single argument, as reflected below.
-
-set -euo pipefail
-
-cd "${GOSRC:-$(dirname $0)/../}"
-
-valid_args() {
- REGEX='^\s+[[:upper:]]+\*[)]'
- egrep --text --no-filename --group-separator=' ' --only-matching "$REGEX" "$0" | \
- cut -d '*' -f 1
-}
-
-# `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 main).
-# 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 v
- # extract the value of 'var Version'
- v=$(sed -ne 's/^var\s\+Version\s\+=\s.*("\(.*\)").*/\1/p' <version/version.go)
- # If it's empty, something has changed in version.go, that would be bad!
- test -n "$v"
- # Value consumed literally, must not have any embedded newlines
- echo -n "$v"
-}
-
-unset OUTPUT
-case "$1" in
- # Wild-card suffix needed by valid_args() e.g. possible bad grep of "$(echo $FOO)"
- VERSION*)
- OUTPUT="${CIRRUS_TAG:-$(scrape_version)}"
- ;;
- NUMBER*)
- OUTPUT="$($0 VERSION | sed 's/-.*//')"
- ;;
- DIST_VER*)
- OUTPUT="$(source /etc/os-release; echo $VERSION_ID | cut -d '.' -f 1)"
- ;;
- DIST*)
- OUTPUT="$(source /etc/os-release; echo $ID)"
- ;;
- ARCH*)
- OUTPUT="${GOARCH:-$(go env GOARCH 2> /dev/null)}"
- ;;
- BASENAME*)
- OUTPUT="podman"
- ;;
- REMOTENAME*)
- OUTPUT="$($0 BASENAME)-remote"
- ;;
- *)
- echo "Error, unknown/unsupported argument '$1', valid arguments:"
- valid_args
- exit 1
- ;;
-esac
-
-if [[ -n "$OUTPUT" ]]
-then
- echo -n "$OUTPUT"
-else
- echo "Error, empty output for info: '$1'" > /dev/stderr
- exit 2
-fi
diff --git a/test/version/main.go b/test/version/main.go
new file mode 100644
index 000000000..2a751de78
--- /dev/null
+++ b/test/version/main.go
@@ -0,0 +1,11 @@
+package main
+
+import (
+ "fmt"
+
+ "github.com/containers/podman/v3/version"
+)
+
+func main() {
+ fmt.Printf(version.Version.String())
+}