From nobody Tue Jul 11 00:53:11 2023 X-Original-To: dev-commits-src-all@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 4R0Mml6q78z4dRSH; Tue, 11 Jul 2023 00:53:11 +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 4R0Mml6Bt6z4Hl1; Tue, 11 Jul 2023 00:53:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689036791; 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=aJxPIPVpKesLjyvcIekXmTy66SfB+r11gd3KnhjMD3U=; b=Ch5LWOlLglSAxmxcGSXpWrM3pMwydWNVXoisDmJk2pnGTEGApGNLH5UwCyi1gUGCrmHcLH 7qtZ0RT5ki4hJ1T55HBWbkVZM5/8gB1RjB7Nq0ohu2Qvu9L9wsac80oa56SIG+qohaiTSd YdTTpKrDbq17jHlgIiDWUMZGYVpI1qu2aoKnp0y22EXKoS4+YZUcETfPhFddDJTwznNWM7 m+c41wZ/avPMRotX0WxQqUSF3Mk48sfOs/pc+ycFX1u3WpLj6KFzpE8AT2BWuC/YeprDAB aqYayiv8c9fZgXwWmFWhM8Gkwe2t/g4XTUQyG9MXU8DoZVT4h/NZ4EMNsc4asw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1689036791; 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=aJxPIPVpKesLjyvcIekXmTy66SfB+r11gd3KnhjMD3U=; b=S0wGQocT7t05aTxJhj/y/JT7VPnUZSIwncpM5A+wgBNkaAsR2oBNZAhN22RKJBPT6kRrAu a7CMeYWP3FUkl/MaxdHcDlJJBx6Ni65kaYBHRWW49yvLrG4R00JFXqGfN43FnOm4sFZ/Lq 0KKa1WZNwrsAd0ncY/6TNgDUf5IW+4ClorlNJP0Inlh4PN6j/D58/bXxIshhY+bA0PwuAp JvGg395+LXGsiK50woEuJf9sAXPeAsb2LrEu8JquOe6hNRf3COPt3yN/NS8l/sFghEFZi8 t3Iajcw4K6qzz8b2XYZOcRNZLr0NFC4dl81YaCEBA9DUAROi9T9qmkYZsQdy5w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1689036791; a=rsa-sha256; cv=none; b=vOYtP4HHFJ8lLn0T5TJIBHo775KvScZs0bozi6Y/yVsAt5+Q1Yeoe0f6ZNt4bWkJp+tGWC 45dup/MDujMFyqZ7ZzEYzam3Ju8p2TZ8fSXoMOnc30XcckgG4HkTEno80jXFCLeCQuosNj pVuk/mI7TOUsjxa3JJcFzLYKtzZ0WG0cOIgefWMCb+eY1cxWp1A26iAdBDLFf814NAfBiQ PRHJ5DHxkItWCkhL/BStk3wJPUX1JfQOXrDUWARHZLEKDsOy3diJqp2Q3HYqj+gacr66u9 glz/goMNOZoVNQfh/GgMrdM0PbjRvvwqAQS5BBxZT5jHo0xPoUu3s7J7/WhCrQ== 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 4R0Mml5HDdz15w7; Tue, 11 Jul 2023 00:53:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 36B0rBRh098488; Tue, 11 Jul 2023 00:53:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 36B0rBWH098487; Tue, 11 Jul 2023 00:53:11 GMT (envelope-from git) Date: Tue, 11 Jul 2023 00:53:11 GMT Message-Id: <202307110053.36B0rBWH098487@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: 1ec7cb1b5d18 - main - depend-cleanup: Add verbose (-v) and pretend/dry-run (-n) flags List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: 1ec7cb1b5d1800b05c0682e0b673be0dece98779 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jrtc27: URL: https://cgit.FreeBSD.org/src/commit/?id=1ec7cb1b5d1800b05c0682e0b673be0dece98779 commit 1ec7cb1b5d1800b05c0682e0b673be0dece98779 Author: Jessica Clarke AuthorDate: 2023-07-11 00:53:04 +0000 Commit: Jessica Clarke CommitDate: 2023-07-11 00:53:04 +0000 depend-cleanup: Add verbose (-v) and pretend/dry-run (-n) flags These are useful for testing new additions to the script. Whilst here, harden the script a little and improve error messages. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D31007 --- tools/build/depend-cleanup.sh | 82 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 66 insertions(+), 16 deletions(-) diff --git a/tools/build/depend-cleanup.sh b/tools/build/depend-cleanup.sh index ce962cc1eb86..b9b38b4ed3e6 100755 --- a/tools/build/depend-cleanup.sh +++ b/tools/build/depend-cleanup.sh @@ -17,22 +17,72 @@ # anyone would try a NO_CLEAN build against an object tree from before the # related change. One year should be sufficient. +set -e +set -u + +warn() +{ + echo "$(basename "$0"):" "$@" >&2 +} + +err() +{ + warn "$@" + exit 1 +} + +usage() +{ + echo "usage: $(basename $0) [-v] [-n] objtop" >&2 +} + +VERBOSE= +PRETEND= +while getopts vn o; do + case "$o" in + v) + VERBOSE=1 + ;; + n) + PRETEND=1 + ;; + *) + usage + exit 1 + ;; + esac +done +shift $((OPTIND-1)) + +if [ $# -ne 1 ]; then + usage + exit 1 +fi + OBJTOP=$1 +shift if [ ! -d "$OBJTOP" ]; then - echo "usage: $(basename $0) objtop" >&2 - exit 1 + err "$OBJTOP: Not a directory" fi if [ -z "${MACHINE+set}" ]; then - echo "$(basename "$0"): MACHINE not set" >&2 - exit 1 + err "MACHINE not set" fi if [ -z "${MACHINE_ARCH+set}" ]; then - echo "$(basename "$0"): MACHINE_ARCH not set" >&2 - exit 1 + err "MACHINE_ARCH not set" fi +run() +{ + if [ "$VERBOSE" ]; then + echo "$@" + fi + if ! [ "$PRETEND" ]; then + "$@" + fi +} + # $1 directory # $2 source filename w/o extension # $3 source extension @@ -40,13 +90,13 @@ clean_dep() { if egrep -qw "$2\.$3" "$OBJTOP"/$1/.depend.$2.*o 2>/dev/null; then echo "Removing stale dependencies and objects for $2.$3" - rm -f \ + run rm -f \ "$OBJTOP"/$1/.depend.$2.* \ "$OBJTOP"/$1/$2.*o fi if egrep -qw "$2\.$3" "$OBJTOP"/obj-lib32/$1/.depend.$2.*o 2>/dev/null; then echo "Removing 32-bit stale dependencies and objects for $2.$3" - rm -f \ + run rm -f \ "$OBJTOP"/obj-lib32/$1/.depend.$2.* \ "$OBJTOP"/obj-lib32/$1/$2.*o fi @@ -63,14 +113,14 @@ if [ -e "$OBJTOP"/cddl/lib/libzfs/.depend.libzfs_changelist.o ] && \ egrep -qw "cddl/contrib/opensolaris/lib/libzfs/common/libzfs_changelist.c" \ "$OBJTOP"/cddl/lib/libzfs/.depend.libzfs_changelist.o; then echo "Removing old ZFS tree" - rm -rf "$OBJTOP"/cddl "$OBJTOP"/obj-lib32/cddl + run rm -rf "$OBJTOP"/cddl "$OBJTOP"/obj-lib32/cddl fi # 20200916 WARNS bumped, need bootstrapped crunchgen stubs if [ -e "$OBJTOP"/rescue/rescue/rescue.c ] && \ ! grep -q 'crunched_stub_t' "$OBJTOP"/rescue/rescue/rescue.c; then echo "Removing old rescue(8) tree" - rm -rf "$OBJTOP"/rescue/rescue + run rm -rf "$OBJTOP"/rescue/rescue fi # 20210105 fda7daf06301 pfctl gained its own version of pf_ruleset.c @@ -78,13 +128,13 @@ if [ -e "$OBJTOP"/sbin/pfctl/.depend.pf_ruleset.o ] && \ egrep -qw "sys/netpfil/pf/pf_ruleset.c" \ "$OBJTOP"/sbin/pfctl/.depend.pf_ruleset.o; then echo "Removing old pf_ruleset dependecy file" - rm -rf "$OBJTOP"/sbin/pfctl/.depend.pf_ruleset.o + run rm -rf "$OBJTOP"/sbin/pfctl/.depend.pf_ruleset.o fi # 20210108 821aa63a0940 non-widechar version of ncurses removed if [ -e "$OBJTOP"/lib/ncurses/ncursesw ]; then echo "Removing stale ncurses objects" - rm -rf "$OBJTOP"/lib/ncurses "$OBJTOP"/obj-lib32/lib/ncurses + run rm -rf "$OBJTOP"/lib/ncurses "$OBJTOP"/obj-lib32/lib/ncurses fi # 20210608 f20893853e8e move from atomic.S to atomic.c @@ -96,7 +146,7 @@ clean_dep lib/libc pdfork S if [ -e "$OBJTOP"/lib/libc++/libc++.ld ] && \ fgrep -q "/usr/lib/libc++.so" "$OBJTOP"/lib/libc++/libc++.ld; then echo "Removing old libc++ linker script" - rm -f "$OBJTOP"/lib/libc++/libc++.ld + run rm -f "$OBJTOP"/lib/libc++/libc++.ld fi # 20220326 fbc002cb72d2 move from bcmp.c to bcmp.S @@ -108,7 +158,7 @@ fi if stat "$OBJTOP"/tests/sys/kqueue/libkqueue/*kqtest* \ "$OBJTOP"/tests/sys/kqueue/libkqueue/.depend.kqtest* >/dev/null 2>&1; then echo "Removing old kqtest" - rm -f "$OBJTOP"/tests/sys/kqueue/libkqueue/.depend.* \ + run rm -f "$OBJTOP"/tests/sys/kqueue/libkqueue/.depend.* \ "$OBJTOP"/tests/sys/kqueue/libkqueue/* fi @@ -118,7 +168,7 @@ clean_dep usr.bin/rs rs c # 20230110 bc42155199b5 usr.sbin/zic/zic -> usr.sbin/zic if [ -d "$OBJTOP"/usr.sbin/zic/zic ] ; then echo "Removing old zic directory" - rm -rf "$OBJTOP"/usr.sbin/zic/zic + run rm -rf "$OBJTOP"/usr.sbin/zic/zic fi # 20230208 29c5f8bf9a01 move from mkmakefile.c to mkmakefile.cc @@ -133,7 +183,7 @@ clean_dep lib/libc kqueue1 S # 20230623 b077aed33b7b OpenSSL 3.0 update if [ -f "$OBJTOP"/secure/lib/libcrypto/aria.o ]; then echo "Removing old OpenSSL 1.1.1 tree" - rm -rf "$OBJTOP"/secure/lib/libcrypto \ + run rm -rf "$OBJTOP"/secure/lib/libcrypto \ "$OBJTOP"/secure/lib/libssl \ "$OBJTOP"/obj-lib32/secure/lib/libcrypto \ "$OBJTOP"/obj-lib32/secure/lib/libssl