1
0
mirror of https://github.com/sstephenson/bats.git synced 2024-11-17 03:32:27 +01:00

Created Install Bats Using GNU Stow (markdown)

Todd A. Jacobs 2014-08-22 22:27:29 -07:00
parent 19e7b2d4b6
commit 81536221f8

@ -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/