Penguin, small TECH.BARWICK.DE
Mac OS X
 

Recent posts

Categories

Archive

Syndication

 



Powered By

Info

Wednesday, March 20, 2013

Install XCode command line tools via the command line

Occasionally I've needed to set up some kind of script or even a server application in a remote office, where the only computer with a UNIX-style environment is a Mac. Although OS X comes with a fair amount of tools built-in, these are usually not sufficient for the specialised configuration required, which means I need to compile some applications from scratch and probably install a command-line driven package management system such as MacPorts. To get this up and running of course, I need a compiler and associated tools, which are not built in. These are available from Apple as part of the XCode package; recently the non-IDE parts of XCode have been made available as a separate dmg file.

The question is of course, how to install the XCode command line tools from the dmg file where the only way of accessing the Mac in question is via ssh (and asking a local user to do it is not possible or practical).

First, copy the .dmg file to the Mac in question. Mount the .dmg file like this:

Some-Mac-mini:incoming root# hdiutil attach xcode461_cltools_10_86938245a.dmg
Checksumming Driver Descriptor Map (DDM : 0)…
     Driver Descriptor Map (DDM : 0): verified   CRC32 $8A35BC60
Checksumming  (Apple_Free : 1)…
                    (Apple_Free : 1): verified   CRC32 $00000000
Checksumming Apple (Apple_partition_map : 2)…
     Apple (Apple_partition_map : 2): verified   CRC32 $624016D7
Checksumming disk image (Apple_HFS : 3)…
.........................................................................................................
          disk image (Apple_HFS : 3): verified   CRC32 $EEA71AA2
Checksumming  (Apple_Free : 4)…
                    (Apple_Free : 4): verified   CRC32 $00000000
verified   CRC32 $7EE49609

/dev/disk3          	Apple_partition_scheme         	
/dev/disk3s1        	Apple_partition_map            	
/dev/disk3s2        	Apple_HFS                      	/Volumes/Command Line Tools (Mountain Lion)

(It may take a few seconds for the mount operation to complete).

On the freshly-mounted volume there should then be a .mpkg file; this can be installed with nary a click of a mouse thusly:

Some-Mac-mini:Command Line Tools (Mountain Lion) root# installer -verbose -pkg Command\ Line\ Tools\ \(Mountain\ Lion\).mpkg  -target /
installer: Package name is Command Line Tools (Mountain Lion)
installer: Installing at base path /
installer: Preparing for installation….....
installer: Preparing the disk….....
installer: Preparing Command Line Tools (Mountain Lion)….....
installer: Waiting for other installations to complete….....
installer: Configuring the installation….....
installer: 	
#
installer: Writing files….....
#
installer: Writing files….....
(...)
installer: Optimizing system for installed software….....
#
installer: Optimizing system for installed software….....
#
(...)
#
installer: Writing package receipts….....
#
installer: Writing package receipts….....
#
installer: Validating packages….....
#
installer: 	Running installer actions…
installer: 	
installer: Finishing the Installation….....
installer: 	
#
installer: The software was successfully installed......
installer: The install was successful.
Some-Mac-mini:Command Line Tools (Mountain Lion) root# cd
Some-Mac-mini:~ root # gcc
i686-apple-darwin11-llvm-gcc-4.2: no input files

And that is all there is to it. Don't forget to unmount the mounted dmg lest confusion arise amongst the local users.

Some-Mac-mini:~ root# mount
/dev/disk0s2 on / (hfs, local, journaled)
devfs on /dev (devfs, local, nobrowse)
map -hosts on /net (autofs, nosuid, automounted, nobrowse)
map auto_home on /home (autofs, automounted, nobrowse)
/dev/disk1s2 on /Volumes/Disk1 (hfs, local, nodev, nosuid, journaled, noowners)
/dev/disk2s2 on /Volumes/Disk2 (hfs, local, nodev, nosuid, journaled, noowners)
/dev/disk3s2 on /Volumes/Command Line Tools (Mountain Lion) (hfs, local, nodev, nosuid, read-only, noowners)
Some-Mac-mini:~ root# hdiutil detach /dev/disk3s2
"disk3" unmounted.
"disk3" ejected.

Posted at 11:30 PM |Comments (0)