Hi Dan,

This is where it started:

https://lists.fedoraproject.org/archives/list/ruby-sig@lists.fedoraproject.org/message/PP6SA43POR5OL34BCQMIORTTMPB3NWIN/


Dne 3.3.2017 v 09:36 Dan Allen napsal(a):
> I'm seeing the following message in the build failure in the gem I
> maintain, asciidoctor:
>
> + rm Rakefile
> + sed -i 's|"Rakefile",||g' asciidoctor.gemspec
> + exit 0
> Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.0fctL3
> + umask 022
> + cd /builddir/build/BUILD
> + cd asciidoctor-1.5.4
> + gem build asciidoctor.gemspec
> WARNING:  See http://guides.rubygems.org/specification-reference/ for help
> ERROR:  While executing gem ... (Gem::InvalidSpecificationException)
>     ["Rakefile"] are not files
>
> That sed expression is highly dependent on how files are specified in
> a gemspec, and it doesn't match how the asciidoctor gemspec defines
> files. Can this alteration be updated to be more robust?

Yep, there is plan to do this more robust, but somebody needs to execute
it :) I hope one day we will have macro similar to
%gemspec_{add,remove}_dep, which I introduced in response to these
issues. These macros handle the more common case, where we need to
modify the gem dependencies.

>
> One way would be to look for the files assignment and subtract an
> entry from it. Something like:
>
> sed -i "s|\.files *=.*|& - ['Rakefile']|" asciidoctor.gemspec

There are several ways how to fix these issues, but unless you use Ruby
to modify the .spec file they will break sooner or later. Actually, if
you use Ruby, it will break as well, but the chances are that it will
break later ;)

And there are several solutions to your issue I can see:

1) Your proposal looks interesting.
2) My first though was:

~~~
@@ -73,7 +73,7 @@ sed -i -e 's|#!/usr/bin/env ruby|#!/usr/bin/ruby|' \
 
 # Clean up development-only file
 rm Rakefile
-sed -i "s|\"Rakefile\",||g" %{gem_name}.gemspec
+sed -i -r "s|\"Rakefile\"(.freeze)?,||g" %{gem_name}.gemspec
 
 %build
 gem build %{gem_name}.gemspec
~~~

3) And my second though was: "Why are you removing the file on this
place at all?". If you did just this:

~~~
@@ -71,10 +71,6 @@ gem spec %{SOURCE0} -l --ruby > %{gem_name}.gemspec
 sed -i -e 's|#!/usr/bin/env ruby|#!/usr/bin/ruby|' \
   bin/%{gem_name} bin/%{gem_name}-safe
 
-# Clean up development-only file
-rm Rakefile
-sed -i "s|\"Rakefile\",||g" %{gem_name}.gemspec
-
 %build
 gem build %{gem_name}.gemspec
 %gem_install -n %{gem_name}-%{version}%{pre}.gem
@@ -84,7 +80,7 @@ gem build %{gem_name}.gemspec
 # Asciidoctor tests require Minitest 5, so we can't run them on EPEL
 %else
 # We need many more packages to run the tests. I'll try to work on
those deps
-# LANG=en_US.utf8 ruby -I"lib:test" test/*_test.rb
+LANG=en_US.utf8 ruby -I"lib:test" test/*_test.rb
 %endif
 
 %install
@@ -107,6 +103,7 @@ cp -a .%{gem_instdir}/man/*.1 \
 %exclude %{gem_instdir}/man
 %exclude %{gem_instdir}/test
 %exclude %{gem_instdir}/features
+%exclude %{gem_instdir}/Rakefile
 %license %{gem_instdir}/LICENSE.adoc
 %doc %{gem_instdir}/CHANGELOG.adoc
 %doc %{gem_instdir}/CONTRIBUTING.adoc
~~~

(or you could remove the Rakefile in %install section if you prefer),
the result would be the same and it would save you some troubles.

>
> Until this is fixed, my gem is going to fail in rawhide because I
> can't change the already released gem. I suspect there are others that
> are failing as well.

In most cases, it is really easier to exclude the file or rm it in
%install section.  But there are certainly packages where there is more
reasons to remove some files (e.g. there are removed some files by
patches applied in %prep section in rubygem-fog, so the .gemspec needs
to be adjusted). So long term, I'd really like to see some macro which
can cope with this.

Vít
_______________________________________________
ruby-sig mailing list -- ruby-sig@lists.fedoraproject.org
To unsubscribe send an email to ruby-sig-le...@lists.fedoraproject.org

Reply via email to