From 81536221f856388a80d552f83a787ca448d1144f Mon Sep 17 00:00:00 2001 From: "Todd A. Jacobs" Date: Fri, 22 Aug 2014 22:27:29 -0700 Subject: [PATCH] Created Install Bats Using GNU Stow (markdown) --- Install-Bats-Using-GNU-Stow.md | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Install-Bats-Using-GNU-Stow.md diff --git a/Install-Bats-Using-GNU-Stow.md b/Install-Bats-Using-GNU-Stow.md new file mode 100644 index 0000000..9914e85 --- /dev/null +++ b/Install-Bats-Using-GNU-Stow.md @@ -0,0 +1,36 @@ +# Purpose + +Sometimes you want to install a package like Bats, but you either don't want to install it in a system directory like /usr/local because you don't have root privileges, or you want to be able to manage multiple versions cleanly. [GNU Stow][1] can handle both use cases well, and installing or upgrading Bats with Stow is trivial. + +## Installing as Root + + stow=/usr/local/stow + version=$(libexec/bats -v | tr A-Z a-z | tr ' ' -) + + # Unstow older versions of Bats. + shopt -s nullglob + old_bats=(`find "$stow" -type d -name bats-\*`) + for package in "${old_bats[@]}"; do + sudo stow --dir="$stow" --delete $(basename "$package") + done + + sudo ./install.sh "${stow}/${version}" + sudo stow --dir="$stow" --restow "$version" + +## Installing as User + + mkdir ~/stow + stow=~/stow + version=$(libexec/bats -v | tr A-Z a-z | tr ' ' -) + + # Unstow older versions of Bats. + shopt -s nullglob + old_bats=(`find "$stow" -type d -name bats-\*`) + for package in "${old_bats[@]}"; do + stow --dir="$stow" --delete $(basename "$package") + done + + ./install.sh "${stow}/${version}" + stow --dir="$stow" --restow "$version" + +[1]: http://www.gnu.org/software/stow/ \ No newline at end of file