From 273bc17fe7e9443e352e9a69e29e04579a4fa9ed Mon Sep 17 00:00:00 2001 From: Jeremy Stephens Date: Tue, 16 Jul 2013 19:57:49 -0500 Subject: [PATCH 1/2] Force copying files for mruby When installing mruby-dev, the cp command doesn't use the force flag. This causes an issue when using a custom build configuration (via MRUBY_CONFIG environment variable) and installing mrbgems from Github, as the pack files in the git repositories are read-only. --- bin/ruby-build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ruby-build b/bin/ruby-build index 9a3098c2..01aca3c6 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -449,7 +449,7 @@ build_package_mruby() { { rake mkdir -p "$PREFIX_PATH" - cp -R build/host/* "$PREFIX_PATH" + cp -fR build/host/* "$PREFIX_PATH" cd "$PREFIX_PATH/bin" ln -fs mruby ruby ln -fs mirb irb From f27c561388a3878e2e8cc18b3cf6eefcf061c4a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Sat, 26 Oct 2013 08:08:07 +0200 Subject: [PATCH 2/2] Recursive copying fixes and tests Use the `cp -f` flag to force unlinking non-writable files. Closes #384 --- bin/ruby-build | 2 +- test/build.bats | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/bin/ruby-build b/bin/ruby-build index 01aca3c6..f7bf691d 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -510,7 +510,7 @@ remove_windows_files() { build_package_copy() { mkdir -p "$PREFIX_PATH" - cp -R . "$PREFIX_PATH" + cp -fR . "$PREFIX_PATH" } before_install_package() { diff --git a/test/build.bats b/test/build.bats index a4f9b7ce..9c34d8e2 100644 --- a/test/build.bats +++ b/test/build.bats @@ -106,3 +106,44 @@ OUT unstub gmake unstub uname } + +@test "copy strategy forces overwrite" { + export RUBY_BUILD_CACHE_PATH="$FIXTURE_ROOT" + + mkdir -p "$INSTALL_ROOT/bin" + touch "$INSTALL_ROOT/bin/package" + chmod -w "$INSTALL_ROOT/bin/package" + + install_fixture definitions/without-checksum + assert_success + + run "$INSTALL_ROOT/bin/package" "world" + assert_success "hello world" +} + +@test "mruby strategy overwrites non-writable files" { + mkdir -p "$RUBY_BUILD_CACHE_PATH" + cd "$RUBY_BUILD_CACHE_PATH" + mkdir -p "mruby-1.0/build/host/bin" + touch "mruby-1.0/build/host/bin"/{mruby,mirb} + tar czf "mruby-1.0.tar.gz" "mruby-1.0" + + mkdir -p "$INSTALL_ROOT/bin" + touch "$INSTALL_ROOT/bin/mruby" + chmod -w "$INSTALL_ROOT/bin/mruby" + + cat > "definition" <