The branch main has been updated by jlduran:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=4f093770b5d55e176786db27d6f99639ae42a40e

commit 4f093770b5d55e176786db27d6f99639ae42a40e
Author:     Jose Luis Duran <[email protected]>
AuthorDate: 2026-01-24 08:58:05 +0000
Commit:     Jose Luis Duran <[email protected]>
CommitDate: 2026-01-25 10:59:27 +0000

    nanobsd: Fix _populate_part()
    
    - Avoid unnecessary subshell execution
    - Fix removing the temporary and empty /cfg directory
    - Do not remove the generated metalog file for /cfg or /data partitions
    
    Fixes:          61ac7309c366 ("nanobsd: Add a provisional populate_part 
function")
    MFC after:      3 days
---
 tools/tools/nanobsd/defaults.sh | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/tools/tools/nanobsd/defaults.sh b/tools/tools/nanobsd/defaults.sh
index 31f3df9a3086..0e5af1e3e95a 100755
--- a/tools/tools/nanobsd/defaults.sh
+++ b/tools/tools/nanobsd/defaults.sh
@@ -745,7 +745,7 @@ populate_slice() {
        nano_umount ${mnt}
 }
 
-_populate_part() (
+_populate_part() {
        local dir fs lbl metalog size type
        type=$1
        fs=$2
@@ -762,7 +762,7 @@ _populate_part() (
        else
                if [ "${type}" = "cfg" ]; then
                        dir=$(mktemp -d -p "${NANO_OBJ}" -t "${type}")
-                       trap "rm -f ${dir}" 1 2 15 EXIT
+                       trap "rm -rf ${dir}" 1 2 15 EXIT
                fi
        fi
 
@@ -770,8 +770,7 @@ _populate_part() (
                # If there is no metalog, create one using the default
                # NANO_DEF_UNAME and NANO_DEF_GNAME for all entries in the spec.
                if [ -z "${metalog}" ]; then
-                       metalog=$(mktemp -p "${NANO_OBJ}" -t "${type}")
-                       trap "rm -f ${metalog}" 1 2 15 EXIT
+                       metalog="${NANO_METALOG}.${type}"
                        echo "/set type=dir uname=${NANO_DEF_UNAME}" \
                            "gname=${NANO_DEF_GNAME} mode=0755" > "${metalog}"
                        echo ". type=dir uname=${NANO_DEF_UNAME}" \
@@ -787,7 +786,7 @@ _populate_part() (
 
                nano_makefs "-DxZ ${NANO_MAKEFS}" "${metalog}" "${size}" 
"${fs}" "${dir}"
        fi
-)
+}
 
 populate_cfg_slice() {
        populate_slice "$1" "$2" "$3" "$4"

Reply via email to