From nobody Sat Apr 25 16:22:23 2026 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 4g2w8d34l3z6blX6 for ; Sat, 25 Apr 2026 16:22:25 +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 "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4g2w8b3166z40lc for ; Sat, 25 Apr 2026 16:22:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1777134143; 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=ItNBp+dV9GRPJrSKnEUFbIF3JGyFqp+EGaMd1rbL7Bg=; b=BwNVrXBbTlpCMyneB7BHwmPLwt8yVg1arVsSrtuFF21WKhxMxYqjVRp7iG/TgH3cGqRctV 7wRMBM9uBTaEhc1WSKJnHW2qUMoadTYlOIS9NRHDqMufBxh/O3WJohWyjv64+VWgAObnPC 5aGFCsmKJ5kjlbkHMcSrmJAEF3/I/IF1x7t2gUjHgYAKfvIczvkouNfZkLpdvlrf+TI13w XiaSFOWINs/HVwEs2OR/kS/rLfbuFb22rO8px7dWHJHvDD4FexvUHckc40MRYrtAb1PcYj lqITxi7NAw58avqPxEo9FJhTf2mMNG68sxwQ1B1pUNMWR/CYDBAmKlqhDyr18Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1777134143; a=rsa-sha256; cv=none; b=YtjnOt/PQsHdUZapa/PtWytPyjxHgFebW2t772PQZ+nzafMAtQILYoobcEQ4ZDbVX2oPmd vBlXYtnHWp7zV+/vTDszkpRIVq+6uluYFjQXStmCATZ3J905Vh6SHrIR68+b758edbdNL1 Scvh9eV+WzqHsZL7sQPfdoSL8WJ11IoAnxCiBjOngGEWDM4hoA3QzUohP1Dw1lbJnK942k bN0A2YckqIBveX/Vo2RBV4l1ixb/EHOWMfPzUnLnXbnHQ+/g7A9qFO/CzG+8HtjgU40P0O h3cEfGTX2q73fSX7/yRGj7e6/bDj54VlNPIh8IcegmEzPAZ/f5+pRl/T0iuUhw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1777134143; 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=ItNBp+dV9GRPJrSKnEUFbIF3JGyFqp+EGaMd1rbL7Bg=; b=OnEC6yZ8UNYRGLUe6ZGN/1cUVpvQE31sOs7PvW5NLnj3fB0s8Q92t+OsjlEYhkGh8pm8tI 9UJfLtdK38c7kwngvRTJyrQdODsimnXiEaRlksIyH0NLHXGWcsQEYTHVdE2qlZVx1iOQh5 ah8gmmoJJpyQ/CCmFKUnxPu0fs3NxRKwe9C70xcBwFrCdi43hd2JpA3xFVGyY8S7E5f1x7 2qfULDiFUO03teH520PyfSggE+LM6UJo9PkV1HS14ey/YFvA2qCeOYd9WjqqIGtFmU6zMw 2loF2sXh+WqvHkxlKJSDaZ5tD5fIzaI2C/PSkZ6X/r0pfhs28x+Ehiq/3oMfwA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4g2w8b2Y4jzhjY for ; Sat, 25 Apr 2026 16:22:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 448b4 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 25 Apr 2026 16:22:23 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Enji Cooper Subject: git: 99b65c8b4772 - stable/14 - release.sh: add chroot cleanup routine 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ngie X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 99b65c8b47724952a22186b7214523fadd012560 Auto-Submitted: auto-generated Date: Sat, 25 Apr 2026 16:22:23 +0000 Message-Id: <69ecea3f.448b4.579a1ad@gitrepo.freebsd.org> The branch stable/14 has been updated by ngie: URL: https://cgit.FreeBSD.org/src/commit/?id=99b65c8b47724952a22186b7214523fadd012560 commit 99b65c8b47724952a22186b7214523fadd012560 Author: Enji Cooper AuthorDate: 2026-03-22 02:57:25 +0000 Commit: Enji Cooper CommitDate: 2026-04-25 16:22:18 +0000 release.sh: add chroot cleanup routine The chroot_cleanup routine handles any cleanup needed post-chroot_setup, etc. This consists of purely tearing down `${CHROOTDIR}/dev` today, but might involve additional steps, as needed for custom functions. This allows end-users to override the various chroot functions without having to modify code in main() or replicate the unmount procedure in an equivalent routine setup via the trap builtin. This change modifies the /dev unmount process to use `umount -f` instead of `umount`. The latter can result in failures if resources are still mounted or are running post-build, whereas the former will clean up any resources still in use by processes running in the chroot at time of build. Moreover, the `chroot_cleanup` routine is now called when the script is killed with `SIGINT` and `SIGTERM`, as well as at `EXIT`, better ensuring that the script's resources are cleaned up in relatively common scenarios that can be detected/handled. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D55450 (as part of a larger change) (cherry picked from commit 60baee1fa4848ac969522e03d2c6f273f334edb7) --- release/release.sh | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/release/release.sh b/release/release.sh index 5a6de297f7a1..1f366e287adc 100755 --- a/release/release.sh +++ b/release/release.sh @@ -44,6 +44,14 @@ load_chroot_env() { } load_target_env() { } buildenv_setup() { } +# chroot_cleanup(): Clean up resources setup in chroot_setup() at exit. +# +# This function can be built upon. `_chroot_cleanup` must be added to the end of +# the override function, if overridden. +chroot_cleanup() { + _chroot_cleanup +} # chroot_cleanup() + usage() { echo "Usage: $0 [-c release.conf]" exit 1 @@ -424,6 +432,18 @@ chroot_arm_build_release() { return 0 } # chroot_arm_build_release() +# chroot_cleanup(): Clean up resources setup in chroot_setup() at exit. +# +# This contains steps which must be executed at exit. +# +# Do not override this function: override `chroot_cleanup instead. +_chroot_cleanup() { + if [ -c "${CHROOTDIR}/dev/null" ]; then + echo "Unmounting /dev in ${CHROOTDIR}" + umount -f "${CHROOTDIR}/dev" + fi +} + # main(): Start here. main() { set -e # Everything must succeed @@ -448,7 +468,7 @@ main() { fi fi env_check - trap "umount ${CHROOTDIR}/dev" EXIT # Clean up devfs mount on exit + trap chroot_cleanup INT EXIT TERM chroot_setup extra_chroot_setup chroot_build_target