Does MacPorts keep a log for actions like install and upgrade?

After I ran sudo port upgrade outdated I’d like to know what was upgraded. The output was longer than my scrollback buffer.

I checked /opt/local/var/macports/logs/ but it seems to only contain logs for some of the compilations, not installation. For example, a copy of the output of sudo port upgrade outdated would be nice. Right now I simply tee the output to a file, but this kills the nice progress bar since port doesn’t see a TTY at the stdout.


Solution 1:

I will be semi helpful here. I can show you where the data is and an SQL query but you might need more for a clean solution.

Macports keeps a registry in an SQLite database in /opt/local/var/macports/registry/registry.db This includes a date which looks like to me the time the package was last installed on your machine

An SQL query returns the data

SELECT
  ports.name, 
  datetime(ports.date, 'unixepoch')
FROM
  ports
ORDER BY
  ports.date

You will need to modify the query for your exact use case to only show a subset (e.g. add a where clause) and something to run it in

A crude way to do this is use sqlite3.

sqlite3 /opt/local/var/macports/registry/registry.db

Then you get a prompt - at that paste in the SQL above - then type in ; and hit return

At the bottom I get

iTerm2|2021-05-10 09:48:10
openjdk16-zulu|2021-05-10 09:49:00
rust|2021-05-16 09:47:44

I have only upgraded rust today