Quantcast
Channel: rtrouton – Der Flounder
Viewing all articles
Browse latest Browse all 764

Building a Grand Unified Xcode 5.0 installer for Mountain Lion

$
0
0

Apple has released Xcode 5.0 through the Mac App Store for all Macs running 10.8.4 and higher. The command line tools can be installed separately through the Xcode preferences, in the Downloads section. You now need an Apple Developer Connection account to install the Xcode 5 command line tools via the Xcode preferences, though a free ADC membership is sufficient.

For my users who are developers, I wanted to include Xcode 5.0 in their new machine builds and also install the command line tools automatically without needing to enter an Apple ID. I also wanted to build this installer as a flat package, so I’m shifting from my previous method using Iceberg to using Packages to build the installer package. See below the jump for the details.

Download Xcode 5.0 from the Apple Developer site and drag the application into /Applications.

Download the latest Mountain Lion Command Line Tools for Xcode disk images from the Apple Developer site.

Verify that the permissions on the Xcode application in /Applications are correct by running the following command:

sudo chown -R root:wheel /Applications/Xcode.app

Screen Shot 2013-09-20 at 11.01.53 AM

 

Set up a new Packages project and select Raw Package.

Screen Shot 2013-09-20 at 10.27.14 AM

In this case, I’m naming the project Xcode 5.0.

Screen Shot 2013-09-20 at 10.28.47 AM

Click on the Settings tab and set the following:

In the Post-Installation Behavior section, set On Success: to Do Nothing

In the Options section, check the box for Require admin password for installation.

Screen Shot 2013-09-20 at 12.22.19 PM

 

Click on the Payload tab, then click on the Applications folder in the listing.

Screen Shot 2013-09-20 at 11.08.47 AM

Go to the Hierarchy menu and select Add Files…

 

Screen Shot 2013-09-20 at 10.32.15 AM

 

Select the Xcode application in /Applications


Screen Shot 2013-09-20 at 10.33.33 AM

 

Verify that it’s now showing up under Applications in your Packages project.

Screen Shot 2013-09-20 at 10.34.14 AM

Click on the Scripts tab in your Packages project.

Screen Shot 2013-09-20 at 11.10.50 AM

Select the Mountain Lion Command Line Tools for Xcode disk image and drag it into the Additional Resources section of your Packages project.

Screen Shot 2013-09-20 at 10.36.34 AM

The last pieces are removing any previous Xcode.app from /Applications and telling the Command Line Tools for Xcode installer to run.

To remove any previous Xcode.app from /Applications, I’m using the following preinstall script:


#!/bin/sh

# Remove existing /Applications/Xcode.app from machine

if [ -d /Applications/Xcode.app ]; then
  rm -rf /Applications/Xcode.app
fi

To install the command line tools, I’m using the following postinstall script:


#!/bin/bash

# Determine OS version
osvers=$(sw_vers -productVersion | awk -F. '{print $2}')

# Determine working directory

install_dir=`dirname $0`

if [[ ${osvers} -eq 8 ]]; then

#
# Installing the Xcode 5.0 10.8 Command Line Tools
#

# Create /tmp/Command Line Tools (Mountain Lion) mountpoint in /tmp

  /bin/mkdir "/tmp/Command Line Tools (Mountain Lion)"

# Mount the latest command line tools disk image as /tmp/Command Line Tools (Mountain Lion)

  /usr/bin/hdiutil attach "$install_dir/command_line_tools_os_x_mountain_lion_for_xcode__september_2013.dmg" -mountpoint "/tmp/Command Line Tools (Mountain Lion)" -nobrowse -noverify -noautoopen

# Install the Xcode command line tools

  /usr/sbin/installer -dumplog -verbose -pkg "/tmp/Command Line Tools (Mountain Lion)/Command Line Tools (Mountain Lion).mpkg" -target /

# Clean-up

# Unmount the command line tools disk image from /tmp/Command Line Tools (Mountain Lion)

  /usr/bin/hdiutil eject "/tmp/Command Line Tools (Mountain Lion)"

# Remove /tmp/Command Line Tools (Mountain Lion) from /tmp

  /bin/rm -rf "/tmp/Command Line Tools (Mountain Lion)"

fi

Once you’ve got the preflight and postflight script built, run the following commands to make the scripts executable:

sudo chmod a+x /path/to/preinstall
sudo chmod a+x /path/to/postinstall

Once completed, add the preinstall and postinstall scripts to your Packages project.

Screen Shot 2013-09-20 at 10.39.13 AM

Last step, go ahead and build the package. (If you don’t know to build, check the Help menu for the Packages User Guide. The information you need is in Chapter 3 – Creating a raw package project and Chapter 10 – Building a project.)

Testing

Once the package has been built, test it by taking it to a test machine running 10.8.4 or 10.8.5 that doesn’t have Xcode 5.0 and install it. The end result should be that Xcode 5.0 installs along with the Xcode command line tools without requiring an Apple ID.



Viewing all articles
Browse latest Browse all 764

Trending Articles