-
Notifications
You must be signed in to change notification settings - Fork 220
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
profile.d: don't try to source non-existent os-release file #1475
base: main
Are you sure you want to change the base?
Conversation
When /etc/os-release does not exist we directly try to source /usr/lib/os-release. This causes a 'No such file or directory' error when entering a toolbox which has neither. Fix this by checking for the presence of /usr/lib/os-release before sourcing it, just like what is done for /etc/os-release. Signed-off-by: Patrick Talbert <[email protected]>
Build failed. ✔️ unit-test SUCCESS in 4m 57s |
@ptalbert should it set some defaults for the expected variables that now are unset? |
On Tue, Apr 2, 2024 at 5:49 PM Michael Hofmann ***@***.***> wrote:
@ptalbert <https://github.com/ptalbert> should it set some defaults for
the expected variables that now are unset?
I don't see this script doing anything special which requires some default
value. In the case where neither os-release file exists the behaviour of
the script will not be any different after this change.
… —
Reply to this email directly, view it on GitHub
<#1475 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABQY3SB6SOHTYNC4VLS5NGDY3LHPNAVCNFSM6AAAAABFTGNLVGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZSGQZDMNZUGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
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.
Welcome to Toolbx! :)
It's true that the complete absence of os-release(5)
makes no difference to the profile.d/toolbox.sh
snippet as it's today. However, the toolbox(1)
binary does make extensive use of os-release(5)
for some critical logic.
The toolbox(1)
binary currently uses the github.com/acobaugh/osrelease Go module to parse os-release(5)
and it has the same structure as the profile.d/toolbox.sh
snippet. ie., /etc/os-release
may be missing, but it somewhat assumes that /usr/lib/os-release
is present. eg., there's no fallback to linux
if ID
is absent.
Therefore, if we are going to make changes to support set-ups without any os-release(5)
, we need to ensure that the whole thing, including the binary and the snippet, works. This brings me to the question: how did you end up without any os-release(5)
?
By using a RHEL6-based container image 😂. But if this is really going to ripple through multiple pieces of code here, maybe it would be easier to just fake an os-release file in the container image -> https://gitlab.com/cki-project/containers/-/merge_requests/539 |
@debarshiray like Michael said, I noticed this when using a rhel6 container image with toolbox. Every time you enter the toolbox (or source your profile in the container) there is this warning about a missing /usr/lib/os-release. For our purposes I am happy to take Michael's solution but maybe there are a few unrelated people out there using toolbox with containers that predate os-release 🤷. If there is something else I can test please let me know. |
When /etc/os-release does not exist we directly try to source /usr/lib/os-release. This causes a 'No such file or directory' error when entering a toolbox which has neither.
Fix this by checking for the presence of /usr/lib/os-release before sourcing it, just like what is done for /etc/os-release.