Open Lynxiayel opened 7 years ago
Can you run: ls /etc/release cat /etc/release
I'll change to using the releases files to determine OS - it's "right", but requires more code.
In OpenSUSE, /etc/release
does not exist, the equivalent is named os-release, running cat /etc/os-release
gives the following:
NAME="openSUSE Tumbleweed"
# VERSION="20200118"
ID="opensuse-tumbleweed"
ID_LIKE="opensuse suse"
VERSION_ID="20200118"
PRETTY_NAME="openSUSE Tumbleweed"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:tumbleweed:20200118"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org/"
LOGO="distributor-logo"
If you want to use the release file to determine the host distro, I think a more usual practice might be using cat /etc/*release
, or maybe you could use lsb_release -si
the ostype is determined by the package management tools being used, eg. dpkg for debian, rpm for opensuse etc. But there are package converting tools like alien that exist, in which case there might be two package manage tools co-existing in the system, eg. dpkg and rpm can both exist.
In my case, I'm using openSUSE, which uses rpm, but I have installed alien, so dpkg also exist in my system. But in the determineos function, dpkg is checked first, so the ostype of mine is incorrected detected as deb-based.
Not sure how this case can be elegantly avoided so far, but I think we should be aware of this special situation.