VirtualBox

source: vbox/trunk/tools/darwin.x86/bin/xcode-4.1-extrator.sh@ 53485

Last change on this file since 53485 was 53376, checked in by vboxsync, 10 years ago

Preps for create a Xcode 4.1 tool tarball.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 KB
Line 
1#!/bin/bash
2# $Id: xcode-4.1-extrator.sh 53376 2014-11-21 18:16:02Z vboxsync $
3## @file
4# Extracts the necessary bits from the Xcode 4.1 lion package (inside installercode_41_lion.dmg).
5
6#
7# Copyright (C) 2014 Oracle Corporation
8#
9# This file is part of VirtualBox Open Source Edition (OSE), as
10# available from http://www.virtualbox.org. This file is free software;
11# you can redistribute it and/or modify it under the terms of the GNU
12# General Public License (GPL) as published by the Free Software
13# Foundation, in version 2 as it comes in the "COPYING" file of the
14# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16#
17
18#
19# Make sure we're talking the same language.
20#
21LC_ALL=C
22export LC_ALL
23
24#
25# Figure the tools/darwin.x86 location.
26#
27MY_DARWIN_DIR=`dirname "$0"`
28MY_DARWIN_DIR=`(cd "${MY_DARWIN_DIR}" ; pwd)`
29MY_DARWIN_DIR=`dirname "${MY_DARWIN_DIR}"`
30
31#
32# Constants.
33#
34MY_PKGS="gcc4.2.pkg llvm-gcc4.2.pkg DeveloperToolsCLI.pkg xcrun.pkg JavaSDK.pkg MacOSX10.6.pkg MacOSX10.7.pkg"
35declare -a MY_FULL_PKGS
36for i in $MY_PKGS;
37do
38 MY_FULL_PKGS[$((${#MY_FULL_PKGS[*]}))]="./Applications/Install Xcode.app/Contents/Resources/Packages/${i}"
39done
40
41#
42# Parse arguments.
43#
44MY_TMP_DIR=/var/tmp/xcode41extractor
45MY_DST_DIR="${MY_DARWIN_DIR}/xcode/v41"
46MY_PKG_FILE=
47
48my_usage()
49{
50 echo "usage: $0 [--tmpdir|-t <tmpdir>] <--destination|-d> <dstdir> <--filename|-f> <dir/InstallXcodeLion.pkg>";
51 exit $1;
52}
53
54while test $# -ge 1;
55do
56 ARG=$1;
57 shift;
58 case "$ARG" in
59
60 --tmpdir|-t)
61 if test $# -eq 0; then
62 echo "error: missing --tmpdir argument." 1>&2;
63 exit 1;
64 fi
65 MY_TMP_DIR="$1";
66 shift;
67 ;;
68
69 --destination|-d)
70 if test $# -eq 0; then
71 echo "error: missing --tmpdir argument." 1>&2;
72 exit 1;
73 fi
74 MY_DST_DIR="$1";
75 shift;
76 ;;
77
78 --filename|-f)
79 if test $# -eq 0; then
80 echo "error: missing --filename argument." 1>&2;
81 exit 1;
82 fi
83 MY_PKG_FILE="$1";
84 shift;
85 ;;
86
87 --h*|-h*|-?|--?)
88 my_usage 0;
89 esac
90done
91
92# Check the package file.
93if [ -z "${MY_PKG_FILE}" ]; then
94 echo "error: missing --filename <dir/InstallXcodeLion.pkg>." 1>&2l
95 my_usage 1;
96fi
97if ! xar -tf "${MY_PKG_FILE}" > /dev/null ; then
98 echo "error: xar has trouble with '${MY_PKG_FILE}'." 1>&2;
99 exit 1;
100fi
101
102# Check the destination directory.
103if [ -z "${MY_DST_DIR}" ]; then
104 echo "error: missing --destination <dstdir>." 1>&2;
105 my_usage 1;
106fi
107if ! mkdir -p "${MY_DST_DIR}"; then
108 echo "error: error creating '${MY_DST_DIR}'." 1>&2;
109 exit 1;
110fi
111
112# Check the temporary directory.
113if [ -z "${MY_TMP_DIR}" ]; then
114 echo "error: empty --tmpdir <tmpdir>." 1>&2;
115 my_usage 1;
116fi
117if ! mkdir -p "${MY_TMP_DIR}/x"; then
118 echo "error: error creating '${MY_TMP_DIR}/x'." 1>&2;
119 exit 1;
120fi
121
122#
123# Extract the "Applications/Install Xcode.app" payload, calling it MainPayload.tar.
124#
125if [ ! -f "${MY_TMP_DIR}/x/MainPayload.tar" ]; then
126 echo "info: Extracting '${MY_PKG_FILE}'..."
127 if ! xar -xvf "${MY_PKG_FILE}" -C "${MY_TMP_DIR}/x"; then
128 echo "error: extraction error." 1>&2;
129 exit 1;
130 fi
131 if ! mv -f "${MY_TMP_DIR}/x/InstallXcodeLion.pkg/Payload" "${MY_TMP_DIR}/x/MainPayload.tar"; then
132 echo "error: Failed to move the package payload. Did you get the right package file?" 1>&2;
133 exit 1;
134 fi
135fi
136
137#
138# Extract the sub-packages from MainPayload.tar. Make sure MacOSX10.7.pkg is the last.
139#
140if [ ! -f "${MY_TMP_DIR}/x/MacOSX10.7.pkg" ]; then
141 echo "info: Extracting packages from 'MainPayload.tar'..."
142 if ! tar xvf "${MY_TMP_DIR}/x/MainPayload.tar" -C "${MY_TMP_DIR}/x" "${MY_FULL_PKGS[@]}"; then
143 echo "error: Failure extracting sub-packages from MainPayload.tar (see above)." 1>&2;
144 exit 1;
145 fi
146
147 for i in $MY_PKGS;
148 do
149 if ! mv -f "${MY_TMP_DIR}/x/Applications/Install Xcode.app/Contents/Resources/Packages/${i}" "${MY_TMP_DIR}/x/${i}"; then
150 echo "error: Failed to move the package ${i}." 1>&2;
151 exit 1;
152 fi
153 done
154fi
155
156#
157# Work the sub-packages, extracting their payload content into the destination directory.
158#
159for i in $MY_PKGS;
160do
161 rm -f -- "${MY_TMP_DIR}/x/Payload";
162 echo "info: Extracting payload of sub-package ${i}...";
163 if ! xar -xvf "${MY_TMP_DIR}/x/${i}" -C "${MY_TMP_DIR}/x" Payload; then
164 echo "error: Failed to extract the payload of sub-package ${i}." 1>&2;
165 exit 1;
166 fi
167 if ! tar xvf "${MY_TMP_DIR}/x/Payload" -C "${MY_DST_DIR}"; then
168 echo "error: Failed to extract the payload content of sub-package ${i}." 1>&2;
169 exit 1;
170 fi
171done
172
173#
174# Clean up.
175#
176echo "info: Successfully extracted. Cleaning up temporary files..."
177rm -Rf -- "${MY_TMP_DIR}/x/"
178rmdir -- "${MY_TMP_DIR}"
179
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette