inspect: use check_tests also for detecting Hurd

Even though the list of checks is very short, at least this migrates
from imperative checks to a "declarative" one.

There should be no behaviour change, other than using os-release if it
contains all the needed information.
This commit is contained in:
Pino Toscano
2018-02-14 15:21:05 +01:00
parent eb4fbe96c9
commit 535a4471f3

View File

@@ -698,6 +698,17 @@ let rec check_openbsd_root mountable data =
and check_hostname_openbsd () =
check_hostname_from_file "/etc/myname"
let hurd_root_tests : tests = [
(* Newer distros include /etc/os-release which is reasonably
* standardized. This entry should be first.
*)
"/etc/os-release", parse_os_release;
"/etc/debian_version", parse_generic DISTRO_DEBIAN;
(* Arch Hurd also exists, but inconveniently it doesn't have
* the normal /etc/arch-release file. XXX
*)
]
(* The currently mounted device may be a Hurd root. Hurd has distros
* just like Linux.
*)
@@ -705,13 +716,7 @@ let rec check_hurd_root mountable data =
let os_type = OS_TYPE_HURD in
data.os_type <- Some os_type;
if Is.is_file "/etc/debian_version" ~followsymlinks:true then (
let distro = DISTRO_DEBIAN in
ignore (parse_generic distro "/etc/debian_version" data)
);
(* Arch Hurd also exists, but inconveniently it doesn't have
* the normal /etc/arch-release file. XXX
*)
check_tests data hurd_root_tests;
(* Determine the architecture. *)
data.arch <- check_architecture ();