From nobody Sun Mar 22 03:02:19 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 4fdh173LMkz6Vn0l for ; Sun, 22 Mar 2026 03:02:19 +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 "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fdh170jxQz45Qc for ; Sun, 22 Mar 2026 03:02:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1774148539; 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=7PZRoW0q151wWHAN842eTgqM51iTIJEfmm1k1UfONuc=; b=FQb58pR85+MmlgTyJFehPmes3VNoCpYxjWJlqqQaWeLmhrocD+xYoovVYD/PfnQyF/bmmH oNTSQQ2WUYoYOyhEclcSrED0zhf6xg/SW0dUMDXia0oQRkVo21WXhsGttP+tQOf3RE0nrV gycsbKY02BllL+elsnA/0z5bfL0KKzZdqYn8bUEu2BDtX5WcQJzXxgYi/Tn+jy13nFe01c chGXgA6dDJxnMVBg85OkMdwv6rPArlsvNW6QPTZnFazgiMmgZJvDc5/GFNbzjFEWxqOAhJ 2Vj3V3JYoN7cwdTP3/4DBebQxgpKBb9txnBQO9klOXRmzMbrFD/NqRQdwjgYig== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1774148539; a=rsa-sha256; cv=none; b=EFTk8FujbPSN7DlUNuWaAMUq584Ov2a/4P1kxAnsLzvFw2TVMR+g/urXyAwkFWpy6kfCbd 83qmkNr8vdK2BoAQ+TmbLv+t1PJcJB9d/927lqYKbmkoHh9z9Zry5T4dwXWFZlYkiLtKk2 M50FGmeR7PqcpmQVc389r9noYKZJiB8V+OjRbl4BakHIdQfEU7A6twQns5rXJvYCRApD/5 hnu0W84PlShSp8E6SvVYmcByg0qe6XpyaYDrm2WWBJFPFOldEmattZsO5kXszaIKbWw006 xfdHNkJC/UnlIzsmijCk4iiJu5ecwHy4xEp6Rw+bWXQdVOE3Pw/2+NDjVhGxMw== 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=1774148539; 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=7PZRoW0q151wWHAN842eTgqM51iTIJEfmm1k1UfONuc=; b=xR9NLZyJck3W+zyGSL60B6dmnKKzeA24b56dUgn+TWRWx4m9g2V/3d7L3L25VMStVy8KL3 uUU8zND+JfNKaZEGZnG7If2erA65tJEeL1nQrzVTmX/D+o3LyY++R9aCr2Nj/SP2xaAn+m sX01m3+w7Juei9jbfIra37GE11d9ixxC0Nru5gdCeKxcP1OqFUrG7fcZvBvgGP0r0aR8cg nHxzUuCjzj+TlwdsyRF5es7u6ERKRm7+gXtMNHfhwYVhF9yusO+8HjYzAxreelvnl84AbY DyJay80cwaMwyle2JUGSLbnIxAm2PTreI2mmq1x4qzNJWNnyaMp1JwRQuv6xzA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fdh170JJwzhHY for ; Sun, 22 Mar 2026 03:02:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1bb04 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 22 Mar 2026 03:02:19 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Enji Cooper Subject: git: 60baee1fa484 - main - 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/main X-Git-Reftype: branch X-Git-Commit: 60baee1fa4848ac969522e03d2c6f273f334edb7 Auto-Submitted: auto-generated Date: Sun, 22 Mar 2026 03:02:19 +0000 Message-Id: <69bf5bbb.1bb04.6928690a@gitrepo.freebsd.org> The branch main has been updated by ngie: URL: https://cgit.FreeBSD.org/src/commit/?id=60baee1fa4848ac969522e03d2c6f273f334edb7 commit 60baee1fa4848ac969522e03d2c6f273f334edb7 Author: Enji Cooper AuthorDate: 2026-03-22 02:57:25 +0000 Commit: Enji Cooper CommitDate: 2026-03-22 03:02:09 +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) --- release/release.sh | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/release/release.sh b/release/release.sh index be3a0785d945..48c505470524 100755 --- a/release/release.sh +++ b/release/release.sh @@ -53,6 +53,14 @@ load_target_env() { } # buildenv_setup(): set up the build environment needed for post-chroot_setup() 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 @@ -436,6 +444,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 @@ -460,7 +480,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