pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/56792: Fix pkg_info -F for directories

>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
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).

% pkg_info -F /usr/pkg/lib/avahi     
pkg_info: can't find package `@pkgdir avahi-0.6.32nb22'
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);
@@ -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

Home | Main Index | Thread Index | Old Index