From 910fa01b2a531d9f045065a6334b7ee81a91b1f3 Mon Sep 17 00:00:00 2001 From: Guillaume Algis Date: Sun, 5 Jul 2015 18:33:02 +0200 Subject: [PATCH 1/4] Make the install script a bit more reliable See http://redsymbol.net/articles/unofficial-bash-strict-mode/ --- Scripts/install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Scripts/install.sh b/Scripts/install.sh index 6c9f6ff..610c121 100644 --- a/Scripts/install.sh +++ b/Scripts/install.sh @@ -1,5 +1,7 @@ #!/bin/sh +set -euo pipefail + DOWNLOAD_URI=https://github.com/alcatraz/Alcatraz/releases/download/1.1.13/Alcatraz.tar.gz PLUGINS_DIR="${HOME}/Library/Application Support/Developer/Shared/Xcode/Plug-ins" From c84f80a28671ef1f94408c2e537608993fd57a2c Mon Sep 17 00:00:00 2001 From: Guillaume Algis Date: Sun, 5 Jul 2015 18:33:24 +0200 Subject: [PATCH 2/4] Remove Alcatraz from the Xcode skipped plugins list at install --- Scripts/install.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Scripts/install.sh b/Scripts/install.sh index 610c121..f3b9ff1 100644 --- a/Scripts/install.sh +++ b/Scripts/install.sh @@ -4,6 +4,19 @@ set -euo pipefail DOWNLOAD_URI=https://github.com/alcatraz/Alcatraz/releases/download/1.1.13/Alcatraz.tar.gz PLUGINS_DIR="${HOME}/Library/Application Support/Developer/Shared/Xcode/Plug-ins" +XCODE_VERSION="$(xcrun xcodebuild -version | head -n1 | awk '{ print $2 }')" +PLIST_PLUGINS_KEY="DVTPlugInManagerNonApplePlugIns-Xcode-${XCODE_VERSION}" +BUNDLE_ID="com.mneorr.Alcatraz" +TMP_FILE="/tmp/${BUNDLE_ID}.xcode-defaults" + +# Remove Alcatraz from Xcode's skipped plugins list if needed +defaults read -app Xcode "$PLIST_PLUGINS_KEY" > "$TMP_FILE" +/usr/libexec/PlistBuddy -c "delete skipped:$BUNDLE_ID" "$TMP_FILE" > /dev/null 2>&1 && { + pgrep Xcode > /dev/null && { echo 'An instance of Xcode is currently running. Please close Xcode before installing Alcatraz.'; exit 1; } + defaults write -app Xcode "$PLIST_PLUGINS_KEY" "$(< $TMP_FILE)" + echo 'Alcatraz was removed from Xcode'\''s skipped plugins list. Next time you start Xcode select "Load Bundle" when prompted.' +} +rm "$TMP_FILE" mkdir -p "${PLUGINS_DIR}" curl -L $DOWNLOAD_URI | tar xvz -C "${PLUGINS_DIR}" From 767f87d2624801ea572f685b533aa129e1657e2c Mon Sep 17 00:00:00 2001 From: Guillaume Algis Date: Sun, 5 Jul 2015 18:36:15 +0200 Subject: [PATCH 3/4] Display currently selected Xcode version in install script --- Scripts/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/install.sh b/Scripts/install.sh index f3b9ff1..9258854 100644 --- a/Scripts/install.sh +++ b/Scripts/install.sh @@ -22,5 +22,5 @@ mkdir -p "${PLUGINS_DIR}" curl -L $DOWNLOAD_URI | tar xvz -C "${PLUGINS_DIR}" # the 1 is not a typo! -echo "Alcatraz successfully installed!!1!🍻 Please restart your Xcode." +echo "Alcatraz successfully installed!!1!🍻 Please restart your Xcode ($XCODE_VERSION)." From 25c4b3d86f28b7f294e20b8f89c48b3860eb9f7e Mon Sep 17 00:00:00 2001 From: Guillaume Algis Date: Sat, 21 Nov 2015 13:22:29 +0100 Subject: [PATCH 4/4] Use mktemp instead of re-using the same tmp file + Fix coding style --- Scripts/install.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Scripts/install.sh b/Scripts/install.sh index 9258854..cfac604 100644 --- a/Scripts/install.sh +++ b/Scripts/install.sh @@ -7,14 +7,19 @@ PLUGINS_DIR="${HOME}/Library/Application Support/Developer/Shared/Xcode/Plug-ins XCODE_VERSION="$(xcrun xcodebuild -version | head -n1 | awk '{ print $2 }')" PLIST_PLUGINS_KEY="DVTPlugInManagerNonApplePlugIns-Xcode-${XCODE_VERSION}" BUNDLE_ID="com.mneorr.Alcatraz" -TMP_FILE="/tmp/${BUNDLE_ID}.xcode-defaults" +TMP_FILE="$(mktemp -t ${BUNDLE_ID})" # Remove Alcatraz from Xcode's skipped plugins list if needed defaults read -app Xcode "$PLIST_PLUGINS_KEY" > "$TMP_FILE" /usr/libexec/PlistBuddy -c "delete skipped:$BUNDLE_ID" "$TMP_FILE" > /dev/null 2>&1 && { - pgrep Xcode > /dev/null && { echo 'An instance of Xcode is currently running. Please close Xcode before installing Alcatraz.'; exit 1; } - defaults write -app Xcode "$PLIST_PLUGINS_KEY" "$(< $TMP_FILE)" - echo 'Alcatraz was removed from Xcode'\''s skipped plugins list. Next time you start Xcode select "Load Bundle" when prompted.' + pgrep Xcode > /dev/null && { + echo 'An instance of Xcode is currently running.' \ + 'Please close Xcode before installing Alcatraz.' + exit 1 + } + defaults write -app Xcode "$PLIST_PLUGINS_KEY" "$(cat "$TMP_FILE")" + echo 'Alcatraz was removed from Xcode'\''s skipped plugins list.' \ + 'Next time you start Xcode select "Load Bundle" when prompted.' } rm "$TMP_FILE" @@ -22,5 +27,6 @@ mkdir -p "${PLUGINS_DIR}" curl -L $DOWNLOAD_URI | tar xvz -C "${PLUGINS_DIR}" # the 1 is not a typo! -echo "Alcatraz successfully installed!!1!🍻 Please restart your Xcode ($XCODE_VERSION)." +echo 'Alcatraz successfully installed!!1!🍻 ' \ + "Please restart your Xcode ($XCODE_VERSION)."