From owner-freebsd-bugs@FreeBSD.ORG Sat Mar 22 11:20:00 2014 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org 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 92451AC8 for ; Sat, 22 Mar 2014 11:20:00 +0000 (UTC) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 71524173 for ; Sat, 22 Mar 2014 11:20:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.8/8.14.8) with ESMTP id s2MBK0BX074074 for ; Sat, 22 Mar 2014 11:20:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.8/8.14.8/Submit) id s2MBK0rX074073; Sat, 22 Mar 2014 11:20:00 GMT (envelope-from gnats) Resent-Date: Sat, 22 Mar 2014 11:20:00 GMT Resent-Message-Id: <201403221120.s2MBK0rX074073@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Lev Serebryakov 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 To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.114 Subject: misc/187838: Add support for "mtree" to populate_data_slice and cust_install_files, unify variable names. Cc: imp@FreeBSD.org X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list Reply-To: Lev Serebryakov List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Mar 2014 11:20:00 -0000 >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: