Created
March 18, 2010 07:23
-
-
Save stuartcarnie/336129 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
usage(){ | |
cat << EOF | |
usage: $0 options | |
This script create links for PLBlocks, which is useful | |
if you are installing the beta SDK into a separate folder. | |
OPTIONS: | |
-s source path of your primate SDK directory, where PLBlocks is installed | |
-d destination path of your beta SDK install | |
-u remove links | |
EOF | |
} | |
checkdir(){ | |
if [ ! -d $1 ]; then | |
echo "${1} is not a directory" | |
exit 1 | |
fi | |
} | |
createlink(){ | |
pushd ./$1 > /dev/null | |
ln -s "$src/$1/$2" . | |
popd > /dev/null | |
} | |
removelink(){ | |
pushd ./$1 > /dev/null | |
if [[ -L "$2" ]]; then | |
rm "$2" | |
fi | |
popd > /dev/null | |
} | |
src= | |
dest= | |
uninstall= | |
while getopts "s:d:u" OPTION; do | |
case "$OPTION" in | |
s) | |
src=$OPTARG | |
;; | |
d) | |
dest=$OPTARG | |
;; | |
u) | |
uninstall=1 | |
;; | |
esac | |
done | |
# remove links | |
if [[ ! -z "$uninstall" ]] && [[ ! -z $dest ]] ; then | |
# ensure / is appended | |
dest=$(echo "${dest}" | sed s:\/$::)"/" | |
checkdir $dest | |
echo "Removing links from '${dest}'..." | |
pushd $dest > /dev/null | |
# install library | |
removelink "Library" "PLBlocks" | |
removelink "Library/Xcode/Plug-ins" "GCC 4.2 (Plausible Blocks).xcplugin" | |
removelink "Platforms/iPhoneOS.platform/Developer/Library/Xcode/Plug-ins" "GCC 4.2 (Plausible Blocks - iPhoneOS).xcplugin" | |
popd > /dev/null | |
exit 0 | |
fi | |
# install links | |
if [[ ! -z $src ]] && [[ ! -z $dest ]] ; then | |
if [[ "$src" == "$dest" ]]; then | |
echo "src cannot equal dest" | |
exit 1 | |
fi | |
# ensure / is appended | |
src=$(echo "${src}" | sed s:\/$::)"/" | |
dest=$(echo "${dest}" | sed s:\/$::)"/" | |
checkdir $src | |
checkdir $dest | |
echo "Installing links from '${src}' to '${dest}'..." | |
pushd $dest > /dev/null | |
# install library | |
createlink "Library" "PLBlocks" | |
createlink "Library/Xcode/Plug-ins" "GCC 4.2 (Plausible Blocks).xcplugin" | |
createlink "Platforms/iPhoneOS.platform/Developer/Library/Xcode/Plug-ins" "GCC 4.2 (Plausible Blocks - iPhoneOS).xcplugin" | |
popd > /dev/null | |
exit 0 | |
fi | |
usage | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment