From nobody@FreeBSD.org  Tue Mar  4 20:59:32 2008
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 1711C1065675
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  4 Mar 2008 20:59:32 +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 D66898FC1F
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  4 Mar 2008 20:59:31 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m24KuVkn016962
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 4 Mar 2008 20:56:31 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m24KuV1I016961;
	Tue, 4 Mar 2008 20:56:31 GMT
	(envelope-from nobody)
Message-Id: <200803042056.m24KuV1I016961@www.freebsd.org>
Date: Tue, 4 Mar 2008 20:56:31 GMT
From: Richard Arends <richard@unixguru.nl>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Rewrite TinyBSD port build and install function
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         121367
>Category:       misc
>Synopsis:       Rewrite TinyBSD port build and install function
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    remko
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Mar 04 21:00:03 UTC 2008
>Closed-Date:    Tue Mar 11 19:25:53 UTC 2008
>Last-Modified:  Tue Mar 11 19:25:53 UTC 2008
>Originator:     Richard Arends
>Release:        7.0-RELEASE
>Organization:
unixguru.nl
>Environment:
FreeBSD freebsd_update.unixguru.nl 7.0-RELEASE FreeBSD 7.0-RELEASE #0: Sun Feb 24 19:59:52 UTC 2008     root@logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
This patch is a rewrite of the port install and build
function in the tinybsd script. After applying this patch, the
port building and install uses the DESTDIR function from bsd.destdir.mk,
which chroot's to the tinybsd workdir. Needed binaries and
libraries are mounted with mount_nullfs at port build time.

Now building a port that has dependencies, or installs a user
or group is not a problem anymore!!
>How-To-Repeat:

>Fix:
Apply the patch

Patch attached with submission follows:

--- tinybsd.orig	2007-08-22 20:44:59.000000000 +0200
+++ tinybsd	2008-03-04 14:52:59.000000000 +0100
@@ -12,13 +12,12 @@
 else
   cd $CURRENTDIR
 fi
+
 WORKDIR=/usr/obj/tinybsdbuild
 KERNCONF=TINYBSD
 BASEFILE="tinybsd.basefiles"
 PORTSFILE="tinybsd.ports"
 PORTSDIR=/usr/ports
-PKGDIRS=/tmp/pkg.dirs
-PKGFILES=/tmp/pkg.files
 DEFINSTARGS="-o 0 -g 0 -m 555"
 TS="=====>"
 
@@ -276,7 +275,7 @@
 copy_binaries() {
 	cd ${CURRENTDIR}/conf/${CONF}
 
-	for file in `cat ${BASEFILE} | grep -v "#" | \
+	for file in `cat ${CURRENTDIR}/conf/${CONF}/${BASEFILE} | grep -v "#" | \
 		cut -f1 -d":" | sort | uniq` ; do
 		echo "${TS} Copying "/${file}" to "${WORKDIR}/${file} 
 		cp -fp /${file} ${WORKDIR}/${file} ;
@@ -284,39 +283,42 @@
 }
 
 install_ports() {
-	for portname in `cat ${PORTSFILE} | grep -v '#'` ; do
-	    cd ${PORTSDIR}/${portname}
-	    pkgname=`make -V PKGNAME`
-	    pkg_info -VQ ${pkgname}
-	    install=`echo $?`
-            if [ ${install} -eq 0 ] ; then
-	       echo "$portname is already installed..."
-	       create_missingdir
-	       copy_ports
-	      else
-	        make install clean
-		create_missingdir
-	        copy_ports
-	    fi
-	done
-}
-
-create_missingdir() {
-pkg_info -L ${pkgname} | egrep -v '(Information|Files|www|share|doc|man|include)' | sort | uniq >> ${PKGDIRS}
-	for dir in `cat ${PKGDIRS}`; do
-   	  if [ ! -d `dirname ${WORKDIR}/${dir}` ] ; then
-    	    mkdir -p `dirname ${WORKDIR}/${dir}`
-   	  fi
+	for portname in `cat ${CURRENTDIR}/conf/${CONF}/${PORTSFILE} | grep -v '#'` ; do
+		if [ ! -d "${WORKDIR}/usr/ports" ]; then
+			mkdir -p "${WORKDIR}/usr/ports"
+		fi
+
+		PNAME=`/usr/bin/basename "${portname}"`
+		PORT_OPTION_FILE="/var/db/ports/${PNAME}/options"
+
+		if [ -f "${PORT_OPTION_FILE}" ]; then
+			mkdir -p "${WORKDIR}/var/db/ports/${PNAME}"
+			cp "${PORT_OPTION_FILE}" "${WORKDIR}/var/db/ports/${PNAME}/"
+		fi
+
+		mount_nullfs /lib "${WORKDIR}/lib"
+		mount_nullfs /usr/bin "${WORKDIR}/usr/bin"
+		mount_nullfs /usr/sbin "${WORKDIR}/usr/sbin"
+		mount_nullfs /usr/ports "${WORKDIR}/usr/ports"
+		mount_nullfs /usr/share "${WORKDIR}/usr/share"
+		mount_nullfs /usr/libexec "${WORKDIR}/usr/libexec"
+		mount_nullfs /usr/lib "${WORKDIR}/usr/lib"
+		mount_nullfs /usr/include "${WORKDIR}/usr/include"
+
+		cd ${PORTSDIR}/${portname}
+		make fetch-recursive
+		make DESTDIR_ENV_LIST=PATH DESTDIR="${WORKDIR}" install
+		make clean
+
+		umount "${WORKDIR}/lib"
+		umount "${WORKDIR}/usr/ports"
+		umount "${WORKDIR}/usr/bin"
+		umount "${WORKDIR}/usr/sbin"
+		umount "${WORKDIR}/usr/share"
+		umount "${WORKDIR}/usr/libexec"
+		umount "${WORKDIR}/usr/lib"
+		umount "${WORKDIR}/usr/include"
 	done
-	rm ${PKGDIRS}
-}
-
-copy_ports() {
-pkg_info -L ${pkgname} | egrep -v '(Information|Files|www|share|doc|man|include)' >> ${PKGFILES}
-        for port in `cat ${PKGFILES}` ; do
-                echo "${TS} Copying "${port}" to "${WORKDIR}${port}
-                cp -fp ${port} ${WORKDIR}${port} ;
-        done
 }
 
 make_kernel() {
@@ -336,13 +338,10 @@
 	TDEPFILE="`mktemp -t deps`"
 	TDEPFILES="`mktemp -t depsymlnk`"
 
-	cd ${CURRENTDIR}/conf/${CONF}
-	for file in `cat ${BASEFILE} ${PKGFILES} | grep -v "#" | cut -f1 -d":"`; do
-		ldd -f "%p\n" /${file} >> ${TDEPFILE} ; # don't worry on progs been "not dynamic"
+	find "${WORKDIR}" -type f |while read file; do
+		ldd -f "%p\n" ${file} >> ${TDEPFILE} ; # don't worry on progs been "not dynamic"
 	done
 
-	rm ${PKGFILES}
-
 	for libdeplib in `cat ${TDEPFILE} | sort | uniq`; do
 		ldd -f "%p\n" /${libdeplib} >> ${TDEPFILE} ;
 	done
@@ -378,15 +377,6 @@
 	rm -fv ${TDEPFILE} ${TDEPFILES}
 }
 
-deinstall_ports() {
-	for portname in `cat ${PORTSFILE} | grep -v '#'` ; do
-            cd ${PORTSDIR}/${portname}    
-             if [ $? -ne ${install} ] ; then
-               make deinstall
-             fi
-	done
-}
-
 create_etc() {
 	cd /usr/src/etc/sendmail/
 	make freebsd.cf freebsd.submit.cf
@@ -416,7 +406,7 @@
 
 symlinks() {
 #set -xv
-	for i in `cat ${BASEFILE} ${PORTSFILE} | grep -v "#" | grep ":"`; do
+	for i in `cat ${CURRENTDIR}/conf/${CONF}/${BASEFILE}| grep -v "#" | grep ":"`; do
 		SOURCE_FILE=`echo $i | awk -F ":" {'print $1'}`
 		TARGET_FILE=`echo $i | awk -F ":" {'print $2'}`
 		chroot ${WORKDIR} /bin/ln -vs /${SOURCE_FILE} ${TARGET_FILE}
@@ -489,7 +479,6 @@
 	echo "${TS} You can see your build log in ${HOME}/tinybsd.log"
 	echo "${TS} Your final image is in ${CURRENTDIR}/${IMG}"
 	echo "${TS} Now use dd(1) to write it."
-
 }
 
 ##########################
@@ -514,12 +503,11 @@
   check_alt_imgname
   create_tree
   copy_binaries
+  create_etc
   install_ports
   make_kernel
   copy_libraries
   symlinks
-  deinstall_ports
-  create_etc
   create_ssh_keys
   personal_conf
   create_image


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->remko 
Responsible-Changed-By: remko 
Responsible-Changed-When: Tue Mar 4 21:05:35 UTC 2008 
Responsible-Changed-Why:  
I'll handle this for Richard 

http://www.freebsd.org/cgi/query-pr.cgi?pr=121367 
State-Changed-From-To: open->patched 
State-Changed-By: remko 
State-Changed-When: Sat Mar 8 15:41:40 UTC 2008 
State-Changed-Why:  
Patched in CURRENT, MFC pending in three days. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: misc/121367: commit references a PR
Date: Sat,  8 Mar 2008 15:41:11 +0000 (UTC)

 remko       2008-03-08 15:41:06 UTC
 
   FreeBSD src repository
 
   Modified files:
     tools/tools/tinybsd  tinybsd 
   Log:
   Improve handling of the tinybsd application wrt ports.  Ports that
   have dependencies or need to install a new user/group, are not
   problematic anymore.
   
   PR:             121367
   Submitted by:   Richard Arends < richard at unixguru dot nl >
   MFC after:      3 days
   
   Revision  Changes    Path
   1.8       +41 -53    src/tools/tools/tinybsd/tinybsd
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: misc/121367: commit references a PR
Date: Tue, 11 Mar 2008 19:19:19 +0000 (UTC)

 remko       2008-03-11 19:19:14 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_7)
     tools/tools/tinybsd  tinybsd 
   Log:
   MFC rev 1.8 tinybsd
   
     Improve handling of the tinybsd application wrt ports.  Ports that
     have dependencies or need to install a new user/group, are not
     problematic anymore.
   
     PR:             121367
     Submitted by:   Richard Arends < richard at unixguru dot nl >
     MFC after:      3 days
   
   Approved by:    imp (mentor, implicit)
   
   Revision  Changes    Path
   1.7.2.1   +41 -53    src/tools/tools/tinybsd/tinybsd
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: remko 
State-Changed-When: Tue Mar 11 19:25:51 UTC 2008 
State-Changed-Why:  
MFC'ed to releng_7, I think releng_6 is just too different at the moment 
to MFC this. If people really want this though please poke me and I'll 
see what I can do to make that happen (where allowed). Thanks Richard 
for the submission! 

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