aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorTim Dysinger2009-10-10 10:06:36 -1000
committerMax Howell2009-10-15 16:23:22 +0100
commit14325ddae150d0e191fc3ccae0ba7beb0d175970 (patch)
tree8f286e35c06c85f6dd6f7ab1936c66a52a07075f /Library
parentb473be9e51a928527cfe1d4f41d8bf7e2ba0e4c3 (diff)
downloadhomebrew-14325ddae150d0e191fc3ccae0ba7beb0d175970.tar.bz2
selflink.sh install directory is now configurable
Signed-off-by: Max Howell <max@methylblue.com> I preserved the behaviour where the whole Library directory is symlinked as no explanation for this change was given…
Diffstat (limited to 'Library')
-rwxr-xr-xLibrary/Contributions/selflink.sh37
1 files changed, 21 insertions, 16 deletions
diff --git a/Library/Contributions/selflink.sh b/Library/Contributions/selflink.sh
index ffa5ba8e4..c08aa739f 100755
--- a/Library/Contributions/selflink.sh
+++ b/Library/Contributions/selflink.sh
@@ -1,41 +1,46 @@
#!/usr/bin/env bash
-# This script links your clone into /usr/local, so you can keep the .git
-# directory out of the way.
+# This script links your clone into $install_base, so you can keep the .git
+# directory out of the way. Default for no parameters is /usr/local
mode=$1
if [[ -z $mode ]]; then
mode="install"
fi
+install_base=$2
+if [[ -z $install_base ]]; then
+ install_base="/usr/local"
+fi
+
source_base=`pwd`
if [[ $mode == install ]]; then
- # Ensure that the Cellar exists
+ # Ensure that the Cellar exists -- otherwise Homebrew breaks
if [[ ! -e "$source_base/Cellar" ]] ; then
mkdir -p "$source_base/Cellar"
fi
- if [[ ! -e "/usr/local/bin" ]] ; then
- mkdir -p /usr/local/bin
+ if [[ ! -e "$install_base/bin" ]] ; then
+ mkdir -p $install_base/bin
fi
- ln -s "$source_base/bin/brew" "/usr/local/bin/brew";
- ln -s "$source_base/Library" "/usr/local/Library";
- ln -s "$source_base/Cellar" "/usr/local/Cellar";
+ ln -s "$source_base/bin/brew" "$install_base/bin/brew";
+ ln -s "$source_base/Library" "$install_base/Library";
+ ln -s "$source_base/Cellar" "$install_base/Cellar";
elif [[ $mode == undo ]]; then
- if [[ -h "/usr/local/bin/brew" ]] ; then
- rm "/usr/local/bin/brew"
+ if [[ -h "$install_base/bin/brew" ]] ; then
+ rm "$install_base/bin/brew"
fi
- if [[ -h "/usr/local/Library" ]] ; then
- rm "/usr/local/Library"
+ if [[ -h "$install_base/Library" ]] ; then
+ rm "$install_base/Library"
fi
- if [[ -h "/usr/local/Cellar" ]] ; then
- rm "/usr/local/Cellar"
+ if [[ -h "$install_base/Cellar" ]] ; then
+ rm "$install_base/Cellar"
fi
else
echo "Unknown command: $mode";
- echo "\tselflink.sh [install] >> symlinks to /usr/local"
- echo "\tselflink.sh undo >> removes symlinks from /usr/local"
+ echo "\tselflink.sh [install] >> symlinks to $install_base"
+ echo "\tselflink.sh undo >> removes symlinks from $install_base"
fi