kwilczynski / ruby-magic

Simple interface to libmagic for Ruby Programming Language
Apache License 2.0
27 stars 8 forks source link

package dependencies as tarballs #16

Closed flavorjones closed 3 years ago

flavorjones commented 3 years ago

Following up on the conversation at #8, this PR introduces the tarball as a file in the gemspec, so that it's delivered as part of the gem file download from rubygems.org.

mini_portile is smart enough to use this file instead of re-downloading it, which will be a better experience for users and save hosting costs for this project.

flavorjones commented 3 years ago

Update: I've added a commit to add the patches to the gemfile.

kwilczynski commented 3 years ago

Hi @flavorjones,

Thank you!

I also believe that our custom clean-up should not cause any issues once the Ruby Gem is installed, very nice.

Krzysztof

stanhu commented 3 years ago

I think this warning can be safely ignored:

$ gem build ruby-magic.gemspec
WARNING:  ports/archives/file-5.39.tar.gz is not world-readable

It seems Nokogiri also has the same permissions?

flavorjones commented 3 years ago

I think this warning can be safely ignored

It's been on my list of "things to look into" for a long time, and nothing bad has happened so far because of it yet. :rofl:

kwilczynski commented 3 years ago

Hi @flavorjones and @stanhu, sorry to common on the closed Pull Request!

Question to the two of you - are you also having some build time issues? For me, a build after a fresh checkout of the repository seems to require the archive to be always present to succeed, as per:

$ rake compile -- --use-system-libraries
Building ruby-magic using system libraries.
checking for ruby.h... yes
checking for rb_thread_call_without_gvl()... yes
checking for rb_thread_blocking_region()... no
checking for magic.h... yes
checking for -lmagic... yes
checking for magic_getpath()... yes
checking for magic_getflags()... yes
checking for utime.h... yes
checking for sys/types.h... yes
checking for sys/time.h... yes
checking for utime()... yes
checking for utimes()... yes
creating extconf.h
creating Makefile
compiling ../../../../ext/magic/functions.c
(...)
linking shared-object magic/magic.bundle
rake aborted!
Don't know how to build task 'ports/archives/file-5.39.tar.gz' (See the list of available tasks with `rake --tasks`)

Tasks: TOP => compile => compile:x86_64-darwin19 => compile:magic:x86_64-darwin19 => copy:magic:x86_64-darwin19:3.0.0 => tmp/x86_64-darwin19/stage/ports/archives/file-5.39.tar.gz
(See full trace by running task with --trace)

Krzysztof

flavorjones commented 3 years ago

Yes, sorry, I'm seeing this problem, too. I didn't test with the --use-system-libraries flag. I'll add a commit to #17 to fix.

kwilczynski commented 3 years ago

Hi @flavorjones,

For some reason, I am still having the same problem when using --use-system-libraries locally.

Even with a fresh checkout followed by bundle install, this problem will manifest itself. I am not sure why I have this issue but we haven't seen it in the CI.

Krzysztof

stanhu commented 3 years ago

@kwilczynski I think the problem is happening in CI: https://github.com/kwilczynski/ruby-magic/runs/2337765182

I think this line is causing the issue: https://github.com/kwilczynski/ruby-magic/blob/af160d9f7ba7e7e7bd6e5c3ebf456c708627785b/ruby-magic.gemspec#L50

When --use-system-libraries is used, the .tar.gz isn't downloaded. Can we fix this by dynamically adding this dependency?

kwilczynski commented 3 years ago

Hi @stanhu,

We should fix it, indeed. I am wondering, whether the approach that Nokogiri uses (dedicated Rake task) would be more appropriate here? What do you think @flavorjones?

Interestingly, I assumed that the Ruby Gem package task would not run (lazy execution) unless it's called, and when I only use clobber or compile then only these tasks would be used - which is fine for local development.

Krzysztof