blob: 440f19b9968b9ed356a542e6a2f685ebb65899fd (
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
|
#!/usr/bin/env bash
# Copyright (C) 2021 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
# shellcheck source=./../unix/DownloadURL.sh
source "${BASH_SOURCE%/*}/../unix/DownloadURL.sh"
# This script installs Xcode
# Prerequisites: Have Xcode prefetched to local cache as xz compressed.
# This can be achieved by fetching Xcode_8.xip from Apple Store.
# Uncompress it with 'xar -xf Xcode_8.xip'
# Then get https://gist.githubusercontent.com/pudquick/ff412bcb29c9c1fa4b8d/raw/24b25538ea8df8d0634a2a6189aa581ccc6a5b4b/parse_pbzx2.py
# with which you can run 'python parse_pbzx2.py Content'.
# This will give you a file called "Content.part00.cpio.xz" that
# can be renamed to Xcode_8.xz for this script.
function InstallXCode() {
sourceFile=$1
version=$2
echo "Uncompressing and installing '$sourceFile'"
if [[ $sourceFile =~ tar ]]; then
cd /Applications/ && sudo tar -zxf "$sourceFile"
elif [[ $sourceFile =~ "xip" ]]; then
if [[ $sourceFile =~ "http" ]]; then
Download "$sourceFile" "/Applications/Xcode_$version.xip"
cd /Applications/ && xip -x "Xcode_$version.xip"
else
cd /Applications/ && xip -x "$sourceFile"
fi
else
xzcat < "$sourceFile" | (cd /Applications/ && sudo cpio -dmi)
fi
echo "Versioning application bundle"
majorVersion=$(echo "$version" | cut -d '.' -f 1)
versionedAppBundle="/Applications/Xcode${majorVersion}.app"
sudo mv /Applications/Xcode*.app "${versionedAppBundle}"
echo "Selecting Xcode"
sudo xcode-select --switch "${versionedAppBundle}"
echo "Accept license"
sudo xcodebuild -license accept
echo "Install packages"
# -runFirstLaunch is valid in 9.x
sudo xcodebuild -runFirstLaunch || true
echo "Enabling developer mode, so that using lldb does not require interactive password entry"
sudo /usr/sbin/DevToolsSecurity -enable
echo "Xcode = $version" >> ~/versions.txt
}
|