pkg/59998: index packages by plists

"[email protected] via gnats" <[email protected]>
Newsgroups gmane.os.netbsd.devel.pkgsrc.bugs
Message-ID <[email protected]>
>Number:         59998
>Category:       pkg
>Synopsis:       index packages by plists
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Feb 13 03:25:00 +0000 2026
>Originator:     Taylor R Campbell
>Release:        
>Organization:
The IndexBSD Packaginc.
>Environment:
>Description:

	pkgin can search packages by name.  It would be nice if we
	could also search packages by what files they install.

>How-To-Repeat:

	Ask: What package do I install to get, say, /usr/pkg/bin/pdfjoin?

>Fix:

	Quick hack to create a locate(1) database of package files from
	my notes the other year:

# generate newline-separated list of $PATHNAME/$PKG
# (hope packages don't have any pathnames with newlines in them...)
# about 500 MB uncompressed for 2022Q4, 30 MB gzipped
# XXX handle long package names wider than 80 columns for progress output
(n=0; for x in *.tgz; do n=$((n + 1)); done; i=0; for x in *.tgz; do printf '\r%80s\r%s/%s %s' '' $i $n $x >&2; pkg_info -qL $x | sed -e 's,$,/'"$x"','; i=$((i + 1)); done | gzip -nc > /tmp/pkgindex.2022Q4.gz; printf '\r%80s\r\n' '' >&2)

# generate bigrams
BIGRAM=$(gunzip -c < /tmp/pkgindex.2022Q4.gz | /usr/libexec/locate.bigram)

# generate locate(1) database
# about 30 MB uncompressed for 2022Q4, 23 MB gzipped
/usr/libexec/locate.code "$BIGRAM" | gzip -nc >/tmp/pkglocate.2022Q4.gz

	Part of this pipeline, of course, is embarrassingly
	parallelizable.

	TBD:
	1. Integrate into pbulk or other infrastructure.
	2. Decide how to publish this.
	3. Ship tool (or pkgin patches) for automatically downloading,
	   caching, and querying the index.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.