Bug 230560

Summary: NanoBSD's default value for NANO_PACKAGE_LIST doesn't work as intended and prevents packages installation
Product: Base System Reporter: f.toscan
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Many People CC: imp
Priority: --- Keywords: patch
Version: 11.2-RELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Patch none

Description f.toscan 2018-08-12 13:24:46 UTC
Created attachment 196125 [details]
Patch

NanoBSD in 11.2-RELEASE (and 11.1 as well) flavors a nice facility, cust_pkgng function, contained in defaults.sh .

defaults.sh also lists nanobsd.sh defaults. NANO_PACKAGE_LIST is used by cust_pkgng to get the list of packages to install and is set by default to "*".

This setting prevents packages installation beside pkg-*, as the variable doesn't expand as intended and the function aborts:

+ cust_pkgng
+ mkdir -p /usr/obj/nanobsd.NET4501/_.w/usr/local/etc
+ local 'PKG_CONF=/usr/obj/nanobsd.NET4501/_.w/usr/local/etc/pkg.conf'
+ local 'PKGCMD=env ASSUME_ALWAYS_YES=YES PKG_DBDIR=/var/db/pkg SIGNATURE_TYPE=none /usr/sbin/pkg'
+ touch /usr/obj/nanobsd.NET4501/_.w/usr/local/etc/pkg.conf
+ grep -Eiq '^PKG_DBDIR:.*' /usr/obj/nanobsd.NET4501/_.w/usr/local/etc/pkg.conf
+ echo 'PKG_DBDIR: "/var/db/pkg"'
+ [ ! -d /usr/src/tools/tools/nanobsd/Pkg ]
+ find -s /usr/src/tools/tools/nanobsd/Pkg -iname 'pkg-*'
+ basename /usr/src/tools/tools/nanobsd/Pkg/pkg-1.10.5_1.txz
+ _NANO_PKG_PACKAGE=pkg-1.10.5_1.txz
+ [ -z pkg-1.10.5_1.txz -o ! -f /usr/src/tools/tools/nanobsd/Pkg/pkg-1.10.5_1.txz ]
+ NANO_PACKAGE_LIST='pkg-1.10.5_1.txz *'
+ mkdir -p /usr/obj/nanobsd.NET4501/_.w/_.p
+ mount -t nullfs -o noatime -o ro /usr/src/tools/tools/nanobsd/Pkg /usr/obj/nanobsd.NET4501/_.w/_.p
+ trap 'umount /usr/obj/nanobsd.NET4501/_.w/_.p ; rm -rf /usr/obj/nanobsd.NET4501/_.w/_.p' 1 2 15 EXIT
+ echo 'pkg-1.10.5_1.txz *'
+ awk '{ print NF }'
+ todo=2
+ echo '=== TODO: 2'
=== TODO: 2
+ echo 'pkg-1.10.5_1.txz *'
pkg-1.10.5_1.txz *
+ echo '==='
===
+ CR 'env ASSUME_ALWAYS_YES=YES PKG_DBDIR=/var/db/pkg SIGNATURE_TYPE=none /usr/sbin/pkg add /_.p/pkg-1.10.5_1.txz'
+ chroot /usr/obj/nanobsd.NET4501/_.w /bin/sh -exc 'env ASSUME_ALWAYS_YES=YES PKG_DBDIR=/var/db/pkg SIGNATURE_TYPE=none /usr/sbin/pkg add /_.p/pkg-1.10.5_1.txz'
+ env 'ASSUME_ALWAYS_YES=YES' 'PKG_DBDIR=/var/db/pkg' 'SIGNATURE_TYPE=none' /usr/sbin/pkg add /_.p/pkg-1.10.5_1.txz
Installing pkg-1.10.5_1...
Extracting pkg-1.10.5_1: .......... done
+ CR 'env ASSUME_ALWAYS_YES=YES PKG_DBDIR=/var/db/pkg SIGNATURE_TYPE=none /usr/sbin/pkg add /_.p/Files'
+ chroot /usr/obj/nanobsd.NET4501/_.w /bin/sh -exc 'env ASSUME_ALWAYS_YES=YES PKG_DBDIR=/var/db/pkg SIGNATURE_TYPE=none /usr/sbin/pkg add /_.p/Files'
+ env 'ASSUME_ALWAYS_YES=YES' 'PKG_DBDIR=/var/db/pkg' 'SIGNATURE_TYPE=none' /usr/sbin/pkg add /_.p/Files
pkg: /_.p/Files: No such file or directory
pkg: Was 'pkg install /_.p/Files' meant?

Failed to install the following 1 package(s): /_.p/Files
+ umount /usr/obj/nanobsd.NET4501/_.w/_.p
+ rm -rf /usr/obj/nanobsd.NET4501/_.w/_.p
+ echo 'NANO RM -rf /usr/obj/nanobsd.NET4501/_.w/_.p'
NANO RM -rf /usr/obj/nanobsd.NET4501/_.w/_.p
+ uname -r
+ command rm -x -rf /usr/obj/nanobsd.NET4501/_.w/_.p

Setting NANO_PACKAGE_LIST to "*.txz" fixes the problem: one can override the setting in nanobsd's configuration file, but I, for one, think that fixing defaults.sh might be useful.

Patch attached.
Comment 1 Warner Losh freebsd_committer freebsd_triage 2018-08-12 16:30:18 UTC
I'll look into this, but I swore I fixed it in -current.
Comment 2 f.toscan 2018-08-13 13:12:56 UTC
(In reply to Warner Losh from comment #1)
Thank you, much appreciated.
Actually, you already fixed this problem in current (rev. 321636): I should have checked there first, sorry (...and my patch was just a dirty band-aid).
Is it possible to have your fix MFCed?
Thanks,
f.
Comment 3 Warner Losh freebsd_committer freebsd_triage 2021-07-09 17:46:44 UTC
This is fixed in 12 and 11 is too old to MFC to at this point. I'm sorry that I let this expire.