Skip to content
This repository was archived by the owner on Jun 28, 2024. It is now read-only.
This repository was archived by the owner on Jun 28, 2024. It is now read-only.

improve robustness of source /etc/os-release #589

@grahamwhaley

Description

@grahamwhaley

We use source /etc/os-release a lot across the repos to check which distro we are on for packaging, testing etc.
According to man os-release (visible at https://www.freedesktop.org/software/systemd/man/os-release.html):

The file /etc/os-release takes precedence over /usr/lib/os-release. Applications should check for the former, and exclusively use its data if it exists, and only fall back to /usr/lib/os-release if it is missing. Applications should not read data from both files at the same time. /usr/lib/os-release is the recommended place to store OS release information as part of vendor trees. /etc/os-release should be a relative symlink to /usr/lib/os-release, to provide compatibility with applications only looking at /etc. A relative symlink instead of an absolute symlink is necessary to avoid breaking the link in a chroot or initrd environment such as dracut.

Thus, I think we should try to source from /etc/os-release, and if that fails then we should try /usr/lib/os-release. Right now we only go to /etc.
This is not a problem for the distros we run on today, but may be in the future.

I wonder if:

source /etc/os-release || source /usr/lib/os-release

would work? If not, we might have to write a little helper func in the global shell lib.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions