[system-dependencies] Use 'xcodebuild -runFirstLaunch' to install first-launch packages instead of manually installing each package. (#4707)
This is more future-proof, since the list of packages may change, or there may be other tasks that need doing in addition to installing packages. Fixes https://github.com/xamarin/maccore/issues/952. This is a backport of the PRs #4662 and #4681.
This commit is contained in:
Родитель
9f0d2f52f5
Коммит
0159abd45b
|
@ -231,6 +231,45 @@ function install_visual_studio () {
|
||||||
rm -f $VS_DMG
|
rm -f $VS_DMG
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function run_xcode_first_launch ()
|
||||||
|
{
|
||||||
|
local XCODE_VERSION="$1"
|
||||||
|
local XCODE_DEVELOPER_ROOT="$2"
|
||||||
|
|
||||||
|
# xcodebuild -runFirstLaunch seems to have been introduced in Xcode 9
|
||||||
|
if ! is_at_least_version "$XCODE_VERSION" 9.0; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Delete any cached files by xcodebuild, because other branches'
|
||||||
|
# system-dependencies.sh keep installing earlier versions of these
|
||||||
|
# packages manually, which means subsequent first launch checks will
|
||||||
|
# succeed because we've successfully run the first launch tasks once
|
||||||
|
# (and this is cached), while someone else (we!) overwrote with
|
||||||
|
# earlier versions (bypassing the cache).
|
||||||
|
#
|
||||||
|
# Removing the cache will make xcodebuild realize older packages are installed,
|
||||||
|
# and (re-)install any newer packages.
|
||||||
|
#
|
||||||
|
# We'll be able to remove this logic one day, when all branches in use are
|
||||||
|
# using 'xcodebuild -runFirstLaunch' instead of manually installing
|
||||||
|
# packages.
|
||||||
|
find /var/folders -name '*com.apple.dt.Xcode.InstallCheckCache*' -print -delete 2>/dev/null | sed 's/^\(.*\)$/ Deleted Xcode cache file: \1 (this is normal)/' || true
|
||||||
|
if ! "$XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild" -checkFirstLaunchStatus; then
|
||||||
|
if ! test -z "$PROVISION_XCODE"; then
|
||||||
|
# Remove sudo's cache as well, otherwise nothing will happen.
|
||||||
|
$SUDO find /var/folders -name '*com.apple.dt.Xcode.InstallCheckCache*' -print -delete 2>/dev/null | sed 's/^\(.*\)$/ Deleted Xcode cache file: \1 (this is normal)/' || true
|
||||||
|
# Run the first launch tasks
|
||||||
|
log "Executing '$SUDO $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -runFirstLaunch'"
|
||||||
|
$SUDO "$XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild" -runFirstLaunch
|
||||||
|
log "Executed '$SUDO $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -runFirstLaunch'"
|
||||||
|
else
|
||||||
|
fail "Xcode has pending first launch tasks. Execute '$XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -runFirstLaunch' to execute those tasks."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function install_specific_xcode () {
|
function install_specific_xcode () {
|
||||||
local XCODE_URL=`grep XCODE$1_URL= Make.config | sed 's/.*=//'`
|
local XCODE_URL=`grep XCODE$1_URL= Make.config | sed 's/.*=//'`
|
||||||
local XCODE_VERSION=`grep XCODE$1_VERSION= Make.config | sed 's/.*=//'`
|
local XCODE_VERSION=`grep XCODE$1_VERSION= Make.config | sed 's/.*=//'`
|
||||||
|
@ -289,7 +328,9 @@ function install_specific_xcode () {
|
||||||
$SUDO $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept
|
$SUDO $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if is_at_least_version $XCODE_VERSION 8.0; then
|
if is_at_least_version "$XCODE_VERSION" 9.0; then
|
||||||
|
run_xcode_first_launch "$XCODE_VERSION" "$XCODE_DEVELOPER_ROOT"
|
||||||
|
elif is_at_least_version $XCODE_VERSION 8.0; then
|
||||||
PKGS="MobileDevice.pkg MobileDeviceDevelopment.pkg XcodeSystemResources.pkg"
|
PKGS="MobileDevice.pkg MobileDeviceDevelopment.pkg XcodeSystemResources.pkg"
|
||||||
for pkg in $PKGS; do
|
for pkg in $PKGS; do
|
||||||
if test -f "$XCODE_DEVELOPER_ROOT/../Resources/Packages/$pkg"; then
|
if test -f "$XCODE_DEVELOPER_ROOT/../Resources/Packages/$pkg"; then
|
||||||
|
@ -335,12 +376,14 @@ function check_specific_xcode () {
|
||||||
$SUDO $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept
|
$SUDO $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild -license accept
|
||||||
else
|
else
|
||||||
fail "The license for Xcode $XCODE_VERSION has not been accepted. Execute '$SUDO $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild' to review the license and accept it."
|
fail "The license for Xcode $XCODE_VERSION has not been accepted. Execute '$SUDO $XCODE_DEVELOPER_ROOT/usr/bin/xcodebuild' to review the license and accept it."
|
||||||
fi
|
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
run_xcode_first_launch "$XCODE_VERSION" "$XCODE_DEVELOPER_ROOT"
|
||||||
|
fi
|
||||||
|
|
||||||
local XCODE_ACTUAL_VERSION=`/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$XCODE_DEVELOPER_ROOT/../version.plist"`
|
local XCODE_ACTUAL_VERSION=`/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$XCODE_DEVELOPER_ROOT/../version.plist"`
|
||||||
# this is a hard match, having 4.5 when requesting 4.4 is not OK (but 4.4.1 is OK)
|
# this is a hard match, having 4.5 when requesting 4.4 is not OK (but 4.4.1 is OK)
|
||||||
if [[ ! "x$XCODE_ACTUAL_VERSION" =~ "x$XCODE_VERSION" ]]; then
|
if [[ ! "x$XCODE_ACTUAL_VERSION" =~ "x$XCODE_VERSION" ]]; then
|
||||||
|
|
Загрузка…
Ссылка в новой задаче