Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for URLs as -p option values. #61

Merged
merged 1 commit into from Aug 2, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/ruby-install
Expand Up @@ -33,6 +33,7 @@ if [[ ! $NO_VERIFY -eq 1 ]]; then
fi

extract_ruby || fail "Unpacking of $RUBY_ARCHIVE failed!"
download_patches || fail "Fetching patches $PATCHES failed!"
apply_patches || fail "Patching $RUBY $RUBY_VERSION failed!"
cd "$SRC_DIR/$RUBY_SRC_DIR"
configure_ruby || fail "Configuration of $RUBY $RUBY_VERSION failed!"
Expand Down
18 changes: 18 additions & 0 deletions share/ruby-install/functions.sh
Expand Up @@ -66,13 +66,31 @@ function extract_ruby()
extract "$SRC_DIR/$RUBY_ARCHIVE" "$SRC_DIR"
}

#
# Download any additional patches
#
function download_patches()
{
for path in ${PATCHES[*]}; do
if [[ $path == http:\/\/* || $path == https:\/\/* ]]; then
log "Downloading patch $path ..."
patch=$(basename $path)
download "$path" "$SRC_DIR/$patch"
fi
done
}

#
# Apply any additional patches
#
function apply_patches()
{
for path in ${PATCHES[*]}; do
log "Applying patch $(basename $path) ..."
if [[ $path == http:\/\/* || $path == https:\/\/* ]]; then
patch=$(basename $path)
path="$SRC_DIR/$patch"
fi
patch -p1 -d "$SRC_DIR/$RUBY_SRC_DIR" < "$path"
done
}
Expand Down
42 changes: 42 additions & 0 deletions test/remote_patches_test.sh
@@ -0,0 +1,42 @@
. ./test/helper.sh

PATCHES="https://raw.github.com/gist/4136373/falcon-gc.diff local.patch"

test_download_patches()
{
local dir="test/subdir"
local SRC_DIR=$dir

mkdir -p "$dir"

download_patches 2>/dev/null

assertTrue "did not download patches to the directory" \
'[[ -f "$dir/falcon-gc.diff" ]]'

rm -r "$dir"
}

test_apply_patches()
{
local dir="test/subdir"
local SRC_DIR=$dir

mkdir -p "$dir"
echo "
diff -Naur subdir.orig/test subdir/test
--- subdir.orig/test 1970-01-01 01:00:00.000000000 +0100
+++ subdir/test 2013-08-02 20:57:08.055843749 +0200
@@ -0,0 +1 @@
+patch
" > "$dir/falcon-gc.diff"

apply_patches 2>/dev/null

assertTrue "did not apply downloaded patches" \
'[[ -f "$dir/test" ]]'

rm -r "$dir"
}

SHUNIT_PARENT=$0 . $SHUNIT2