Skip to content
This repository has been archived by the owner on Jul 27, 2024. It is now read-only.

Installation and Setup

Abhijit Hiremagalur and Brian Cunnie edited this page Jul 17, 2013 · 9 revisions

How do I set it up?

These instructions were tested under OS X Lion 10.7.4 and Xcode 4.3.3

Initial Workstation Creation

Get a workstation.

  1. Boot from a Lion Install USB drive
  2. Choose Disk Utility; click Continue
  3. Use System Preferences to partition it into 2 partions (Partition Map Scheme: GUID Partition Table; Format: Mac OS Extended (Journaled))
  4. name the first one after the hostname (e.g. "osx-build-machine")
  5. name the second one "NEWLY_IMAGED"
  6. Click Apply
  7. Cmd-Q to quit Disk Utility.

Install 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 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 Don't transfer now; click Continue

  9. Enter Your Apple ID

  10. Type in your Apple ID, e.g. [email protected]

  11. Type in the password, e.g. Loves2dance

  12. Click Continue

  13. Review your Registration; click Continue

  14. Fill out the Create Your Computer Account

  15. Full Name: e.g. pivotal

  16. Account Name: e.g. pivotal

  17. Password: e.g. loves2dance

  18. Verify: e.g. loves2dance

  19. Uncheck Allow my Apple ID...

  20. Password Hint: e.g. How do you feel about dancing?

  21. Click Continue

  22. Click Start Using Lion

  23. Log in as user

  24. Bring up a terminal

  25. Type curl -LO https://github.com/downloads/kennethreitz/osx-gcc-installer/GCC-10.7-v2.pkg

  26. Type *sudo installer -package .pkg -target /

  27. Type in your password

  28. Click on the App Store icon in the dock.

  29. Type Xcode in the search bar; press return.

  30. Click on the gray Free button in Xcode. It will turn into a green Install App button; click that.

  31. Enter your App Store userid & password (i.e. your Apple Id).

  32. Click on the Xcode Icon

  33. Click Agree to Xcode License Agreement

  34. Click Install to Xcode Component Installation

  35. Type in your password; click Install Software

  36. Click Start Using Xcode

  37. Click XcodePreferencesDownloadsComponents

  38. Select Command Line Tools; click Install

  39. Press Cmd-Q to quit Xcode.

  40. In your terminal window

  41. Type sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

  42. Type sudo softwareupdate -i -a

  43. Bring up Address Book; remove the entry corresponding to the Appstore user (to avoid Chrome using that information to pre-populate address fields) (we want to minimize the personally-identifiable information)

Create the mostly-pristine image on the DeployStudio server:

  1. Click Apple IconRestart; click Restart
  2. Hold down the Option key while rebooting.
  3. Select the DeployStudio Netboot. You have set up a DeployStudio NetBoot server, haven't you?
  4. Click Create a master from a volume
  5. Press the Play button (looks like an arrow).
  6. On the Hard Drive dropdown, select NEWLY_IMAGED
  7. Image name, e.g. 10.7.4_4.3.3_12.07.06_23.21
  8. Press the Play button (looks like an arrow).
  9. When it's finished, you'll need to create a symbolic link on the DeployStudio server, in the Masters/HFS subdirectory, e.g.
    ln -s 10.7.4_4.3.3_12.02.23_23.30.i386.hfs.dmg lion_mostly_pristine.i386.hfs.dmg
  10. The machine will reboot when it has finished.
  11. Click Restart on the login screen.
  12. Hold down the Option key while it reboots.
  13. Select Persistent. Click the .

Only if you use VMWare Fusion.

VMWare Fusion does not allow netbooting (as of 4.1.3). If that is the case, you can still create the mostly-pristine image on the DeployStudio server, but the process is more complex:

  1. Boot from the Install image, again.
  2. Bring up Disk Utility
  3. Select NEWLY_IMAGED
  4. Click Restore
  5. Drag-and-drop Persistent to Source:
  6. Drag-and-drop NEWLY_IMAGED to Destination:
  7. Click Restore
  8. Click Erase
  9. Click on the Apple in the upper-left-hand corner
  10. Click Startup Disk...
  11. Select the first Persistent partition
  12. Click Restart...
  13. When it reboots, log in
  14. Bring up Terminal
  15. Type sudo diskutil rename /Volumes/Persistent\ 1 NEWLY_IMAGED
  16. Mount the DeployStudio server's hard drive.
  17. Type DESTFILE=10.7.4-4.3.3-$(date +%y.%m.%d-%H.%M).hfs.dmg
  18. Type sudo hdiutil create -srcfolder /Volumes/NEWLY_IMAGED /Volumes/DeployStudio/Masters/HFS/$DESTFILE
  19. Type sudo asr imagescan --allowfragmentedcatalog --source /Volumes/DeployStudio/Masters/HFS/$DESTFILE
  20. Type cd /Volumes/DeployStudio/Masters/HFS/; ln -sf $DESTFILE lion_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 Screen Saver: Never
  • System Preferences → Screen Sharing: Checked
  • System Preferences → Remote Login: Checked
  • System Preferences → Users & Groups → Automatic login: pivotal
  • System Preferences → Users & Groups → pivotal → Login Items → +
    Add the network share where the DeploySutdio masters are located.
  1. Fix sudo
  • Bring up a terminal
  • sudo visudo
  • append the following line to the sudoers:
    %staff ALL=(ALL) NOPASSWD: ALL
  1. Set up ssh
  • 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:
    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
  • test: ssh osx-build-machine
  1. Install Jenkins
  2. Add the Git Plugin
  3. Access Jenkins from its web interface

Create the Jenkins job

  1. Job name: Apple Orchard 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 * * * * *
  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.

Create the Jenkins trigger project

  1. Project name: Apple Orchard Trigger
  2. Source Code Management
  3. Select Git
  4. URL of repository: [email protected]:pivotal/pivotal_workstation.git
  5. Build Triggers
  6. Check Poll SCM
  7. Schedule 1,16,31,46 * * * *
  8. Build
  9. Execute Shell

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 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/