From owner-svn-src-all@freebsd.org Mon Dec 7 04:02:53 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7D3659A008C; Mon, 7 Dec 2015 04:02:53 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3DFC71AE1; Mon, 7 Dec 2015 04:02:53 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tB742qrk082145; Mon, 7 Dec 2015 04:02:52 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tB742qRb082143; Mon, 7 Dec 2015 04:02:52 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201512070402.tB742qRb082143@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Mon, 7 Dec 2015 04:02:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r291917 - head/tools/tools/nanobsd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Dec 2015 04:02:53 -0000 Author: imp Date: Mon Dec 7 04:02:52 2015 New Revision: 291917 URL: https://svnweb.freebsd.org/changeset/base/291917 Log: Fix up mtree with additional entries written to it by nanobsd. implement support for NanoBSD touching a file (and possibly recording that fact) as well as replacing a directory with a symlink. Also specify the default uname and gname for files and use that as a /set command at the top of the generated METALOG file. Modified: head/tools/tools/nanobsd/defaults.sh (contents, props changed) head/tools/tools/nanobsd/nanobsd.sh (contents, props changed) Modified: head/tools/tools/nanobsd/defaults.sh ============================================================================== --- head/tools/tools/nanobsd/defaults.sh Mon Dec 7 04:02:42 2015 (r291916) +++ head/tools/tools/nanobsd/defaults.sh Mon Dec 7 04:02:52 2015 (r291917) @@ -157,6 +157,9 @@ NANO_SLICE_ALTROOT=s2 NANO_SLICE_CFG=s3 NANO_SLICE_DATA=s4 +# Default ownwership for nopriv build +NANO_DEF_UNAME=root +NANO_DEF_GNAME=wheel ####################################################################### # Architecture to build. Corresponds to TARGET_ARCH in a buildworld. @@ -241,6 +244,37 @@ rm ( ) { esac } +# +# Create empty files in the target tree, and record the fact. All paths +# are relative to NANO_WORLDDIR. +# +tgt_touch ( ) ( + + cd "${NANO_WORLDDIR}" + for i; do + touch $i + echo "./${i} type=file" >> ${NANO_METALOG} + done +) + +# +# Convert a directory into a symlink. Takes two arguments, the +# current directory and what it should become a symlink to. The +# directory is removed and a symlink is created. If we're doing +# a nopriv build, then append this fact to the metalog +# +tgt_dir2symlink () ( + dir=$1 + symlink=$2 + + cd "${NANO_WORLDDIR}" + rm -rf "$dir" + ln -s "$symlink" "$dir" + if [ -n $NANO_METALOG ]; then + echo "./${dir} type=link mode=0777 link=${symlink}" >> ${NANO_METALOG} + fi +) + # run in the world chroot, errors fatal CR ( ) { chroot "${NANO_WORLDDIR}" /bin/sh -exc "$*" @@ -413,6 +447,11 @@ native_xtools ( ) ( ) > ${NANO_OBJ}/_.native_xtools 2>&1 ) +# +# Run the requested set of customization scripts, run after we've +# done an installworld, installed the etc files, installed the kernel +# and tweaked them in the standard way. +# run_customize ( ) ( pprint 2 "run customize scripts" @@ -425,6 +464,10 @@ run_customize ( ) ( done ) +# +# Run any last-minute customization commands after we've had a chance to +# setup nanobsd, prune empty dirs from /usr, etc +# run_late_customize ( ) ( pprint 2 "run late customize scripts" @@ -437,6 +480,33 @@ run_late_customize ( ) ( done ) +# +# Hook called after we run all the late customize commands, but +# before we invoke the disk imager. The nopriv build uses it to +# read in the meta log, apply the changes other parts of nanobsd +# have been recording their actions. It's not anticipated that +# a user's cfg file would override this. +# +fixup_before_diskimage ( ) ( + + # Run the deduplication script that takes the matalog journal and + # combines multiple entries for the same file (see source for + # details). We take the extra step of removing the size keywords. This + # script, and many of the user scripts, copies, appeneds and otherwise + # modifies files in the build, changing their sizes. These actions are + # impossible to trap, so go ahead remove the size= keyword. For this + # narrow use, it doesn't buy us any protection and just gets in the way. + # The dedup tool's output must be sorted due to limitations in awk. + if [ -n ${NANO_METALOG} ]; then + pprint 2 "Fixing metalog" + cp ${NANO_METALOG} ${NANO_METALOG}.pre + (echo "/set uname=${NANO_DEF_UNAME} gname=${NANO_DEF_GNAME}" && + cat ${NANO_METALOG}.pre) | \ + ${NANO_TOOLS}/mtree-dedup.awk | \ + sed -e 's/ size=[0-9][0-9]*//' | sort > ${NANO_METALOG} + fi +) + setup_nanobsd ( ) ( pprint 2 "configure nanobsd setup" pprint 3 "log: ${NANO_OBJ}/_.dl" @@ -474,8 +544,7 @@ setup_nanobsd ( ) ( echo "mount -o ro /dev/${NANO_DRIVE}${NANO_SLICE_CFG}" > conf/default/etc/remount # Put /tmp on the /var ramdisk (could be symlink already) - rm -rf tmp - ln -s var/tmp tmp + tgt_dir2symlink tmp var/tmp ) > ${NANO_OBJ}/_.dl 2>&1 ) Modified: head/tools/tools/nanobsd/nanobsd.sh ============================================================================== --- head/tools/tools/nanobsd/nanobsd.sh Mon Dec 7 04:02:42 2015 (r291916) +++ head/tools/tools/nanobsd/nanobsd.sh Mon Dec 7 04:02:52 2015 (r291917) @@ -178,6 +178,7 @@ run_customize setup_nanobsd prune_usr run_late_customize +fixup_before_diskimage if $do_image ; then create_diskimage else