How to make MacPorts reinstall requested ports from a different boot drive?
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 }' &gt;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 == &quot;installed&quot;) {act=&quot;(active)&quot;} else {act=&quot;&quot;} } 
{ cmd = &quot;date -r&quot; $8 &quot; +%Y-%m-%dT%T%z&quot;; cmd | getline mydate; close(cmd) }
{ printf (&quot;%s @%s_%s %s platform=%s %s archs=%s date=%s\n&quot;,
    $1, $2, $3, act,$5, $6, $7, mydate)
}' &gt;myports.txt