-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Makefile: Handle unexpected empty var. values #14435
Conversation
4f8b00b
to
593df42
Compare
Fixes containers#14021 Substitution values built from `$(shell ...)` output can easily be empty due to the shell's default `pipefail` behavior. This can also hide non-zero exit codes, similarly resulting in empty values being set. While not a perfect fix, the situation is improved by using the `err_if_empty` function in all cases where empty values would be unexpected. Remove the definitions for `GIT_BRANCH` and `GIT_BRANCH_CLEAN` which don't seem to actually be used anywhere (including in code). Add a simple release-test to verify `podman info` outputs a non-empty value for "GitCommit". Signed-off-by: Chris Evich <[email protected]>
Final review-note: I'm a little nervous about build-targets used outside of CI. I did not check/test any of them 😨 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole thing makes me super uncomfortable. I don't understand its ramifications. I don't understand why only some vars get the err_if_empty
treatment.
I did run make
with my .git
subdirectory renamed, and confirmed that it still builds; but I don't know what else to test. I'd like to see the scope of this PR reduced to a reasonably small bare minimum, then give it a month or two (including releases and bodhi builds) before getting aggressive with TMPDIR
and GOOS
and _HLP_whatever
. But that's just a preference, and I won't block because of it.
DATE_FMT = %s | ||
ifdef SOURCE_DATE_EPOCH | ||
BUILD_INFO ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u "+$(DATE_FMT)") | ||
BUILD_INFO ?= $(shell date -u -d "@$(call err_if_empty,SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+$(DATE_FMT)" 2>/dev/null || date -u "+$(DATE_FMT)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the ifdef
just above, isn't this change unnecessary (and hence misleading)?
$(if $(GIT_COMMIT),-X $(LIBPOD)/define.gitCommit=$(GIT_COMMIT),) \ | ||
$(if $(BUILD_INFO),-X $(LIBPOD)/define.buildInfo=$(BUILD_INFO),) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Empty define.X=
seems harmless, and has been working for many years, and is actually pretty clean and easy to read... so I'd be inclined to just revert this change, leaving it as it was
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, thanks. I was unsure of it as well.
$(MAKE) podman-v$(call err_if_empty,RELEASE_NUMBER).msi | ||
podman-v%.msi: test/version/version podman-remote-windows podman-remote-windows-docs podman-winpath win-sshproxy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no way to review Windows code. @n1hility are you our Windows expert? Could you bless this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure looks fine, will test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
everything passes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW: We do actually publish the latest test-builds of this MSI (among other binaries). It's available from https://api.cirrus-ci.com/v1/artifact/github/containers/podman/artifacts/binary/podman-<version>.msi
Currently <version> is v4.2.0-dev
. Though the build is out of date due to a problem I'm working on fixing elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah thanks! good to know
Oh, that's simple to answer, it relates to #14021. We only need to check cases where a
I'm not sure how to do both that, and fix #14021 😞 |
Ok then. Fingers crossed, then. /lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cevich, n1hility, rhatdan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Aye 😞 sometimes that's all there is to do. But a fix could be one revert away 😁 Thanks for reviewing, I do appreciate it. |
Fixes #14021
Substitution values built from
$(shell ...)
output can easily be emptydue to the shell's default
pipefail
behavior. This can also hidenon-zero exit codes, similarly resulting in empty values being set.
While not a perfect fix, the situation is improved by using the
err_if_empty
function in all cases where empty values would beunexpected. Also remove the definitions for
GIT_BRANCH
andGIT_BRANCH_CLEAN
which don't seem to actually be used anywhere(including in code).
Does this PR introduce a user-facing change?