Commit d14d0c1a authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab Committed by Jonathan Corbet

scripts: sphinx-pre-install: improve distro detection check

The Arch-linux detection is hit by catting /etc/issue, whose
contents is (nowadays):

	Arch Linux \r (\l)

It sounds a little ackward to print such string, so,
instead, let's use the /etc/os-release file, with exists
on lots of distributions and should provide a more reliable
result.

We'll keep the old tests before it, in order to avoid possible
regressions with the other distros, although the new way should
probably work on all the currently supported distributions.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/472924557afdf2b5492ae2a48c5ecfae216d54e2.1586883286.git.mchehab+huawei@kernel.orgSigned-off-by: default avatarJonathan Corbet <corbet@lwn.net>
parent d98dbbe0
...@@ -780,6 +780,24 @@ $system_release = catcheck("/etc/system-release") if !$system_release; ...@@ -780,6 +780,24 @@ $system_release = catcheck("/etc/system-release") if !$system_release;
$system_release = catcheck("/etc/redhat-release") if !$system_release; $system_release = catcheck("/etc/redhat-release") if !$system_release;
$system_release = catcheck("/etc/lsb-release") if !$system_release; $system_release = catcheck("/etc/lsb-release") if !$system_release;
$system_release = catcheck("/etc/gentoo-release") if !$system_release; $system_release = catcheck("/etc/gentoo-release") if !$system_release;
# This seems more common than LSB these days
if (!$system_release) {
my %os_var;
if (open IN, "cat /etc/os-release|") {
while (<IN>) {
if (m/^([\w\d\_]+)=\"?([^\"]*)\"?\n/) {
$os_var{$1}=$2;
}
}
$system_release = $os_var{"NAME"};
if (defined($os_var{"VERSION_ID"})) {
$system_release .= " " . $os_var{"VERSION_ID"} if (defined($os_var{"VERSION_ID"}));
} else {
$system_release .= " " . $os_var{"VERSION"};
}
}
}
$system_release = catcheck("/etc/issue") if !$system_release; $system_release = catcheck("/etc/issue") if !$system_release;
$system_release =~ s/\s+$//; $system_release =~ s/\s+$//;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment