Skip to content

Instantly share code, notes, and snippets.

@jonseymour
Created June 19, 2014 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonseymour/f05d97da2b29d4a03192 to your computer and use it in GitHub Desktop.
Save jonseymour/f05d97da2b29d4a03192 to your computer and use it in GitHub Desktop.
Script to extract components of Xcode 4.1 required to build VirtualBox on a OSX 10.9 system.
#!/usr/bin/env bash
#
# NAME
# extract-xcode41.sh
#
# DESCRIPTION
# 1. Copy this file into the same directory that contains installxcode_41_lion.dmg downloaded from Apple
# 2. Change into that directory
# 3. Run the file
# ./extract-xcode41.sh
# 4. Add --with-xcode-dir=$(pwd)/xcode41-partial to arguments of the ./configure command used to configure the VirtualBox build
#
DMG=${DMG:-installxcode_41_lion.dmg}
MNT=${MNT:-$(pwd)/mnt}
UNPACK=${UNPACK:-$(pwd)/unpack}
IMAGE=${IMAGE:-$(pwd)/xcode41-partial}
PACKAGES="DevSDK.pkg MacOSX10.6.pkg MacOSX10.7.pkg XcodeTools.pkg llvm-gcc4.2.pkg gcc4.2.pkg DeveloperTools.pkg"
die()
{
echo "fatal: $*" 1>&2
exit 1
}
main()
{
cat 1>&2 <<EOF
DMG=$DMG
MNT=$MNT
UNPACK=$UNPACK
IMAGE=$IMAGE
EOF
test -f "$DMG" || die "DMG=$DMG does not exist"
mkdir -p "${MNT}" &&
mkdir -p "${UNPACK}" &&
mkdir -p "${IMAGE}/Developer/usr/share/man/man3" &&
hdiutil mount "${DMG}" -mountpoint "${MNT}" &&
cd "${UNPACK}" &&
xar -xf "${MNT}/InstallXcodeLion.pkg" &&
mkdir -p InstallXcodeLion.pkg/Payload.cpio &&
cd InstallXcodeLion.pkg/Payload.cpio &&
gzip -dc ../Payload | cpio -id &&
cd "Applications/Install Xcode.app/Contents/Resources/Packages" &&
for p in $PACKAGES
do
local u="$(basename "$p" .pkg).unpkg"
mkdir -p "$u" && (
cd "$u"
xar -xf "../$p"
gzip -dc Payload | (cd "${IMAGE}/Developer"; cpio -id)
)
done &&
rm -rf "${UNPACK}" &&
hdiutil detach "${MNT}" &&
rmdir "${MNT}" &&
echo "Successfully extracted parts of Xcode 4.1 required to build VirtualBox into '${IMAGE}'. Add --with-xcode-dir=${IMAGE} to ./configure arguments."
}
cmd=${1:-main}
shift 1
$cmd "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment