[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#1019397: gem2deb: fails to cross build with gem_installer.rb

Control: tags -1 + patch

Hi Antonio,

On Thu, Sep 08, 2022 at 06:32:52PM +0200, Helmut Grohne wrote:
> That leads to the question of what actually is wrong. One relatively
> obvious thing to be wrong (once you know that my host architecture was
> armel) is the x86-64-linux-gnu part in there. It comes from
> lib/gem2deb/gem_installer.rb and is computed by
> rubygems_integration_target. There ist uses RbConfig::CONFIG['arch'],
> which presumably uses the build architectures rbconfig.rb rather than
> the host architecture one. Do you happen to know how to fix this aspect?
> However this is not what ultimately made the build fail. Later, we are
> instructed to check mkmf.log to see the actual failure. Unfortunately,
> mkmf.log is not part of the build log. Another build with keeping the
> build tree later, one can see that it used the build architecture
> compiler, which happened to fail to find the host architecture ruby
> header. Again, this seems to be rooted in using the wrong rbconfig.rb.
> I suppose that RUBYLIB is not augmented in the right way for running gem
> install in gem_installer.rb. Does that make sense to you?
> I'd appreciate a response indicating whether I'm looking in the right
> direction.

Assuming that both of these would be correct, I tried implementing it
(without knowing ruby). Before too long, I managed to cross build
ruby-oj using the attached patch. It really does quite precisely what I
sketched in the above paragraphs. Does that work for you?

diff --minimal -Nru gem2deb-2.0.3/debian/changelog gem2deb-2.0.3+nmu1/debian/changelog
--- gem2deb-2.0.3/debian/changelog	2022-07-31 01:44:54.000000000 +0200
+++ gem2deb-2.0.3+nmu1/debian/changelog	2022-09-08 20:48:33.000000000 +0200
@@ -1,3 +1,10 @@
+gem2deb (2.0.3+nmu1) UNRELEASED; urgency=medium
+  * Non-maintainer upload.
+  * Make gem_installer.rb work for cross building. (Closes: #1019397)
+ -- Helmut Grohne <helmut@subdivi.de>  Thu, 08 Sep 2022 20:48:33 +0200
 gem2deb (2.0.3) unstable; urgency=medium
   * Gem2Deb::YAML: fix loading more metadata.yml files.
diff --minimal -Nru gem2deb-2.0.3/lib/gem2deb/gem_installer.rb gem2deb-2.0.3+nmu1/lib/gem2deb/gem_installer.rb
--- gem2deb-2.0.3/lib/gem2deb/gem_installer.rb	2022-07-31 01:44:54.000000000 +0200
+++ gem2deb-2.0.3+nmu1/lib/gem2deb/gem_installer.rb	2022-09-08 20:48:24.000000000 +0200
@@ -201,16 +201,17 @@
     def rubygems_integration_target(rubyver)
       if metadata.has_native_extensions?
-        arch = RbConfig::CONFIG['arch']
         api_version = Gem2Deb::RUBY_API_VERSION[rubyver]
-        "/usr/lib/#{arch}/rubygems-integration/#{api_version}"
+        "/usr/lib/#{host_arch}/rubygems-integration/#{api_version}"
     def run_gem(ruby, command, *args)
-      run(ruby, '-S', 'gem', command, '--config-file', '/dev/null', '--verbose', *args)
+      maybe_crossbuild(ruby) do
+        run(ruby, '-S', 'gem', command, '--config-file', '/dev/null', '--verbose', *args)
+      end
     def load_gemspec_data!

Reply to: