Add support to detect BSD systems. Thanks to Gavrilin Andrey <gaal.dev@gmail.com...
authorOtavio Salvador <otavio@debian.org>
Fri, 24 Feb 2012 01:11:11 +0000 (23:11 -0200)
committerOtavio Salvador <otavio@debian.org>
Fri, 24 Feb 2012 01:11:11 +0000 (23:11 -0200)
debian/changelog
os-probes/common/50mounted-tests
os-probes/mounted/common/90bsd-distro [new file with mode: 0755]

index d5e4493..2e52ce0 100644 (file)
@@ -1,11 +1,16 @@
 os-prober (1.50) UNRELEASED; urgency=low
 
+  [ Joey Hess ]
   * Clarify license version is GPL-2+, for all code written by Joey
     Hess, Colin Watson, Christian Perrier, Otavio Salvador and
     Joshua Kwan. The license had just been "GNU GPL"; other contributors
     to os-prober are encouraged to clarify which GPL versions apply to
     their code.
 
+  [ Otavio Salvador ]
+  * Add support to detect BSD systems. Thanks to Gavrilin Andrey
+    <gaal.dev@gmail.com> for the patch (refs: #659208).
+
  -- Joey Hess <joeyh@debian.org>  Tue, 13 Dec 2011 17:54:33 -0400
 
 os-prober (1.49) unstable; urgency=low
index 7865b51..9d878c0 100755 (executable)
@@ -54,9 +54,20 @@ if which grub-mount >/dev/null 2>&1 && \
 else
        ro_partition "$partition"
        for type in $types $delaytypes; do
-               if mount -o ro -t "$type" "$partition" "$tmpmnt" 2>/dev/null; then
+               if [ "$type" = ufs ]; then
+                       for ufstype in ufs2 44bsd; do
+                               if mount -o ro,ufstype=$ufstype -t "$type" "$partition" "$tmpmnt" 2>/dev/null; then
+                                       mounted=1
+                               fi
+                       done
+               else
+                       if mount -o ro -t "$type" "$partition" "$tmpmnt" 2>/dev/null; then
+                               mounted=1
+                       fi
+               fi
+
+               if [ "$mounted" ]; then
                        debug "mounted as $type filesystem"
-                       mounted=1
                        break
                fi
        done
diff --git a/os-probes/mounted/common/90bsd-distro b/os-probes/mounted/common/90bsd-distro
new file mode 100755 (executable)
index 0000000..b190aab
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/sh
+# Test for *BSD distributions.
+set -e
+
+. /usr/share/os-prober/common.sh
+
+partition="$1"
+dir="$2"
+type="$3"
+
+if [ "$type" = ufs ]; then
+  disk=$(echo $partition | gawk '{ match($0, /([[:alpha:][:punct:]]+)[[:digit:]]+/, disk); print disk[1] }')
+
+  if [ ! -z "$disk" ]; then
+    tpartition=$(echo $partition | sed 's|\/|\\/|g')
+
+    system=$(fdisk -l $disk | awk '/'$tpartition'[[:blank:]]+\*[[:blank:]]+.+[[:blank:]]+.+BSD/ {print $7}')
+
+    if [ ! -z "$system" ]; then
+      title=
+
+      if [ -f $dir/etc/motd ]; then
+        case $system in
+        FreeBSD | NetBSD | OpenBSD) title=$(cat $dir/etc/motd | gawk '{ match($0, /('$system')[[:blank:]]+([[:graph:]]+)[[:blank:]]+(\([[:print:]]+\))/, title); print title[1], title[2], title[3]; exit 0}')
+                                    ;;
+        esac
+      fi
+
+      if [ -z "$title" ]; then
+        title="$system"
+      fi
+
+      label="$(count_next_label "$system")"
+      echo "$partition:$title:$label:chain"
+
+      exit 0
+    else
+      exit 1
+    fi
+  else
+    exit 1
+  fi
+else
+  exit 1
+fi