git: 4ab019329025 - main - bsdconfig: simplify pkg installation and ABI detection
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 05 Oct 2023 15:31:30 UTC
The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=4ab0193290255dffce3e123b7b9eec8f768740de commit 4ab0193290255dffce3e123b7b9eec8f768740de Author: Baptiste Daroussin <bapt@FreeBSD.org> AuthorDate: 2023-10-05 15:16:31 +0000 Commit: Baptiste Daroussin <bapt@FreeBSD.org> CommitDate: 2023-10-05 15:30:17 +0000 bsdconfig: simplify pkg installation and ABI detection --- usr.sbin/bsdconfig/share/packages/musthavepkg.subr | 34 ++++++++-------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/usr.sbin/bsdconfig/share/packages/musthavepkg.subr b/usr.sbin/bsdconfig/share/packages/musthavepkg.subr index 9b5d94675345..0a1026afe86c 100644 --- a/usr.sbin/bsdconfig/share/packages/musthavepkg.subr +++ b/usr.sbin/bsdconfig/share/packages/musthavepkg.subr @@ -44,26 +44,16 @@ f_include $BSDCFG_SHARE/mustberoot.subr f_musthavepkg_init() { local funcname=f_musthavepkg_init - local pkg_abi_awk=' # BEGIN-AWK - $1 ~ /^ABI/ && $0 = $NF, sub(/^"/, "") && sub(/".*/, "") { - print; found = 1; exit - } END { exit ! found } - ' # END-AWK - if [ "$PKG_ABI" ]; then # Already set - f_dprintf "PKG_ABI=[%s]" "$PKG_ABI" - export PKG_ABI - f_quietly pkg -N -vv # return status (pkg(8) functional?) - return $? - fi - - # Attempt to get PKG_ABI without prematurely bootstrapping pkg(8) - if f_eval_catch -k PKG_ABI $funcname pkg \ - "pkg -N -vv | awk '%s'" "$pkg_abi_awk" - then - f_dprintf "PKG_ABI=[%s]" "$PKG_ABI" - export PKG_ABI - return $SUCCESS + if f_quietly pkg -N; then + if [ -n "$PKG_ABI" ]; then + export PKG_ABI + return $SUCCESS + fi + if f_eval_catch -k PKG_ABI $funcname pkg "pkg config abi"; then + export PKG_ABI + return $SUCCESS + fi fi # pkg(8) not yet bootstrapped; ask for permission unless nonInteractive @@ -74,10 +64,10 @@ f_musthavepkg_init() # Bootstrap pkg(8) f_dialog_info "$msg_bootstrapping_pkg" - f_eval_catch -k PKG_ABI $funcname pkg \ - "ASSUME_ALWAYS_YES=1 pkg -vv | awk '%s'" "$pkg_abi_awk" || + f_eval_catch $funcname pkg \ + "pkg bootstrap -y" || f_die 1 "$msg_must_have_pkg_to_execute" "$pgm" - + f_eval_catch -k PKG_ABI $funcname pkg "pkg config abi" f_dprintf "PKG_ABI=[%s]" "$PKG_ABI" export PKG_ABI return $SUCCESS