makefiles/utils/strings.mk: Fix version_is_greater_or_equal [backport 2023.01]#19135
Merged
bors[bot] merged 1 commit intoRIOT-OS:2023.01-branchfrom Jan 13, 2023
Conversation
The Makefile function `version_is_greater_or_equal` is used to check if a version of GNU Make is at least the required one. However, it has the built-in assumption the version numbers have to format x.y.z, but Alpine Linux currently ships GNU Make 4.4. This results in `$(call _pad_number,3,)` which runs `printf '$03d' ''` in the shell, which is not valid. This fixes the issue by making `_pad_number` more robust by fall back to printing `0` with the given padding, if the number given to print is empty. (cherry picked from commit 8c055f0)
kaspar030
approved these changes
Jan 12, 2023
Contributor
kaspar030
left a comment
There was a problem hiding this comment.
backport-ACK.
bors merge
Contributor
|
🕐 Waiting for PR status (GitHub check) to be set, probably by CI. Bors will automatically try to run when all required PR statuses are set. |
Contributor
|
bors merge |
Contributor
|
Already running a review |
Contributor
|
bors cancel |
Contributor
|
Canceled. |
Contributor
|
bors merge |
Contributor
|
Already running a review |
bors bot
added a commit
that referenced
this pull request
Jan 13, 2023
19135: makefiles/utils/strings.mk: Fix version_is_greater_or_equal [backport 2023.01] r=benpicco a=maribu # Backport of #19133 ### Contribution description The Makefile function `version_is_greater_or_equal` is used to check if a version of GNU Make is at least the required one. However, it has the built-in assumption the version numbers have to format x.y.z, but Alpine Linux currently ships GNU Make 4.4. This results in `$(call _pad_number,3,)` which runs `printf '$03d' ''` in the shell, which is not valid. This fixes the issue by making `_pad_number` more robust by fall back to printing `0` with the given padding, if the number given to print is empty. ### Testing procedure Append ```Makefile $(info A=$(call version_is_greater_or_equal,4.2.0,4.2.0)) $(info B=$(call version_is_greater_or_equal,4.2,4.2.0)) $(info C=$(call version_is_greater_or_equal,4.1,4.2.0)) $(info D=$(call version_is_greater_or_equal,4.1.9,4.2.0)) $(info E=$(call version_is_greater_or_equal,5.1.9,4.2.0)) $(info F=$(call version_is_greater_or_equal,5.0.0,4.2.0)) $(info G=$(call version_is_greater_or_equal,4.2.1,4.2.0)) $(info H=$(call version_is_greater_or_equal,4.3.1,4.2.0)) ``` e.g. to `makefiles/utils/strings.mk`, build something and observe the info output. This yields ``` A=1 B=1 C= D= E=1 F=1 G=1 H=1 ``` for me and does not complain about invalid `printf` invocations. ### Issues/PRs references None Co-authored-by: Marian Buschsieweke <[email protected]>
Contributor
|
bors cancel |
Contributor
|
Canceled. |
Contributor
|
Build succeeded: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #19133
Contribution description
The Makefile function
version_is_greater_or_equalis used to check if a version of GNU Make is at least the required one. However, it has the built-in assumption the version numbers have to format x.y.z, but Alpine Linux currently ships GNU Make 4.4. This results in$(call _pad_number,3,)which runsprintf '$03d' ''in the shell, which is not valid.This fixes the issue by making
_pad_numbermore robust by fall back to printing0with the given padding, if the number given to print is empty.Testing procedure
Append
e.g. to
makefiles/utils/strings.mk, build something and observe the info output.This yields
for me and does not complain about invalid
printfinvocations.Issues/PRs references
None