[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-hackers
Subject:    nanoBSD: =?UTF-8?Q?cust=5Fpkgng=28=29=20fetches=20ports-mgmt/pkg?= =?UTF-8?Q?=20regardless=20of=20re
From:       Michael <embhd () posteo ! de>
Date:       2023-02-09 19:30:41
Message-ID: 81d8f972bb1738771716aa77f207bbce () posteo ! de
[Download RAW message or body]

Good evening,

I noticed that in cust_pkng(), pkg(7) (/usr/sbin/pkg) fetches pkg(8) 
(ports-mgmt/pkg) from remote even though the function itself requires a 
binary package of pkg(8) for bootstrapping. This also seems to be the 
reason why _.cust.cust_pkng notes that "the most recent version of 
pkg-X.Y.Z is already installed" - first, pkg(7) fetches and builds 
pkg(8), which then tries to install pkg(8) once more.
At the same time, I would guess that if the nanoBSD-image is for an 
entirely different plattform/architecture, the just bootstrapped pkg(8) 
would not be able to run during later operation, since I don't think it 
has been compiled for the later host system.

My current solution is to change the command set in ${PKGCMD} to use the 
build system's pkg(8), which chroots itself to ${NANO_WORLDDIR}. This 
also makes the separate calls to chroot(8) by means of CR() and CR0() 
unnecessary. Since the latter does not seem to be used anywhere else and 
the former only once in clean_build(), they can be removed altogether if 
the remaining call to CR() in clean_build() is replaced with a direct 
call to chroot(8).

I suppose this is also somewhat related to 
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=260467, since the 
corresponding line in cust_pkgng() is `CR "${PKGCMD} add 
/_.p/${_NANO_PKG_PACKAGE}"`. With the solution above, pkg(7) would never 
be invoked in the first place and the bug wouldn't pop up, at least in 
the default function.

Am I missing anything?

Regards,
Michael

PS: I originally posted this (minus some re-wording) to freebsd-embedded 
about two weeks ago, but never received any response.
["defaults.patch" (text/x-patch)]

diff --git a/tools/tools/nanobsd/defaults.sh b/tools/tools/nanobsd/defaults.sh
index 45d9fe44c650..e5d6cacdb344 100755
--- a/tools/tools/nanobsd/defaults.sh
+++ b/tools/tools/nanobsd/defaults.sh
@@ -277,16 +277,6 @@ tgt_dir2symlink ( ) (
 	fi
 )
 
-# run in the world chroot, errors fatal
-CR ( ) {
-	chroot "${NANO_WORLDDIR}" /bin/sh -exc "$*"
-}
-
-# run in the world chroot, errors not fatal
-CR0 ( ) {
-	chroot "${NANO_WORLDDIR}" /bin/sh -c "$*" || true
-}
-
 clean_build ( ) (
 	pprint 2 "Clean and create object directory (${MAKEOBJDIRPREFIX})"
 
@@ -740,7 +730,7 @@ cust_install_files ( ) (
 	find . -print | grep -Ev '/(CVS|\.svn|\.hg|\.git)/' | cpio ${CPIO_SYMLINK} -Ldumpv \
${NANO_WORLDDIR}  
 	if [ -n "${NANO_CUST_FILES_MTREE}" -a -f ${NANO_CUST_FILES_MTREE} ]; then
-		CR "mtree -eiU -p /" <${NANO_CUST_FILES_MTREE}
+		chroot "${NANO_WORLDDIR}" /bin/sh -exc "mtree -eiU -p / <${NANO_CUST_FILES_MTREE}"
 	fi
 )
 
@@ -750,7 +740,7 @@ cust_install_files ( ) (
 cust_pkgng ( ) (
 	mkdir -p ${NANO_WORLDDIR}/usr/local/etc
 	local PKG_CONF="${NANO_WORLDDIR}/usr/local/etc/pkg.conf"
-	local PKGCMD="env BATCH=YES ASSUME_ALWAYS_YES=YES \
PKG_DBDIR=${NANO_PKG_META_BASE}/pkg SIGNATURE_TYPE=none /usr/sbin/pkg" +	local \
PKGCMD="env BATCH=YES ASSUME_ALWAYS_YES=YES PKG_DBDIR=${NANO_PKG_META_BASE}/pkg \
SIGNATURE_TYPE=none pkg -c ${NANO_WORLDDIR}"  
 	# Ensure pkg.conf points pkg to where the package meta data lives.
 	touch ${PKG_CONF}
@@ -783,7 +773,7 @@ cust_pkgng ( ) (
 	trap "umount ${NANO_WORLDDIR}/dev; umount ${NANO_WORLDDIR}/_.p ; rm -xrf \
${NANO_WORLDDIR}/_.p" 1 2 15 EXIT  
 	# Install pkg-* package
-	CR "${PKGCMD} add /_.p/${_NANO_PKG_PACKAGE}"
+	${PKGCMD} add /_.p/${_NANO_PKG_PACKAGE}
 
 	(
 		# Expand any glob characters in pacakge list
@@ -798,11 +788,11 @@ cust_pkgng ( ) (
 
 		# Install packages
 		for _PKG in $_PKGS; do
-			CR "${PKGCMD} add /_.p/${_PKG}"
+			${PKGCMD} add /_.p/${_PKG}
 		done
 	)
 
-	CR0 "${PKGCMD} info"
+	${PKGCMD} info || true
 
 	trap - 1 2 15 EXIT
 	umount ${NANO_WORLDDIR}/dev



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic