How can one do a complete clean reinstall of a port and at the same time a complete clean reinstall of all its dependenceis?
Asked
Active
Viewed 1.1k times
8
-
Well this is odd. Just [posted](http://stackoverflow.com/questions/22238497/cleaning-out-all-other-installed-pythons-on-os-x) minutes ago. – Drewness Mar 06 '14 at 23:46
2 Answers
18
From the MacPorts wiki (migration):
https://trac.macports.org/wiki/Migration
After having saved a list of installed ports using:
port -qv installed > myports.txt
and having removed them with:
sudo port -f uninstall installed
Download and execute the restore_ports script. (If you installed MacPorts from source and used a custom prefix, then you'll need to use the -p
option when you run restore_ports.tcl
; see ./restore_ports.tcl -h
.)
curl -O https://svn.macports.org/repository/macports/contrib/restore_ports/restore_ports.tcl
chmod +x restore_ports.tcl
sudo ./restore_ports.tcl myports.txt
-
1@KirkRoybal: That link is the definitive answer to this question, straight from the MacPorts people. This should be the accepted answer. – jvriesem Aug 24 '15 at 16:57
5
Save your currently installed ports
sudo port list installed | sed 's/ .*//' | sort | uniq > ports.lst
Then uninstall everything, leaving the structure in place
sudo port clean installed
sudo port -f uninstall installed
Then reinstall everything, with the new dependencies:
for package in $(<ports.lst); do sudo port install $package; done

Jens
- 8,423
- 9
- 58
- 78

Kirk Roybal
- 17,273
- 1
- 29
- 38
-
2This gives me *all* installed ports. Is there a way to list only the leaves of the dependency graph? For example, I wouldn't need to know of ports that will be installed as a dependency of another port. – Jens Dec 12 '14 at 07:17
-
1Also wanted to point out that this approach doesn't keep the installed variants. Using `port -v installed` or somesuch instead of the `port list installed` would be better IMO. – Jens Jan 10 '15 at 16:11
-
-
@jvriesem well he's offering to download some script.. why doing this if you could show commands in here.. – holms Dec 03 '15 at 01:35
-
@holms: This is true, though the script is the script that the MacPorts developers recommend using. Presumably their script has more than just the commands in this answer for some reason. (One would hope! :-) ) Once nice thing about this answer is that it's transparent. – jvriesem Dec 03 '15 at 17:56
-