From nobody Sat Apr 25 16:21:48 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 4g2w7w52Frz6blSm for ; Sat, 25 Apr 2026 16:21:48 +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 4g2w7w3j71z3y4X for ; Sat, 25 Apr 2026 16:21:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1777134108; 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=/8jOW5xbS7EPg0ZQ3pb9qBj8MBq+vhQHykVt7DSwBUk=; b=c+oRfJ4aQB6cqkGthD1G1wmCpiUYQsa5ENhZScG7Ku/ef2z8k6lhm/SzttBd1xQFH/PzVa ltc6ugQEVw0YNVP6zc9bJnzPKiMLBxLGwDEmtPrl8Al8+HwT11YGkXOo9L5Yuqqo5lbbq5 BrAOVt+s2uzR5CMeCo/Y37Fc/BKTZWW3duU5fRSLyxTZDZIo3cAiHakUomK+qH8r7EHIB7 8v4KFQoxACwBNlIzdA8Gp5iE46MYAF2/23L7iQflcWd5jzi/BuqyigwN9O3/cDbZyXMV7m gG4CxMQpO7lCIeygvw3V3d0l7LA37g4fsQZLXRUf3ygzaedlfrpdcfir1Aflug== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1777134108; a=rsa-sha256; cv=none; b=KHy0DNbYkUTHLLETgFDK8HIHyQeGy9mn+nBF0NilSCaG+xSCLm3YswxGXsQfxikedgqi7f JC0r5I87jjum0IZGafy4QlpSChUilS4vydKyXqew7TZ3a2JC3QU4vUYfNK5hnFfQeeKoXn 5MLB16j/6ZSJMr23+t04PYJJWQ7nDx8S3bXhwdVG8FwyOMso0PmtVTvJKnjVb8iU+66RPW 8v+K/XDtgKHgG0AP3oKycZjh0kjyEUC5blRpvACSnFc0gtItJ6OGfaevwiFI+XOfiAJ/nq cbNez6fpC2pQLTitPhmV+dB+gPvnjJBiksXM5Pb2IBZeqNSrbFkDtsNbEu6FuA== 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=1777134108; 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=/8jOW5xbS7EPg0ZQ3pb9qBj8MBq+vhQHykVt7DSwBUk=; b=gLBRv4cjUcue8yWLFPTe8sl5LRfMlj8ZUbDu8U82iYYySaEK1/JR5w5gfreu4js/8BgEwT p0PfGmcerA3BVIyzdZa6QVg5aDRz53mUWY9dl8DnMELbfeHONeir9daDbyETCpf91GLQ35 W+nUSYWtG9TmejWl9XND5PTcdwlPqMO/wbdRRSO98ML61KgYO7sIJe3qcvMEo+oIgeaK2N 588MRtI6O0FbFCZUbZJWozTwoAzTc80RmRzKdDfoCTkcuXj0I96pI5q9w73PeNRCH5yTFB OV0pOI/o5ZApQn0qf2s3HAOAwQYLKoqHpdsUtfc6TzZ9PfRPPoRODyVMSBIE3g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4g2w7w315dzh0Y for ; Sat, 25 Apr 2026 16:21:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 42e78 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 25 Apr 2026 16:21:48 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Enji Cooper Subject: git: 91c6c5fe7b12 - stable/15 - 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/15 X-Git-Reftype: branch X-Git-Commit: 91c6c5fe7b1240a589807c6a1b8f1dddb73e105c Auto-Submitted: auto-generated Date: Sat, 25 Apr 2026 16:21:48 +0000 Message-Id: <69ecea1c.42e78.2097f669@gitrepo.freebsd.org> The branch stable/15 has been updated by ngie: URL: https://cgit.FreeBSD.org/src/commit/?id=91c6c5fe7b1240a589807c6a1b8f1dddb73e105c commit 91c6c5fe7b1240a589807c6a1b8f1dddb73e105c Author: Enji Cooper AuthorDate: 2026-03-22 02:57:25 +0000 Commit: Enji Cooper CommitDate: 2026-04-25 16:21:42 +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 480d6b34f191..da5cc9dc5d25 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 @@ -427,6 +435,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 @@ -451,7 +471,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