From nobody@FreeBSD.org  Wed Sep 29 04:41:24 2010
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 449511065672
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 29 Sep 2010 04:41:24 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 32E4D8FC16
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 29 Sep 2010 04:41:24 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o8T4fNf3018692
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 29 Sep 2010 04:41:23 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o8T4fN2n018691;
	Wed, 29 Sep 2010 04:41:23 GMT
	(envelope-from nobody)
Message-Id: <201009290441.o8T4fN2n018691@www.freebsd.org>
Date: Wed, 29 Sep 2010 04:41:23 GMT
From: John Hixson <john@ixsystems.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: pc-sysinstall patch that modifies image writing to decompress to stdout
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         151049
>Category:       bin
>Synopsis:       [patch] pc-sysinstall(8) patch that modifies image writing to decompress to stdout
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    imp
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep 29 04:50:00 UTC 2010
>Closed-Date:    Thu Oct 21 11:21:11 MDT 2010
>Last-Modified:  Thu Oct 21 11:21:11 MDT 2010
>Originator:     John Hixson
>Release:        9.0-CURRENT
>Organization:
iXsystems
>Environment:
FreeBSD thinkbsd 9.0-CURRENT FreeBSD 9.0-CURRENT #6: Sat Sep 25 05:21:08 PDT 2010     john@thinkbsd:/usr/obj/usr/src/sys/THINKBSD  amd64

>Description:
This is an updated patch to the last patch to do this which fixes a local variable issue. This patch decompresses compressed images to the stdout when writing to a device to avoid running out of space issues. 
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

diff -urN usr.sbin/pc-sysinstall.orig/backend/functions.sh usr.sbin/pc-sysinstall/backend/functions.sh
--- usr.sbin/pc-sysinstall.orig/backend/functions.sh	2010-09-28 20:24:03.000000000 -0700
+++ usr.sbin/pc-sysinstall/backend/functions.sh	2010-09-28 21:38:04.000000000 -0700
@@ -325,64 +325,8 @@
   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"
@@ -418,11 +362,51 @@
     get_compression_type "${IMAGE_FILE}"
 	COMPRESSION="${VAL}"
 
-	decompress_file "${IMAGE_FILE}" "${COMPRESSION}"
-	IMAGE_FILE="${VAL}"
-  fi
+    case "${COMPRESSION}" in
+      lzw)
+        rc_halt "uncompress ${IMAGE_FILE} -c | dd of=${DEVICE_FILE} bs=128k"
+        IMAGE_FILE="${IMAGE_FILE%.Z}"
+        ;;
+
+      lzo)
+        rc_halt "lzop -d $IMAGE_{FILE} -c | dd of=${DEVICE_FILE} bs=128k"
+        IMAGE_FILE="${IMAGE_FILE%.lzo}"
+        ;;
+
+      lzma)
+        rc_halt "lzma -d ${IMAGE_FILE} -c | dd of=${DEVICE_FILE} bs=128k"
+        IMAGE_FILE="${IMAGE_FILE%.lzma}"
+        ;;
+
+      gzip)
+        rc_halt "gunzip ${IMAGE_FILE} -c | dd of=${DEVICE_FILE} bs=128k"
+        IMAGE_FILE="${IMAGE_FILE%.gz}"
+        ;;
 
-  rc_halt "dd if=${IMAGE_FILE} of=${DEVICE_FILE} bs=128k"
+      bzip2)
+        rc_halt "bunzip2 ${IMAGE_FILE} -c | dd of=${DEVICE_FILE} bs=128k"
+        IMAGE_FILE="${IMAGE_FILE%.bz2}"
+        ;;
+
+      xz)
+        rc_halt "xz -d ${IMAGE_FILE} -c | dd of=${DEVICE_FILE} bs=128k"
+        IMAGE_FILE="${IMAGE_FILE%.xz}"
+        ;;
+
+      zip)
+        rc_halt "unzip ${IMAGE_FILE} -c | dd of=${DEVICE_FILE} bs=128k"
+        IMAGE_FILE="${IMAGE_FILE%.zip}"
+        ;;
+
+      *) 
+        exit_err "ERROR: ${COMPRESSION} compression is not supported"
+        ;;
+    esac
+
+  else
+    rc_halt "dd if=${IMAGE_FILE} of=${DEVICE_FILE} bs=128k"
+
+  fi
 };
 
 install_fresh()


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->imp 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Wed Sep 29 07:38:03 UTC 2010 
Responsible-Changed-Why:  
Over to maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=151049 
State-Changed-From-To: open->closed 
State-Changed-By: imp 
State-Changed-When: Thu Oct 21 11:20:58 MDT 2010 
State-Changed-Why:  
Committed. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=151049 
>Unformatted:
