From josemi@freebsd.jazztel.es  Tue Nov 16 16:52:53 2004
Return-Path: <josemi@freebsd.jazztel.es>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 8006A16A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 16 Nov 2004 16:52:53 +0000 (GMT)
Received: from smtp2.jazztel.es (smtp2.jazztel.es [62.14.3.162])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 0008C43D1F
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 16 Nov 2004 16:52:52 +0000 (GMT)
	(envelope-from josemi@freebsd.jazztel.es)
Received: from antivirus
	by smtp2.jazztel.es
	with antivirus id 1CU6ZV-0006eT-00
	for FreeBSD-gnats-submit@freebsd.org
	Tue, 16 Nov 2004 17:52:49 +0100
Received: from [212.106.252.3] (helo=rguez.homeunix.net)
	by smtp2.jazztel.es
	with esmtp id 1CU6ZU-0006d5-00
	for FreeBSD-gnats-submit@freebsd.org
	Tue, 16 Nov 2004 17:52:49 +0100
Received: from redesjm.local (orion.redesjm.local [192.168.254.16])
	by rguez.homeunix.net (8.13.1/8.13.1) with ESMTP id iAGGqo7G081530
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 16 Nov 2004 17:52:50 +0100 (CET)
	(envelope-from freebsd@redesjm.local)
Received: (from freebsd@localhost)
	by redesjm.local (8.13.1/8.13.1/Submit) id iAGGqocd052763;
	Tue, 16 Nov 2004 17:52:50 +0100 (CET)
	(envelope-from freebsd)
Message-Id: <200411161652.iAGGqocd052763@redesjm.local>
Date: Tue, 16 Nov 2004 17:52:50 +0100 (CET)
From: Jose M Rodriguez <josemi@freebsd.jazztel.es>
Reply-To: Jose M Rodriguez <josemi@freebsd.jazztel.es>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] aditional support for /etc/rc.initdiskless
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         74005
>Category:       conf
>Synopsis:       [PATCH] aditional support for /etc/rc.initdiskless
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-rc
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Nov 16 17:00:50 GMT 2004
>Closed-Date:    Wed Feb 22 05:15:19 GMT 2006
>Last-Modified:  Wed Feb 22 05:15:19 GMT 2006
>Originator:     Jose M Rodriguez
>Release:        FreeBSD 5.3-STABLE i386
>Organization:
Redes JM
>Environment:
System: FreeBSD orion.redesjm.local 5.3-STABLE FreeBSD 5.3-STABLE #0: Tue Nov 16 13:26:33 CET 2004 root@orion.redesjm.local:/usr/obj/usr/src/sys/ORION i386


>Description:
	Add aditional support to /etc/rc.initdiskless, in the way
	of use pax instead of cpio and any version of gzip.

	This also add suppor for uncompressed pax tarballs (ustar)

	Working in the way of be capable of remote booting without
	/rescue or /stand and maintain compatibility with any version
	of FreeBSD from RELENG_4

>How-To-Repeat:
>Fix:

	This have now very limited test, use with care

--- patch-initdiskless begins here ---
--- etc/rc.d/initdiskless.orig	Thu Oct 28 21:34:40 2004
+++ etc/rc.d/initdiskless	Thu Oct 28 21:34:51 2004
@@ -91,10 +91,15 @@
 #		initialize it from a template, it is preferrable to specify
 #		it in fstab e.g. as  "md /tmp mfs -s=30m,rw 0 0"
 #
+# /conf/T/SUBDIR.pax
+#		The file is expanded into /SUBDIR (and a memory filesystem
+#		is created for /SUBDIR if necessary). The presence of this
+#		file prevents the copy from other sources
+#
 # /conf/T/SUBDIR.cpio.gz
-#		The file is cpio'd into /SUBDIR (and a memory filesystem is
-#		created for /SUBDIR if necessary). The presence of this file
-#		prevents the copy from /conf/T/SUBDIR/
+#		The file is expanded into /SUBDIR (and a memory filesystem
+#		is created for /SUBDIR if necessary). The presence of this
+#		file prevents the copy from /conf/T/SUBDIR/
 #
 # /conf/T/SUBDIR.remove
 #		The list of paths contained in the file are rm -rf'd
@@ -250,6 +255,7 @@
 #   it before attemping to the remount.  This allows the root to be
 #   relocated without needing to change the remount files.
 #
+
 for i in ${templates} ; do
     for j in /conf/$i/* ; do
 	# memory filesystem size specification
@@ -291,27 +297,56 @@
 # so if the cpio archive is present, it prevents the files from dir/
 # from being copied.
 
+# a valid gzip
+if [ -x /bin/gzip ]; then
+	use_gunzip="/bin/gzip -d"
+elif [ -x /rescue/gzip ]; then
+	use_gunzip="/rescue/gzip -d"
+elif [ -x /stand/gzip ]; then
+	use_gunzip="/stand/gzip -d"
+else
+	use_gunzip=""
+fi
+
 for i in ${templates} ; do
-    for j in /conf/$i/* ; do
-	subdir=${j##*/}
-	if [ -d $j -a ! -f $j.cpio.gz  ]; then
+    for j in /conf/$i/*.pax ; do
+	subdir=${j%*.pax}
+	subdir=${subdir##*/}
+	eval _from=\$md_from_${subdir}_${i}
+	if [ -r $j -a ! -n "${_from}" ]; then
 	    create_md $subdir
-	    cp -Rp $j/* /$subdir
+	    echo "Loading /$subdir from pax archive $j"
+	    (cd / ; /bin/pax -r -pe ${busbir} < $j )
+	    eval md_from_${subdir}_${i}="$j"
 	fi
     done
-    for j in /conf/$i/*.cpio.gz ; do
-	subdir=${j%*.cpio.gz}
-	subdir=${subdir##*/}
-	if [ -f $j ]; then
+    if [ -n "${use_gunzip}" ]; then
+	for j in /conf/$i/*.cpio.gz ; do
+	    subdir=${j%*.cpio.gz}
+	    subdir=${subdir##*/}
+	    eval _from=\$md_from_${subdir}_${i}
+	    if [ -r $j -a ! -n "${_from}" ]; then
+		create_md $subdir
+		echo "Loading /$subdir from cpio archive $j"
+		(cd / ; ${use_gunzip} < $j | /bin/pax -r -pe ${subdir} )
+		eval md_from_${subdir}_${i}="$j"
+	    fi
+	done
+    fi
+    for j in /conf/$i/* ; do
+	subdir=${j##*/}
+	eval _from=\$md_from_${subdir}_${i}
+	if [ -d $j -a ! -n "${_from}" ]; then
 	    create_md $subdir
-	    echo "Loading /$subdir from cpio archive $j"
-	    (cd / ; /stand/gzip -d < $j | /stand/cpio --extract -d )
+	    echo "Copying /$subdir from $j"
+	    cp -Rp $j/* /$subdir
+	    eval md_from_${subdir}_${i}="$j"
 	fi
     done
     for j in /conf/$i/*.remove ; do
 	subdir=${j%*.remove}
 	subdir=${subdir##*/}
-	if [ -f $j ]; then
+	if [ -r $j ]; then
 	    # doubly sure it is a memory disk before rm -rf'ing
 	    create_md $subdir
 	    (cd /$subdir; rm -rf `/bin/cat $j`)
--- patch-initdiskless ends here ---



>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-rc 
Responsible-Changed-By: dougb 
Responsible-Changed-When: Wed Feb 22 02:21:36 UTC 2006 
Responsible-Changed-Why:  

Bring to the attention of the list 

http://www.freebsd.org/cgi/query-pr.cgi?pr=74005 
State-Changed-From-To: open->feedback 
State-Changed-By: brooks 
State-Changed-When: Wed Feb 22 05:07:06 UTC 2006 
State-Changed-Why:  
Given that we've replaced cpio with tar in HEAD and RELENG_6 I'm not 
convinced the added complexity it worth it here. Moving the tar call 
into a function to make it easy to edit would make some sense, but I 
don't feel a great desire to support non-default installs out of the box 
here given the cost involved.  Note that with tar being used, virtually 
any archive will work as the cpio.gz. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=74005 
State-Changed-From-To: feedback->closed 
State-Changed-By: brooks 
State-Changed-When: Wed Feb 22 05:14:40 UTC 2006 
State-Changed-Why:  
As stated in the previous message I'm not all that intrested in 
this proposed change and the senders address bounces. 

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