NetBSD Problem Report #56792

From www@netbsd.org  Wed Apr 13 09:49:52 2022
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id B955E1A921F
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 13 Apr 2022 09:49:52 +0000 (UTC)
Message-Id: <20220413094951.11A871A923B@mollari.NetBSD.org>
Date: Wed, 13 Apr 2022 09:49:51 +0000 (UTC)
From: anthony.mallet@laas.fr
Reply-To: anthony.mallet@laas.fr
To: gnats-bugs@NetBSD.org
Subject: Fix pkg_info -F for directories
X-Send-Pr-Version: www-1.0

>Number:         56792
>Category:       pkg
>Synopsis:       Fix pkg_info -F for directories
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Apr 13 09:50:00 +0000 2022
>Originator:     Anthony Mallet
>Release:        pkgsrc-current, pkg_install 20211115
>Organization:
>Environment:
any
>Description:
pkg_info -F <file> returns the package name to which <file> belongs.

However, pkg_info -F <dir> for *empty* directories managed by a package returns a cryptic error message, due to missing bits in the search  algorithm. In pkgdb.byfile.db, empty directories are stored with @pkgdir plist prefix and this is not filtered out by pkg-info -F. (see How-to-repeat below for an example).

A simple fix is attached. (but it harcodes the '@pkgdir' string instead of using functions from lib/plist.c, but such functions don't exist yet in lib/plist.c).

>How-To-Repeat:
% pkg_info -F /usr/pkg/lib/avahi     
pkg_info: can't find package `@pkgdir avahi-0.6.32nb22'
>Fix:
diff --git pkgtools/pkg_install/files/info/main.c pkgtools/pkg_install/files/info/main.c
index 6827443f0..0a0d00d4f 100644
--- pkgtools/pkg_install/files/info/main.c
+++ pkgtools/pkg_install/files/info/main.c
@@ -259,6 +259,7 @@ main(int argc, char **argv)

 			if (s == NULL)
 				errx(EXIT_FAILURE, "No matching pkg for %s.", CheckPkg);
+			if (strncmp(s, "@pkgdir ", 8) == 0) s += 8;
 			CheckPkg = xstrdup(s);

 			pkgdb_close();
@@ -286,6 +287,7 @@ main(int argc, char **argv)
 			s = pkgdb_retrieve(*argv);

 			if (s) {
+				if (strncmp(s, "@pkgdir ", 8) == 0) s += 8;
 				lpp = alloc_lpkg(s);
 				TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link);
 			} else

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.