summaryrefslogtreecommitdiff
path: root/tools/darwin.amd64/bin/xcode-6.2-extractor.sh
blob: 4c4f89d9dcaeae66099fcd3d57e965e6e8fe9ab8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/bash
# $Id$
## @file
# Extracts the necessary bits from the Xcode 6.2 (Xcode_6.2.dmg,
# md5sum fe4c6c99182668cf14bfa5703bedeed6) and the Command Line
# Tools for Xcode 6.2 (10.9: commandlinetoolsosx10.9forxcode6.2.dmg,
# 10.10: commandlinetoolsosx10.10forxcode6.2.dmg).
#
# This script allows extracting the tools on systems where the command line
# tools refuse to install due to version checks.
#

#
# Copyright (C) 2014-2016 Oracle Corporation
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
# you can redistribute it and/or modify it under the terms of the GNU
# General Public License (GPL) as published by the Free Software
# Foundation, in version 2 as it comes in the "COPYING" file of the
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
#

#
# Make sure we're talking the same language.
#
LC_ALL=C
export LC_ALL

#
# Figure the tools/darwin.x86 location.
#
MY_DARWIN_DIR=`dirname "$0"`
MY_DARWIN_DIR=`(cd "${MY_DARWIN_DIR}" ; pwd)`
MY_DARWIN_DIR=`dirname "${MY_DARWIN_DIR}"`

#
# Parse arguments.
#
MY_DST_DIR="${MY_DARWIN_DIR}/xcode/v6.2"
MY_XCODE_APP="/Volumes/Xcode/Xcode.app"

my_usage()
{
    echo "usage: $0 <--destination|-d> <dstdir>  <--xcode-app|-x> </Volumes/Xcode/Xcode.app>";
    exit $1;
}

while test $# -ge 1;
do
    ARG=$1;
    shift;
    case "$ARG" in

        --destination|-d)
            if test $# -eq 0; then
                echo "error: missing --tmpdir argument." 1>&2;
                exit 1;
            fi
            MY_DST_DIR="$1";
            shift;
            ;;

        --xcode-app|-x)
            if test $# -eq 0; then
                echo "error: missing --xcode-app argument." 1>&2;
                exit 1;
            fi
            MY_XCODE_APP="$1";
            shift;
            ;;

        --h*|-h*|-?|--?)
            my_usage 0;
    esac
done

# Check the xcode application.
if [ -z "${MY_XCODE_APP}" ]; then
    echo "error: missing --xcode-app <dir/Xcode.app>." 1>&2l
    my_usage 1;
fi
if ! test -d "${MY_XCODE_APP}/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk" ; then
    echo "error: missing '/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk' under '${MY_XCODE_APP}'." 1>&2;
    exit 1;
fi

# Check the destination directory.
if [ -z "${MY_DST_DIR}" ]; then
    echo "error: missing --destination <dstdir>." 1>&2;
    my_usage 1;
fi
if ! mkdir -p "${MY_DST_DIR}"; then
    echo "error: error creating '${MY_DST_DIR}'." 1>&2;
    exit 1;
fi

#
# Copy bits from the Xcode package. Must retain a valid .pkg bundle structure or xcrun
# doesn't work, which breaks 'cpp' (needed for dtrace and maybe more).
#
for item in \
        Contents/Info.plist \
        Contents/version.plist \
        Contents/PkgInfo\
        Contents/Frameworks/IDEFoundation.framework \
        Contents/PlugIns/IDEModelFoundation.ideplugin \
        Contents/PlugIns/IDEStandardExecutionActionsCore.ideplugin \
        Contents/PlugIns/Xcode3Core.ideplugin \
        Contents/SharedFrameworks/DTXConnectionServices.framework \
        Contents/SharedFrameworks/DVTFoundation.framework \
        Contents/SharedFrameworks/DVTSourceControl.framework \
        Contents/SharedFrameworks/LLDB.framework \
        Contents/Developer/Toolchains/XcodeDefault.xctoolchain \
        Contents/Developer/usr \
        Contents/Developer/Platforms/MacOSX.platform/Info.plist \
        Contents/Developer/Platforms/MacOSX.platform/version.plist \
        Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs \
        ;
do
    echo "Copying ${item}..."
    if [ -d "${MY_XCODE_APP}/${item}" ]; then
        if ! mkdir -p "${MY_DST_DIR}/x.app/${item}"; then
            echo "error: error creating directory '${MY_DST_DIR}/x.app/${item}'." 1>&2;
            exit 1;
        fi
        if ! cp -af "${MY_XCODE_APP}/${item}/" "${MY_DST_DIR}/x.app/${item}/"; then
            echo "error: problem occured copying directory \"${MY_XCODE_APP}/${item}/\" to \"${MY_DST_DIR}/x.app/${item}/\"." 1>&2;
            exit 1;
        fi
    else
        dir=`dirname "${item}"`
        if ! mkdir -p "${MY_DST_DIR}/x.app/${dir}"; then
            echo "error: error creating directory '${MY_DST_DIR}/x.app/${dir}'." 1>&2;
            exit 1;
        fi
        if ! cp -P "${MY_XCODE_APP}/${item}" "${MY_DST_DIR}/x.app/${item}"; then
            echo "error: problem occured copying \"${MY_XCODE_APP}/${item}\" to \"${MY_DST_DIR}/x.app/${item}\"." 1>&2;
            exit 1;
        fi
    fi
done

#
# Done.
#
echo "info: Successfully extracted."