From lev@onlyone.friendlyhosting.spb.ru  Sat Mar 22 11:11:26 2014
Return-Path: <lev@onlyone.friendlyhosting.spb.ru>
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTPS id EC44A981;
	Sat, 22 Mar 2014 11:11:25 +0000 (UTC)
Received: from onlyone.friendlyhosting.spb.ru (onlyone.friendlyhosting.spb.ru [46.4.40.135])
	by mx1.freebsd.org (Postfix) with ESMTP id 734149B;
	Sat, 22 Mar 2014 11:11:25 +0000 (UTC)
Received: by onlyone.friendlyhosting.spb.ru (Postfix, from userid 1000)
	id CD54D4AC31; Sat, 22 Mar 2014 15:11:17 +0400 (MSK)
Message-Id: <20140322111117.CD54D4AC31@onlyone.friendlyhosting.spb.ru>
Date: Sat, 22 Mar 2014 15:11:17 +0400 (MSK)
From: Lev Serebryakov <lev@FreeBSD.org>
Reply-To: Lev Serebryakov <lev@FreeBSD.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc: imp@FreeBSD.org
Subject: Add support for "mtree" to populate_data_slice and cust_install_files, unify variable names.
X-Send-Pr-Version: 3.114
X-GNATS-Notify:

>Number:         187838
>Category:       bin
>Synopsis:       [patch] Add support for mtree(8) to populate_data_slice and cust_install_files, unify variable names.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    imp
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sat Mar 22 11:20:00 UTC 2014
>Closed-Date:    
>Last-Modified:  Sat Mar 22 18:19:49 UTC 2014
>Originator:     Lev Serebryakov
>Release:        FreeBSD 11.0-CURRENT amd64
>Organization:
FreeBSD
>Environment:
System: FreeBSD fbsd-c-64.vm.home.serebryakov.spb.ru 11.0-CURRENT FreeBSD 11.0-CURRENT #10 r263296M: Tue Mar 18 23:38:19 MSK 2014 root@fbsd-c-64.vm.home.serebryakov.spb.ru:/usr/obj/data/src/sys/VBOX amd64

>Description:

  (1) Add support for ".mtree" files in source trees used by
      populate_data_slice and cust_install_files. These files
      could be placed anywere in these trees (multiple times)
      and will be applied to target (nanobsd world) trees.

      It allows system files to be owned by regular user.
      
  (2) Add NANO_FILESDIR variable.
  
  (3) Unify variable names: NANO_PACKAGE_DIR is only one with "_DIR'
      suffix, not simple "DIR".

  I use these changes locally for ages.

>How-To-Repeat:
>Fix:

Index: tools/tools/nanobsd/nanobsd.sh
===================================================================
--- tools/tools/nanobsd/nanobsd.sh	(revision 263618)
+++ tools/tools/nanobsd/nanobsd.sh	(working copy)
@@ -45,10 +45,6 @@
 # Where nanobsd additional files live under the source tree
 NANO_TOOLS=tools/tools/nanobsd
 
-# Where cust_pkg() finds packages to install
-NANO_PACKAGE_DIR=${NANO_SRC}/${NANO_TOOLS}/Pkg
-NANO_PACKAGE_LIST="*"
-
 # Object tree directory
 # default is subdir of /usr/obj
 #NANO_OBJ=""
@@ -157,6 +153,13 @@
 
 NANO_ARCH=`uname -p`
 
+# Where cust_install_files finds files to install
+NANO_FILESDIR=${NANO_TOOLS}/Files
+
+# Where cust_pkg() finds packages to install
+NANO_PACKAGEDIR=${NANO_SRC}/${NANO_TOOLS}/Pkg
+NANO_PACKAGE_LIST="*"
+
 # Directory to populate /cfg from
 NANO_CFGDIR=""
 
@@ -447,7 +450,20 @@
 )
 
 populate_data_slice ( ) (
-	populate_slice "$1" "$2" "$3" "$4"
+	local dev dir mnt lbl
+	dev=$1
+	dir=$2
+	mnt=$3
+	lbl=$4
+	
+	populate_slice "$dev" "$dir" "$mnt" "$lbl"
+	
+	find ${mnt} -type f -name .mtree -delete
+	cd ${dir}
+	find . -type f -name .mtree -print | while read fn ; do
+		fdir=`dirname ${fn}`
+		mtree -Ueq -f ${fn} -p ${mnt}/${fdir}
+	done
 )
 
 create_i386_diskimage ( ) (
@@ -704,17 +720,21 @@
 # Install the stuff under ./Files
 
 cust_install_files () (
-	cd ${NANO_TOOLS}/Files
-	find . -print | grep -Ev '/(CVS|\.svn)' | cpio -Ldumpv ${NANO_WORLDDIR}
+	cd ${NANO_FILESDIR}
+	find . -print | grep -Ev '/(CVS|\.svn|.mtree)' | cpio -dumpv ${NANO_WORLDDIR}
+	find . -type f -name .mtree -print | while read fn ; do
+		dir=`dirname ${fn}`
+		mtree -Ueq -f ${fn} -p ${NANO_WORLDDIR}/${dir}
+	done
 )
 
 #######################################################################
-# Install packages from ${NANO_PACKAGE_DIR}
+# Install packages from ${NANO_PACKAGEDIR}
 
 cust_pkg () (
 
 	# If the package directory doesn't exist, we're done.
-	if [ ! -d ${NANO_PACKAGE_DIR} ]; then
+	if [ ! -d ${NANO_PACKAGEDIR} ]; then
 		echo "DONE 0 packages"
 		return 0
 	fi
@@ -722,7 +742,7 @@
 	# Copy packages into chroot
 	mkdir -p ${NANO_WORLDDIR}/Pkg
 	(
-		cd ${NANO_PACKAGE_DIR}
+		cd ${NANO_PACKAGEDIR}
 		find ${NANO_PACKAGE_LIST} -print |
 		    cpio -Ldumpv ${NANO_WORLDDIR}/Pkg
 	)
@@ -764,16 +784,16 @@
 cust_pkgng () (
 
 	# If the package directory doesn't exist, we're done.
-	if [ ! -d ${NANO_PACKAGE_DIR} ]; then
+	if [ ! -d ${NANO_PACKAGEDIR} ]; then
 		echo "DONE 0 packages"
 		return 0
 	fi
 
 	# Find a pkg-* package
-	for x in `find -s ${NANO_PACKAGE_DIR} -iname 'pkg-*'`; do
+	for x in `find -s ${NANO_PACKAGEDIR} -iname 'pkg-*'`; do
 		_NANO_PKG_PACKAGE=`basename "$x"`
 	done
-	if [ -z "${_NANO_PKG_PACKAGE}" -o ! -f "${NANO_PACKAGE_DIR}/${_NANO_PKG_PACKAGE}" ]; then
+	if [ -z "${_NANO_PKG_PACKAGE}" -o ! -f "${NANO_PACKAGEDIR}/${_NANO_PKG_PACKAGE}" ]; then
 		echo "FAILED: need a pkg/ package for bootstrapping"
 		exit 2
 	fi
@@ -781,7 +801,7 @@
 	# Copy packages into chroot
 	mkdir -p ${NANO_WORLDDIR}/Pkg
 	(
-		cd ${NANO_PACKAGE_DIR}
+		cd ${NANO_PACKAGEDIR}
 		find ${NANO_PACKAGE_LIST} -print |
 		cpio -Ldumpv ${NANO_WORLDDIR}/Pkg
 	)
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->imp 
Responsible-Changed-By: lev 
Responsible-Changed-When: Sat Mar 22 11:28:25 UTC 2014 
Responsible-Changed-Why:  

According to src/MAINTAINERS  


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

From: Vladislav Prodan <universite@ukr.net>
To: Lev Serebryakov <lev@freebsd.org>
Cc: freebsd-gnats-submit@freebsd.org
Subject: Re: misc/187838: Add support for "mtree" to populate_data_slice and
 cust_install_files, unify variable names.
Date: Sat, 22 Mar 2014 13:26:01 +0200

 > 
 > >Number: 187838
 > >Category: misc
 > >Synopsis: Add support for "mtree" to populate_data_slice and cust_install_files, unify variable names.
 > >Confidential: no
 > >Severity: non-critical
 > >Priority: medium
 > >Responsible: freebsd-bugs
 > >State: open
 > >Quarter: 
 > >Keywords: 
 > >Date-Required:
 > >Class: change-request
 > >Submitter-Id: current-users
 > >Arrival-Date: Sat Mar 22 11:20:00 UTC 2014
 > >Closed-Date:
 > >Last-Modified:
 > >Originator: Lev Serebryakov
 > >Release: FreeBSD 11.0-CURRENT amd64
 > >Organization:
 > FreeBSD
 > >Environment:
 > System: FreeBSD fbsd-c-64.vm.home.serebryakov.spb.ru 11.0-CURRENT FreeBSD 11.0-CURRENT #10 r263296M: Tue Mar 18 23:38:19 MSK 2014 root@fbsd-c-64.vm.home.serebryakov.spb.ru:/usr/obj/data/src/sys/VBOX amd64
 > 
 > >Description:
 > 
 > (1) Add support for ".mtree" files in source trees used by
 > populate_data_slice and cust_install_files. These files
 > could be placed anywere in these trees (multiple times)
 > and will be applied to target (nanobsd world) trees.
 > 
 
 Some continue to use RCS :)
 I also ask you to exclude directories RCS  and files with the extension .v
 
 
 
 -- 
 Vladislav V. Prodan 
 System & Network Administrator 
 http://support.od.ua 
 +380 67 4584408, +380 99 4060508
 VVP88-RIPE
  
>Unformatted:
