Add os-release support
authorColin Watson <cjwatson@debian.org>
Fri, 20 Jan 2017 02:02:06 +0000 (02:02 +0000)
committerColin Watson <cjwatson@debian.org>
Fri, 20 Jan 2017 02:02:06 +0000 (02:02 +0000)
Based loosely on a patch by Török Edwin.

Closes: #794409

debian/changelog
os-probes/mounted/common/90linux-distro

index 1d6d389..f5f7747 100644 (file)
@@ -25,6 +25,8 @@ os-prober (1.72) UNRELEASED; urgency=medium
     Vatankhah; part of #694668).
   * Call dmraid only once (thanks, Jeff Mahoney).
   * Fix typos in README (thanks, Nyav; closes: #803155).
+  * Add os-release support (based loosely on a patch by Török Edwin; closes:
+    #794409).
 
  -- Colin Watson <cjwatson@debian.org>  Sat, 31 Dec 2016 17:11:49 +0000
 
index 54be364..854ead7 100755 (executable)
@@ -18,7 +18,10 @@ type="$3"
 # moved /lib* to /usr and only left symlinks behind.
 # TODO: look for ld-linux.so on arches that have it
 if (ls "$dir"/lib*/ld*.so* && [ -d "$dir/boot" ] || ls "$dir"/usr/lib*/ld*.so*) >/dev/null 2>/dev/null; then
-       if [ -e "$dir/etc/debian_version" ]; then
+       if [ -e "$dir/etc/os-release" ]; then
+               short="$(grep ^NAME= "$dir/etc/os-release" | sed 's/^[^=]*=//; s/^['\''"]\(.*\)['\''"]$/\1/; s/\\\(.\)/\1/g; s/[[:space:]].*//')"
+               long="$(grep ^PRETTY_NAME= "$dir/etc/os-release" | sed 's/^[^=]*=//; s/^['\''"]\(.*\)['\''"]$/\1/; s/\\\(.\)/\1/g')"
+       elif [ -e "$dir/etc/debian_version" ]; then
                short="Debian"
                long="$(printf "Debian GNU/Linux (%s)\n" "$(cat "$dir/etc/debian_version")")"
        # RPM derived distributions may also have a redhat-release or