Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F167507791
D58952.id184452.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
6 KB
Referenced Files
None
Subscribers
None
D58952.id184452.diff
View Options
diff --git a/tools/tools/nanobsd/defaults.sh b/tools/tools/nanobsd/defaults.sh
--- a/tools/tools/nanobsd/defaults.sh
+++ b/tools/tools/nanobsd/defaults.sh
@@ -361,11 +361,24 @@
-e 's,sysctl -n kern.bootfile,echo /boot/kernel/kernel,' \
-e 's,service sshd restart,#service sshd restart,' \
/usr/sbin/freebsd-update > "${fu_bin}"
+ if ! $do_root; then
+ # Patch freebsd-update(8) to avoid checking if the user is root
+ # and setting ownership/permissions on install(1)
+ # while keeping the INDEX-NEW file, which will be appended to
+ # the metalog once it is converted to mtree(8) format
+ sed -i "" \
+ -e 's/\[ `id -u` != 0 \]/false/g' \
+ -e 's/-o ${OWNER} -g ${group}/-U/g' \
+ -e 's/-m ${PERM}//g' \
+ -e "s,fetch_inspect_system INDEX-OLD INDEX-PRESENT INDEX-NEW || return 1,cp INDEX-NEW ${NANO_METALOG}.pds; fetch_inspect_system INDEX-OLD INDEX-PRESENT INDEX-NEW || return 1,g" \
+ "${fu_bin}"
+ fi
FREEBSD_UPDATE="env PAGER=/bin/cat"
FREEBSD_UPDATE="${FREEBSD_UPDATE} /bin/sh ${fu_bin}"
fu_basedir="${NANO_WORLDDIR}"
FREEBSD_UPDATE="${FREEBSD_UPDATE} -b ${fu_basedir}"
- fu_workdir="${NANO_WORLDDIR}/var/db/freebsd-update"
+ fu_workdir="${NANO_OBJ}/_.cache/freebsd-update"
+ mkdir -p "$fu_workdir"
FREEBSD_UPDATE="${FREEBSD_UPDATE} -d ${fu_workdir}"
FREEBSD_UPDATE="${FREEBSD_UPDATE} --currently-running ${NANO_REVISION}-${NANO_BRANCH}"
FREEBSD_UPDATE="${FREEBSD_UPDATE} -f ${NANO_WORLDDIR}/etc/freebsd-update.conf"
@@ -374,19 +387,36 @@
yes | ${FREEBSD_UPDATE} install
fi
+ if ! $do_root && [ -f "${NANO_METALOG}.pds" ]; then
+ # Convert our copy of INDEX-NEW from freebsd-update
+ # to an mtree(8) format and append it to the metalog
+ ${NANO_TOOLS}/freebsd-update-index-to-mtree.awk \
+ "${NANO_METALOG}.pds" >> "$NANO_METALOG"
+ rm -f "${NANO_METALOG}.pds"
+ fi
+
set -o xtrace
# Remove old kernel
- rm -rf "${NANO_WORLDDIR}/boot/kernel.old"
- # Remove freebsd-update(8) database files
- rm -rf "${NANO_WORLDDIR}"/var/db/freebsd-update/*
- # Remove etcupdate(8) database
- rm -rf "${NANO_WORLDDIR}/var/db/etcupdate"
+ tgt_rm boot/kernel.old
_xxx_remove_extra_dist_files
) > "${NANO_LOG}/_.pds" 2>&1
}
+# Generate the METALOG from the distribution tarballs
+nano_distset_metalog() {
+ rm -f "$NANO_METALOG"
+
+ for distset in $NANO_DISTRIBUTIONS; do
+ tar -cf - --format=mtree \
+ --options='!uid,!gid,!nlink,!size,!time' \
+ @"$(nano_distset_dir)/${distset}" \
+ 2>/dev/null >> "$NANO_METALOG"
+ done
+ _xxx_libarchive_mtree_bug
+}
+
#######################################################################
# freebsd-base(7) (pkgbase) variables and functions
#
@@ -674,6 +704,21 @@
done
}
+#
+# Remove files or directories in the target tree, and record the fact.
+# All paths are relative to NANO_WORLDDIR
+#
+tgt_rm() {
+ for i; do
+ chflags -Rf 0 "${NANO_WORLDDIR}/${i}" || true
+ rm -rf "${NANO_WORLDDIR:?}/${i}"
+
+ if [ -n "$NANO_METALOG" ]; then
+ sed -i "" -e "\|^\./${i}/|d" -e "\|^\./${i} |d" "$NANO_METALOG"
+ fi
+ done
+}
+
#
# Switch the current root partition in the target file system tab.
# Takes two arguments: the current, and the new partition.
@@ -1143,11 +1188,13 @@
# Remove all empty directories under NANO_WORLDDIR/usr
prune_usr() {
# Remove all empty directories in /usr
- find "${NANO_WORLDDIR}"/usr -type d -depth -print |
- while read d
- do
- rmdir $d > /dev/null 2>&1 || true
- done
+ find "${NANO_WORLDDIR}/usr" -type d -depth -empty |
+ while read -r d; do
+ rmdir "$d" > /dev/null 2>&1 || true
+ if [ -n "$NANO_METALOG" ]; then
+ sed -i "" -e "\|^\.${d#"$NANO_WORLDDIR"} |d" "$NANO_METALOG"
+ fi
+ done
}
#
diff --git a/tools/tools/nanobsd/freebsd-update-index-to-mtree.awk b/tools/tools/nanobsd/freebsd-update-index-to-mtree.awk
new file mode 100755
--- /dev/null
+++ b/tools/tools/nanobsd/freebsd-update-index-to-mtree.awk
@@ -0,0 +1,80 @@
+#!/usr/bin/awk -f
+
+# Convert an octal string to a decimal integer
+# strtol(str, NULL, 8).
+function octtoint(str, _i, _n) {
+ _n = 0
+ for (_i = 1; _i <= length(str); _i++) {
+ _n = _n * 8 + substr(str, _i, 1)
+ }
+
+ return _n
+}
+
+# fflagstostr(3)
+function fflagstostr(flags, _out) {
+ flags = int(flags)
+ if (flags == 0) return ""
+
+ # User flags
+ if (and(flags, 1)) _out = _out (_out ? "," : "") "uappnd" # 1
+ if (and(flags, 2)) _out = _out (_out ? "," : "") "uarch" # 2
+ if (and(flags, 4)) _out = _out (_out ? "," : "") "uchg" # 4
+ if (and(flags, 8)) _out = _out (_out ? "," : "") "nodump" # 8
+ if (and(flags, 32)) _out = _out (_out ? "," : "") "uunlnk" # 20
+
+ # System flags
+ if (and(flags, 32768)) _out = _out (_out ? "," : "") "sappnd" # 100000
+ if (and(flags, 65536)) _out = _out (_out ? "," : "") "sarch" # 200000
+ if (and(flags, 131072)) _out = _out (_out ? "," : "") "schg" # 400000
+ if (and(flags, 262144)) _out = _out (_out ? "," : "") "sunlnk" # 800000
+
+ return _out
+}
+
+BEGIN {
+ FS = "|"
+}
+
+{
+ # Skip invalid entries and comments
+ if (NF < 7 || $1 ~ /^#/) next
+
+ # mtree(8) expects the relative root entry to be "."
+ path = $1
+ if (path == "/") {
+ sub(/^\//, ".", path)
+ } else {
+ sub(/^\//, "./", path)
+ }
+
+ # Map types
+ if ($2 == "d") type = "dir"
+ else if ($2 == "L") type = "link"
+ else type = "file"
+
+ # Build the mtree string (excluding the path itself)
+ # entry = type, uid, gid, mode, flags, link
+ entry = sprintf("type=%s uid=%s gid=%s mode=%s", type, $3, $4, $5)
+
+ flags = fflagstostr(octtoint($6))
+ if (flags != "") {
+ entry = entry " flags=" flags
+ }
+
+ if (type == "link" && $7 != "") {
+ entry = entry " link=" $7
+ }
+
+ # The last entry overrides the existing entry
+ entries[path] = entry
+}
+
+END {
+ # Sort entries
+ sort_cmd = "sort"
+ for (entry in entries) {
+ print entry " " entries[entry] | sort_cmd
+ }
+ close(sort_cmd)
+}
diff --git a/tools/tools/nanobsd/legacy.sh b/tools/tools/nanobsd/legacy.sh
--- a/tools/tools/nanobsd/legacy.sh
+++ b/tools/tools/nanobsd/legacy.sh
@@ -370,5 +370,8 @@
${dataimage} \
-o ${IMG}
+ rm -f "${NANO_OBJ}/_.altroot.image" \
+ "${NANO_OBJ}/_.cfg.part"\
+ "${NANO_OBJ}/_.data.part"
) > ${NANO_LOG}/_.di 2>&1
}
diff --git a/tools/tools/nanobsd/nanobsd.sh b/tools/tools/nanobsd/nanobsd.sh
--- a/tools/tools/nanobsd/nanobsd.sh
+++ b/tools/tools/nanobsd/nanobsd.sh
@@ -208,6 +208,9 @@
nano_configure_pkgbase_pkg
else
nano_fetch_distsets
+ if ! $do_root; then
+ nano_distset_metalog
+ fi
fi
if $do_installworld; then
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Aug 23, 9:11 AM (6 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
37128562
Default Alt Text
D58952.id184452.diff (6 KB)
Attached To
Mode
D58952: nanobsd: Support -PU builds with DISTRIBUTIONS
Attached
Detach File
Event Timeline
Log In to Comment