svn commit: r212337 - in head/usr.sbin/pc-sysinstall: backend backend-query doc examples pc-sysinstall

Warner Losh imp at FreeBSD.org
Wed Sep 8 20:10:24 UTC 2010


Author: imp
Date: Wed Sep  8 20:10:24 2010
New Revision: 212337
URL: http://svn.freebsd.org/changeset/base/212337

Log:
  pc-sysinstall(8) patch that allows images to be written to disks
  
  This patch creates the "image" directive for the pc-sysinstall config
  file. This allows disks to be configured with an image instead of
  partitioning.
  
  PR:		150137
  Submitted by:	John Hixson

Modified:
  head/usr.sbin/pc-sysinstall/backend-query/disk-list.sh
  head/usr.sbin/pc-sysinstall/backend/Makefile
  head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
  head/usr.sbin/pc-sysinstall/backend/functions-disk.sh
  head/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh
  head/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh
  head/usr.sbin/pc-sysinstall/backend/functions-packages.sh
  head/usr.sbin/pc-sysinstall/backend/functions-parse.sh
  head/usr.sbin/pc-sysinstall/backend/functions.sh
  head/usr.sbin/pc-sysinstall/backend/parseconfig.sh
  head/usr.sbin/pc-sysinstall/doc/help-index
  head/usr.sbin/pc-sysinstall/examples/README
  head/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh

Modified: head/usr.sbin/pc-sysinstall/backend-query/disk-list.sh
==============================================================================
--- head/usr.sbin/pc-sysinstall/backend-query/disk-list.sh	Wed Sep  8 20:09:50 2010	(r212336)
+++ head/usr.sbin/pc-sysinstall/backend-query/disk-list.sh	Wed Sep  8 20:10:24 2010	(r212337)
@@ -27,6 +27,7 @@
 
 ARGS=$1
 FLAGS_MD=""
+FLAGS_CD=""
 FLAGS_VERBOSE=""
 
 shift
@@ -39,6 +40,9 @@ do
     -v)
       FLAGS_VERBOSE=1
       ;;
+    -c)
+      FLAGS_CD=1
+      ;;
   esac
   shift
 done
@@ -62,9 +66,12 @@ do
   DEV="${i}"
 
   # Make sure we don't find any cd devices
-  case "${DEV}" in
-    acd[0-9]*|cd[0-9]*|scd[0-9]*) continue ;;
-  esac
+  if [ -z "${FLAGS_CD}" ]
+  then
+    case "${DEV}" in
+      acd[0-9]*|cd[0-9]*|scd[0-9]*) continue ;;
+    esac
+  fi
 
   # Check the dmesg output for some more info about this device
   NEWLINE=$(dmesg | sed -n "s/^$DEV: .*<\(.*\)>.*$/ <\1>/p" | head -n 1)

Modified: head/usr.sbin/pc-sysinstall/backend/Makefile
==============================================================================
--- head/usr.sbin/pc-sysinstall/backend/Makefile	Wed Sep  8 20:09:50 2010	(r212336)
+++ head/usr.sbin/pc-sysinstall/backend/Makefile	Wed Sep  8 20:10:24 2010	(r212337)
@@ -7,7 +7,7 @@ FILES=	functions-bsdlabel.sh functions-c
 	functions-newfs.sh functions-packages.sh functions-parse.sh \
 	functions-runcommands.sh functions-unmount.sh \
 	functions-upgrade.sh functions-users.sh \
-	functions.sh parseconfig.sh startautoinstall.sh
+	functions.sh parseconfig.sh startautoinstall.sh installimage.sh
 FILESMODE=	${BINMODE}
 FILESDIR=${SHAREDIR}/pc-sysinstall/backend
 NO_OBJ=

Modified: head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
==============================================================================
--- head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh	Wed Sep  8 20:09:50 2010	(r212336)
+++ head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh	Wed Sep  8 20:10:24 2010	(r212337)
@@ -566,9 +566,8 @@ populate_disk_label()
 setup_disk_label()
 {
   # We are ready to start setting up the label, lets read the config and do the actions
-
   # First confirm that we have a valid WORKINGSLICES
-  if [ -z "${WORKINGSLICES}" ]; then
+  if [ -z "${WORKINGSLICES}" -a -z "${WORKINGIMAGES}" ]; then
     exit_err "ERROR: No slices were setup! Please report this to the maintainers"
   fi
 
@@ -613,6 +612,12 @@ setup_disk_label()
     populate_disk_label "${i}"
   done
 
+  for i in $WORKINGIMAGES
+  do
+    image=`echo "${i}"|cut -f2 -d:`
+    check_image_layout "${image}" 
+  done
+
   # Check if we made a root partition
   if [ "$FOUNDROOT" = "-1" ]
   then
@@ -631,3 +636,166 @@ setup_disk_label()
   fi
 };
 
