From nobody@FreeBSD.org  Fri Feb 11 15:08:40 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 253F8106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 11 Feb 2011 15:08:40 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 1350B8FC0A
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 11 Feb 2011 15:08:40 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p1BF8dIi037683
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 11 Feb 2011 15:08:39 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p1BF8dUL037682;
	Fri, 11 Feb 2011 15:08:39 GMT
	(envelope-from nobody)
Message-Id: <201102111508.p1BF8dUL037682@red.freebsd.org>
Date: Fri, 11 Feb 2011 15:08:39 GMT
From: Kris Moore <kmoore@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: bin: usr.sbin/pc-sysinstall - Add Extract-Only option for pc-sysinstall
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         154685
>Category:       bin
>Synopsis:       bin: usr.sbin/pc-sysinstall - Add Extract-Only option for pc-sysinstall
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    jpaetzel
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Fri Feb 11 15:10:09 UTC 2011
>Closed-Date:    Thu Feb 17 16:34:25 UTC 2011
>Last-Modified:  Thu Feb 17 16:40:04 UTC 2011
>Originator:     Kris Moore
>Release:        9.0-Current
>Organization:
PC-BSD / iXsystems
>Environment:
FreeBSD 9.0-CURRENT
>Description:
The attached patch adds a new "Extract Only" option to pc-sysinstall, for users who want to do complex disk-setups manually, and then point pc-sysinstall to a mount-point for installation. 
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

diff -ruN usr.sbin/pc-sysinstall/backend/functions.sh usr.sbin/pc-sysinstall/backend/functions.sh
--- usr.sbin/pc-sysinstall/backend/functions.sh	2011-01-27 10:26:03.733382991 -0500
+++ usr.sbin/pc-sysinstall/backend/functions.sh	2011-01-27 12:39:07.471755753 -0500
@@ -409,6 +409,7 @@
   fi
 };
 
+# Setup and install on a new disk / partition
 install_fresh()
 {
   # Lets start setting up the disk slices now
@@ -458,6 +459,39 @@
   echo_log "Installation finished!"
 };
 
+# Extract the system to a pre-mounted directory
+install_extractonly()
+{
+  # 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
+  
+  # Set a hostname on the install system
+  setup_hostname
+      
+  # Set the root_pw if it is specified
+  set_root_pw
+
+  echo_log "Installation finished!"
+};
+
 install_image()
 {
   # We are ready to begin extraction, lets start now
@@ -478,7 +512,7 @@
   # Do any localization in configuration
   run_localize
 
-  # ow run any commands specified
+  # Now run any commands specified
   run_commands
   
   # Merge any old configuration files
diff -ruN usr.sbin/pc-sysinstall/backend/parseconfig.sh usr.sbin/pc-sysinstall/backend/parseconfig.sh
--- usr.sbin/pc-sysinstall/backend/parseconfig.sh	2011-01-27 10:26:03.733382991 -0500
+++ usr.sbin/pc-sysinstall/backend/parseconfig.sh	2011-01-27 12:45:59.303378946 -0500
@@ -67,11 +67,10 @@
 export CFGF
 
 # Start by doing a sanity check, which will catch any obvious mistakes in the config
-file_sanity_check "installMode disk0 installType installMedium packageType"
+file_sanity_check "installMode installType installMedium packageType"
 
 # We passed the Sanity check, lets grab some of the universal config settings and store them
-check_value installMode "fresh upgrade"
-check_value bootManager "bsd none"
+check_value installMode "fresh upgrade extract"
 check_value installType "PCBSD FreeBSD"
 check_value installMedium "dvd usb ftp rsync image"
 check_value packageType "uzip tar rsync split"
@@ -108,6 +107,16 @@
     fi
     ;;
 
+  extract)
+    # Extracting only, make sure we have a valid target directory
+    get_value_from_cfg installLocation
+    FSMNT="${VAL}" ; export FSMNT
+    if [ -z "$FSMNT" ] ; then exit_err "Missing installLocation=" ; fi
+    if [ ! -d "$FSMNT" ] ; then exit_err "No such directory: $FSMNT" ; fi
+
+    install_extractonly
+    ;;
+
   upgrade)
     install_upgrade
     ;;
diff -ruN usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf
--- usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf	2011-01-27 10:26:03.670379474 -0500
+++ usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf	2011-01-27 12:28:39.739272231 -0500
@@ -36,8 +36,8 @@
 export RSYNCTRIES
 
 # Set our mount-points
-CDMNT="/cdmnt-install"
-FSMNT="/mnt"
+CDMNT=${CDMNT-/cdmnt-install}
+FSMNT=${FSMNT-/mnt}
 UZIP_DIR="/usr"
 BOOT_PART_MOUNT="/boot-mount"
 export FSMNT CDMNT UZIP_DIR BOOT_PART_MOUNT
diff -ruN usr.sbin/pc-sysinstall/examples/README usr.sbin/pc-sysinstall/examples/README
--- usr.sbin/pc-sysinstall/examples/README	2011-01-27 10:26:03.649376160 -0500
+++ usr.sbin/pc-sysinstall/examples/README	2011-01-27 13:02:59.950214147 -0500
@@ -12,9 +12,9 @@
 When hostname= is not present, pc-sysinstall will auto-generate
 a hostname such as freebsd-XXXX or pcbsd-XXXX
 
-# installMode=(fresh or upgrade)
+# installMode=(fresh/upgrade/extract)
 
-Set the type of install we are doing, fresh or upgrade.
+Set the type of install we are doing.
 
 Fresh installs will format and mount the target disks before
 extracting the install images to the system. Using this mode
@@ -27,6 +27,19 @@
 additional files to exclude from overwriting during the
 install process.
 
+Extract will skip any disk setup, and perform an installation
+to the directory specified by "installLocation=". This location
+should be a directory with your pre-mounted file-systems ready
+for file extraction. When using the "extract" option, /etc/fstab
+on the installed system will *not* be automatically configured. 
+
+# installLocation=
+
+Used only when installMode is set to extract. 
+
+This is set to the location you want to extract your system to,
+and should already be mounted properly. 
+
 # installInteractive=(yes or no)
 
 Set if the installer is running in interactive mode, and
@@ -320,7 +333,7 @@
 # runScript=
 
 runScript will copy the specified script into FSMNT, and run it in chroot of the system
-Usefull when you have a 3rd party script on the DVD / USB, and you want to copy it into
+Useful when you have a 3rd party script on the DVD / USB, and you want to copy it into
 the installed system and run
 
 # runExtCommand=
@@ -330,7 +343,7 @@
 
 
 ########################################################################
-# PC-BSD SPECIFC OPTIONS
+# PC-BSD SPECIFIC OPTIONS
 ########################################################################
 
 Options for time-zones and NTP on the installed system


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->jpaetzel 
Responsible-Changed-By: jpaetzel 
Responsible-Changed-When: Fri Feb 11 15:44:22 UTC 2011 
Responsible-Changed-Why:  
I'll take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=154685 
State-Changed-From-To: open->closed 
State-Changed-By: jpaetzel 
State-Changed-When: Thu Feb 17 16:34:02 UTC 2011 
State-Changed-Why:  
Committed, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=154685 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/154685: commit references a PR
Date: Thu, 17 Feb 2011 16:33:47 +0000 (UTC)

 Author: jpaetzel
 Date: Thu Feb 17 16:33:41 2011
 New Revision: 218776
 URL: http://svn.freebsd.org/changeset/base/218776
 
 Log:
   Add "Extract Only" functionality to pc-sysinstall.  This allows disk setup to
   be done manually, pc-sysinstall is pointed to a mount-point for installation.
   
   PR:	bin/154685
   Submitted by:	kmoore
   Approved by:	kib (mentor)
 
 Modified:
   head/usr.sbin/pc-sysinstall/backend/functions.sh
   head/usr.sbin/pc-sysinstall/backend/parseconfig.sh
   head/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf
   head/usr.sbin/pc-sysinstall/examples/README
 
 Modified: head/usr.sbin/pc-sysinstall/backend/functions.sh
 ==============================================================================
 --- head/usr.sbin/pc-sysinstall/backend/functions.sh	Thu Feb 17 16:21:26 2011	(r218775)
 +++ head/usr.sbin/pc-sysinstall/backend/functions.sh	Thu Feb 17 16:33:41 2011	(r218776)
 @@ -409,6 +409,7 @@ write_image()
    fi
  };
  
 +# Setup and install on a new disk / partition
  install_fresh()
  {
    # Lets start setting up the disk slices now
 @@ -458,6 +459,39 @@ install_fresh()
    echo_log "Installation finished!"
  };
  
 +# Extract the system to a pre-mounted directory
 +install_extractonly()
 +{
 +  # 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
 +  
 +  # Set a hostname on the install system
 +  setup_hostname
 +      
 +  # Set the root_pw if it is specified
 +  set_root_pw
 +
 +  echo_log "Installation finished!"
 +};
 +
  install_image()
  {
    # We are ready to begin extraction, lets start now
 @@ -478,7 +512,7 @@ install_upgrade()
    # Do any localization in configuration
    run_localize
  
 -  # ow run any commands specified
 +  # Now run any commands specified
    run_commands
    
    # Merge any old configuration files
 
 Modified: head/usr.sbin/pc-sysinstall/backend/parseconfig.sh
 ==============================================================================
 --- head/usr.sbin/pc-sysinstall/backend/parseconfig.sh	Thu Feb 17 16:21:26 2011	(r218775)
 +++ head/usr.sbin/pc-sysinstall/backend/parseconfig.sh	Thu Feb 17 16:33:41 2011	(r218776)
 @@ -67,11 +67,10 @@ fi
  export CFGF
  
  # Start by doing a sanity check, which will catch any obvious mistakes in the config
 -file_sanity_check "installMode disk0 installType installMedium packageType"
 +file_sanity_check "installMode installType installMedium packageType"
  
  # We passed the Sanity check, lets grab some of the universal config settings and store them
 -check_value installMode "fresh upgrade"
 -check_value bootManager "bsd none"
 +check_value installMode "fresh upgrade extract"
  check_value installType "PCBSD FreeBSD"
  check_value installMedium "dvd usb ftp rsync image"
  check_value packageType "uzip tar rsync split"
 @@ -108,6 +107,16 @@ case "${INSTALLMODE}" in
      fi
      ;;
  
 +  extract)
 +    # Extracting only, make sure we have a valid target directory
 +    get_value_from_cfg installLocation
 +    FSMNT="${VAL}" ; export FSMNT
 +    if [ -z "$FSMNT" ] ; then exit_err "Missing installLocation=" ; fi
 +    if [ ! -d "$FSMNT" ] ; then exit_err "No such directory: $FSMNT" ; fi
 +
 +    install_extractonly
 +    ;;
 +
    upgrade)
      install_upgrade
      ;;
 
 Modified: head/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf
 ==============================================================================
 --- head/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf	Thu Feb 17 16:21:26 2011	(r218775)
 +++ head/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf	Thu Feb 17 16:33:41 2011	(r218776)
 @@ -36,8 +36,8 @@ RSYNCTRIES="3"
  export RSYNCTRIES
  
  # Set our mount-points
 -CDMNT="/cdmnt-install"
 -FSMNT="/mnt"
 +CDMNT=${CDMNT-/cdmnt-install}
 +FSMNT=${FSMNT-/mnt}
  UZIP_DIR="/usr"
  BOOT_PART_MOUNT="/boot-mount"
  export FSMNT CDMNT UZIP_DIR BOOT_PART_MOUNT
 
 Modified: head/usr.sbin/pc-sysinstall/examples/README
 ==============================================================================
 --- head/usr.sbin/pc-sysinstall/examples/README	Thu Feb 17 16:21:26 2011	(r218775)
 +++ head/usr.sbin/pc-sysinstall/examples/README	Thu Feb 17 16:33:41 2011	(r218776)
 @@ -12,9 +12,9 @@ installed system
  When hostname= is not present, pc-sysinstall will auto-generate
  a hostname such as freebsd-XXXX or pcbsd-XXXX
  
 -# installMode=(fresh or upgrade)
 +# installMode=(fresh/upgrade/extract)
  
 -Set the type of install we are doing, fresh or upgrade.
 +Set the type of install we are doing.
  
  Fresh installs will format and mount the target disks before
  extracting the install images to the system. Using this mode
 @@ -27,6 +27,19 @@ The conf/exclude-from-upgrade file can b
  additional files to exclude from overwriting during the
  install process.
  
 +Extract will skip any disk setup, and perform an installation
 +to the directory specified by "installLocation=". This location
 +should be a directory with your pre-mounted file-systems ready
 +for file extraction. When using the "extract" option, /etc/fstab
 +on the installed system will *not* be automatically configured. 
 +
 +# installLocation=
 +
 +Used only when installMode is set to extract. 
 +
 +This is set to the location you want to extract your system to,
 +and should already be mounted properly. 
 +
  # installInteractive=(yes or no)
  
  Set if the installer is running in interactive mode, and
 @@ -320,7 +333,7 @@ Run the specified command within chroot 
  # runScript=
  
  runScript will copy the specified script into FSMNT, and run it in chroot of the system
 -Usefull when you have a 3rd party script on the DVD / USB, and you want to copy it into
 +Useful when you have a 3rd party script on the DVD / USB, and you want to copy it into
  the installed system and run
  
  # runExtCommand=
 @@ -330,7 +343,7 @@ The variable $FSMNT is set to the mount-
  
  
  ########################################################################
 -# PC-BSD SPECIFC OPTIONS
 +# PC-BSD SPECIFIC OPTIONS
  ########################################################################
  
  Options for time-zones and NTP on the installed system
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
