Installation and Setup under VMWare Fusion and Mountain Lion - pivotal-sprout/sprout-orchard GitHub Wiki

How do I set it up?

These instructions were tested under VMware Fusion 5.0.3, OS X Mountain Lion 10.8.4, and Xcode 4.6.2

Initial Virtual Machine Creation & Disk Partitioning

  1. Start VMWare Fusion
  2. Cmd-N to start a new virtual machine
  3. Click Continue without disc
  4. Use operating system or disc image (choose a disc or disc image); click Continue
  5. Select the ML install disk image (probably InstallESD.dmg); click Continue
  6. Set Version to closest available match; click Continue
  7. Click Customize Settings
  • Select a save location for the VM
  • Hard Disk: 80GB
  • Set Processors & Memory:
    2 processor cores
    4GB
  • Network Adapter:
    select Connect directly to the physical network (Bridged)
    Advanced options → Mac Address: click Generate
  • You'll probably want to create an entry for this machine in your DNS server and add the created MAC address to your DHCP server.
  1. Fire up the VM
  2. Choose your language
  3. Choose Disk Utility; click Continue
  4. Partition into 2 partions, one 45GB, the other the remaining (Partition Map Scheme: GUID Partition Table; Format: Mac OS Extended (Journaled))
  5. name the 45GB Persistent
  6. name the other one NEWLY_IMAGED (must use this exact string, currently lots of hardcoded dependencies in the scripts)
  7. Click Apply; click Partition
  8. Disk Utility → Quit Disk utility (don't use Cmd-Q to quit Disk Utility; you'll quit VMware Fusion instead)

Install Mountain Lion on the Persistent partition

  1. Select Reinstall Mac OS X; Click Continue.
  2. Splash screen, click Continue.
  3. Click Agree.
  4. Click Agree, again.
  5. Select the Persistent (40GB) partition; click Install (takes ~7-30 minutes).
  6. Select Country, e.g. United States; click Continue.
  7. Select keyboard layout, e.g. U.S.; click Continue.
  8. Select Not Now; click Continue
  9. Click Enable Location Services if you want, click Continue
  10. Click Skip; click Skip
  11. Click Continue; click Agree
  12. Fill out the Create Your Computer Account
  13. Full Name: e.g. pivotal
  14. Account Name: e.g. pivotal
  15. Password: e.g. loves2dance
  16. Verify: e.g. loves2dance
  17. Password Hint: e.g. How do you feel about dancing?
  18. Click Continue
  19. Confirm timezone; Click Continue
  20. Click Skip to Skip registration; click Skip again
  21. Click Start Using your Mac
  22. Bring up Finder; eject Mac OS X Install disk
  23. VMware → Virtual Machine → Update VMware Tools
  24. Click Install to connect the Tools installer CD
  25. Click OK to continue anyway
  26. Double-click Install VMware Tools; go with defaults
  27. Click Restart to finish installing the software
  1. Log in as user
  2. Click on the App Store icon in the dock.
  3. Type Xcode in the search bar; press return.
  4. Click on the gray Free button in Xcode. It will turn into a green Install App button; click that.
  5. Enter your App Store userid & password (i.e. your Apple Id).
  6. Click on the Xcode Icon
  7. Click Agree to Xcode License Agreement
  8. Click Install to Xcode Component Installation
  9. Type in your password; click Install Software
  10. ApplicationsXcode
  11. Click Agree; click Install; enter your password; click Start Using Xcode
  12. Click XcodePreferencesDownloadsComponents
  13. Select most-recent IOS simulator; click Install
  14. Select second-most-recent IOS simulator; click Install
  15. Select Command Line Tools; click Install
  16. Xcode → Quit Xcode
  17. System PreferencesSoftware UpdateCheck Now
  18. Install all available updates
  19. App Store → Quit App Store

Set Up Second (NEWLY_IMAGED) Partition

  1. Go to the Virtual Machine → CD/DVD(SCSI) → Connect CD/DVD.

  2. System Preferences → Startup Disk → Choose Mac OS X Install ESD

  3. Click Restart...; click Restart

  4. Bring up Disk Utility

  5. Select NEWLY_IMAGED

  6. Click Restore

  7. Drag-and-drop Persistent to Source:

  8. Drag-and-drop NEWLY_IMAGED to Destination:

  9. Click Restore

  10. Click Erase

  11. Disk Utility → Quit Disk Utility

  12. Utilities → Terminal to bring up terminal

  13. Type diskutil rename /Volumes/Persistent\ 1 NEWLY_IMAGED

  14. Click on the Apple in the upper-left-hand corner

  15. Click Startup Disk...

  16. Select the Persistent partition

  17. Click Restart...

  18. When it reboots, log in

  19. Bring up Terminal

  20. Mount the DeployStudio server's hard drive. Check Remember this password in my keychain

  21. Type DESTFILE=10.8.5-4.6.3-$(date -u +%Y-%m-%d-%H:%M).i386.hfs.dmg

  22. (note: the following steps are perhaps overly cautious; shouldn't need to unmount/fsck/mount-read-only)

  23. Type sudo diskutil unmount /Volumes/NEWLY_IMAGED

  24. Type sudo fsck_hfs -r $(diskutil info NEWLY_IMAGED | grep Node | awk '{ print $3 }')

  25. Type sudo diskutil mount readOnly $(diskutil info NEWLY_IMAGED | grep Node | awk '{ print $3 }')

  26. Type sudo hdiutil create -srcfolder /Volumes/NEWLY_IMAGED /Volumes/DeployStudio/Masters/HFS/$DESTFILE

  27. Type sudo asr imagescan --allowfragmentedcatalog --source /Volumes/DeployStudio/Masters/HFS/$DESTFILE

  28. Type cd /Volumes/DeployStudio/Masters/HFS/; ln -sf $DESTFILE ML_mostly_pristine.i386.hfs.dmg

Post-pristine Configuration of "Persistent" personality

  1. Boot the OS X Build machine
  2. System tweaks:
  • System Preferences → Energy Saver → Computer Sleep → Never
  • System Preferences → Energy Saver → Display Sleep → Never
  • System Preferences → Energy Saver → Put the hard disk(s) ... → Unchecked
  • System Preferences → Desktop & Screen Saver → Screen Saver → Start after: Never
  • System Preferences → Sharing → Screen Sharing: Checked
  • System Preferences → Sharing → Remote Login: Checked
  • System Preferences → Users & Groups → Login Options → Automatic login: pivotal
  • System Preferences → Users & Groups → pivotal → Login Items → + (not the "+" under Login Options)
    Add the network share where the DeployStudio masters are located.
  1. Fix sudo
  • Bring up a terminal
  • sudo visudo
  • append the following line to the sudoers:
    %staff ALL=(ALL) NOPASSWD: ALL
  • sudo mdutil -i off /
  1. Set up ssh (note: if you have multiple Apple Orchard builds, e.g. one VM to build Lion, a different VM to build Mountain Lion, we suggest using the same set of ssh keys across the VMs)
    To complete the next steps you need to have already set-up Jenkins, if that hasn't been done yet, please do that before proceeding.
  • ssh-keygen -f ~/.ssh/id_sprout-orchard -N ''
  • cp ~/.ssh/{id_sprout-orchard.pub,authorized_keys}
  • scp ~/.ssh/id_sprout-orchard jenkins_user@jenkins_server:.ssh/
  • [Pivotal Labs only: install ssh-keys to access private cookbooks]
  1. Append id_sprout-orchard.pub to the end of the DeployStudio server's userid's .ssh/authorized_keys
  2. Test passwordless ssh from the build VM to the DeployStudio:
    ssh -i ~/.ssh/id_sprout-orchard deploy_userid@deploystudio_server

Setting up Jenkins

Jenkins is an extendable open source continuous integration server. This is how to set up Jenkins to kick off an automatic build of a new image every time a change is committed to the build cookbook(s).

  1. Set up ssh's config
  • vim ~/.ssh/config
    Host osx-build-machine
    IdentityFile ~/.ssh/id_sprout-orchard User osx-build-machine-user
  • test password-less ssh & sudo: ssh osx-build-machine sudo id
  1. Install Jenkins
  2. Add the Git Plugin
  3. Access Jenkins from its web interface

Create the Jenkins job

For convenience, we have copied the Jenkins XML configuration into the repo.

  1. Job name: Apple Orchard ML Image
    free-style software project
  2. Description: Creates images to be used by DeployStudio
  3. Source Code Management
  4. Select Git
  5. URL of repository: git://github.com/pivotal-sprout/sprout-orchard.git
  6. Build Triggers
  7. Check Poll SCM
  8. Schedule 1,16,31,46 * * * *
  9. Build
  10. Select Execute Shell
  11. Execute shell Command: Use this shell script as a template, modifying the shell variables to suit your setup.
  12. Click Save

Create the Jenkins trigger job

  1. Job name: Apple Orchard Workstation Trigger
    free-style software project
  2. Click OK
  3. Description: Triggers a new build of Apple Orchard when the chef cookbook has been modified.
  4. Source Code Management
  5. Select Git
  6. URL of repository: https://github.com/pivotal-sprout/sprout-wrap.git
  7. Build Triggers
  8. Check Poll SCM
  9. Schedule * 1,16,31,46 * * *  
  10. Post-build actions
  11. Check Build other projects
  12. Projects to build Apple Orchard ML Image
  13. Click Save

Create the DeployStudio workflow

  1. ssh into the DeployStudio server as the deploy user: e.g. ssh deploy@deploystudio
  2. cd into the Masters directory, e.g. cd /Shared\ Items/DeployStudio/Masters/HFS/
  3. Create a symbolic link to the pristine image: ln -s ML_mostly_pristine.i386.hfs.dmg ML_HEAD.i386.hfs.dmg
  4. Create 10.8 Recovery HD Creation.pkg using Der Flounder's recipe.
  5. Put the resulting .pkg into DeployStudio's packages directory (e.g. /Shared Items/DeployStudio/Packages/ )
  6. Open DeployStudio Admin
  7. Enter the Server address, User name, and Password; click Connect
  8. Select Workflows from the left hand navbar
  9. Click the + button at the bottom (not the one that's grayed-out)
  10. Enter the information:
  • Title, e.g. 1 - ML HEAD
  • Description, e.g. Mountain Lion (OS X 10.8) HEAD
  1. Click the + next to "Drop Tasks Here"
  2. Drag-and-drop Partition over to the tasks
  3. Configure the Partition:
  • Target Volume: First Disk Available
  • Checked: Automate
  1. Drag-and-drop Restore over to the tasks, after "Partition"
  2. Configure the Restore:
  • Target volume: First disk available
  • Image: HFS, use the dropdown to select ML_HEAD.i386.hfs.dmg
    (you might need to restart the DeployStudio daemon to pick up the ML_HEAD dmg)
  • Checked: Automate
  1. Drag-and-drop Package Install over to the tasks, after "Restore"
  • Target volume: Previous task target
  • Package: 10.8 Recovery HD Creation.pkg
  • Checked: Automate
  1. Drag-and-drop Software update over to the tasks, after "Package Install"
  2. Click Save

Bonus Points: Populate the cache directories

We found that caching downloaded software on the Jenkins server and pre-populating the build machine had a number of advantages, the greatest of which was reduced fragility (i.e. a build was more likely to complete because, for example, it wasn't dependent on being able to download source code from a server off the coast of Spain). It also greatly speeded up the build process, and reduced Internet bandwidth usage.

On the build machine, after a successful build

sudo chown -R $USER /Volumes/NEWLY_IMAGED/var/chef/cache/

On the Jenkins machine, after a successful build

  1. sudo mkdir -p /var/chef/cache
  2. sudo chown -R jenkins-user /var/chef/cache
  3. rsync -avH --delete --stats osx-build-machine:/Volumes/NEWLY_IMAGED/var/chef/cache /var/chef/
  4. sudo mkdir -p /Library/Caches/Homebrew
  5. sudo chown $USER /Library/Caches/Homebrew
  6. rsync -avH --delete --stats osx-build-machine:/Volumes/NEWLY_IMAGED/Library/Caches/Homebrew /Library/Caches/
⚠️ **GitHub.com Fallback** ⚠️