Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Mar 2014 15:11:17 +0400 (MSK)
From:      Lev Serebryakov <lev@FreeBSD.org>
To:        FreeBSD-gnats-submit@freebsd.org
Cc:        imp@FreeBSD.org
Subject:   misc/187838: Add support for "mtree" to populate_data_slice and cust_install_files, unify variable names.
Message-ID:  <20140322111117.CD54D4AC31@onlyone.friendlyhosting.spb.ru>
Resent-Message-ID: <201403221120.s2MBK0rX074073@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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.

      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:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140322111117.CD54D4AC31>