Skip to content
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

Display Linux variant at ./configure time #1928

Closed
wants to merge 6 commits into from

Conversation

kinkie
Copy link
Contributor

@kinkie kinkie commented Oct 30, 2024

Linux standards offer an /etc/os-release file containing
information about the operating system.

Parse that file and print an identifier of the Linux version at
configure time.

@kinkie
Copy link
Contributor Author

kinkie commented Oct 30, 2024

Sample output:

CenOS Stream 9

checking simplified host os... linux (version )
configure: Building on CentOS Stream 9
checking for gcc... ccache gcc

Debian Trixie

checking build system type... x86_64-pc-linux-gnux32
checking host system type... x86_64-pc-linux-gnux32
checking simplified host os... linux (version 32)
configure: Building on Debian GNU/Linux trixie/sid
checking for gcc... ccache gcc

Ubuntu Noble

checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking simplified host os... linux (version )
configure: Building on Ubuntu 24.04.1 LTS
checking for gcc... ccache gcc

Gentoo

checking host system type... i686-pc-linux-gnu
checking simplified host os... linux (version )
configure: Building on Gentoo Linux
checking for gcc... ccache gcc

MacOS

checking host system type... aarch64-apple-darwin24.1.0
checking simplified host os... darwin (version 24.1.0)
checking for gcc... gcc

kinkie and others added 2 commits October 31, 2024 12:43
* In Autoconf, _cv_ "Indicates that this shell variable is a cache value".
* /etc/os-release may be Linux-specific, but our code is not.
* This is `build` info (as opposed to `host` or `target`).
* Match os-release source instead of introducing "distro name".
* Removed excessive empty lines.
@rousskov rousskov changed the title Display Linux variant at configure time Display Linux variant at ./configure time Oct 31, 2024
Copy link
Contributor

@rousskov rousskov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this addition! I am sure this code can be enhanced to cover other OSes, but we do not have to do that in this PR.

While those grep commands can be merged into one and sed commands can be removed using unportable grep features like grep -P (available on Linux), keeping that part of code more portable might help in future enhancements.

I adjusted PR title to reduce "configuration" ambiguity and committed minor polishing touches. Please adjust further as needed -- I only insist on _cv_ removal.

@rousskov rousskov added S-waiting-for-author author action is expected (and usually required) S-could-use-an-approval An approval may speed this PR merger (but is not required) labels Oct 31, 2024
@kinkie
Copy link
Contributor Author

kinkie commented Oct 31, 2024

Thank you for this addition! I am sure this code can be enhanced to cover other OSes, but we do not have to do that in this PR.

While those grep commands can be merged into one and sed commands can be removed using unportable grep features like grep -P (available on Linux), keeping that part of code more portable might help in future enhancements.

I thought about it, but that wouldn't work:

$ grep NAME /etc/os-release
PRETTY_NAME="Ubuntu 24.04 LTS"
NAME="Ubuntu"
VERSION_CODENAME=noble
UBUNTU_CODENAME=noble

There really is no standardisation on the contents of /etc/os-release, it seems.
In other words, matching on "NAME=" would yield two lines on ubuntu, and we may make no assumptions about their order. Other distros do not provide a PRETTY_NAME at all.

We really need a logic like "try PRETTY_NAME, and if not available fall back on NAME"

I adjusted PR title to reduce "configuration" ambiguity and committed minor polishing touches. Please adjust further as needed -- I only insist on _cv_ removal.

I don't think coverin gother OSes will be necessary, they should be already covered by the "simplified host os" line above.

@kinkie kinkie added M-cleared-for-merge https://github.com/measurement-factory/anubis#pull-request-labels backport-to-v6 maintainer has approved these changes for v6 backporting and removed S-waiting-for-author author action is expected (and usually required) labels Oct 31, 2024
@rousskov
Copy link
Contributor

I don't think coverin gother OSes will be necessary, they should be already covered by the "simplified host os" line above.

This is not my area of expertise. I am happy to assume that you are right. Do you want to try to remove those sed calls using non-portable Linux tricks? If not, then there is nothing else to do here.

@kinkie
Copy link
Contributor Author

kinkie commented Oct 31, 2024

I don't think coverin gother OSes will be necessary, they should be already covered by the "simplified host os" line above.

This is not my area of expertise. I am happy to assume that you are right. Do you want to try to remove those sed calls using non-portable Linux tricks? If not, then there is nothing else to do here.

Nah, I'd leave as-is. We still want to adhere to best autoconf practices and make least assumptions possible on the host system.

squid-anubis pushed a commit that referenced this pull request Nov 1, 2024
Linux standards offer an /etc/os-release file containing
information about the operating system.

Parse that file and print an identifier of the Linux version at
configure time.
@squid-anubis squid-anubis added the M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels label Nov 1, 2024
@squid-anubis squid-anubis added M-merged https://github.com/measurement-factory/anubis#pull-request-labels and removed M-waiting-staging-checks https://github.com/measurement-factory/anubis#pull-request-labels M-cleared-for-merge https://github.com/measurement-factory/anubis#pull-request-labels labels Nov 1, 2024
squidadm pushed a commit to squidadm/squid that referenced this pull request Nov 2, 2024
Linux standards offer an /etc/os-release file containing
information about the operating system.

Parse that file and print an identifier of the Linux version at
configure time.
yadij pushed a commit that referenced this pull request Nov 2, 2024
Linux standards offer an /etc/os-release file containing
information about the operating system.

Parse that file and print an identifier of the Linux version at
configure time.
@yadij yadij removed backport-to-v6 maintainer has approved these changes for v6 backporting S-could-use-an-approval An approval may speed this PR merger (but is not required) labels Nov 2, 2024
@yadij
Copy link
Contributor

yadij commented Nov 2, 2024

Backported for 6.12

kinkie added a commit to kinkie/squid that referenced this pull request Nov 4, 2024
Linux standards offer an /etc/os-release file containing
information about the operating system.

Parse that file and print an identifier of the Linux version at
configure time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M-merged https://github.com/measurement-factory/anubis#pull-request-labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants