1. Install external hard drive. I used a LaCie d2 Quadra. Didn’t bother with their Setup Assistant (who the heck still writes software that requires Rosetta?), just erased it with Disk Utility and formatted it as one big journaled OS X volume.
2. Install SuperDuper (http://www.shirt-pocket.com/SuperDuper/SuperDuperDescription.html). I’m sure Carbon Copy Cloner is just as good, I just happen to be a SuperDuper user.
2a. At this point you may wish to delete anything from applications, documents, or your own user account that you won't want on the rebuilt machine. Apple's Migration Assistant is lamentably missing fine-toothed options for what to transfer.
3. Log out and log back in with the shift key held down to prevent startup items from running.
4. Launch SuperDuper and back up the internal hard drive to the external hard drive with the "Backup - All Files" script.
5. Restart, holding down the Option key when the box restarts. This will let you choose to restart from the backup you just made. Booting from the external drive will take a lot longer than from the internal one, but don't skip this step. You'll feel pretty darned stupid if you bootable backup isn't. Hold down shift after selecting the drive to bypass startup items so you don't clutter the backup.
6. While you're in there, launch terminal and :
gem list > gemlist.txt
port list installed > portlist.txt
This will come in handy later.
7. Now it's time to do some cleaning up of your backup to prepare for the later migration. Mac's Migration Assistant doesn't offer a lot of granularity, so you need to get rid of anything from your Applications, Documents, and other descendants of your home directory that you don't want to move. The more you delete now, the faster the migration will go, so delete any applications and documents that you don't want on the rebuilt Mac. Good time to clean up the Dock as well. I blew away my local gems as well at this point.
I also recommend completely blowing away /usr/local and /opt/local to make sure you’re doing a “clean everything” install even after migrating. Edit your .bash_login to remove them from the path as well (optionally, you may want to rename these directories to have them for reference).
pg_dumpall
8. Put in the Snow Leopard DVD. Ignore the Finder window when it pops up.
9. Power down the computer.
10. Unplug the backup drive. No sense taking changes.
11. Restart with the option key held down again. Choose the Mac OS X Install DVD to boot from.
12. The "Erase and Install" option is gone from the Snow Leopard installer, so when you get to the "Install Mac OS X" screen select Disk Utility from the Utilities menu instead.
13. Select the "Macintosh HD" partition on your hard drive. Select the Erase tab. Select the "Mac OS Extended (Journaled)" format. Click Erase. Grit your teeth and confirm.
14. When OS X is done reformatting the partition, close Disk Utility, click Continue on the OS X installer, and work your way through the rest of the prompts.
15. When you get to the "Do You Already Own a Mac?" screen (this is after the installation restart, so don't panic when the machine restarts), plug the external drive back in. Select "From another volume on this Mac" and click Continue.
16. The top of the "Transfer Your Information" screen should show that you're transferring from the external drive. Leave all the options checked and click Transfer.
17. Log into happy new OS X. Bask in it for a little bit. Wait a minute for Software Update to kick in, or run it manually and install whatever it comes up with.
18. While you've got the Snow Leopard DVD in the drive, pop option the Optional Installs folder and install XCode.
19. I personally prefer wget to curl (just habit, I suppose) which means that I have to install it:
GNU wget home page: http://www.gnu.org/software/wget/
Download wget-latest.tar.gz from http://ftp.gnu.org/gnu/wget/
tar -xzvf wget-latest.tar.gz
cd wget-1.11.4/
./configure
make
sudo make install
19. I'm trying a no-MacPorts approach this time around. This means installing a current readline by hand, since multiple pieces of software still reportedly have issues with Apple's default version:
GNU Readline home page: http://tiswww.case.edu/php/chet/readline/rltop.html
wget ftp://ftp.cwru.edu/pub/bash/readline-6.0.tar.gz
tar -xvzf readline-6.0.tar.gz
cd readline-6.0
./configure
make
sudo make install
20. This is a good point to make sure your .bash_login and .bash_profile are the way you want them. For me, that’s an empty .bash_login and a pretty minimal .bash_profile. Here’s my .bash_profile, though you probably want to tune your own:
export PATH=/usr/local/git/bin:/usr/local/bin/src:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:~/bin:$PATH
export EDITOR='mate -w'
export PAGER=most
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
export PS1='\[\033[1;36m\]\h\[\033[0;33m\] \w \[\033[31;40m\]$(parse_git_branch)\[\033[00m\] $ '
export HISTCONTROL=erasedups
export HISTSIZE=10000
shopt -s histappend
EVENT_NOKQUEUE=yes
21. Snow Leopard includes a recent version of SQLite, but you know, as long as we're building things we may as well make it current.
SQLite Download Page: http://www.sqlite.org/download.html
SQLite Build Instructions: http://www.sqlite.org/cvstrac/wiki?p=HowToCompile
wget http://www.sqlite.org/sqlite-amalgamation-3.6.17.tar.gz
tar -xvzf sqlite-amalgamation-3.6.17.tar.gz
cd sqlite-3.6.17/
./configure
make
sudo make install
22. Now for MySQL. If you have a previous version of MySQL installed, you probably have the old MySQL preference pane, which doesn't work under Snow Leopard. Fortunately swoon.net has recompiled a 64-bit version. Grab it from http://www.swoon.net/site/software.html and install it. Then pop into System Preferences and stop your MySQL server if it's running.
23. Given that there are prebuilt x64 binaries for OS X, I don't feel any particular need to build this from scratch. I've found anything past MySQL 5.1 to be problematic for Rails.
MySQL Download Page: http://dev.mysql.com/downloads/mysql/5.1.html#macosx-dmg
Pick a mirror and download the "Mac OS X 10.5 (x86_64)" version.
Mount the dmg and run the mysql package and then the mysql startup item package. Then start MySQL:
sudo /Library/StartupItems/MySQLCOM/MySQLCOM start
24. If you have existing MySQL databases to bring over from an old version, see the instructions at http://gist.github.com/177368 from edward - remember to change the old directory name to match the version you were running before.
25. SQLite and MySQL are nice, but these days I’m using PostgreSQL for new Rails work. If you want a shortcut, there’s an installer that runs on OS X: grab it from http://www.enterprisedb.com/products/pgdownload.do#osx and run it. But to get best performance, you probably should build by hand. There are good instructions at http://devoh.com/posts/2008/10/installing-postgresql-on-mac-os-x-10.5-leopard for that (from which I lifted most of the commands below), though you need to update the download version. Don’t install the postgres gem though; it’s slow and outdated, and anyhow there’s still work to do to get gems set up.
PostgreSQL source code: http://www.postgresql.org/ftp/source/
wget ftp://ftp.postgresql.org/pub/source/v8.4.0/postgresql-8.4.0.tar.gz
tar -xvzf postgresql-8.4.0.tar.gz
cd postgresql-8.4.0
./configure --enable-thread-safety --with-bonjour
make
sudo make install
sudo dscl . create /Users/_postgres UniqueID 113
sudo dscl . create /Users/_postgres PrimaryGroupID 113
sudo dscl . create /Users/_postgres NFSHomeDirectory /usr/local/pgsql/
sudo dscl . create /Users/_postgres RealName "PostgreSQL Server"
sudo dscl . create /Users/_postgres Password "*"
sudo dscl . append /Users/_postgres RecordName postgres
sudo dscl . create /Groups/_postgres
sudo dscl . create /Groups/_postgres PrimaryGroupID 113
sudo dscl . append /Groups/_postgres RecordName postgres
sudo dscl . create /Groups/_postgres RealName "PostgreSQL Users"
sudo mkdir /usr/local/pgsql/data
sudo chown postgres:postgres /usr/local/pgsql/data
cd /usr/local/pgsql/bin
sudo -u postgres ./initdb -D /usr/local/pgsql/data -U postgres -W -A md5
You probably want to follow Devoh’s instructions for hooking up launchd, as well as creating a user and database.
26. [reload pg databases]
27. Databases in hand, let’s turn to ruby. Given that I expect a transition to ruby 1.9 over the next year, and I find myself wanting to test on odd rubies from time to time, I’m going to completely ignore the system ruby except to bootstrap a multiruby setup.
Ruby Version Manager homepage: http://rvm.beginrescueend.com/
sudo gem install rvm
rvm-install
rvm install 1.8.6 -C --enable-shared,--with-readline-dir=/usr/local
rvm install 1.8.7 -C --enable-shared,--with-readline-dir=/usr/local
rvm install 1.9.1 -C --enable-shared,--with-readline-dir=/usr/local
rvm install 1.9.2 -C --enable-shared,--with-readline-dir=/usr/local
(I’m skipping ree and jruby and rubinius for the moment)
rvm 1.8.7 --default
28. Time to install the two problematic gems. I’m just going to do this under 1.8.7 for now, will update the other rubies later.
MySQL:
sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
PostgreSQL:
(instructions from http://www.icoretech.org/2009/08/how-to-install-pg-postgresql-gem-on-snow-leopard-64-bit/)
sudo -s
export ARCHFLAGS='-arch x86_64'
export PATH=/usr/local/pgsql/bin:${PATH}
gem install pg
29. Rest of the gems should be easier. Grab the gemlist.txt file you created way back at the start and edit it to one gem name per line. Ditch anything you know you don’t need. Then fire up IRB and run:
File.open('/Users/mike/gemlist.txt').each_line {|line| `sudo gem install #{line.split.first}`}
[stalled at RedCloth?]
30. This is a good time to get git on the system. Fortunately, there’s an easy and functional OS X installer for that: http://code.google.com/p/git-osx-installer/ . Download, mount the disk image, and run the installer and shell script.
31. imagemagick used to be a bear, but at the moment there’s a good install script for it on GitHub. So, now that you have your shiny new copy of git:
git clone git://github.com/maddox/magick-installer.git
cd magick-installer/
./magick-installer.sh
32. I also need memcached locally. Good install instructions are at https://wincent.com/wiki/Installing_memcached_1.4.1_on_Mac_OS_X_10.6_Snow_Leopard :
wget http://www.monkey.org/~provos/libevent-1.4.12-stable.tar.gz
tar xvzf libevent-1.4.12-stable.tar.gz
cd libevent-1.4.12-stable
./configure
make
sudo make install
wget http://memcached.googlecode.com/files/memcached-1.4.1.tar.gz
tar xvzf memcached-1.4.1.tar.gz
cd memcached-1.4.1
./configure
make
sudo make install
33. I’d like to run gem server locally on a startup basis (http://luigimontanez.com/2008/running-a-local-gem-documentation-server-on-mac-os-x-2) but I need to figure out how (or whether) that can be made to play nicely with rvm. Meanwhile, bdoc (http://github.com/manalang/bdoc/tree/master) is an acceptable alternative:
sudo gem install manalang-bdoc
34. Finally (for now!) I prefer most as a pager
Most home page: http://www.jedsoft.org/most/
You’ll need some prerequisites first:
pcre:
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-7.9.tar.gz
tar xvzf pcre-7.9.tar.gz
cd pcre-7.9
./configure
make
sudo make install
Oniguruma:
wget http://www.geocities.jp/kosako3/oniguruma/archive/onig-5.9.1.tar.gz
tar xvzf onig-5.9.1.tar.gz
cd onig-5.9.1
./configure
make
sudo make install
S-Lang:
wget ftp://space.mit.edu/pub/davis/slang/v2.2/slang-2.2.0.tar.gz
tar xvzf slang-2.2.0.tar.gz
cd slang-2.2.0
./configure
make
sudo make install
And now most at last:
wget ftp://space.mit.edu/pub/davis/most/most-5.0.0.tar.gz
tar xvzf most-5.0.0.tar.gz
cd most-5.0.0
./configure
make
sudo make install