Discussion:
querying the registry for installed files
René J.V. Bertin
2016-10-28 18:41:58 UTC
Permalink
Hi,

I think the registry keeps track of all installed files, whether they belong to active or inactive ports, right?
If so, is there a way to query the registry with a filename pattern, to obtain the full paths of known matching filesand the port(s) which provide them?

Thanks,
René
Ken Cunningham
2016-10-28 19:20:26 UTC
Permalink
Rene, do you mean

port provides /path/to/file

or something fancier?

Ken
Post by René J.V. Bertin
Hi,
I think the registry keeps track of all installed files, whether they belong to active or inactive ports, right?
If so, is there a way to query the registry with a filename pattern, to obtain the full paths of known matching filesand the port(s) which provide them?
Thanks,
René
_______________________________________________
macports-dev mailing list
https://lists.macosforge.org/mailman/listinfo/macports-dev
Brandon Allbery
2016-10-28 19:23:15 UTC
Permalink
"port provides" actually does some extra work to normalize paths before
querying; I believe René is looking for the underlying database, and
possibly its constraints (e.g. whether it includes inactives --- which I
don't think it does).

On Fri, Oct 28, 2016 at 3:20 PM, Ken Cunningham <
Post by Ken Cunningham
Rene, do you mean
port provides /path/to/file
or something fancier?
Ken
Post by René J.V. Bertin
Hi,
I think the registry keeps track of all installed files, whether they
belong to active or inactive ports, right?
Post by René J.V. Bertin
If so, is there a way to query the registry with a filename pattern, to
obtain the full paths of known matching filesand the port(s) which provide
them?
Post by René J.V. Bertin
Thanks,
René
_______________________________________________
macports-dev mailing list
https://lists.macosforge.org/mailman/listinfo/macports-dev
_______________________________________________
macports-dev mailing list
https://lists.macosforge.org/mailman/listinfo/macports-dev
--
brandon s allbery kf8nh sine nomine associates
***@gmail.com ***@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
Clemens Lang
2016-10-28 19:22:41 UTC
Permalink
Post by René J.V. Bertin
I think the registry keeps track of all installed files, whether they
belong to active or inactive ports, right?
If so, is there a way to query the registry with a filename pattern,
to obtain the full paths of known matching filesand the port(s) which
provide them?
Isn't this essentially what 'port provides' does?

But yes, that's possible:
sqlite> .load macports.sqlext
sqlite> select
ports.name
, files.path
from files
join ports
on files.id = ports.id
where
files.active = 1
and ports.name = 'apr'
and files.path like '%/include/%';
--
Clemens
René J.V. Bertin
2016-10-28 19:46:26 UTC
Permalink
On Friday October 28 2016 21:22:41 Clemens Lang wrote:

Hi,
Post by Clemens Lang
Isn't this essentially what 'port provides' does?
Only if you already know the full path to the file, and if you're only interested in the active port.

What I have in mind is two-fold:
- an alternative to spotlight's `mdfind -name` limited to files installed by MacPorts (which could be enough justification to exclude ${prefix} from SpotLight indexing).
- a way to find the port(s) that install a given file, even if they're not currently active (as in, which port was it again I have to activate to re-enable that nifty command called something like ...).

Thanks for the suggestions, I'll play around with them!

R.
Vincent Habchi
2016-10-28 19:24:05 UTC
Permalink
sqlite3 register.db

if ‘exp’ is the expression you’re looking for (e.g. ‘%qt4%’ for all files containing …qt4…)

sqlite> WITH i AS (SELECT id FROM files WHERE path LIKE exp GROUP BY id) SELECT name FROM ports, i WHERE ports.id = i.id;

Assuming you want the name of the ports which provides the files you’re looking for

Vincent
Vincent Habchi
2016-10-28 19:34:32 UTC
Permalink
Post by Vincent Habchi
if ‘exp’ is the expression you’re looking for (e.g. ‘%qt4%’ for all files containing …qt4…)
sqlite> WITH i AS (SELECT id FROM files WHERE path LIKE exp GROUP BY id) SELECT name FROM ports, i WHERE ports.id = i.id;
Assuming you want the name of the ports which provides the files you’re looking for
Oh, if you want the files, a simple

SELECT path FROM ports WHERE path LIKE exp;

is enough!

V.
René J.V. Bertin
2016-10-31 08:20:28 UTC
Permalink
On Friday October 28 2016 21:34:32 Vincent Habchi wrote:

Hi,
Post by Vincent Habchi
Post by Vincent Habchi
sqlite> WITH i AS (SELECT id FROM files WHERE path LIKE exp GROUP BY id) SELECT name FROM ports, i WHERE ports.id = i.id;
This works great, and as expected *much* faster than any other method one could think of currently. Ideally one would find a means to input standard regexps for the pattern. And I'd probably also want to print some more information about the results to avoid printing just the port name as many times as you have versions/variants installed. But that could also be achieved by running the output through uniq (or sort -u) and then into `port installed`).

%> /opt/local/bin/sqlite3 /opt/local/var/macports/registry/registry.db
SQLite version 3.14.2 2016-09-12 18:50:49
Enter ".help" for usage hints.
sqlite> WITH i AS (SELECT id FROM files WHERE path LIKE '%reator%' GROUP BY id) SELECT name FROM ports, i WHERE ports.id = i.id;
db48
qt5-creator-devel
qt5-creator
py34-pyqt5
qt5-kde-devel-zz-docs
kf5-breeze-icons
kf5-kio
kf5-kdelibs4support
kf5-kdevelop-devel
qt5-kde-devel
qt5-kde-devel
kf5-kio
kf5-kdelibs4support
kf5-breeze-icons
kf5-kdevelop-devel
kf5-marble
kf5-kio-extras
kf5-kdevelop-devel
kf5-okteta
kf5-kdevelop-devel
Post by Vincent Habchi
Oh, if you want the files, a simple
SELECT path FROM ports WHERE path LIKE exp;
This however does not work:

%> /opt/local/bin/sqlite3 /opt/local/var/macports/registry/registry.db
SQLite version 3.14.2 2016-09-12 18:50:49
Enter ".help" for usage hints.
sqlite> SELECT path FROM ports WHERE path LIKE '%reator%';
Error: no such column: path

R.
René J.V. Bertin
2016-11-01 14:10:30 UTC
Permalink
Hi,

A variant of my earlier question: is there a magic formula to query the registry which files (and/or ports) depend on a given binary file? IOW, an elegant alternative to something like

%> sudo bzip2 -v foo
%> sudo port -v rev-upgrade
%> sudo bunzip2 foo.bz2

Thanks,
R.
Clemens Lang
2016-11-01 17:11:25 UTC
Permalink
Hi,
Post by René J.V. Bertin
A variant of my earlier question: is there a magic formula to query
the registry which files (and/or ports) depend on a given binary file?
IOW, an elegant alternative to something like
No, there's no such thing in the registry. The registry only has
per-port information, so the best you can do is a combination of 'port
provides' and 'port dependents'.
Post by René J.V. Bertin
%> sudo bzip2 -v foo
%> sudo port -v rev-upgrade
%> sudo bunzip2 foo.bz2
I don't understand how bzip2 and port rev-upgrade relate.
--
Clemens
Brandon Allbery
2016-11-01 17:33:26 UTC
Permalink
Post by Clemens Lang
I don't understand how bzip2 and port rev-upgrade relate.
I think that's a hack: save and nuke the port in question (manually), then
let rev-upgrade catch the broken dependents for you.
--
brandon s allbery kf8nh sine nomine associates
***@gmail.com ***@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
René J.V. Bertin
2016-11-01 18:52:18 UTC
Permalink
On Tuesday November 01 2016 13:33:26 Brandon Allbery wrote:

Hi,

In hindsight it indeed seems unlikely that the registry would contain this kind of information.
Post by Brandon Allbery
I think that's a hack: save and nuke the port in question (manually), then
let rev-upgrade catch the broken dependents for you.
Exactly, though nuking evokes something a bit less precise than what this actually does :)

R.

Loading...