1 | #!/bin/bash
|
---|
2 | # $Id: xcode-6.2-extractor.sh 98103 2023-01-17 14:15:46Z vboxsync $
|
---|
3 | ## @file
|
---|
4 | # Extracts the necessary bits from the Xcode 6.2 (Xcode_6.2.dmg,
|
---|
5 | # md5sum fe4c6c99182668cf14bfa5703bedeed6) and the Command Line
|
---|
6 | # Tools for Xcode 6.2 (10.9: commandlinetoolsosx10.9forxcode6.2.dmg,
|
---|
7 | # 10.10: commandlinetoolsosx10.10forxcode6.2.dmg).
|
---|
8 | #
|
---|
9 | # This script allows extracting the tools on systems where the command line
|
---|
10 | # tools refuse to install due to version checks.
|
---|
11 | #
|
---|
12 |
|
---|
13 | #
|
---|
14 | # Copyright (C) 2014-2023 Oracle and/or its affiliates.
|
---|
15 | #
|
---|
16 | # This file is part of VirtualBox base platform packages, as
|
---|
17 | # available from https://www.virtualbox.org.
|
---|
18 | #
|
---|
19 | # This program is free software; you can redistribute it and/or
|
---|
20 | # modify it under the terms of the GNU General Public License
|
---|
21 | # as published by the Free Software Foundation, in version 3 of the
|
---|
22 | # License.
|
---|
23 | #
|
---|
24 | # This program is distributed in the hope that it will be useful, but
|
---|
25 | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
26 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
27 | # General Public License for more details.
|
---|
28 | #
|
---|
29 | # You should have received a copy of the GNU General Public License
|
---|
30 | # along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
31 | #
|
---|
32 | # SPDX-License-Identifier: GPL-3.0-only
|
---|
33 | #
|
---|
34 |
|
---|
35 | #
|
---|
36 | # Make sure we're talking the same language.
|
---|
37 | #
|
---|
38 | LC_ALL=C
|
---|
39 | export LC_ALL
|
---|
40 |
|
---|
41 | #
|
---|
42 | # Figure the tools/darwin.x86 location.
|
---|
43 | #
|
---|
44 | MY_DARWIN_DIR=`dirname "$0"`
|
---|
45 | MY_DARWIN_DIR=`(cd "${MY_DARWIN_DIR}" ; pwd)`
|
---|
46 | MY_DARWIN_DIR=`dirname "${MY_DARWIN_DIR}"`
|
---|
47 |
|
---|
48 | #
|
---|
49 | # Parse arguments.
|
---|
50 | #
|
---|
51 | MY_DST_DIR="${MY_DARWIN_DIR}/xcode/v6.2"
|
---|
52 | MY_XCODE_APP="/Volumes/Xcode/Xcode.app"
|
---|
53 |
|
---|
54 | my_usage()
|
---|
55 | {
|
---|
56 | echo "usage: $0 <--destination|-d> <dstdir> <--xcode-app|-x> </Volumes/Xcode/Xcode.app>";
|
---|
57 | exit $1;
|
---|
58 | }
|
---|
59 |
|
---|
60 | while test $# -ge 1;
|
---|
61 | do
|
---|
62 | ARG=$1;
|
---|
63 | shift;
|
---|
64 | case "$ARG" in
|
---|
65 |
|
---|
66 | --destination|-d)
|
---|
67 | if test $# -eq 0; then
|
---|
68 | echo "error: missing --tmpdir argument." 1>&2;
|
---|
69 | exit 1;
|
---|
70 | fi
|
---|
71 | MY_DST_DIR="$1";
|
---|
72 | shift;
|
---|
73 | ;;
|
---|
74 |
|
---|
75 | --xcode-app|-x)
|
---|
76 | if test $# -eq 0; then
|
---|
77 | echo "error: missing --xcode-app argument." 1>&2;
|
---|
78 | exit 1;
|
---|
79 | fi
|
---|
80 | MY_XCODE_APP="$1";
|
---|
81 | shift;
|
---|
82 | ;;
|
---|
83 |
|
---|
84 | --h*|-h*|-?|--?)
|
---|
85 | my_usage 0;
|
---|
86 | esac
|
---|
87 | done
|
---|
88 |
|
---|
89 | # Check the xcode application.
|
---|
90 | if [ -z "${MY_XCODE_APP}" ]; then
|
---|
91 | echo "error: missing --xcode-app <dir/Xcode.app>." 1>&2l
|
---|
92 | my_usage 1;
|
---|
93 | fi
|
---|
94 | if ! test -d "${MY_XCODE_APP}/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" ; then
|
---|
95 | echo "error: missing '/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk' under '${MY_XCODE_APP}'." 1>&2;
|
---|
96 | exit 1;
|
---|
97 | fi
|
---|
98 |
|
---|
99 | # Check the destination directory.
|
---|
100 | if [ -z "${MY_DST_DIR}" ]; then
|
---|
101 | echo "error: missing --destination <dstdir>." 1>&2;
|
---|
102 | my_usage 1;
|
---|
103 | fi
|
---|
104 | if ! mkdir -p "${MY_DST_DIR}"; then
|
---|
105 | echo "error: error creating '${MY_DST_DIR}'." 1>&2;
|
---|
106 | exit 1;
|
---|
107 | fi
|
---|
108 |
|
---|
109 | #
|
---|
110 | # Copy bits from the Xcode package. Must retain a valid .pkg bundle structure or xcrun
|
---|
111 | # doesn't work, which breaks 'cpp' (needed for dtrace and maybe more).
|
---|
112 | #
|
---|
113 | for item in \
|
---|
114 | Contents/Info.plist \
|
---|
115 | Contents/version.plist \
|
---|
116 | Contents/PkgInfo\
|
---|
117 | Contents/Frameworks/IDEFoundation.framework \
|
---|
118 | Contents/PlugIns/IDEModelFoundation.ideplugin \
|
---|
119 | Contents/PlugIns/IDEStandardExecutionActionsCore.ideplugin \
|
---|
120 | Contents/PlugIns/Xcode3Core.ideplugin \
|
---|
121 | Contents/SharedFrameworks/DTXConnectionServices.framework \
|
---|
122 | Contents/SharedFrameworks/DVTFoundation.framework \
|
---|
123 | Contents/SharedFrameworks/DVTSourceControl.framework \
|
---|
124 | Contents/SharedFrameworks/LLDB.framework \
|
---|
125 | Contents/Developer/Toolchains/XcodeDefault.xctoolchain \
|
---|
126 | Contents/Developer/usr \
|
---|
127 | Contents/Developer/Platforms/MacOSX.platform/Info.plist \
|
---|
128 | Contents/Developer/Platforms/MacOSX.platform/version.plist \
|
---|
129 | Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs \
|
---|
130 | ;
|
---|
131 | do
|
---|
132 | echo "Copying ${item}..."
|
---|
133 | if [ -d "${MY_XCODE_APP}/${item}" ]; then
|
---|
134 | if ! mkdir -p "${MY_DST_DIR}/x.app/${item}"; then
|
---|
135 | echo "error: error creating directory '${MY_DST_DIR}/x.app/${item}'." 1>&2;
|
---|
136 | exit 1;
|
---|
137 | fi
|
---|
138 | if ! cp -af "${MY_XCODE_APP}/${item}/" "${MY_DST_DIR}/x.app/${item}/"; then
|
---|
139 | echo "error: problem occured copying directory \"${MY_XCODE_APP}/${item}/\" to \"${MY_DST_DIR}/x.app/${item}/\"." 1>&2;
|
---|
140 | exit 1;
|
---|
141 | fi
|
---|
142 | else
|
---|
143 | dir=`dirname "${item}"`
|
---|
144 | if ! mkdir -p "${MY_DST_DIR}/x.app/${dir}"; then
|
---|
145 | echo "error: error creating directory '${MY_DST_DIR}/x.app/${dir}'." 1>&2;
|
---|
146 | exit 1;
|
---|
147 | fi
|
---|
148 | if ! cp -P "${MY_XCODE_APP}/${item}" "${MY_DST_DIR}/x.app/${item}"; then
|
---|
149 | echo "error: problem occured copying \"${MY_XCODE_APP}/${item}\" to \"${MY_DST_DIR}/x.app/${item}\"." 1>&2;
|
---|
150 | exit 1;
|
---|
151 | fi
|
---|
152 | fi
|
---|
153 | done
|
---|
154 |
|
---|
155 | #
|
---|
156 | # Done.
|
---|
157 | #
|
---|
158 | echo "info: Successfully extracted."
|
---|
159 |
|
---|