bin/150921: pc-sysinstall patch that allows images to be written to
disks
John Hixson
john at ixsystems.com
Fri Sep 24 19:20:03 UTC 2010
>Number: 150921
>Category: bin
>Synopsis: pc-sysinstall patch that allows images to be written to disks
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: update
>Submitter-Id: current-users
>Arrival-Date: Fri Sep 24 19:20:02 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator: John Hixson
>Release: 9.0-CURRENT
>Organization:
iXsystems
>Environment:
FreeBSD thinkbsd 9.0-CURRENT FreeBSD 9.0-CURRENT #4: Fri Aug 20 05:23:56 PDT 2010 john at thinkbsd:/usr/obj/usr/src/sys/THINKBSD amd64
>Description:
More work on installing based on images, yet, still more needs to be done.
>How-To-Repeat:
>Fix:
Patch attached with submission follows:
diff -urN /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/Makefile usr.sbin/pc-sysinstall/backend/Makefile
--- /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/Makefile 2010-09-24 12:07:45.000000000 -0700
+++ usr.sbin/pc-sysinstall/backend/Makefile 2010-08-26 14:15:33.000000000 -0700
@@ -1,4 +1,4 @@
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/Makefile,v 1.6 2010/09/08 20:10:24 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/Makefile,v 1.5 2010/08/19 05:59:27 imp Exp $
FILES= functions-bsdlabel.sh functions-cleanup.sh functions-disk.sh \
functions-extractimage.sh functions-ftp.sh functions-installcomponents.sh \
diff -urN /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
--- /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh 2010-09-24 12:07:45.000000000 -0700
+++ usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh 2010-09-24 12:04:50.000000000 -0700
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh,v 1.5 2010/09/08 20:10:24 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh,v 1.4 2010/08/24 06:11:46 imp Exp $
# Functions related to disk operations using bsdlabel
@@ -165,7 +165,6 @@
WRKSLICE="$2"
FOUNDPARTS="1"
-
# Lets setup the BSDLABEL
BSDLABEL="${TMPDIR}/bsdLabel-${WRKSLICE}"
export BSDLABEL
@@ -193,6 +192,11 @@
SIZE=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 2`
MNT=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 3`
+ if echo $STRING | grep -E '^/.+' >/dev/null 2>&1
+ then
+ IMAGE=`echo ${STRING} | cut -f1 -d' '`
+ fi
+
# Check if we have a .eli extension on this FS
echo ${FS} | grep ".eli" >/dev/null 2>/dev/null
if [ "$?" = "0" ]
@@ -214,10 +218,18 @@
then
USINGENCROOT="0" ; export USINGENCROOT
fi
-
+
+ if [ -n "${IMAGE}" ]
+ then
+ FS="IMAGE"
+ SIZE=`ls -l "${IMAGE}" | awk '{ print $5 }'`
+ MNT=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 2`
+ SIZE=`convert_byte_to_megabyte $SIZE`
+ fi
+
# Now check that these values are sane
case $FS in
- UFS|UFS+S|UFS+J|ZFS|SWAP) ;;
+ UFS|UFS+S|UFS+J|ZFS|SWAP|IMAGE) ;;
*) exit_err "ERROR: Invalid file system specified on $line" ;;
esac
@@ -254,7 +266,7 @@
# Check if we found a valid root partition
check_for_mount "${MNT}" "/"
if [ "$?" = "0" ] ; then
- FOUNDROOT="0" ; export FOUNDROOT
+ FOUNDROOT="0" ; export FOUNDROOT
fi
# Check if we have a "/boot" instead
@@ -267,7 +279,7 @@
fi
fi
- else
+ else
# Done with the a: partitions
# Check if we found a valid root partition not on a:
@@ -306,7 +318,7 @@
fi
# Save this data to our partition config dir
- echo "${FS}:${MNT}:${ENC}:${PLABEL}:MBR:${XTRAOPTS}" >${PARTDIR}/${WRKSLICE}${PARTLETTER}
+ echo "${FS}:${MNT}:${ENC}:${PLABEL}:MBR:${XTRAOPTS}:${IMAGE}" >${PARTDIR}/${WRKSLICE}${PARTLETTER}
# If we have a enc password, save it as well
if [ ! -z "${ENCPASS}" ] ; then
@@ -327,6 +339,8 @@
*) exit_err "ERROR: bsdlabel only supports up to letter h for partitions." ;;
esac
+ unset IMAGE
+
fi # End of subsection locating a slice in config
echo $line | grep "^commitDiskLabel" >/dev/null 2>/dev/null
@@ -567,7 +581,7 @@
{
# 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}" -a -z "${WORKINGIMAGES}" ]; then
+ if [ -z "${WORKINGSLICES}" ]; then
exit_err "ERROR: No slices were setup! Please report this to the maintainers"
fi
@@ -612,12 +626,6 @@
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
@@ -653,7 +661,7 @@
then
PARTLETTER=`echo "$SLICE" | sed -E 's|^.+([a-h])$|\1|'`
- grep -E '^.+ +/ +' "${FSTAB}" >/dev/null 2>&1
+ cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/$' >/dev/null 2>&1
if [ "$?" = "0" ]
then
if [ "${PARTLETTER}" = "a" ]
@@ -662,10 +670,14 @@
else
FOUNDROOT="1"
fi
+
+ ROOTIMAGE="1"
+
export FOUNDROOT
+ export ROOTIMAGE
fi
- grep -E '^.+ +/boot +' "${FSTAB}" >/dev/null 2>&1
+ cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/boot$' >/dev/null 2>&1
if [ "$?" = "0" ]
then
if [ "${PARTLETTER}" = "a" ]
@@ -700,7 +712,7 @@
then
PARTNUMBER=`echo "${SLICE}" | sed -E 's|^.+p([0-9]*)$|\1|'`
- grep -E '^.+ +/ +' "${FSTAB}" >/dev/null 2>&1
+ cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/$' >/dev/null 2>&1
if [ "$?" = "0" ]
then
if [ "${PARTNUMBER}" = "2" ]
@@ -709,10 +721,14 @@
else
FOUNDROOT="1"
fi
+
+ ROOTIMAGE="1"
+
export FOUNDROOT
+ export ROOTIMAGE
fi
- grep -E '^.+ +/boot +' "${FSTAB}" >/dev/null 2>&1
+ cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/boot$' >/dev/null 2>&1
if [ "$?" = "0" ]
then
if [ "${PARTNUMBER}" = "2" ]
@@ -731,42 +747,45 @@
return 1
};
-check_image_layout()
+check_disk_layout()
{
local SLICES
- local IMAGE
local TYPE
+ local DISK
local RES
- local MD
local F
- IMAGE="$1"
+ DISK="$1"
TYPE="MBR"
- if [ -z "${IMAGE}" ]
+ if [ -z "${DISK}" ]
then
return 1
fi
- MD=`mdconfig -af "${IMAGE}"`
- if [ "$?" != "0" ]
+ SLICES_MBR=`ls /dev/${DISK}s[1-4]*[a-h]* 2>/dev/null`
+ SLICES_GPT=`ls /dev/${DISK}p[0-9]* 2>/dev/null`
+ SLICES_SLICE=`ls /dev/${DISK}[a-h]* 2>/dev/null`
+
+ if [ -n "${SLICES_MBR}" ]
then
- return 1
+ SLICES="${SLICES_MBR}"
+ TYPE="MBR"
+ RES=0
fi
-
- SLICES=`ls /dev/${MD}s[1-4]*[a-h]* 2>/dev/null`
- if [ "$?" != "0" ]
+ if [ -n "${SLICES_GPT}" ]
then
- SLICES=`ls /dev/${MD}p[0-9]* 2>/dev/null`
- if [ -n "${SLICES}" ]
- then
- TYPE="GPT"
- RES=0
- fi
- else
+ SLICES="${SLICES_GPT}"
+ TYPE="GPT"
RES=0
fi
-
+ if [ -n "${SLICES_SLICE}" ]
+ then
+ SLICES="${SLICES_SLICE}"
+ TYPE="MBR"
+ RES=0
+ fi
+
for slice in ${SLICES}
do
F=1
@@ -796,6 +815,5 @@
umount /mnt
done
- mdconfig -d -u "${MD}"
return ${RES}
};
diff -urN /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/functions-disk.sh usr.sbin/pc-sysinstall/backend/functions-disk.sh
--- /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/functions-disk.sh 2010-09-24 12:07:45.000000000 -0700
+++ usr.sbin/pc-sysinstall/backend/functions-disk.sh 2010-09-24 12:04:48.000000000 -0700
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-disk.sh,v 1.5 2010/09/08 20:10:24 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-disk.sh,v 1.4 2010/08/24 06:11:46 imp Exp $
# Functions related to disk operations using gpart
@@ -400,12 +400,12 @@
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`"
+ | grep -v ${DISK} \
+ | grep -v ' free' \
+ | tr -s '\t' ' ' \
+ | cut -d ' ' -f 4 \
+ | sed '/^$/d' \
+ | tail -n 1`"
if [ -z "${LASTSLICE}" ]
then
@@ -466,7 +466,7 @@
if [ "$PSCHEME" = "MBR" -o -z "$PSCHEME" ] ; then
PSCHEME="MBR"
tmpSLICE="${DISK}s1"
- else
+ else
tmpSLICE="${DISK}p1"
fi
@@ -486,29 +486,44 @@
;;
image)
- if [ -n "${IMAGE}" ]
+ if [ -z "${IMAGE}" ]
then
- write_image "${IMAGE}" "${DISK}"
- else
- exit_err "ERROR: partition type image specified with no image!"
+ 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
+
+
+ if [ -n "${IMAGE}" ]
+ then
+ local DEST
+
+ if [ -n "${tmpSLICE}" ]
+ then
+ DEST="${tmpSLICE}"
+ else
+ DEST="${DISK}"
+ fi
+
+ if iscompressed "${IMAGE}"
+ then
+ local COMPRESSION
+
+ get_compression_type "${IMAGE}"
+ COMPRESSION="${VAL}"
+
+ decompress_file "${IMAGE}" "${COMPRESSION}"
+ IMAGE="${VAL}"
+ fi
+
+ write_image "${IMAGE}" "${DEST}"
+ check_disk_layout "${DEST}"
+ fi
# Now save which disk<num> this is, so we can parse it later during slice partition setup
- if [ -n "${tmpSLICE}" ]
+ if [ -z "${IMAGE}" ]
then
echo "disk${disknum}" >${SLICECFGDIR}/$tmpSLICE
fi
@@ -524,7 +539,6 @@
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`"
diff -urN /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh usr.sbin/pc-sysinstall/backend/functions-extractimage.sh
--- /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh 2010-09-24 12:07:45.000000000 -0700
+++ usr.sbin/pc-sysinstall/backend/functions-extractimage.sh 2010-09-20 20:41:10.000000000 -0700
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh,v 1.6 2010/09/08 20:10:24 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh,v 1.5 2010/08/24 06:11:46 imp Exp $
# Functions which perform the extraction / installation of system to disk
@@ -147,6 +147,7 @@
then
exit_err "ERROR: Failed extracting ${KERNELS}"
fi
+ rm -rf "${FSMNT}/boot/kernel"
mv "${FSMNT}/boot/GENERIC" "${FSMNT}/boot/kernel"
else
exit_err "ERROR: ${KERNELS}/install.sh does not exist"
@@ -328,6 +329,46 @@
};
+start_image_install()
+{
+ if [ -z "${IMAGE_FILE}" ]
+ then
+ exit_err "ERROR: installMedium set to image but no image file specified!"
+ fi
+
+ # We are ready to start mounting, lets read the config and do it
+ while read line
+ do
+ echo $line | grep "^disk0=" >/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"
+ 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}" ]
+ then
+
+ # Write the image
+ write_image "${IMAGE_FILE}" "${DISK}"
+
+ # Increment our disk counter to look for next disk and unset
+ unset DISK
+ break
+
+ else
+ exit_err "ERROR: commitDiskPart was called without procceding disk<num>= and partition= entries!!!"
+ fi
+ fi
+
+ done <${CFGF}
+};
# Entrance function, which starts the installation process
init_extraction()
@@ -393,6 +434,7 @@
sftp) ;;
rsync) start_rsync_copy ;;
+ image) start_image_install ;;
*) exit_err "ERROR: Unknown install medium" ;;
esac
diff -urN /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh
--- /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh 2010-09-24 12:07:45.000000000 -0700
+++ usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh 2010-08-25 13:06:01.000000000 -0700
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh,v 1.4 2010/09/08 20:10:24 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh,v 1.3 2010/08/24 06:11:46 imp Exp $
# Functions which check and load any optional modules specified in the config
diff -urN /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh
--- /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh 2010-08-24 16:07:51.000000000 -0700
+++ usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh 2010-09-24 12:05:29.000000000 -0700
@@ -126,6 +126,7 @@
UFS+S) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
UFS+J) mount_partition ${PART}${EXT}.journal ${PARTFS} ${PARTMNT} "async,noatime" ;;
ZFS) mount_partition ${PART} ${PARTFS} ${PARTMNT} ;;
+ IMAGE) mount_partition ${PART} ${PARTFS} ${PARTMNT} ;;
*) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
esac
fi
@@ -174,7 +175,14 @@
rc_halt "swapon /dev/${PART}"
fi
;;
- *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
+ IMAGE)
+ if [ ! -d "${PARTMNT}" ]
+ then
+ mkdir -p "${PARTMNT}"
+ fi
+ mount_partition ${PART} ${PARTFS} ${PARTMNT}
+ ;;
+ *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
esac
fi
done
diff -urN /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/functions-newfs.sh usr.sbin/pc-sysinstall/backend/functions-newfs.sh
--- /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/functions-newfs.sh 2010-08-24 16:07:51.000000000 -0700
+++ usr.sbin/pc-sysinstall/backend/functions-newfs.sh 2010-09-17 04:07:02.000000000 -0700
@@ -100,6 +100,7 @@
PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d ':' -f 4`"
PARTGEOM="`cat ${PARTDIR}/${PART} | cut -d ':' -f 5`"
PARTXTRAOPTS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 6`"
+ PARTIMAGE="`cat ${PARTDIR}/${PART} | cut -d ':' -f 7`"
# Make sure journaling isn't enabled on this device
if [ -e "/dev/${PART}.journal" ]
@@ -185,6 +186,11 @@
sleep 2
;;
+ IMAGE)
+ write_image "${PARTIMAGE}" "${PART}"
+ sleep 2
+ ;;
+
*) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
esac
diff -urN /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/functions-packages.sh usr.sbin/pc-sysinstall/backend/functions-packages.sh
--- /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/functions-packages.sh 2010-09-24 12:07:45.000000000 -0700
+++ usr.sbin/pc-sysinstall/backend/functions-packages.sh 2010-08-25 13:05:36.000000000 -0700
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-packages.sh,v 1.6 2010/09/08 20:10:24 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-packages.sh,v 1.5 2010/08/24 06:11:46 imp Exp $
# Functions which runs commands on the system
diff -urN /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/functions-parse.sh usr.sbin/pc-sysinstall/backend/functions-parse.sh
--- /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/functions-parse.sh 2010-09-24 12:07:45.000000000 -0700
+++ usr.sbin/pc-sysinstall/backend/functions-parse.sh 2010-08-26 18:12:57.000000000 -0700
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-parse.sh,v 1.4 2010/09/08 20:10:24 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-parse.sh,v 1.3 2010/08/24 06:11:46 imp Exp $
# functions.sh
# Library of functions which pc-sysinstall may call upon for parsing the config
diff -urN /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/functions.sh usr.sbin/pc-sysinstall/backend/functions.sh
--- /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/functions.sh 2010-09-24 12:07:45.000000000 -0700
+++ usr.sbin/pc-sysinstall/backend/functions.sh 2010-09-24 12:05:23.000000000 -0700
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions.sh,v 1.4 2010/09/08 20:10:24 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions.sh,v 1.3 2010/08/24 06:11:46 imp Exp $
# functions.sh
# Library of functions which pc-sysinstall may call upon
@@ -284,27 +284,123 @@
fi
};
+iscompressed()
+{
+ local FILE
+ local RES
+
+ FILE="$1"
+ RES=1
+
+ if echo "${FILE}" | \
+ grep -iE '\.(Z|lzo|lzw|lzma|gz|bz2|xz|zip)$' >/dev/null 2>&1
+ then
+ RES=0
+ fi
+
+ return ${RES}
+}
+
+get_compression_type()
+{
+ local FILE
+ local SUFFIX
+
+ FILE="$1"
+ SUFFIX=`echo "${FILE}" | sed -E 's|^(.+)\.(.+)$|\2|'`
+
+ VAL=""
+ SUFFIX=`echo "${SUFFIX}" | tr A-Z a-z`
+ case "${SUFFIX}" in
+ z) VAL="lzw" ;;
+ lzo) VAL="lzo" ;;
+ lzw) VAL="lzw" ;;
+ lzma) VAL="lzma" ;;
+ gz) VAL="gzip" ;;
+ bz2) VAL="bzip2" ;;
+ xz) VAL="xz" ;;
+ zip) VAL="zip" ;;
+ esac
+
+ export VAL
+}
+
+decompress_file()
+{
+ local FILE
+ local COMPRESSION
+
+ FILE="$1"
+ COMPRESSION="$2"
+
+ if [ -n "${COMPRESSION}" ]
+ then
+ case "${COMPRESSION}" in
+ lzw)
+ rc_halt "uncompress ${FILE}"
+ VAL="${FILE%.Z}"
+ ;;
+
+ lzo)
+ rc_halt "lzop -d ${FILE}"
+ VAL="${FILE%.lzo}"
+ ;;
+
+ lzma)
+ rc_halt "lzma -d ${FILE}"
+ VAL="${FILE%.lzma}"
+ ;;
+
+ gzip)
+ rc_halt "gunzip ${FILE}"
+ VAL="${FILE%.gz}"
+ ;;
+
+ bzip2)
+ rc_halt "bunzip2 ${FILE}"
+ VAL="${FILE%.bz2}"
+ ;;
+
+ xz)
+ rc_halt "xz -d ${FILE}"
+ VAL="${FILE%.xz}"
+ ;;
+
+ zip)
+ rc_halt "unzip ${FILE}"
+ VAL="${FILE%.zip}"
+ ;;
+
+ *)
+ exit_err "ERROR: ${COMPRESSION} compression is not supported"
+ ;;
+ esac
+ fi
+
+ export VAL
+}
+
write_image()
{
+ local IMAGE_FILE
+ local DEVICE_FILE
+
IMAGE_FILE="$1"
DEVICE_FILE="$2"
if [ -z "${IMAGE_FILE}" ]
then
- echo "ERROR: Image file not specified!"
- exit 1
+ exit_err "ERROR: Image file not specified!"
fi
if [ -z "${DEVICE_FILE}" ]
then
- echo "ERROR: Device file not specified!"
- exit 1
+ exit_err "ERROR: Device file not specified!"
fi
if [ ! -f "${IMAGE_FILE}" ]
then
- echo "ERROR: '${IMAGE_FILE}' does not exist!"
- exit 1
+ exit_err "ERROR: '${IMAGE_FILE}' does not exist!"
fi
DEVICE_FILE="${DEVICE_FILE#/dev/}"
@@ -312,16 +408,21 @@
if [ ! -c "${DEVICE_FILE}" ]
then
- echo "ERROR: '${DEVICE_FILE}' is not a character device!"
- exit 1
+ exit_err "ERROR: '${DEVICE_FILE}' is not a character device!"
fi
- if [ "${RES}" = "0" ]
+ if iscompressed "${IMAGE_FILE}"
then
- rc_halt "dd if=${IMAGE_FILE} of=${DEVICE_FILE} ibs=16k obs=16k"
+ local COMPRESSION
+
+ get_compression_type "${IMAGE_FILE}"
+ COMPRESSION="${VAL}"
+
+ decompress_file "${IMAGE_FILE}" "${COMPRESSION}"
+ IMAGE_FILE="${VAL}"
fi
- return 0
+ rc_halt "dd if=${IMAGE_FILE} of=${DEVICE_FILE} bs=128k"
};
install_fresh()
@@ -329,45 +430,57 @@
# 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
+ if [ -z "${ROOTIMAGE}" ]
+ then
+
+ # 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
+ # 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
+ # Lets mount the partitions now
+ mount_all_filesystems
- # We are ready to begin extraction, lets start now
- init_extraction
+ # 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 optional modules to load
+ install_components
- # Check if we have any packages to install
- install_packages
+ # Check if we have any packages to install
+ install_packages
- # Do any localization in configuration
- run_localize
+ # Do any localization in configuration
+ run_localize
- # Save any networking config on the installed system
- save_networking_install
+ # Save any networking config on the installed system
+ save_networking_install
- # Now add any users
- setup_users
+ # Now add any users
+ setup_users
- # Now run any commands specified
- run_commands
+ # Now run any commands specified
+ run_commands
- # Do any last cleanup / setup before unmounting
- run_final_cleanup
+ # Do any last cleanup / setup before unmounting
+ run_final_cleanup
- # Unmount and finish up
- unmount_all_filesystems
+ # Unmount and finish up
+ unmount_all_filesystems
+ fi
echo_log "Installation finished!"
-}
+};
+
+install_image()
+{
+ # We are ready to begin extraction, lets start now
+ init_extraction
+
+ echo_log "Installation finished!"
+};
install_upgrade()
{
@@ -397,4 +510,4 @@
unmount_upgrade
echo_log "Upgrade finished!"
-}
+};
diff -urN /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/installimage.sh usr.sbin/pc-sysinstall/backend/installimage.sh
--- /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/installimage.sh 2010-09-08 20:33:07.000000000 -0700
+++ usr.sbin/pc-sysinstall/backend/installimage.sh 2010-08-26 12:58:04.000000000 -0700
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/installimage.sh,v 1.1 2010/09/09 03:33:07 imp Exp $
+# $FreeBSD$
# Source our functions scripts
. ${BACKEND}/functions.sh
diff -urN /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/parseconfig.sh usr.sbin/pc-sysinstall/backend/parseconfig.sh
--- /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend/parseconfig.sh 2010-09-24 12:07:45.000000000 -0700
+++ usr.sbin/pc-sysinstall/backend/parseconfig.sh 2010-09-20 23:04:32.000000000 -0700
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/parseconfig.sh,v 1.5 2010/09/08 20:10:24 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/parseconfig.sh,v 1.4 2010/08/24 06:11:46 imp Exp $
# Main install configuration parsing script
#
@@ -73,7 +73,7 @@
check_value installMode "fresh upgrade"
check_value bootManager "bsd none"
check_value installType "PCBSD FreeBSD"
-check_value installMedium "dvd usb ftp rsync"
+check_value installMedium "dvd usb ftp rsync image"
check_value packageType "uzip tar rsync split"
if_check_value_exists partition "all s1 s2 s3 s4 free image"
if_check_value_exists mirrorbal "load prefer round-robin split"
@@ -100,7 +100,12 @@
# If we are not doing an upgrade, lets go ahead and setup the disk
case "${INSTALLMODE}" in
fresh)
- install_fresh
+ if [ "${INSTALLMEDIUM}" = "image" ]
+ then
+ install_image
+ else
+ install_fresh
+ fi
;;
upgrade)
@@ -108,7 +113,7 @@
;;
*)
- exit 1
+ exit 1
;;
esac
diff -urN /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend-query/disk-list.sh usr.sbin/pc-sysinstall/backend-query/disk-list.sh
--- /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/backend-query/disk-list.sh 2010-09-24 12:07:45.000000000 -0700
+++ usr.sbin/pc-sysinstall/backend-query/disk-list.sh 2010-08-24 16:15:15.000000000 -0700
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/disk-list.sh,v 1.5 2010/09/08 20:10:24 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend-query/disk-list.sh,v 1.4 2010/08/24 06:11:46 imp Exp $
ARGS=$1
FLAGS_MD=""
diff -urN /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf
--- /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf 2010-08-19 12:23:00.000000000 -0700
+++ usr.sbin/pc-sysinstall/conf/pc-sysinstall.conf 2010-09-20 20:41:12.000000000 -0700
@@ -68,6 +68,10 @@
FBSD_ARCH=`uname -m`
export FBSD_UZIP_FILE FBSD_TAR_FILE FBSD_BRANCH FBSD_BRANCH_DIR FBSD_ARCH
+# Location of image file
+IMAGE_FILE="/home/john/tmp/PCBSD8.1-x86-USB.img"
+export IMAGE_FILE
+
# Our internet mirror listing file location
NETSERVER="http://updates.pcbsd.org"
ARCH="`uname -m`"
diff -urN /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/examples/README usr.sbin/pc-sysinstall/examples/README
--- /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/examples/README 2010-09-24 12:07:45.000000000 -0700
+++ usr.sbin/pc-sysinstall/examples/README 2010-09-20 20:41:07.000000000 -0700
@@ -153,7 +153,7 @@
Setting this option will instruct pc-sysinstall to install the BSD boot Manager,
or leave it empty
-# image=(/path/to/image/file)
+# image=(/path/to/image/file) (/mountpoint)
Setting this option will instruct pc-sysinstall to write the image file
specified by the path to the disk.
@@ -217,7 +217,7 @@
The following settings specify the type, locations and sources
for this installation
-# installMedium=(dvd, usb, ftp, rsync)
+# installMedium=(dvd, usb, ftp, rsync, image)
Set installMedium= to the source type we will be using for this install.
@@ -226,6 +226,7 @@
usb - Search for and mount the USB drive which contains the install archive
ftp - The install archive will be fetched from a FTP / HTTP server before install
rsync - Pull the system data from a ssh + rsync server, specified with variables below
+image - Install system from an image
# installType=(PCBSD, FreeBSD)
@@ -364,4 +365,4 @@
Setting autoLoginUser will enable the specified user to log into the desktop
automatically without entering a password
-$FreeBSD: src/usr.sbin/pc-sysinstall/examples/README,v 1.3 2010/09/08 20:10:24 imp Exp $
+$FreeBSD: src/usr.sbin/pc-sysinstall/examples/README,v 1.2 2010/08/19 06:11:06 imp Exp $
diff -urN /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh
--- /usr/home/john/src/freebsd/9.0-CURRENT/src/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh 2010-09-24 12:07:46.000000000 -0700
+++ usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh 2010-09-23 14:38:17.000000000 -0700
@@ -30,7 +30,7 @@
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh,v 1.11 2010/09/08 20:10:24 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh,v 1.10 2010/08/24 06:11:46 imp Exp $
#####################################################################
# User-editable configuration variables
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-bugs
mailing list