すべての開発ツール&の依存関係をクリーンなOSXマシンにインストールするシェルスクリプトを作成しようとしています。XCodeのインストールを自動化するにはどうすればいいですか?
誰かがXCodeのインストールを自動化する最良の方法を知っていますか?
- ドキュメント開発環境:
は、私がこれをやっています。
- 新しい開発者のためにオンボードのプロセスをスピードアップします。
- automate-everythingの原則に従ってください。
すべての開発ツール&の依存関係をクリーンなOSXマシンにインストールするシェルスクリプトを作成しようとしています。XCodeのインストールを自動化するにはどうすればいいですか?
誰かがXCodeのインストールを自動化する最良の方法を知っていますか?
は、私がこれをやっています。
まず、ログインApple Developer Downloads SiteにとOSXのバージョンのために働くXCode.dmgのバージョンを取得します。さまざまなOSXプラットフォーム(たとえば、10.10のヨセミテ、10.9のマーベリックスなど)をサポートするために、カップルのバージョンを入手することができます。あなたがアクセスできるファイルのホストへのdmgをアップロードします(例:アマゾンS3、Dropboxが、選択のあなたの共有ホスティングプロバイダ、などが...)
を変更し、次のスクリプトでDOWNLOAD_BASE_URL
、およびは DMGSの名前を変更します適切なバージョン&ビルド番号またはスクリプト以下に追加して:
#!/bin/bash
DOWNLOAD_BASE_URL=http://example.com/path/to/xcode/dmgs/
## Figure out OSX version (source: https://www.opscode.com/chef/install.sh)
function detect_platform_version() {
# Matching the tab-space with sed is error-prone
platform_version=$(sw_vers | awk '/^ProductVersion:/ { print $2 }')
major_version=$(echo $platform_version | cut -d. -f1,2)
# x86_64 Apple hardware often runs 32-bit kernels (see OHAI-63)
x86_64=$(sysctl -n hw.optional.x86_64)
if [ $x86_64 -eq 1 ]; then
machine="x86_64"
fi
}
detect_platform_version
# Determine which XCode version to use based on platform version
case $platform_version in
"10.10") XCODE_DMG='XCode-6.1.1-6A2008a.dmg' ;;
"10.9") XCODE_DMG='XCode-5.0.2-5A3005.dmg' ;;
*) XCODE_DMG='XCode-5.0.1-5A2053.dmg' ;;
esac
# Bootstrap XCode from dmg
if [ ! -d "/Applications/Xcode.app" ]; then
echo "INFO: XCode.app not found. Installing XCode..."
if [ ! -e "$XCODE_DMG" ]; then
curl -L -O "${DOWNLOAD_BASE_URL}/${XCODE_DMG}"
fi
hdiutil attach "$XCODE_DMG"
export __CFPREFERENCES_AVOID_DAEMON=1
sudo installer -pkg '/Volumes/XCode/XCode.pkg' -target/
hdiutil detach '/Volumes/XCode'
fi
あなたはXCodeのコマンドラインツールをインストールするに興味があるかもしれない、ともXCodeのライセンス契約をバイパス:
curl -Ls https://gist.github.com/trinitronx/6217746/raw/58456d6675e437cebbf771c60b6005b4491a0980/xcode-cli-tools.sh | sudo bash
# We need to accept the xcodebuild license agreement before building anything works
# Silly Apple...
if [ -x "$(which expect)" ]; then
echo "INFO: GNU expect found! By using this script, you automatically accept the XCode License agreement found here: http://www.apple.com/legal/sla/docs/xcode.pdf"
expect ./bootstrap-scripts/accept-xcodebuild-license.exp
else
echo -e "\x1b[31;1mERROR:\x1b[0m Could not find expect utility (is '$(which expect)' executable?)"
echo -e "\x1b[31;1mWarning:\x1b[0m You have not agreed to the Xcode license.\nBuilds will fail! Agree to the license by opening Xcode.app or running:\n
xcodebuild -license\n\nOR for system-wide acceptance\n
sudo xcodebuild -license"
exit 1
fi
代替this applescript I createdを使用することです。
は、使用するには: How download and Install Command Line Tools for Xcode:git clone https://gist.github.com/6237049.git
cd 6237049/
# Edit the script with AppleScript Editor to replace your APPLE ID and PASSWORD
osascript Install_XCode.applescript
また、ここで私の答えに興味があるかもしれません。
他の方法をAppleScriptメソッドよりもお勧めします。 AppleScriptは、OSX上のApp Storeアプリケーションの将来のバージョンでは常に同じとは限らないUI要素階層に依存します。それは私には壊れやすいようです。コマンドラインからdmgを介してXCodeをインストールするのがおそらく最も信頼できる方法です。
Xcode 4.3以降、アプリケーションバンドルとして提供されています。初めてアプリを起動すると、インストールが続行されます。ベータ版であるため、まだ修正されていませんが、起動後のインストールパッケージは、コンテンツ/リソース/パッケージというディレクトリ内のアプリケーションバンドルにあります。
環境に応じて、インストールスクリプトはXcode.appバンドルをApplicationsディレクトリにコピーするだけで、ユーザーは初めて起動時にインストールを完了できます。または、バンドルをコピーして、installer(8)
ユーティリティを使用して追加のパッケージを手動でインストールすることもできます。インストーラの使用方法の詳細については、man pagesを参照してください。
ダウンロードとインストールの両方を自動化するための多くのものが古くなっています。私は別のプロジェクトのために何かの仕事であったと私はかなり良い解決策の作業を持っていると思うしました:
https://github.com/rockholla/macosa/blob/master/bin/macosa_xcode
そしてここでダウンロード一部です:
https://github.com/rockholla/macosa/blob/master/bin/macosa_xcode_download
これはおそらく、より良い質問ですhttp://serverfault.comのために。 –