Discussion:
uname vs /etc/os-release
James Hanley
2018-11-14 18:26:37 UTC
Permalink
uname doesn't (appear to) do it now, but should it extract information
from /etc/os-release for rendering?
-Jim
Eli Schwartz
2018-11-14 19:58:24 UTC
Permalink
Post by James Hanley
uname doesn't (appear to) do it now, but should it extract information
from /etc/os-release for rendering?
That's extremely linux specific, and coreutils uname doesn't do it
either. What's the point? This is supposed to describe the operating
system you are using, not the vendor of your package manager.
--
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User
Bernd Petrovitsch
2018-11-15 00:10:27 UTC
Permalink
Post by James Hanley
uname doesn't (appear to) do it now, but should it extract information
from /etc/os-release for rendering?
Why should it? What are you missing? Please bring something serious and
not just a wish/claim/..... Thank you.

In fact:
- /etc/os-release is just a text file in the filesystem which seems to
contains some information about the installed distribution (and I
don't if it exists outside of the Linux world).
- The `uname` binary (as in `man 1 uname`) uses the uname() sys-call (as
in `man 2 uname`) - `strace` it and see for yourself (and why didn't
you do this before?).

MfG,
Bernd
--
Bernd Petrovitsch Email : ***@petrovitsch.priv.at
LUGA : http://www.luga.at
Eli Schwartz
2018-11-15 01:54:56 UTC
Permalink
Post by Bernd Petrovitsch
Post by James Hanley
uname doesn't (appear to) do it now, but should it extract information
from /etc/os-release for rendering?
Why should it? What are you missing? Please bring something serious and
not just a wish/claim/..... Thank you.
- /etc/os-release is just a text file in the filesystem which seems to
contains some information about the installed distribution (and I
don't if it exists outside of the Linux world).
I'm fairly confident it does not exist outside of the Linux world. It's
a Freedesktop.org specification pushed by the developers of systemd.

If you know what non-Linux operating system you're using, then any
possible information you might want to find out will have one canonical
way to find it out, which I believe is usually by using `uname -r` as
the operating system version instead of the Linux kernel version...
Post by Bernd Petrovitsch
- The `uname` binary (as in `man 1 uname`) uses the uname() sys-call (as
in `man 2 uname`) - `strace` it and see for yourself (and why didn't
you do this before?).
MfG,
Bernd
The -o flag does indeed print a compile-time macro that does not come
from the uname() syscall, which for busybox is set in
CONFIG_UNAME_OSNAME, and for GNU coreutils is set via an autotools macro.

But you're correct in your main point which is that it has no useful
information.

As the help text for both uname executables indicates, it is the
*operating system* name. As you pointed out, /etc/os-release does not
contain the operating system name, it assumes the operating system is
already Linux, then provides information about which distributor
provided the specific compilation of the "Linux" operating system.

It would break the spec for the uname command to provide information
other than the operating system. This is independent of whether it uses
the uname() syscall to obtain the info.

...

I think the problem here is that many people are confused about what a
*distribution* of the "Linux operating system" is, and think that
different distributions are actually different operating systems to the
same degree that Windows and Linux and macOS and Solaris and the
different *BSDs etc. are different operating systems.
--
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User
Loading...