aarnt / octoxbps

A Qt-based XBPS front end
GNU General Public License v2.0
73 stars 10 forks source link

Fix detection of Void Linux in getLinuxDistro #24

Closed dexgs closed 2 years ago

dexgs commented 2 years ago

Before this change, OctoXBPS detects Void Linux based on whether or not the string, PRETTY_NAME="void", occurs in the file, /etc/os-release. As of March 15 2022, the contents of /etc/os-release have been changed and PRETTY_NAME="Void Linux" replaces the previous value. (see https://github.com/void-linux/void-packages/commit/1dfc401d1237120e8e936627e7e28d2441916e80)

With this change, Void Linux is detected based on the value of ID in /etc/os-release which is less subject to change.

This change is important because OctoXBPS only checks for the existence of the local package db if it detects that it is running on either Void Linux or Trident Linux. If OctoXBPS does not detect that it is running on either distribution (which it doesn't without this change), it will prompt for elevated privileges in order to synchronize the local package database with the remote database using xbps-install -Syy every time it is started, regardless of whether or not there are remote changes that need to be synced.

Personally, I believe that it would be better to remove the distribution check from Package::hasXBPSDatabase as it eliminates this sort of error happening in the future and I don't understand what is gained from having it in the first place. However, that sort of thing is ultimately up to you as the maintainer of this project, so I have only included a fix for the current approach in this commit.

ahesford commented 2 years ago

This should definitely just be removed.

Getting it "right" without removal is a lot more complicated, because single or double quotes are optional for a single word like "void". Also note that the use of ID_LIKE is fairly common, so something like Project Trident may well have decided to set ID=trident but ID_LIKE=void. Some other descendant may arise in the future and take the same course. While this may not be in the official spec, its widespread use means it probably ought to be acknowledged.

cf. https://www.linux.org/docs/man5/os-release.html

0x5c commented 2 years ago

While this may not be in the official spec, its widespread use means it probably ought to be acknowledged.

It is part of the spec now, the version on linux.org is ancient, dating from 2015 (systemd 219) https://www.freedesktop.org/software/systemd/man/os-release.html

dexgs commented 2 years ago

I think it's worth noting that Project Trident is shutting down, meaning the distribution check can be fully removed.