mirror of
https://github.com/rbenv/ruby-build.git
synced 2024-12-28 20:55:31 +01:00
Improve installer script
* Shorter. * Preserve timestamps and permissions. * Overwrite existing files.
This commit is contained in:
parent
719f8832a3
commit
60e575ae67
2 changed files with 55 additions and 11 deletions
17
install.sh
17
install.sh
|
@ -1,4 +1,7 @@
|
|||
#!/bin/sh
|
||||
# Usage: PREFIX=/usr/local ./install.sh
|
||||
#
|
||||
# Installs ruby-build under $PREFIX.
|
||||
|
||||
set -e
|
||||
|
||||
|
@ -11,15 +14,7 @@ fi
|
|||
BIN_PATH="${PREFIX}/bin"
|
||||
SHARE_PATH="${PREFIX}/share/ruby-build"
|
||||
|
||||
mkdir -p "${BIN_PATH}"
|
||||
mkdir -p "${SHARE_PATH}"
|
||||
mkdir -p "$BIN_PATH" "$SHARE_PATH"
|
||||
|
||||
for file in bin/*; do
|
||||
cp "${file}" "${BIN_PATH}"
|
||||
done
|
||||
|
||||
for file in share/ruby-build/*; do
|
||||
cp "${file}" "${SHARE_PATH}"
|
||||
done
|
||||
|
||||
echo "Installed ruby-build at ${PREFIX}"
|
||||
install -p bin/* "$BIN_PATH"
|
||||
install -p share/ruby-build/* "$SHARE_PATH"
|
||||
|
|
49
test/installer.bats
Normal file
49
test/installer.bats
Normal file
|
@ -0,0 +1,49 @@
|
|||
#!/usr/bin/env bats
|
||||
|
||||
load test_helper
|
||||
|
||||
@test "installs ruby-build into PREFIX" {
|
||||
cd "$TMP"
|
||||
PREFIX="${PWD}/usr" run "${BATS_TEST_DIRNAME}/../install.sh"
|
||||
assert_success ""
|
||||
|
||||
cd usr
|
||||
|
||||
assert [ -x bin/ruby-build ]
|
||||
assert [ -x bin/rbenv-install ]
|
||||
assert [ -x bin/rbenv-uninstall ]
|
||||
|
||||
assert [ -e share/ruby-build/1.8.6-p383 ]
|
||||
assert [ -e share/ruby-build/ree-1.8.7-2012.02 ]
|
||||
}
|
||||
|
||||
@test "overwrites old installation" {
|
||||
cd "$TMP"
|
||||
mkdir -p bin share/ruby-build
|
||||
touch bin/ruby-build
|
||||
touch share/ruby-build/1.8.6-p383
|
||||
|
||||
PREFIX="$PWD" run "${BATS_TEST_DIRNAME}/../install.sh"
|
||||
assert_success ""
|
||||
|
||||
assert [ -x bin/ruby-build ]
|
||||
run grep "install_package" share/ruby-build/1.8.6-p383
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "unrelated files are untouched" {
|
||||
cd "$TMP"
|
||||
mkdir -p bin share/bananas
|
||||
chmod g-w bin
|
||||
touch bin/bananas
|
||||
touch share/bananas/docs
|
||||
|
||||
PREFIX="$PWD" run "${BATS_TEST_DIRNAME}/../install.sh"
|
||||
assert_success ""
|
||||
|
||||
assert [ -e bin/bananas ]
|
||||
assert [ -e share/bananas/docs ]
|
||||
|
||||
run ls -ld bin
|
||||
assert_equal "r-x" "${output:4:3}"
|
||||
}
|
Loading…
Reference in a new issue