-
Notifications
You must be signed in to change notification settings - Fork 28
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
rpm2img: use latest rpm release for inventory #342
Conversation
twoliter/embedded/rpm2img
Outdated
sort -r -k 1,2 | \ | ||
head -n 1 | \ | ||
cut -d ' ' -f 3 | \ | ||
awk '/^1/{print $1}' | \ | ||
cut -d '.' -f 3)" |
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.
head
usage often leads to SIGPIPE since it doesn't keep reading from the pipe after a match, and we have -o pipefail
set.
I would just pass it to awk
after the initial sort:
sort -r -k 1,2 | \ | |
head -n 1 | \ | |
cut -d ' ' -f 3 | \ | |
awk '/^1/{print $1}' | \ | |
cut -d '.' -f 3)" | |
sort -r -k 1,2 | \ | |
awk -F '.' 'END {print $--NF}' )" |
and maybe add a check that CORE_KIT_GIT_SHA
is actually non-zero length.
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.
Nice, I really need to learn more awk
. Only modification I made here was to undo the -r
since we're grabbing the release from the last line instead of the first.
^ Makes suggestions from @bcressey. Still testing that the if statements catch the failure cases. |
echo "Extracted invalid Git sha from bottlerocket-core-kit: '${CORE_KIT_GIT_SHA}'" >&2 | ||
exit 1 | ||
fi | ||
|
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.
Description of changes:
In cases where Kits contained RPMs built from multiple git checkouts, the
Release
field in the inventory could be malformed.This always selects the most-recent release present for the inventory.
Testing done:
Before:
After:
I actually couldn't create a package with no BUILD_ID. RPM rejected it.
Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.