+check_fstab_mbr()
+{
+  local SLICE
+  local FSTAB
+
+  if [ -z "$2" ]
+  then
+	return 1
+  fi
+
+  SLICE="$1"
+  FSTAB="$2/etc/fstab"
+
+  if [ -f "${FSTAB}" ]
+  then
+    PARTLETTER=`echo "$SLICE" | sed -E 's|^.+([a-h])$|\1|'`
+
+    grep -E '^.+ +/ +' "${FSTAB}" >/dev/null 2>&1
+    if [ "$?" = "0" ]
+    then
+      if [ "${PARTLETTER}" = "a" ]
+      then
+        FOUNDROOT="0"
+      else
+        FOUNDROOT="1"
+      fi
+      export FOUNDROOT
+    fi
+
+    grep -E '^.+ +/boot +' "${FSTAB}" >/dev/null 2>&1
+    if [ "$?" = "0" ]
+    then
+      if [ "${PARTLETTER}" = "a" ]
+      then
+        USINGBOOTPART="0"
+      else 
+        exit_err "/boot partition must be first partition"
+      fi 
+      export USINGBOOTPART
+    fi
+
+    return 0
+  fi
+
+  return 1
+};
+
+check_fstab_gpt()
+{
+  local SLICE
+  local FSTAB
+
+  if [ -z "$2" ]
+  then
+	return 1
+  fi
+
+  SLICE="$1"
+  FSTAB="$2/etc/fstab"
+
+  if [ -f "${FSTAB}" ]
+  then
+    PARTNUMBER=`echo "${SLICE}" | sed -E 's|^.+p([0-9]*)$|\1|'`
+
+    grep -E '^.+ +/ +' "${FSTAB}" >/dev/null 2>&1
+    if [ "$?" = "0" ]
+    then
+      if [ "${PARTNUMBER}" = "2" ]
+      then
+        FOUNDROOT="0"
+      else
+        FOUNDROOT="1"
+      fi
+      export FOUNDROOT
+    fi
+
+    grep -E '^.+ +/boot +' "${FSTAB}" >/dev/null 2>&1
+    if [ "$?" = "0" ]
+    then
+      if [ "${PARTNUMBER}" = "2" ]
+      then
+        USINGBOOTPART="0"
+      else 
+        exit_err "/boot partition must be first partition"
+      fi 
+      export USINGBOOTPART
+    fi
+
+    return 0
+  fi
+
+
+  return 1
+};
+
+check_image_layout()
+{
+  local SLICES
+  local IMAGE
+  local TYPE
+  local RES
+  local MD
+  local F
+
+  IMAGE="$1"
+  TYPE="MBR"
+
+  if [ -z "${IMAGE}" ]
+  then
+	return 1
+  fi
+
+  MD=`mdconfig -af "${IMAGE}"`
+  if [ "$?" != "0" ]
+  then
+	return 1
+  fi
+
+  SLICES=`ls /dev/${MD}s[1-4]*[a-h]* 2>/dev/null`
+  if [ "$?" != "0" ]
+  then
+    SLICES=`ls /dev/${MD}p[0-9]* 2>/dev/null`
+    if [ -n "${SLICES}" ]
+    then
+      TYPE="GPT"
+      RES=0
+    fi
+  else
+    RES=0
+  fi
+
+  for slice in ${SLICES}
+  do
+    F=1
+    mount ${slice} /mnt 2>/dev/null
+    if [ "$?" != "0" ]
+    then
+      continue
+    fi 
+
+    if [ "${TYPE}" = "MBR" ]
+    then
+	  check_fstab_mbr "${slice}" "/mnt"
+      F="$?"
+
+    elif [ "${TYPE}" = "GPT" ]
+    then
+	  check_fstab_gpt "${slice}" "/mnt"
+      F="$?"
+    fi 
+
+    if [ "${F}" = "0" ]
+    then
+      umount /mnt
+      break 
+    fi
+
+    umount /mnt
+  done
+
+  mdconfig -d -u "${MD}"
+  return ${RES}
+};

Modified: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh
==============================================================================
--- head/usr.sbin/pc-sysinstall/backend/functions-disk.sh	Wed Sep  8 20:09:50 2010	(r212336)
+++ head/usr.sbin/pc-sysinstall/backend/functions-disk.sh	Wed Sep  8 20:10:24 2010	(r212337)
@@ -231,9 +231,6 @@ get_disk_heads()
 get_disk_mediasize()
 {
   mediasize=`diskinfo -v ${1} | grep "# mediasize in sectors" | tr -s ' ' | cut -f 2`
-
-  # Not sure why this is, memory disks need it though.
-  mediasize=`expr ${mediasize} - 10`
   VAL="${mediasize}" ; export VAL
 };
 
@@ -336,164 +333,205 @@ setup_disk_slice()
   # We are ready to start setting up the disks, lets read the config and do the actions
   while read line
   do
-     echo $line | grep "^disk${disknum}=" >/dev/null 2>/dev/null
-     if [ "$?" = "0" ]
-     then
-
-       # Found a disk= entry, lets get the disk we are working on
-       get_value_from_string "${line}"
-       strip_white_space "$VAL"
-       DISK="$VAL"
+    echo $line | grep "^disk${disknum}=" >/dev/null 2>/dev/null
+    if [ "$?" = "0" ]
+    then
+
+      # Found a disk= entry, lets get the disk we are working on
+      get_value_from_string "${line}"
+      strip_white_space "$VAL"
+      DISK="$VAL"
      
-       # Before we go further, lets confirm this disk really exists
-       if [ ! -e "/dev/${DISK}" ]
-       then
-         exit_err "ERROR: The disk ${DISK} does not exist!"
-       fi
-
-       # Make sure we stop any gmirrors on this disk
-       stop_all_gmirror ${DISK}
-
-       # Make sure we stop any geli stuff on this disk
-       stop_all_geli ${DISK}
-
-       # Make sure we don't have any zpools loaded
-       stop_all_zfs
-
-     fi
-
-     # Lets look if this device will be mirrored on another disk
-     echo $line | grep "^mirror=" >/dev/null 2>/dev/null
-     if [ "$?" = "0" ]
-     then
-
-       # Found a disk= entry, lets get the disk we are working on
-       get_value_from_string "${line}"
-       strip_white_space "$VAL"
-       MIRRORDISK="$VAL"
+      # Before we go further, lets confirm this disk really exists
+      if [ ! -e "/dev/${DISK}" ]
+      then
+        exit_err "ERROR: The disk ${DISK} does not exist!"
+      fi
+
+      # Make sure we stop any gmirrors on this disk
+      stop_all_gmirror ${DISK}
+
+      # Make sure we stop any geli stuff on this disk
+      stop_all_geli ${DISK}
+
+      # Make sure we don't have any zpools loaded
+      stop_all_zfs
+
+    fi
+
+    # Lets look if this device will be mirrored on another disk
+    echo $line | grep "^mirror=" >/dev/null 2>/dev/null
+    if [ "$?" = "0" ]
+    then
+
+      # Found a disk= entry, lets get the disk we are working on
+      get_value_from_string "${line}"
+      strip_white_space "$VAL"
+      MIRRORDISK="$VAL"
      
-       # Before we go further, lets confirm this disk really exists
-       if [ ! -e "/dev/${MIRRORDISK}" ]
-       then
-         exit_err "ERROR: The mirror disk ${MIRRORDISK} does not exist!"
-       fi
-     fi
-
-     # Lets see if we have been given a mirror balance choice
-     echo $line | grep "^mirrorbal=" >/dev/null 2>/dev/null
-     if [ "$?" = "0" ]
-     then
-
-       # Found a disk= entry, lets get the disk we are working on
-       get_value_from_string "${line}"
-       strip_white_space "$VAL"
-       MIRRORBAL="$VAL"
-     fi
-
-     echo $line | grep "^partition=" >/dev/null 2>/dev/null
-     if [ "$?" = "0" ]
-     then
-       # Found a partition= entry, lets read / set it 
-       get_value_from_string "${line}"
-       strip_white_space "$VAL"
-       PTYPE="$VAL"
-
-       # We are using free space, figure out the slice number
-       if [ "${PTYPE}" = "free" -o "${PTYPE}" = "FREE" ]
-       then
-         # Lets figure out what number this slice will be
-         LASTSLICE="`gpart show ${DISK} | grep -v ${DISK} | grep -v ' free' |tr -s '\t' ' ' | cut -d ' ' -f 4 | sed '/^$/d' | tail -n 1`"
-         if [ -z "${LASTSLICE}" ]
-         then
-           LASTSLICE="1"
-         else
-           LASTSLICE="`expr $LASTSLICE + 1`"
-         fi
-
-         if [ $LASTSLICE -gt 4 ]
-         then
-           exit_err "ERROR: BSD only supports primary partitions, and there are none availble on $DISK"
-         fi
-
-       fi
-     fi
-
-     # Check if we have a partscheme specified
-     echo $line | grep "^partscheme=" >/dev/null 2>/dev/null
-     if [ "$?" = "0" ] ; then
-       # Found a partscheme= entry, lets read / set it 
-       get_value_from_string "${line}"
-       strip_white_space "$VAL"
-       PSCHEME="$VAL"
-       if [ "$PSCHEME" != "GPT" -a "$PSCHEME" != "MBR" ] ; then
-	 exit_err "Unknown partition scheme: $PSCHEME" 
-       fi
-     fi
-
-     echo $line | grep "^bootManager=" >/dev/null 2>/dev/null
-     if [ "$?" = "0" ]
-     then
-       # Found a bootManager= entry, lets read /set it
-       get_value_from_string "${line}"
-       strip_white_space "$VAL"
-       BMANAGER="$VAL"
-     fi
-
-     echo $line | grep "^commitDiskPart" >/dev/null 2>/dev/null
-     if [ "$?" = "0" ]
-     then
-       # Found our flag to commit this disk setup / lets do sanity check and do it
-       if [ ! -z "${DISK}" -a ! -z "${PTYPE}" ]
-       then
-         case ${PTYPE} in
-           all|ALL)
-		     if [ "$PSCHEME" = "MBR" -o -z "$PSCHEME" ] ; then
-               PSCHEME="MBR"
-               tmpSLICE="${DISK}s1"  
-			 else
-               tmpSLICE="${DISK}p1"  
-			 fi
-
-             run_gpart_full "${DISK}" "${BMANAGER}" "${PSCHEME}"
-			 ;;
-
-           s1|s2|s3|s4)
-			 tmpSLICE="${DISK}${PTYPE}" 
-             # Get the number of the slice we are working on
-             s="`echo ${PTYPE} | awk '{print substr($0,length,1)}'`" 
-             run_gpart_slice "${DISK}" "${BMANAGER}" "${s}"
-			 ;;
-
-           free|FREE)
-			 tmpSLICE="${DISK}s${LASTSLICE}"
-             run_gpart_free "${DISK}" "${LASTSLICE}" "${BMANAGER}"
-			 ;;
-
-           *) exit_err "ERROR: Unknown PTYPE: $PTYPE" ;;
-         esac
-
-         # Now save which disk<num> this is, so we can parse it later during slice partition setup
-         echo "disk${disknum}" >${SLICECFGDIR}/$tmpSLICE
-
-         # Save any mirror config
-         if [ ! -z "$MIRRORDISK" ]
-         then
-           # Default to round-robin if the user didn't specify
-           if [ -z "$MIRRORBAL" ]
-           then
-             MIRRORBAL="round-robin"
-           fi
-           echo "$MIRRORDISK:$MIRRORBAL" >${MIRRORCFGDIR}/$DISK
-         fi
-
-
-         # Increment our disk counter to look for next disk and unset
-         unset BMANAGER PTYPE DISK MIRRORDISK MIRRORBAL PSCHEME
-         disknum="`expr $disknum + 1`"
-       else
-         exit_err "ERROR: commitDiskPart was called without procceding disk<num>= and partition= entries!!!" 
-       fi
-     fi
+      # Before we go further, lets confirm this disk really exists
+      if [ ! -e "/dev/${MIRRORDISK}" ]
+      then
+        exit_err "ERROR: The mirror disk ${MIRRORDISK} does not exist!"
+      fi
+    fi
+
+    # Lets see if we have been given a mirror balance choice
+    echo $line | grep "^mirrorbal=" >/dev/null 2>/dev/null
+    if [ "$?" = "0" ]
+    then
+
+      # Found a disk= entry, lets get the disk we are working on
+      get_value_from_string "${line}"
+      strip_white_space "$VAL"
+      MIRRORBAL="$VAL"
+    fi
+
+    echo $line | grep "^partition=" >/dev/null 2>/dev/null
+    if [ "$?" = "0" ]
+    then
+      # Found a partition= entry, lets read / set it 
+      get_value_from_string "${line}"
+      strip_white_space "$VAL"
+      PTYPE=`echo $VAL|tr A-Z a-z`
+
+      # We are using free space, figure out the slice number
+      if [ "${PTYPE}" = "free" ]
+      then
+        # Lets figure out what number this slice will be
+        LASTSLICE="`gpart show ${DISK} \
+			| grep -v ${DISK} \
+			| grep -v ' free' \
+			| tr -s '\t' ' ' \
+			| cut -d ' ' -f 4 \
+			| sed '/^$/d' \
+			| tail -n 1`"
+
+        if [ -z "${LASTSLICE}" ]
+        then
+          LASTSLICE="1"
+        else
+          LASTSLICE="`expr $LASTSLICE + 1`"
+        fi
+
+        if [ $LASTSLICE -gt 4 ]
+        then
+          exit_err "ERROR: BSD only supports primary partitions, and there are none availble on $DISK"
+        fi
+
+      fi
+    fi
+
+    # Check if we have an image file defined
+    echo $line | grep "^image=" >/dev/null 2>/dev/null
+    if [ "$?" = "0" ] ; then
+      # Found an image= entry, lets read / set it
+      get_value_from_string "${line}"
+      strip_white_space "$VAL"
+      IMAGE="$VAL"
+      if [ ! -f "$IMAGE" ] ; then
+        exit_err "$IMAGE file does not exist"
+      fi
+    fi
+
+    # Check if we have a partscheme specified
+    echo $line | grep "^partscheme=" >/dev/null 2>/dev/null
+    if [ "$?" = "0" ] ; then
+      # Found a partscheme= entry, lets read / set it 
+      get_value_from_string "${line}"
+      strip_white_space "$VAL"
+      PSCHEME="$VAL"
+      if [ "$PSCHEME" != "GPT" -a "$PSCHEME" != "MBR" ] ; then
+        exit_err "Unknown partition scheme: $PSCHEME" 
+      fi
+    fi
+
+    echo $line | grep "^bootManager=" >/dev/null 2>/dev/null
+    if [ "$?" = "0" ]
+    then
+      # Found a bootManager= entry, lets read /set it
+      get_value_from_string "${line}"
+      strip_white_space "$VAL"
+      BMANAGER="$VAL"
+    fi
+
+    echo $line | grep "^commitDiskPart" >/dev/null 2>/dev/null
+    if [ "$?" = "0" ]
+    then
+      # Found our flag to commit this disk setup / lets do sanity check and do it
+      if [ ! -z "${DISK}" -a ! -z "${PTYPE}" ]
+      then
+        case ${PTYPE} in
+          all)
+            if [ "$PSCHEME" = "MBR" -o -z "$PSCHEME" ] ; then
+              PSCHEME="MBR"
+              tmpSLICE="${DISK}s1"  
+			else
+              tmpSLICE="${DISK}p1"  
+            fi
+
+            run_gpart_full "${DISK}" "${BMANAGER}" "${PSCHEME}"
+            ;;
+
+          s1|s2|s3|s4)
+            tmpSLICE="${DISK}${PTYPE}" 
+            # Get the number of the slice we are working on
+            s="`echo ${PTYPE} | awk '{print substr($0,length,1)}'`" 
+            run_gpart_slice "${DISK}" "${BMANAGER}" "${s}"
+            ;;
+
+          free)
+            tmpSLICE="${DISK}s${LASTSLICE}"
+            run_gpart_free "${DISK}" "${LASTSLICE}" "${BMANAGER}"
+            ;;
+
+          image)
+            if [ -n "${IMAGE}" ]
+            then
+              write_image "${IMAGE}" "${DISK}"
+            else 
+			  exit_err "ERROR: partition type image specified with no image!"
+            fi 
+
+            IMAGE="${DISK}:${IMAGE}"
+            if [ -z "${WORKINGIMAGES}" ]
+            then
+			  WORKINGIMAGES="${IMAGE}"
+            else 
+			  WORKINGIMAGES="${WORKINGIMAGES} ${IMAGE}"
+            fi 
+
+            export WORKINGIMAGES
+            ;;
+
+          *) exit_err "ERROR: Unknown PTYPE: $PTYPE" ;;
+        esac
+
+        # Now save which disk<num> this is, so we can parse it later during slice partition setup
+        if [ -n "${tmpSLICE}" ]
+        then
+          echo "disk${disknum}" >${SLICECFGDIR}/$tmpSLICE
+        fi
+
+        # Save any mirror config
+        if [ ! -z "$MIRRORDISK" ]
+        then
+          # Default to round-robin if the user didn't specify
+          if [ -z "$MIRRORBAL" ]
+          then
+            MIRRORBAL="round-robin"
+          fi
+          echo "$MIRRORDISK:$MIRRORBAL" >${MIRRORCFGDIR}/$DISK
+        fi
+
+
+        # Increment our disk counter to look for next disk and unset
+        unset BMANAGER PTYPE DISK MIRRORDISK MIRRORBAL PSCHEME IMAGE
+        disknum="`expr $disknum + 1`"
+      else
+        exit_err "ERROR: commitDiskPart was called without procceding disk<num>= and partition= entries!!!" 
+      fi
+    fi
 
   done <${CFGF}
 
@@ -590,8 +628,7 @@ init_mbr_full_disk()
   totalblocks="`expr ${totalblocks} \* ${sec}`"
   if [ -z "${totalblocks}" ]
   then
-	get_disk_mediasize "${_intDISK}"
-	totalblocks="${VAL}"
+    totalblocks=`gpart show "${_intDISK}"|tail -2|head -1|awk '{ print $2 }'`
   fi
 
   # Now set the ending block to the total disk block size

Modified: head/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh
==============================================================================
--- head/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh	Wed Sep  8 20:09:50 2010	(r212336)
+++ head/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh	Wed Sep  8 20:10:24 2010	(r212337)
@@ -377,7 +377,7 @@ init_extraction()
       fi
       ;;
 
-    ftp|sftp)
+    ftp)
       if [ "$PACKAGETYPE" = "split" ]
       then
         fetch_split_files
@@ -390,9 +390,9 @@ init_extraction()
       fi
       ;;
 
-      rsync) start_rsync_copy ;;
-    img)
-		;;
+    sftp) ;;
+
+    rsync) start_rsync_copy ;;
     *) exit_err "ERROR: Unknown install medium" ;;
   esac
 

Modified: head/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh
==============================================================================
--- head/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh	Wed Sep  8 20:09:50 2010	(r212336)
+++ head/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh	Wed Sep  8 20:10:24 2010	(r212337)
@@ -60,7 +60,7 @@ copy_component()
 	    RESULT="$?"
         ;;
 
-      ftp|sftp)
+      ftp)
         get_value_from_cfg ftpPath
         if [ -z "$VAL" ]
         then
@@ -71,6 +71,8 @@ copy_component()
         fetch_file "${FTPPATH}/${COMPFILEDIR}/${SUBDIR}/${CFILE}" "${FSMNT}/${COMPTMPDIR}/${CFILE}" "0"
         RESULT="$?"
        ;;
+
+      sftp) ;;
     esac
 
     if [ "${RESULT}" != "0" ]

Modified: head/usr.sbin/pc-sysinstall/backend/functions-packages.sh
==============================================================================
--- head/usr.sbin/pc-sysinstall/backend/functions-packages.sh	Wed Sep  8 20:09:50 2010	(r212336)
+++ head/usr.sbin/pc-sysinstall/backend/functions-packages.sh	Wed Sep  8 20:10:24 2010	(r212337)
@@ -113,7 +113,8 @@ get_package_index()
 
     case "${INSTALLMEDIUM}" in
       usb|dvd) get_package_index_by_fs ;;
-      ftp|sftp) get_package_index_by_ftp "${FTPPATH}" ;;
+      ftp) get_package_index_by_ftp "${FTPPATH}" ;;
+      sftp) ;;
       *) RES=1 ;;
     esac
 
@@ -369,6 +370,7 @@ fetch_package()
 
   case "${INSTALLMEDIUM}" in
     usb|dvd) fetch_package_by_fs "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" ;;
-    ftp|sftp) fetch_package_by_ftp "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" ;;
+    ftp) fetch_package_by_ftp "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" ;;
+    sftp) ;;
   esac
 };

Modified: head/usr.sbin/pc-sysinstall/backend/functions-parse.sh
==============================================================================
--- head/usr.sbin/pc-sysinstall/backend/functions-parse.sh	Wed Sep  8 20:09:50 2010	(r212336)
+++ head/usr.sbin/pc-sysinstall/backend/functions-parse.sh	Wed Sep  8 20:10:24 2010	(r212337)
@@ -85,6 +85,7 @@ if_check_value_exists()
     VALID="1"
     for i in ${2}
     do
+      VAL=`echo "$VAL"|tr A-Z a-z`
       if [ "$VAL" = "${i}" ]
       then 
         VALID="0"

Modified: head/usr.sbin/pc-sysinstall/backend/functions.sh
==============================================================================
--- head/usr.sbin/pc-sysinstall/backend/functions.sh	Wed Sep  8 20:09:50 2010	(r212336)
+++ head/usr.sbin/pc-sysinstall/backend/functions.sh	Wed Sep  8 20:10:24 2010	(r212337)
@@ -283,3 +283,118 @@ get_zpool_name()
     return
   fi
 };
+
+write_image()
+{
+  IMAGE_FILE="$1"
+  DEVICE_FILE="$2"
+
+  if [ -z "${IMAGE_FILE}" ]
+  then
+    echo "ERROR: Image file not specified!"
+    exit 1
+  fi
+ 
+  if [ -z "${DEVICE_FILE}" ]
+  then
+    echo "ERROR: Device file not specified!"
+    exit 1
+  fi
+ 
+  if [ ! -f "${IMAGE_FILE}" ]
+  then
+    echo "ERROR: '${IMAGE_FILE}' does not exist!"
+    exit 1
+  fi
+
+  DEVICE_FILE="${DEVICE_FILE#/dev/}"
+  DEVICE_FILE="/dev/${DEVICE_FILE}"
+ 
+  if [ ! -c "${DEVICE_FILE}" ]
+  then
+    echo "ERROR: '${DEVICE_FILE}' is not a character device!"
+    exit 1
+  fi
+
+  if [ "${RES}" = "0" ]
+  then
+    rc_halt "dd if=${IMAGE_FILE} of=${DEVICE_FILE} ibs=16k obs=16k"
+  fi
+
+  return 0
+};
+
+install_fresh()
+{
+  # Lets start setting up the disk slices now
+  setup_disk_slice
+  
+  # Disk setup complete, now lets parse WORKINGSLICES and setup the bsdlabels
+  setup_disk_label
+  
+  # Now we've setup the bsdlabels, lets go ahead and run newfs / zfs 
+  # to setup the filesystems
+  setup_filesystems
+
+  # Lets mount the partitions now
+  mount_all_filesystems
+
+  # We are ready to begin extraction, lets start now
+  init_extraction 
+
+  # Check if we have any optional modules to load 
+  install_components
+
+  # Check if we have any packages to install
+  install_packages
+
+  # Do any localization in configuration
+  run_localize
+  
+  # Save any networking config on the installed system
+  save_networking_install
+
+  # Now add any users
+  setup_users
+
+  # Now run any commands specified
+  run_commands
+  
+  # Do any last cleanup / setup before unmounting
+  run_final_cleanup
+
+  # Unmount and finish up
+  unmount_all_filesystems
+
+  echo_log "Installation finished!"
+}
+
+install_upgrade()
+{
+  # We're going to do an upgrade, skip all the disk setup 
+  # and start by mounting the target drive/slices
+  mount_upgrade
+  
+  # Start the extraction process
+  init_extraction
+
+  # Do any localization in configuration
+  run_localize
+
+  # ow run any commands specified
+  run_commands
+  
+  # Merge any old configuration files
+  merge_old_configs
+
+  # Check if we have any optional modules to load 
+  install_components
+
+  # Check if we have any packages to install
+  install_packages
+
+  # All finished, unmount the file-systems
+  unmount_upgrade
+
+  echo_log "Upgrade finished!"
+}

Modified: head/usr.sbin/pc-sysinstall/backend/parseconfig.sh
==============================================================================
--- head/usr.sbin/pc-sysinstall/backend/parseconfig.sh	Wed Sep  8 20:09:50 2010	(r212336)
+++ head/usr.sbin/pc-sysinstall/backend/parseconfig.sh	Wed Sep  8 20:10:24 2010	(r212337)
@@ -73,9 +73,9 @@ file_sanity_check "installMode disk0 ins
 check_value installMode "fresh upgrade"
 check_value bootManager "bsd none"
 check_value installType "PCBSD FreeBSD"
-check_value installMedium "dvd usb ftp rsync img"
+check_value installMedium "dvd usb ftp rsync"
 check_value packageType "uzip tar rsync split"
-if_check_value_exists partition "all ALL s1 s2 s3 s4 free FREE"
+if_check_value_exists partition "all s1 s2 s3 s4 free image"
 if_check_value_exists mirrorbal "load prefer round-robin split"
 
 # We passed all sanity checks! Yay, lets start the install
@@ -98,79 +98,18 @@ PACKAGETYPE="${VAL}" ; export PACKAGETYP
 start_networking
 
 # If we are not doing an upgrade, lets go ahead and setup the disk
-if [ "${INSTALLMODE}" = "fresh" ]
-then
-
-  # Lets start setting up the disk slices now
-  setup_disk_slice
-  
-  # Disk setup complete, now lets parse WORKINGSLICES and setup the bsdlabels
-  setup_disk_label
-  
-  # Now we've setup the bsdlabels, lets go ahead and run newfs / zfs 
-  # to setup the filesystems
-  setup_filesystems
-
-  # Lets mount the partitions now
-  mount_all_filesystems
-
-  # We are ready to begin extraction, lets start now
-  init_extraction
-
-  # Check if we have any optional modules to load 
-  install_components
-
-  # Check if we have any packages to install
-  install_packages
-
-  # Do any localization in configuration
-  run_localize
-  
-  # Save any networking config on the installed system
-  save_networking_install
-
-  # Now add any users
-  setup_users
-
-  # Now run any commands specified
-  run_commands
-  
-  # Do any last cleanup / setup before unmounting
-  run_final_cleanup
-
-  # Unmount and finish up
-  unmount_all_filesystems
-
-  echo_log "Installation finished!"
-  exit 0
-
-else
-  # We're going to do an upgrade, skip all the disk setup 
-  # and start by mounting the target drive/slices
-  mount_upgrade
-  
-  # Start the extraction process
-  init_extraction
-
-  # Do any localization in configuration
-  run_localize
-
-  # Now run any commands specified
-  run_commands
-  
-  # Merge any old configuration files
-  merge_old_configs
-
-  # Check if we have any optional modules to load 
-  install_components
-
-  # Check if we have any packages to install
-  install_packages
-
-  # All finished, unmount the file-systems
-  unmount_upgrade
-
-  echo_log "Upgrade finished!"
-  exit 0
-fi
+case "${INSTALLMODE}" in
+  fresh)
+	install_fresh
+    ;;
+
+  upgrade)
+    install_upgrade
+    ;;
+
+  *)
+	exit 1
+    ;;
+esac
 
+exit 0

Modified: head/usr.sbin/pc-sysinstall/doc/help-index
==============================================================================
--- head/usr.sbin/pc-sysinstall/doc/help-index	Wed Sep  8 20:09:50 2010	(r212336)
+++ head/usr.sbin/pc-sysinstall/doc/help-index	Wed Sep  8 20:10:24 2010	(r212337)
@@ -9,6 +9,8 @@ Help Commands
    	Display the help data for the specified command
 
 System Query Commands
+    install-image <image> <device>
+        Installs an image file to a device file
 
     disk-list 
         Provides a listing of the disk drives detected on this system

Modified: head/usr.sbin/pc-sysinstall/examples/README
==============================================================================
--- head/usr.sbin/pc-sysinstall/examples/README	Wed Sep  8 20:09:50 2010	(r212336)
+++ head/usr.sbin/pc-sysinstall/examples/README	Wed Sep  8 20:10:24 2010	(r212337)
@@ -114,7 +114,7 @@ root zpool of the target system to updat
  # disk0=ada0s1a
 
 
-# partition=(all, free, s1, s1, s3, s4)
+# partition=(all, free, s1, s1, s3, s4, image)
 
 After setting disk[0-9], the partition= variable is used to specify which target
 partition we will be working with for this device.
@@ -124,7 +124,9 @@ Setting this to "all" will setup the dis
 Setting this to "free" will allow pc-sysinstall to search for the first available
 primary slice with free space, and create the slice. 
 
-Setting this to "s1, s2, s3 or s4" will use the specified MBR slice
+Setting this to "s1, s2, s3 or s4" will use the specified MBR slice.
+
+Setting this to "image" will use an image to configure the disk.
 
 (This tag is unused for upgrades)
 
@@ -151,6 +153,11 @@ specified this defaults to "round-robin"
 Setting this option will instruct pc-sysinstall to install the BSD boot Manager,
 or leave it empty
 
+# image=(/path/to/image/file)
+
+Setting this option will instruct pc-sysinstall to write the image file
+specified by the path to the disk.
+
 # commitDiskPart
 
 This command must be placed at the end of the diskX= section, before starting

Modified: head/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh
==============================================================================
--- head/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh	Wed Sep  8 20:09:50 2010	(r212336)
+++ head/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh	Wed Sep  8 20:10:24 2010	(r212337)
@@ -116,6 +116,10 @@ case $1 in
     fi
   ;;
 
+  # Install an image file to a device
+  install-image) ${BACKEND}/installimage.sh "${2}" "${3}"
+  ;;
+
   # Parse an auto-install directive, and begin the installation
   start-autoinstall) ${BACKEND}/startautoinstall.sh ${2}
   ;;


More information about the svn-src-all mailing list