Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I've been learning the shell for a few weeks and have installed several packages. I know/remember what some of them are, like oh-my-zsh and emacs 24 (which was a nightmare to upgrade to), but not sure sure about what else. I've used different methods like curl, wget and Macports.

My question is, if and when I want to do a clean installation of MacOS, how do I backup or script a fresh installation of these packages? In other words, when I do a new install of MacOS I won't be restoring from Time Machine using Migration Assistant: rather I'll install the system and manually restore files. How do I know the installation paths and dependancies of what I've installed in my previous installation using the command line? Is there a txt file somewhere that the system maintains to keep track of what has been installed?

(MacOS 10.8.2)

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Since OS X has no package manager, anything you install would have been manual, through MacPorts or through Installer.

If you want a list of the binaries your terminal has access to, you can run the following commands to check the most common spots, and output the result as a text file:

touch ~/Binaries.txt
ls /usr/bin > ~/Binaries.txt
ls /usr/sbin >> ~/Binaries.txt
ls /usr/local/bin >> ~/Binaries.txt
ls /usr/local/sbin >> ~/Binaries.txt
ls /opt/local/bin >> ~/Binaries.txt
ls /opt/local/sbin >> ~/Binaries.txt

Alternatively, if you just want to get the packages installed by MacPorts, run the following (this is probably the one you want):

touch ~/MacPorts.txt
port installed > ~/MacPorts.txt

And for Homebrew:

touch ~/HomeBrew.txt
brew list > ~/HomeBrew.txt

And finally, for all packages installed by Installer

touch ~/InstalledPackages.txt
pkgutil --packages > ~/InstalledPackages.txt

To restore, for example, your MacPorts ports from the list generated above, use the following:

 port install $(cat ~/MacPorts.txt)
share|improve this answer
    
This is an excellent answer, thank you. –  Elliott Nov 11 '12 at 18:12
    
No problem! Please mark it as accepted if it solves your problem :) –  Yasyf Nov 11 '12 at 22:31
    
Isn't it better to run port list requested rather than port installed, so that MacPorts installs only the dependencies that are in use and in the right order? –  Deditos Nov 26 '12 at 12:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.