need to test

This commit is contained in:
Maxim Lobanov
2020-10-31 18:41:04 +03:00
parent 14a848397e
commit b49a705f6b
9 changed files with 245 additions and 222 deletions

View File

@@ -1,69 +0,0 @@
#!/bin/sh
# The script currently requires 2 external variables to be set: XCODE_INSTALL_USER
# and XCODE_INSTALL_PASSWORD, in order to access the Apple Developer Center
set -e
source ~/utils/utils.sh
source ~/utils/xcode-utils.sh
if [ -z $XCODE_INSTALL_USER ] || [ -z $XCODE_INSTALL_PASSWORD ]; then
echo "Required environment variables XCODE_INSTALL_USER and XCODE_INSTALL_PASSWORD are not set"
exit 1
fi
XCODE_COUNT=$(get_toolset_value '.xcode.versions | length')
XCODE_LOCAL_LIST=$(get_toolset_value '.xcode.versions[].localVersion')
DEFAULT_XCODE_VERSION=$(get_toolset_value '.xcode.default')
WORK_DIR="${HOME}/Library/Caches/XcodeInstall"
# Update the list of available versions
xcversion update
for ((XCODE_INDEX=0; XCODE_INDEX<XCODE_COUNT; XCODE_INDEX++)); do
LOCAL_VERSION=$(get_toolset_value ".xcode.versions[$XCODE_INDEX].localVersion")
XCODE_VERSION=$(get_toolset_value ".xcode.versions[$XCODE_INDEX].version")
SYMLINKS=($(get_toolset_value ".xcode.versions[$XCODE_INDEX].symlinks"))
echo "Installing Xcode '$XCODE_VERSION' to '/Applications/Xcode_${LOCAL_VERSION}.app'"
downloadXcode $XCODE_VERSION
echo "Extracting Xcode.app ($VERSION_TO_INSTALL) to ${WORK_DIR} ..."
extractXcodeXip $WORK_DIR
echo "Validating unpacked Xcode ${XCODE_VERSION}"
validateXcodeIntegrity "$WORK_DIR"
echo "Copying Xcode.app to /Applications/Xcode_${LOCAL_VERSION}.app"
mv -f "${WORK_DIR}/Xcode.app" "/Applications/Xcode_${LOCAL_VERSION}.app"
echo "Accepting license for Xcode ${XCODE_VERSION}..."
approveXcodeLicense "$LOCAL_VERSION"
echo "Creating symlinks..."
createXcodeSymlinks $LOCAL_VERSION $SYMLINKS
find $WORK_DIR -mindepth 1 -delete
done
echo "Running 'runFirstLaunch' for all Xcode versions"
runFirstLaunchXcodeList $XCODE_LOCAL_LIST
echo "Running 'runFirstLaunch' for default Xcode ${DEFAULT_XCODE_VERSION}..."
runFirstLaunch $DEFAULT_XCODE_VERSION
echo "Setting Xcode ${DEFAULT_XCODE_VERSION} as default"
sudo xcode-select -s "/Applications/Xcode_${DEFAULT_XCODE_VERSION}.app/Contents/Developer"
echo "Adding symlink '/Applications/Xcode_${DEFAULT_XCODE_VERSION}.app' -> '/Applications/Xcode.app'"
ln -s "/Applications/Xcode_${DEFAULT_XCODE_VERSION}.app" "/Applications/Xcode.app"
echo "Enabling developer mode"
sudo /usr/sbin/DevToolsSecurity --enable
echo "Setting environment variables 'XCODE_<VERSION>_DEVELOPER_DIR'"
setXcodeDeveloperDirVariables
echo "Doing cleanup. Emptying ${WORK_DIR}..."
rm -rf "$WORK_DIR"

View File

@@ -0,0 +1,38 @@
# The script currently requires 2 external variables to be set: XCODE_INSTALL_USER
# and XCODE_INSTALL_PASSWORD, in order to access the Apple Developer Center
$ErrorActionPreference = "Stop"
Import-Module "$PSScriptRoot/../../helpers/Common.Helpers.psm1"
Import-Module "$PSScriptRoot/../../helpers/Xcode.Installer.psm1"
if ([string]::IsNullOrEmpty($env:XCODE_INSTALL_USER) -or [string]::IsNullOrEmpty($env:XCODE_INSTALL_PASSWORD)) {
throw "Required environment variables XCODE_INSTALL_USER and XCODE_INSTALL_PASSWORD are not set"
}
$os = Get-OSVersion
$xcodeVersions = Get-ToolsetValue "xcode.versions"
$defaultXcode = Get-ToolsetValue "xcode.default"
& xcversion update
Write-Host "Installing Xcode versions..."
foreach ($xcode in $xcodeVersions) {
Install-XcodeVersion -Version $xcode.version -LocalLink $xcode.localLink
Build-XcodeSymlinks -Version $xcode.localLink -Symlinks $xcode.symlinks
Build-ProvisionatorSymlink -Version $xcode.version
}
Write-Host "Configuring Xcode versions..."
if ($os.IsLessThanCatalina) {
Install-XcodeAdditionalPackages -Version $xcodeVersions[0].localLink
}
$xcodeVersions | ForEach-Object { Invoke-XcodeRunFirstLaunch -Version $_.localLink }
Invoke-XcodeRunFirstLaunch -Version $defaultXcode
Write-Host "Setting default Xcode to $defaultXcode"
Switch-Xcode -Version $defaultXcode
New-Item -Path "/Applications/Xcode.app" -ItemType SymbolicLink -Value (Get-XcodeRootPath -Version $defaultXcode)
Write-Host "Setting environment variables 'XCODE_<VERSION>_DEVELOPER_DIR'"
Set-XcodeDeveloperDirEnvironmentVariables