Skip to content

Masquerade PopOS as Ubuntu #279

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

andrewswait
Copy link

@andrewswait andrewswait commented Apr 25, 2025

Issue: #277

Changes

PopOS is not supported by api.r-hub.io yet but it should essentially be the same as Ubuntu (in the context of installing R) so I'm masquerading it as that here.

Related

There's a workaround discussed here where you set the RIG_PLATFORM environment variable.

Before I came across that I was looking through the code and saw a tweak for opensuse-leap that seemed like precedent for adding some tweaks to actual vs extracted/determined distro. I've added a match and a simple test for this where you could add any number of other 'masquerade as' default rules to save people having to discover/set RIG_PLATFORM.

Issue: r-lib#277

PopOS is not supported by api.r-hub.io yet but PopOS is essentially just
Ubuntu (in the context of installing R) so we masquerade it as that.
@@ -742,6 +731,29 @@ pub fn detect_linux() -> Result<OsVersion, Box<dyn Error>> {
})
}

fn determine_id_from_os_release_contents(lines: &[String]) -> Result<String, Box<dyn Error>> {
Copy link
Author

Choose a reason for hiding this comment

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

I extracted this pretty much as it was just to demonstrate extraction of the PopOS distro name / ID from /etc/os-release contents.

@andrewswait
Copy link
Author

andrewswait commented Apr 25, 2025

@gaborcsardi I don't have permissions to add you as a reviewer so commenting instead.

The redhat build checks seem to be failing but this looks like some kind of OS registration issue.

If you like this PR (in principle at least) let me know if there's anything else you'd like added (e2e testing etc).

@gaborcsardi
Copy link
Member

Thanks! It would be nice to have a generic mechanism for this. PopOS has this, for 22.04 at least:

root@bfc97b39f8b1:~# cat /etc/os-release
NAME="Pop!_OS"
VERSION="22.04 LTS"
ID=pop
ID_LIKE="ubuntu debian"
PRETTY_NAME="Pop!_OS 22.04 LTS"
VERSION_ID="22.04"
HOME_URL="https://pop.system76.com"
SUPPORT_URL="https://support.system76.com"
BUG_REPORT_URL="https://github.com/pop-os/pop/issues"
PRIVACY_POLICY_URL="https://system76.com/privacy"
VERSION_CODENAME=jammy
UBUNTU_CODENAME=jammy
LOGO=distributor-logo-pop-os

So maybe we could parse the ID_LIKE field as well. I am not sure why they put both ubuntu and debian there, if it is based on ubuntu, but we can break on spaces and take the first expression.

The difficulty is that we would first try pop and fall back on ubuntu, which means that we would do two HTTP requests.

@andrewswait
Copy link
Author

So maybe we could parse the ID_LIKE field as well. I am not sure why they put both ubuntu and debian there, if it is based on ubuntu, but we can break on spaces and take the first expression.

Oh I like the idea of using ID_LIKE 👌🏻 I should have noticed that! The ID_LIKE definition here is:

"""
It should list identifiers of
operating systems that are closely related to the local
operating system in regards to packaging and programming
interfaces, for example listing one or more OS identifiers the
local OS is a derivative from. An OS should generally only
list other OS identifiers it itself is a derivative of, and
not any OSes that are derived from it, though symmetric
relationships are possible.
...
"""

That seems to fit the bill 👍🏻

The difficulty is that we would first try pop and fall back on ubuntu, which means that we would do two HTTP requests.

What if we just encode the list of officially supported distros as a constant and if we get an ID that doesn't fit those we fallback to using ID_LIKE? Then we still only do one HTTP request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants