From nobody Tue Aug 9 21:59:07 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4M2RmX0D3gz4YHMr; Tue, 9 Aug 2022 21:59:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4M2RmW6d5mz42dS; Tue, 9 Aug 2022 21:59:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660082348; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OW50BE6hDa3kxKbClIbRJJPWcOULVUCgkBK5Pq22LUk=; b=K1ONgOe1st+ThIC8DV53GPOtDXeyCzPHPszr+7bci7JaFbZaws0ta71LzYJbCdnTwkoURN TvM/J2cDE4XZKHx3FnCkECfHBcs7bCwC9PAbxxy9SU2IkEA1OqRo0+rhjB2P8cdh/mynxz 5ejvFqLwzo2vt+6P5219Wc97a8qcXJbAvrU1QOx0J230Yvz3DyZX8a6sc5wTKx+yUvVYZK kvGVRPNOLs+U5NzlwG2ulMpvh06l2+OtQrwMA6DCY8M0F1vPgNQahN5Q5priYbZTZSvr3F wHvyJWoAjZt1UtchqUB8jNx85biUZZNXsQsRilnOvXNB4CZ6ZtpHkKxRbHyjww== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4M2RmW5k9VznLM; Tue, 9 Aug 2022 21:59:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 279Lx7iG086524; Tue, 9 Aug 2022 21:59:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 279Lx7KG086523; Tue, 9 Aug 2022 21:59:07 GMT (envelope-from git) Date: Tue, 9 Aug 2022 21:59:07 GMT Message-Id: <202208092159.279Lx7KG086523@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Jessica Clarke Subject: git: febca0e64361 - main - etcupdate: Add a -N flag to perform a NO_ROOT build List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jrtc27 X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: febca0e643612eb1ce14fbd892c2af7e17717bf5 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660082348; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=OW50BE6hDa3kxKbClIbRJJPWcOULVUCgkBK5Pq22LUk=; b=eej+IQqzbDwQX3wYN9PpCrPqfA12YzvT1Di9587Yy99GmwVAjD0x+Z+z1eWXf7sxUJ42Y4 N8UOmol7t3N+4IcyiaMu46jawTUsShMw1LFoeRZODJoIi6iQzaHkAjBb7HPMsl0mPNjlrC zt0ikWIqVYdWlFK9h7skmxuzaHNqb3M5rV994HQD7hwjRc+mhBHzAzx4vA7ULfXtDVWGEi 6mN7hXTfE/Nw4S346QR4gopOJFl8xeFi6xeDJjellMJJyNQr3evbGzCKeOzdF9nRaTyy/L Mn77Bts1RkMKVgcAP6KkVL1fw6YNdyX9U2SzFiY0BrnuKGvNkBkNwkLxImyu+A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660082348; a=rsa-sha256; cv=none; b=fsvlT6p4rqyUrMcg+57LGT4OQMYZyLNa40RvzVTk9HQ/RjrOEToqTumypU6Z+WrkEqynnq aJdHhcNyaiV4f8gl/QX39yWz4QOg/ACuzxlgUqMFy5QvkJugY6GRwVdJ7629nK8lgVIAy1 BHYQum4ieUX/4YfKWLZrryPed7GH5lTyOmk4aAG/7dSn7dTa0T60uyz50I+U8QcSJ6gCUH Xv9mg1wB+71stRjPLwxwwUVu6uGCZbXX1GXgKE2RBKKIcTZ4jlohjDnOaqnf1hqxbealIf ZbW5KeilmAk08JLuLIVJxGcWQQlL6Nz5MPl5510NG2ROy8YYuN2WOsdsNF+0Fg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=febca0e643612eb1ce14fbd892c2af7e17717bf5 commit febca0e643612eb1ce14fbd892c2af7e17717bf5 Author: Jessica Clarke AuthorDate: 2022-08-09 21:57:47 +0000 Commit: Jessica Clarke CommitDate: 2022-08-09 21:57:47 +0000 etcupdate: Add a -N flag to perform a NO_ROOT build This is in preparation for including an etcupdate tree when performing a -DNO_ROOT release image build. Although -DNO_ROOT can be passed via -M, to be useful we need to mangle the resulting METALOG to mirror the various cleanups to the tree that are done after the build (removing generated files, empty files and empty directories), so etcupdate needs its own flag. Reviewed by: jhb, pauamma Obtained from: CheriBSD Differential Revision: https://reviews.freebsd.org/D35857 --- usr.sbin/etcupdate/etcupdate.8 | 15 ++++++++--- usr.sbin/etcupdate/etcupdate.sh | 57 ++++++++++++++++++++++++++++++++++------- 2 files changed, 60 insertions(+), 12 deletions(-) diff --git a/usr.sbin/etcupdate/etcupdate.8 b/usr.sbin/etcupdate/etcupdate.8 index be107f6a214d..773568eef9ec 100644 --- a/usr.sbin/etcupdate/etcupdate.8 +++ b/usr.sbin/etcupdate/etcupdate.8 @@ -33,7 +33,7 @@ .Nd "manage updates to system files not updated by installworld" .Sh SYNOPSIS .Nm -.Op Fl npBF +.Op Fl npBFN .Op Fl d Ar workdir .Op Fl r | Fl s Ar source | Fl t Ar tarball .Op Fl A Ar patterns @@ -44,7 +44,7 @@ .Op Fl m Ar make .Nm .Cm build -.Op Fl B +.Op Fl BN .Op Fl d Ar workdir .Op Fl s Ar source .Op Fl L Ar logfile @@ -59,7 +59,7 @@ .Op Fl L Ar logfile .Nm .Cm extract -.Op Fl B +.Op Fl BN .Op Fl d Ar workdir .Op Fl s Ar source | Fl t Ar tarball .Op Fl D Ar destdir @@ -518,6 +518,15 @@ option is not specified, then a temporary .Dq current tree will be extracted to perform the comparison. +.It Fl N +Perform a +.Dv NO_ROOT +build when building a +.Dq current +tree. +The resulting tree will include a corresponding +.Pa METALOG +file at its root. .It Fl p Enable .Dq pre-world diff --git a/usr.sbin/etcupdate/etcupdate.sh b/usr.sbin/etcupdate/etcupdate.sh index d9993fb2e58a..0190e5868f05 100755 --- a/usr.sbin/etcupdate/etcupdate.sh +++ b/usr.sbin/etcupdate/etcupdate.sh @@ -62,13 +62,13 @@ usage() { cat < etcupdate diff [-d workdir] [-D destdir] [-I patterns] [-L logfile] - etcupdate extract [-B] [-d workdir] [-s source | -t tarball] + etcupdate extract [-BN] [-d workdir] [-s source | -t tarball] [-D destdir] [-L logfile] [-M options] [-m make] etcupdate resolve [-p] [-d workdir] [-D destdir] [-L logfile] etcupdate revert [-d workdir] [-D destdir] [-L logfile] file ... @@ -184,14 +184,24 @@ always_install() # $1 - directory to store new tree in build_tree() ( - local destdir dir file make + local destdir dir file make autogenfiles metatmp make="$MAKE_CMD $MAKE_OPTIONS -DNO_FILEMON" + if [ -n "$noroot" ]; then + make="$make -DNO_ROOT" + metatmp=`mktemp $WORKDIR/etcupdate-XXXXXXX` + : > $metatmp + trap "rm -f $metatmp; trap '' EXIT; return 1" INT + trap "rm -f $metatmp" EXIT + else + metatmp="/dev/null" + trap "return 1" INT + fi + log "Building tree at $1 with $make" exec >&3 2>&1 - trap 'return 1' INT mkdir -p $1/usr/obj destdir=`realpath $1` @@ -219,13 +229,38 @@ build_tree() # Purge auto-generated files. Only the source files need to # be updated after which these files are regenerated. - rm -f $1/etc/*.db $1/etc/passwd $1/var/db/services.db || return 1 + autogenfiles="./etc/*.db ./etc/passwd ./var/db/services.db" + (cd $1 && printf '%s\n' $autogenfiles >> $metatmp && \ + rm -f $autogenfiles) || return 1 # Remove empty files. These just clutter the output of 'diff'. - find $1 -type f -size 0 -delete || return 1 + (cd $1 && find . -type f -size 0 -delete -print >> $metatmp) || \ + return 1 # Trim empty directories. - find $1 -depth -type d -empty -delete || return 1 + (cd $1 && find . -depth -type d -empty -delete -print >> $metatmp) || \ + return 1 + + if [ -n "$noroot" ]; then + # Rewrite the METALOG to exclude the files (and directories) + # removed above. $metatmp contains the list of files to delete, + # and we append #METALOG# as a delimiter followed by the + # original METALOG. This lets us scan through $metatmp in awk + # building up a table of names to delete until we reach the + # delimiter, then emit all the entries of the original METALOG + # after it that aren't in that table. We also exclude ./usr/obj + # and its children explicitly for simplicity rather than + # building up that list (and in practice only ./usr/obj itself + # will be in the METALOG since nothing is installed there). + echo '#METALOG#' >> $metatmp || return 1 + cat $1/METALOG >> $metatmp || return 1 + awk '/^#METALOG#$/ { metalog = 1; next } + { f=$1; gsub(/\/\/+/, "/", f) } + !metalog { rm[f] = 1; next } + !rm[f] && f !~ /^\.\/usr\/obj(\/|$)/ { print }' \ + $metatmp > $1/METALOG || return 1 + fi + return 0 ) @@ -1738,7 +1773,8 @@ dryrun= ignore= nobuild= preworld= -while getopts "d:m:nprs:t:A:BD:FI:L:M:" option; do +noroot= +while getopts "d:m:nprs:t:A:BD:FI:L:M:N" option; do case "$option" in d) WORKDIR=$OPTARG @@ -1798,6 +1834,9 @@ while getopts "d:m:nprs:t:A:BD:FI:L:M:" option; do M) MAKE_OPTIONS="$OPTARG" ;; + N) + noroot=YES + ;; *) echo usage