Skip to content

Commit 03bbae0

Browse files
committed
Add BuildOrigin field to podman info
BuiltOrigin is a field that can be set at build time by packagers. This helps us trace how and where the binary was built and installed from, allowing us to see if the issue is due to a specfic installation or a general podman bug. This field shows up in podman version and in podman info when populated. Automatically set the BuildOrigin field when building the macOS pkginstaller to pkginstaller. Usage: make podman-remote BUILD_ORIGIN="mypackaging" Signed-off-by: Ashley Cui <[email protected]>
1 parent 8ff491b commit 03bbae0

File tree

5 files changed

+34
-23
lines changed

5 files changed

+34
-23
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ GOFLAGS ?= -trimpath
119119
LDFLAGS_PODMAN ?= \
120120
$(if $(GIT_COMMIT),-X $(LIBPOD)/define.gitCommit=$(GIT_COMMIT),) \
121121
$(if $(BUILD_INFO),-X $(LIBPOD)/define.buildInfo=$(BUILD_INFO),) \
122+
$(if $(BUILD_ORIGIN),-X $(LIBPOD)/define.buildOrigin=$(BUILD_ORIGIN),) \
122123
-X $(LIBPOD)/config._installPrefix=$(PREFIX) \
123124
-X $(LIBPOD)/config._etcDir=$(ETCDIR) \
124125
-X $(PROJECT)/v5/pkg/systemd/quadlet._binDir=$(BINDIR) \

cmd/podman/client.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package main
33
import "github.com/containers/podman/v5/libpod/define"
44

55
type clientInfo struct {
6-
OSArch string `json:"OS"`
7-
Provider string `json:"provider"`
8-
Version string `json:"version"`
6+
OSArch string `json:"OS"`
7+
Provider string `json:"provider"`
8+
Version string `json:"version"`
9+
BuildOrigin string `json:"buildOrigin,omitempty" yaml:",omitempty"`
910
}
1011

1112
func getClientInfo() (*clientInfo, error) {
@@ -18,8 +19,9 @@ func getClientInfo() (*clientInfo, error) {
1819
return nil, err
1920
}
2021
return &clientInfo{
21-
OSArch: vinfo.OsArch,
22-
Provider: p,
23-
Version: vinfo.Version,
22+
OSArch: vinfo.OsArch,
23+
Provider: p,
24+
Version: vinfo.Version,
25+
BuildOrigin: vinfo.BuildOrigin,
2426
}, nil
2527
}

cmd/podman/system/version.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ API Version:\t{{.APIVersion}}
9797
Go Version:\t{{.GoVersion}}
9898
{{if .GitCommit -}}Git Commit:\t{{.GitCommit}}\n{{end -}}
9999
Built:\t{{.BuiltTime}}
100+
{{if .BuildOrigin -}}Build Origin:\t{{.BuildOrigin}}\n{{end -}}
100101
OS/Arch:\t{{.OsArch}}
101102
{{- end}}
102103
@@ -108,6 +109,7 @@ API Version:\t{{.APIVersion}}
108109
Go Version:\t{{.GoVersion}}
109110
{{if .GitCommit -}}Git Commit:\t{{.GitCommit}}\n{{end -}}
110111
Built:\t{{.BuiltTime}}
112+
{{if .BuildOrigin -}}Built Origin:\t{{.BuildOrigin}}\n{{end -}}
111113
OS/Arch:\t{{.OsArch}}
112114
{{- end}}{{- end}}
113115
`

contrib/pkginstaller/package.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ PRODUCTSIGN_IDENTITY=${PRODUCTSIGN_IDENTITY:-mock}
99
NO_CODESIGN=${NO_CODESIGN:-0}
1010
HELPER_BINARIES_DIR="/opt/podman/bin"
1111
MACHINE_POLICY_JSON_DIR="/opt/podman/config"
12+
BUILT_FOR="pkginstaller"
1213

1314
tmpBin="contrib/pkginstaller/tmp-bin"
1415

@@ -42,7 +43,7 @@ function build_podman() {
4243
}
4344

4445
function build_podman_arch(){
45-
make -B GOARCH="$1" podman-remote HELPER_BINARIES_DIR="${HELPER_BINARIES_DIR}"
46+
make -B GOARCH="$1" podman-remote HELPER_BINARIES_DIR="${HELPER_BINARIES_DIR}" BUILT_FOR="${BUILT_FOR}"
4647
make -B GOARCH="$1" podman-mac-helper
4748
mkdir -p "${tmpBin}"
4849
cp bin/darwin/podman "${tmpBin}/podman-$1"

libpod/define/version.go

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,22 @@ var (
1616
// BuildInfo is the time at which the binary was built
1717
// It will be populated by the Makefile.
1818
buildInfo string
19+
// BuildOrigin is the packager of the binary.
20+
// It will be populated at build-time.
21+
buildOrigin string
1922
)
2023

2124
// Version is an output struct for API
2225
type Version struct {
23-
APIVersion string
24-
Version string
25-
GoVersion string
26-
GitCommit string
27-
BuiltTime string
28-
Built int64
29-
OsArch string
30-
Os string
26+
APIVersion string
27+
Version string
28+
GoVersion string
29+
GitCommit string
30+
BuiltTime string
31+
Built int64
32+
BuildOrigin string `json:",omitempty" yaml:",omitempty"`
33+
OsArch string
34+
Os string
3135
}
3236

3337
// GetVersion returns a VersionOutput struct for API and podman
@@ -43,13 +47,14 @@ func GetVersion() (Version, error) {
4347
}
4448
}
4549
return Version{
46-
APIVersion: version.APIVersion[version.Libpod][version.CurrentAPI].String(),
47-
Version: version.Version.String(),
48-
GoVersion: runtime.Version(),
49-
GitCommit: gitCommit,
50-
BuiltTime: time.Unix(buildTime, 0).Format(time.ANSIC),
51-
Built: buildTime,
52-
OsArch: runtime.GOOS + "/" + runtime.GOARCH,
53-
Os: runtime.GOOS,
50+
APIVersion: version.APIVersion[version.Libpod][version.CurrentAPI].String(),
51+
Version: version.Version.String(),
52+
GoVersion: runtime.Version(),
53+
GitCommit: gitCommit,
54+
BuiltTime: time.Unix(buildTime, 0).Format(time.ANSIC),
55+
Built: buildTime,
56+
BuildOrigin: buildOrigin,
57+
OsArch: runtime.GOOS + "/" + runtime.GOARCH,
58+
Os: runtime.GOOS,
5459
}, nil
5560
}

0 commit comments

Comments
 (0)