I recently changed workstations and went from OSx 10.7.5 to OSX 10.11! Yay!

I have a lot of installation to do. Nuts.... (But worth it!)

I have temporarily mounted my old workstation's hard drive to copy over important files. Since I have a different OS, a different version of XCode (and command line tools), and a different version of MacPorts, I'd rather do a fresh install of all my requested ports rather than semi-blindly copy stuff over from the old drive.

MacPorts has a great Migration guide (link) that shows how to create a list of all installed ports, then reinstall them once software has been upgraded — but that's for upgrading on the same boot drive. My new drive has no installed ports because I just installed MacPorts.

Is there a way to list requested ports on the old hard drive in order to upgrade them on my new drive?

  • Perhaps the old workstation's MacPorts left a file on the old hard drive that tells what ports were installed and/or requested?
    – jvriesem
    May 5, 2017 at 17:00
  • As explained in the migration guide, the installed ports list should be made from the starting version of MacOS X and MacPorts.
    – dan
    May 6, 2017 at 4:09
  • @danielAzuelos: Is there a way to run that version of MacPorts, then, from a different boot drive? (I don't even know where that executable would be.)
    – jvriesem
    May 6, 2017 at 5:49
  • Does your old installation have this file - /opt/local/var/macports/registry/registry.db? You could build a requested list from this sqlite3 database?
    – fd0
    May 25, 2017 at 18:46

1 Answer 1


Actually, I think you want the results of port -qv installed to restore your installation but I'll show you how to produce both files.

Mount the old hard drive and copy this file into a folder in your home folder- /opt/local/var/macports/registry/registry.db. Now navigate to that folder.

To produce the requested.txt file:

sqlite3 registry.db 'select name, requested from ports' |
awk -F '|' '{ if ( $2 == 1 ) print $1 }' >requested.txt

To produce the myports.txt file:

sqlite3 registry.db \
'select name,  version, revision, state, os_platform, os_major, archs, date from ports' |
sort |
awk -F'|' '{ if ( $4 == "installed") {act="(active)"} else {act=""} } 
{ cmd = "date -r" $8 " +%Y-%m-%dT%T%z"; cmd | getline mydate; close(cmd) }
{ printf ("%s @%s_%s %s platform=%s %s archs=%s date=%s\n",
    $1, $2, $3, act,$5, $6, $7, mydate)
}' >myports.txt
  • I get an error from awk: non-terminated string %s @%s_%s ... at source line 3 context is >>> <<< awk: giving up Do you think there is a mistake in the awk code? Apr 3, 2021 at 16:33
  • 1
    Yes, problems with quoting. The edit should fix it.
    – fd0
    Apr 7, 2021 at 18:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .