[PC-BSD Commits] r6172 - pcbsd/trunk/pc-sysinstall/backend-query

svn at pcbsd.org svn at pcbsd.org
Thu Feb 4 07:23:47 PST 2010


Author: kris
Date: 2010-02-04 07:23:47 -0800 (Thu, 04 Feb 2010)
New Revision: 6172

Modified:
   pcbsd/trunk/pc-sysinstall/backend-query/update-part-list.sh
Log:

Improved update partition detection routine, able to find PC-BSD partitions & Correctly identify freebsd version as well



Modified: pcbsd/trunk/pc-sysinstall/backend-query/update-part-list.sh
===================================================================
--- pcbsd/trunk/pc-sysinstall/backend-query/update-part-list.sh	2010-02-04 14:58:22 UTC (rev 6171)
+++ pcbsd/trunk/pc-sysinstall/backend-query/update-part-list.sh	2010-02-04 15:23:47 UTC (rev 6172)
@@ -4,57 +4,76 @@
 
 rm ${TMPDIR}/AvailUpgrades >/dev/null 2>/dev/null
 
-for i in `find -E /dev -regex '/dev/(ad|ar|aacd|mixd|mlyd|amrd|idad|twed|da)[0-9]+s[1-4]' -print 2>/dev/null`
+# Create our device listing
+SYSDISK="`sysctl kern.disks | cut -d ':' -f 2 | sed 's/^[ \t]*//'`"
+DEVS=""
+
+# Now loop through these devices, and list the disk drives
+for i in ${SYSDISK}
 do
-  # Set our flag that we have not found any mounts
-  FOUNDMNT="0"
-  ZROOT=""
 
-  if [ -e "${i}a.journal" ]
+  # Get the current device
+  DEV="${i}"
+  # Make sure we don't find any cd devices
+  echo "${DEV}" | grep -e "^acd[0-9]" -e "^cd[0-9]" -e "^scd[0-9]" >/dev/null 2>/dev/null
+  if [ "$?" != "0" ]
   then
-    mount ${i}a.journal ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
-    FOUNDMNT="1"
-  elif [ -e "${i}a" ]
-  then
-    mount ${i}a ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
-    FOUNDMNT="1"
+   DEVS="${DEVS} `ls /dev/${i}s*`" 
   fi
 
-  if [ "${FOUNDMNT}" = "1" ]
-  then
-   PART="${i}"
+done
 
-   # Check if this is a ZFS boot partition
-   cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep '^vfs.root.mountfrom="zfs:' >/dev/null 2>/dev/null
-   if [ "$?" = "0" ]
-   then
-      ZROOT="`cat ${FSMNT}/boot/loader.conf | grep vfs.root.mountfrom | cut -d '=' -f 2 | cut -d ':' -f 2 | cut -d '/' -f 1`"
-      umount ${FSMNT}
-      # Import the zfs pool now
-      zpool import -R ${FSMNT} -f ${ZROOT} >>${LOGOUT} 2>>${LOGOUT}
+for i in $DEVS
+do
+    # Set our flag that we have not found any mounts
+    FOUNDMNT="0"
+    ZROOT=""
 
-      # Now mount the root partition for ZFS
-      mount -t zfs ${ZROOT}/root ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
+    if [ -e "${i}a.journal" ]
+    then
+      mount ${i}a.journal ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
+      FOUNDMNT="1"
+    elif [ -e "${i}a" ]
+    then
+      mount ${i}a ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
+      FOUNDMNT="1"
+      fi
+
+    if [ "${FOUNDMNT}" = "1" ]
+    then
+      PART="${i}"
+
+      # Check if this is a ZFS boot partition
+      cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep '^vfs.root.mountfrom="zfs:' >/dev/null 2>/dev/null
+      if [ "$?" = "0" ]
+      then
+         ZROOT="`cat ${FSMNT}/boot/loader.conf | grep vfs.root.mountfrom | cut -d '=' -f 2 | cut -d ':' -f 2 | cut -d '/' -f 1`"
+         umount ${FSMNT} >/dev/null 2>/dev/null
+         # Import the zfs pool now
+         zpool import -R ${FSMNT} -f ${ZROOT} >>${LOGOUT} 2>>${LOGOUT}
+
+         # Now mount the root partition for ZFS
+         mount -t zfs ${ZROOT}/root ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
       
-      # Mount the bootdir now
-      mount ${PART}a ${FSMNT}/bootdir >>${LOGOUT} 2>>${LOGOUT}
+         # Mount the bootdir now
+         mount ${PART}a ${FSMNT}/bootdir >>${LOGOUT} 2>>${LOGOUT}
 
-      zfs mount -a >>${LOGOUT} 2>>${LOGOUT}
-   fi
+         zfs mount -a >>${LOGOUT} 2>>${LOGOUT}
+      fi
 
-   touch ${TMPDIR}/TempUMount
+      touch ${TMPDIR}/TempUMount
 
-   mount -t devfs devfs ${FSMNT}/dev
-   chroot ${FSMNT} /sbin/mount -a >>${LOGOUT} >>${LOGOUT}
+      mount -t devfs devfs ${FSMNT}/dev
+      chroot ${FSMNT} /sbin/mount -a >>${LOGOUT} 2>>${LOGOUT}
 
   
-# Now lets see what type of system we've found here
+      # Now lets see what type of system we've found here
 
-    # Create Script
-    echo '#!/bin/sh
+      # Create Script
+      echo '#!/bin/sh
 /etc/rc.d/ldconfig start
-PATH=\"/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/local/sbin\" ; export PATH
-LD_LIBRARY_PATH="/usr/local/lib:/usr/local/lib/qt4:/usr/local/kde4/lib" ; export LD_LIBRARY_PATH
+PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/PCBSD/local/bin" ; export PATH
+LD_LIBRARY_PATH="/usr/local/lib:/usr/local/lib/qt4:/usr/local/kde4/lib:/usr/PCBSD/local/lib:/usr/PCBSD/local/kde4/lib" ; export LD_LIBRARY_PATH
 
 which pbreg
 if [ "$?" = "0" ]
@@ -62,55 +81,55 @@
   pbreg get /PC-BSD/Version >/.pcver 2>/.pcver
 fi
 
-uname -r >/.fbver 2>/.fbver' >${FSMNT}/getver.sh 
+file /bin/sh | sed "s/for FreeBSD/#/" | cut -d "#" -f 2 | cut -d "," -f 1 >/.fbver 2>/.fbver' >${FSMNT}/getver.sh 
 
-    chmod 755 ${FSMNT}/getver.sh >>/dev/null 2>>/dev/null
-    chroot ${FSMNT} /getver.sh >>${LOGOUT} 2>>${LOGOUT}
-    PCVER="`cat ${FSMNT}/.pcver 2>/dev/null`"
-    FBVER="`cat ${FSMNT}/.fbver 2>/dev/null`"
+      chmod 755 ${FSMNT}/getver.sh >>/dev/null 2>>/dev/null
+      chroot ${FSMNT} /getver.sh >>${LOGOUT} 2>>${LOGOUT}
+      PCVER="`cat ${FSMNT}/.pcver 2>/dev/null`"
+      FBVER="`cat ${FSMNT}/.fbver 2>/dev/null`"
        
-    # Remove old files
-    rm ${FSMNT}/.pcver >/dev/null 2>/dev/null
-    rm ${FSMNT}/.fbver >/dev/null 2>/dev/null
-    rm ${FSMNT}/getver.sh 2>/dev/null 
+      # Remove old files
+      rm ${FSMNT}/.pcver >/dev/null 2>/dev/null
+      rm ${FSMNT}/.fbver >/dev/null 2>/dev/null
+      rm ${FSMNT}/getver.sh 2>/dev/null 
 
-    # Echo our found partition / version
-    if [ -z "${PCVER}" ]
-    then
-      echo "${i}: FreeBSD ${FBVER}"
-    else
-      echo "${i}: PC-BSD ${PCVER}"
-    fi
+      # Echo our found partition / version
+      if [ -z "${PCVER}" ]
+      then
+        echo "${i}: FreeBSD ${FBVER}"
+      else
+        echo "${i}: PC-BSD ${PCVER}"
+      fi
 
 
-    # If we are on ZFS, cleanup after the mount
-    if [ ! -z "${ZROOT}" ]
-    then
-      umount ${FSMNT}/bootdir >>${LOGOUT} 2>>${LOGOUT}
-      /bin/sh /tmp/TempUMount >>${LOGOUT} 2>>${LOGOUT}
+      # If we are on ZFS, cleanup after the mount
+      if [ ! -z "${ZROOT}" ]
+      then
+        umount ${FSMNT}/bootdir >>${LOGOUT} 2>>${LOGOUT}
+        /bin/sh /tmp/TempUMount >>${LOGOUT} 2>>${LOGOUT}
 
-      # Unmount any extra fs from the zfs pool
-      zfs unmount -a >>${LOGOUT} 2>>${LOGOUT}
+        # Unmount any extra fs from the zfs pool
+        zfs unmount -a >>${LOGOUT} 2>>${LOGOUT}
 
-      umount ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
-      rm /tmp/TempUMount >/dev/null 2>/dev/null
+        umount ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
+        rm /tmp/TempUMount >/dev/null 2>/dev/null
 
-      # Remount the bootdir to /mnt
-      mount ${PART}a ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
+        # Remount the bootdir to /mnt
+        mount ${PART}a ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
 
-      # Copy over our ZFS cache data
-      cp /boot/zfs/* ${FSMNT}/boot/zfs/ >>${LOGOUT} 2>>${LOGOUT}
+        # Copy over our ZFS cache data
+        cp /boot/zfs/* ${FSMNT}/boot/zfs/ >>${LOGOUT} 2>>${LOGOUT}
 
-      # Unmount the /bootdir partition again
-      umount ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
-    else
-      # Unmount FS
-      chroot ${FSMNT} /sbin/umount -a >>${LOGOUT} >>${LOGOUT}
-      umount ${FSMNT}/usr >>${LOGOUT} 2>>${LOGOUT}
-      umount ${FSMNT}/dev >>${LOGOUT} 2>>${LOGOUT}
-      umount ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
-    fi
+        # Unmount the /bootdir partition again
+        umount ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
+      else
+        # Unmount FS
+        chroot ${FSMNT} /sbin/umount -a >>${LOGOUT} 2>>${LOGOUT}
+        umount ${FSMNT}/usr >>${LOGOUT} 2>>${LOGOUT}
+        umount ${FSMNT}/dev >>${LOGOUT} 2>>${LOGOUT}
+        umount ${FSMNT} >>${LOGOUT} 2>>${LOGOUT}
+      fi
     
-  fi # End of if ${i}a
-     
+    fi # End of if ${i}a
+
 done



More information about the Commits mailing list