summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-12-03 16:25:37 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-12-03 17:59:12 +0000
commitab125675f37421098ab070dbd85b4f40bbbf17cd (patch)
tree479ac194598d68060b5e3433b8d57989ab37b820
parentb59c830d9a0427c6918bcd2346c3f965da29cac9 (diff)
downloadimport-ab125675f37421098ab070dbd85b4f40bbbf17cd.tar.gz
rubygems: Fix broken build-commands when .gemspec is in a subdirectory
The rubygems.to_chunk tool was assuming the .gemspec file always lived at the top of the chunk repo, but this isn't the case for <https://github.com/rails/rails>. Now it is smarter.
-rw-r--r--baserockimport/exts/importer_bundler_extensions.rb4
-rwxr-xr-xbaserockimport/exts/rubygems.find_deps4
-rwxr-xr-xbaserockimport/exts/rubygems.to_chunk22
3 files changed, 20 insertions, 10 deletions
diff --git a/baserockimport/exts/importer_bundler_extensions.rb b/baserockimport/exts/importer_bundler_extensions.rb
index 88c82e2..8eba91b 100644
--- a/baserockimport/exts/importer_bundler_extensions.rb
+++ b/baserockimport/exts/importer_bundler_extensions.rb
@@ -44,9 +44,7 @@ module Importer
matches[0]
end
- def create_bundler_definition_for_gemspec(gem_name, path)
- gemspec_file = locate_gemspec(gem_name, path)
-
+ def create_bundler_definition_for_gemspec(gem_name, gemspec_file)
# Using the real Gemfile doesn't get great results, because people can put
# lots of stuff in there that is handy for developers to have but
# irrelevant if you just want to produce a .gem. Also, there is only one
diff --git a/baserockimport/exts/rubygems.find_deps b/baserockimport/exts/rubygems.find_deps
index ae08b65..df7e302 100755
--- a/baserockimport/exts/rubygems.find_deps
+++ b/baserockimport/exts/rubygems.find_deps
@@ -76,8 +76,10 @@ class RubyGemDependencyFinder < Importer::Base
log.info("Finding dependencies for #{gem_name} based on source code in " \
"#{source_dir_name}")
+ gemspec_file = locate_gemspec(gem_name, source_dir_name)
+
resolved_specs = Dir.chdir(source_dir_name) do
- definition = create_bundler_definition_for_gemspec(gem_name, source_dir_name)
+ definition = create_bundler_definition_for_gemspec(gem_name, gemspec_file)
definition.resolve_remotely!
end
diff --git a/baserockimport/exts/rubygems.to_chunk b/baserockimport/exts/rubygems.to_chunk
index 1573d8b..323cbb0 100755
--- a/baserockimport/exts/rubygems.to_chunk
+++ b/baserockimport/exts/rubygems.to_chunk
@@ -66,7 +66,7 @@ class RubyGemChunkMorphologyGenerator < Importer::Base
spec.signing_key != nil
end
- def generate_chunk_morph_for_gem(spec)
+ def generate_chunk_morph_for_gem(gemspec_file, spec)
description = 'Automatically generated by rubygems.to_chunk'
bin_dir = "\"$DESTDIR/$PREFIX/bin\""
@@ -122,17 +122,21 @@ class RubyGemChunkMorphologyGenerator < Importer::Base
# provide the private key of the Gem's maintainer.
configure_commands <<
"sed -e '/cert_chain\\s*=/d' -e '/signing_key\\s*=/d' -i " \
- "#{spec.name}.gemspec"
+ "#{gemspec_file}"
end
+ gemspec_dirname = File.dirname(gemspec_file)
+ gemspec_basename = File.basename(gemspec_file)
+
build_commands = [
- "gem build #{spec.name}.gemspec",
+ "cd #{gemspec_dirname} && gem build #{gemspec_basename}",
]
install_commands = [
"mkdir -p #{gem_dir}",
"gem install --install-dir #{gem_dir} --bindir #{bin_dir} " \
- "--ignore-dependencies --local ./#{spec.full_name}.gem"
+ "--ignore-dependencies --local " \
+ "#{gemspec_dirname}/#{spec.full_name}.gem"
]
{
@@ -153,19 +157,25 @@ class RubyGemChunkMorphologyGenerator < Importer::Base
log.info("Creating chunk morph for #{gem_name} based on " \
"source code in #{source_dir_name}")
+ gemspec_file = locate_gemspec(gem_name, source_dir_name)
+
resolved_specs = Dir.chdir(source_dir_name) do
# FIXME: resolving the specs for all the dependencies of the target gem
# isn't necessary here. In fact, just reading/executing the .gemspec
# would be enough, and would speed this program up and remove a lot of
# pointless network access to rubygems.org.
- definition = create_bundler_definition_for_gemspec(gem_name, source_dir_name)
+ definition = create_bundler_definition_for_gemspec(gem_name, gemspec_file)
definition.resolve_remotely!
end
spec = get_spec_for_gem(resolved_specs, gem_name)
validate_spec(spec, source_dir_name, expected_version)
- morph = generate_chunk_morph_for_gem(spec)
+ gemspec_file_in_chunk_repo =
+ Pathname.new(gemspec_file).
+ relative_path_from(Pathname.new(source_dir_name))
+
+ morph = generate_chunk_morph_for_gem(gemspec_file_in_chunk_repo, spec)
write_morph(STDOUT, morph)
end
end