Commit 09e55a8b authored by Mislav Marohnić's avatar Mislav Marohnić
Browse files

Merge branch 'jruby-sed'

Closes #476
parents 578f0c5c 9effc7a6
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -519,7 +519,8 @@ install_jruby_launcher() {
fix_jruby_shebangs() {
  for file in "${PREFIX_PATH}/bin"/*; do
    if [ "$(head -c 20 "$file")" = "#!/usr/bin/env jruby" ]; then
      sed -i '' -E "1s:.+:#\!${PREFIX_PATH}/bin/jruby:" "$file"
      sed -i.bak -E "1s:.+:#\!${PREFIX_PATH}/bin/jruby:" "$file"
      rm "$file".bak
    fi
  done
}
+44 −5
Original line number Diff line number Diff line
@@ -11,6 +11,13 @@ setup() {
  stub curl false
}

executable() {
  local file="$1"
  mkdir -p "${file%/*}"
  cat > "$file"
  chmod +x "$file"
}

cached_tarball() {
  mkdir -p "$RUBY_BUILD_CACHE_PATH"
  pushd "$RUBY_BUILD_CACHE_PATH" >/dev/null
@@ -24,12 +31,10 @@ tarball() {
  local configure="$path/configure"
  shift 1

  mkdir -p "$path"
  cat > "$configure" <<OUT
  executable "$configure" <<OUT
#!$BASH
echo "$name: \$@" \${RUBYOPT:+RUBYOPT=\$RUBYOPT} >> build.log
OUT
  chmod +x "$configure"

  for file; do
    mkdir -p "$(dirname "${path}/${file}")"
@@ -230,12 +235,11 @@ OUT
@test "can use RUBY_CONFIGURE to apply a patch" {
  cached_tarball "ruby-2.0.0"

  cat > "${TMP}/custom-configure" <<CONF
  executable "${TMP}/custom-configure" <<CONF
#!$BASH
apply -p1 -i /my/patch.diff
exec ./configure "\$@"
CONF
  chmod +x "${TMP}/custom-configure"

  stub apply 'echo apply "$@" >> build.log'
  stub_make_install
@@ -332,6 +336,41 @@ bundle exec rake install
OUT
}

@test "JRuby build" {
  executable "${RUBY_BUILD_CACHE_PATH}/jruby-1.7.9/bin/jruby" <<OUT
#!${BASH}
echo jruby "\$@" >> ../build.log
OUT
  executable "${RUBY_BUILD_CACHE_PATH}/jruby-1.7.9/bin/gem" <<OUT
#!/usr/bin/env jruby
nice gem things
OUT
  cached_tarball "jruby-1.7.9" bin/foo.exe bin/bar.dll bin/baz.bat

  run_inline_definition <<DEF
install_package "jruby-1.7.9" "http://jruby.org/downloads/jruby-bin-1.7.9.tar.gz" jruby
DEF
  assert_success

  assert_build_log <<OUT
jruby gem install jruby-launcher
OUT

  run ls "${INSTALL_ROOT}/bin"
  assert_output <<OUT
gem
jruby
ruby
OUT

  assert [ -x "${INSTALL_ROOT}/bin/gem" ]
  run cat "${INSTALL_ROOT}/bin/gem"
  assert_output <<OUT
#!${INSTALL_ROOT}/bin/jruby
nice gem things
OUT
}

@test "non-writable TMPDIR aborts build" {
  export TMPDIR="${TMP}/build"
  mkdir -p "$TMPDIR"