forked from pool/rubygem-gem2rpm
12e58c4955
- make sure license.txt is also symlinked - integrate more of the version into the mod_weight to give an easier job to update-alternatives - use --force in update-alternatives to replace (old) binaries OBS-URL: https://build.opensuse.org/request/show/178307 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/rubygem-gem2rpm?expand=0&rev=8
293 lines
9.8 KiB
Diff
293 lines
9.8 KiB
Diff
diff -ru gem2rpm-0.9.2.orig/bin/gem2rpm gem2rpm-0.9.2/bin/gem2rpm
|
|
--- gem2rpm-0.9.2.orig/bin/gem2rpm 2013-04-30 13:31:08.586730796 +0200
|
|
+++ gem2rpm-0.9.2/bin/gem2rpm 2013-05-02 10:33:35.314236973 +0200
|
|
@@ -121,9 +121,15 @@
|
|
if output_file.nil?
|
|
Gem2Rpm::convert(gemfile, template, $stdout, nongem, local, doc_subpackage) unless deps
|
|
else
|
|
+ oldfile=IO.readlines(output_file) if File.exists? output_file
|
|
+ oldlicense=nil
|
|
+ oldfile.each do |line|
|
|
+ m = line.match(%r{^License:\s*(\w.*)$})
|
|
+ oldlicense = m[1] if m
|
|
+ end if oldfile
|
|
begin
|
|
out = open(output_file, "w")
|
|
- Gem2Rpm::convert(gemfile, template, out, nongem, local, doc_subpackage)
|
|
+ Gem2Rpm::convert(gemfile, template, out, nongem, local, doc_subpackage, oldlicense)
|
|
ensure
|
|
out.close()
|
|
end
|
|
Nur in gem2rpm-0.9.2/bin: gem2rpm.orig.
|
|
diff -ru gem2rpm-0.9.2.orig/lib/gem2rpm/specification.rb gem2rpm-0.9.2/lib/gem2rpm/specification.rb
|
|
--- gem2rpm-0.9.2.orig/lib/gem2rpm/specification.rb 2013-04-30 13:31:08.586730796 +0200
|
|
+++ gem2rpm-0.9.2/lib/gem2rpm/specification.rb 2013-05-02 10:33:35.314236973 +0200
|
|
@@ -6,7 +6,11 @@
|
|
class Specification < SimpleDelegator
|
|
# A long description of gem wrapped to 78 characters.
|
|
def description
|
|
- Helpers::word_wrap(super.to_s.chomp, 78) + "\n"
|
|
+ text=super
|
|
+ if text.nil? or text.empty?
|
|
+ text=self.__getobj__().summary
|
|
+ end
|
|
+ Helpers::word_wrap(text.to_s.chomp, 78) + "\n"
|
|
end
|
|
|
|
# A list of Gem::Dependency objects this gem depends on (includes every
|
|
@@ -15,6 +19,17 @@
|
|
super.map {|d| Gem2Rpm::Dependency.new d}
|
|
end
|
|
|
|
+ # a short summary trimmed to 70 characters
|
|
+ def summary
|
|
+ text = super
|
|
+ if text.length >= 70
|
|
+ text = text[0,70].split(/\s/)
|
|
+ text = text[0, text.length-1].join(" ")
|
|
+ end
|
|
+ text = text[0, text.length-1] if text[-1] == '.'
|
|
+ text
|
|
+ end
|
|
+
|
|
# List of dependencies that are used for development.
|
|
def development_dependencies
|
|
super.map {|d| Gem2Rpm::Dependency.new d}
|
|
diff -ru gem2rpm-0.9.2.orig/lib/gem2rpm.rb gem2rpm-0.9.2/lib/gem2rpm.rb
|
|
--- gem2rpm-0.9.2.orig/lib/gem2rpm.rb 2013-04-30 13:31:08.586730796 +0200
|
|
+++ gem2rpm-0.9.2/lib/gem2rpm.rb 2013-05-02 10:33:35.314236973 +0200
|
|
@@ -31,11 +31,14 @@
|
|
end
|
|
|
|
def Gem2Rpm.convert(fname, template=TEMPLATE, out=$stdout,
|
|
- nongem=true, local=false, doc_subpackage = true)
|
|
+ nongem=true, local=false, doc_subpackage = true, oldlicense=nil)
|
|
package = Gem2Rpm::Package.new(fname)
|
|
format = Gem2Rpm::Format.new(package)
|
|
spec = Gem2Rpm::Specification.new(package.spec)
|
|
- spec.description ||= spec.summary
|
|
+ #spec.description ||= spec.summary
|
|
+ if spec.licenses.empty? && oldlicense
|
|
+ spec.licenses = oldlicense.split(' and ')
|
|
+ end
|
|
download_path = ""
|
|
unless local
|
|
begin
|
|
diff -ru gem2rpm-0.9.2.orig/templates/opensuse.spec.erb gem2rpm-0.9.2/templates/opensuse.spec.erb
|
|
--- gem2rpm-0.9.2.orig/templates/opensuse.spec.erb 2013-04-30 13:31:08.586730796 +0200
|
|
+++ gem2rpm-0.9.2/templates/opensuse.spec.erb 2013-06-10 12:04:00.205318552 +0200
|
|
@@ -1,7 +1,7 @@
|
|
#
|
|
-# spec file for package rubygem-<%= spec.name %> (Version <%= spec.version %>)
|
|
+# spec file for package rubygem-<%= spec.name %>
|
|
#
|
|
-# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
|
+# Copyright (c) <%= Time.now.year %> SUSE LINUX Products GmbH, Nuernberg, Germany.
|
|
#
|
|
# All modifications and additions to the file contributed by third parties
|
|
# remain the property of their copyright owners, unless otherwise agreed
|
|
@@ -15,58 +15,169 @@
|
|
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
|
#
|
|
|
|
-# norootforbuild
|
|
+
|
|
Name: rubygem-<%= spec.name %>
|
|
Version: <%= spec.version %>
|
|
Release: 0
|
|
%define mod_name <%= spec.name %>
|
|
-#
|
|
-Group: Development/Languages/Ruby
|
|
-License: GPLv2+ or Ruby
|
|
-#
|
|
+%define mod_full_name %{mod_name}-%{version}
|
|
+<% unless spec.executables.empty?
|
|
+ versions=spec.version.to_s.split('.')
|
|
+ begin v1=Integer(versions[0]) rescue v1=1 end
|
|
+ begin v2=Integer(versions[1]) rescue v2=0 end
|
|
+ begin v3=Integer(versions[2]) rescue v3=0 end
|
|
+ weight=v1*10000+v2*100+v3
|
|
+ -%>
|
|
+%define mod_branch -%{version}
|
|
+%define mod_weight <%= weight %>
|
|
+<% end -%>
|
|
+
|
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
|
-BuildRequires: rubygems_with_buildroot_patch
|
|
-Requires: rubygems >= <%= Gem::RubyGemsVersion %>
|
|
-<%
|
|
-# no need to add a requires ruby >= 0 here. will be pulled in via rubygems already
|
|
- unless spec.required_ruby_version == ['']
|
|
--%>
|
|
-Requires: ruby <%= spec.required_ruby_version %>
|
|
-BuildRequires: ruby-devel <%= spec.required_ruby_version %>
|
|
+BuildRequires: ruby-macros >= 1
|
|
+<% for req in spec.required_ruby_version -%>
|
|
+<% unless req.empty? -%>
|
|
+Requires: ruby <%= req %>
|
|
+BuildRequires: ruby-devel <%= req %>
|
|
+<% end -%>
|
|
<% end -%>
|
|
-<% for d in spec.dependencies -%>
|
|
+<% for d in spec.runtime_dependencies -%>
|
|
+<% if ['rdoc'].include? d.name.to_s -%>
|
|
+# <%= d.name %> <%= d.__getobj__().requirement %>
|
|
<% for req in d.requirement -%>
|
|
-BuildRequires: rubygem-<%= d.name %> <%= req %>
|
|
-Requires: rubygem-<%= d.name %> <%= req %>
|
|
+BuildRequires: rubygem(<%= d.name %>) <%= req %>
|
|
<% end -%>
|
|
<% end -%>
|
|
-#
|
|
+<% end -%>
|
|
+<% unless spec.rdoc_options.empty? -%>
|
|
+BuildRequires: rubygem(rdoc) > 3.10
|
|
+<% end -%>
|
|
+<% unless spec.homepage.nil? || spec.homepage.empty? -%>
|
|
Url: <%= spec.homepage %>
|
|
-Source: %{mod_name}-%{version}.gem
|
|
-#
|
|
-Summary: <%= spec.summary.gsub(/\.$/, "") %>
|
|
+<% end -%>
|
|
+Source: http://rubygems.org/gems/%{mod_full_name}.gem
|
|
+Summary: <%= spec.summary %>
|
|
+<% unless spec.licenses.empty? -%>
|
|
+License: <%= spec.licenses.join(" and ") %>
|
|
+<% else -%>
|
|
+License: CHECK(Ruby)
|
|
+<% end -%>
|
|
+Group: Development/Languages/Ruby
|
|
+<% unless spec.executables.empty? -%>
|
|
+PreReq: update-alternatives
|
|
+<% end -%>
|
|
+
|
|
%description
|
|
-<%= spec.description %>
|
|
+<%= spec.description -%>
|
|
|
|
+<% if spec.has_rdoc -%>
|
|
+%package doc
|
|
+Summary: RDoc documentation for %{mod_name}
|
|
+Group: Development/Languages/Ruby
|
|
+Requires: %{name} = %{version}
|
|
+
|
|
+%description doc
|
|
+Documentation generated at gem installation time.
|
|
+Usually in RDoc and RI formats.
|
|
+
|
|
+<% end -%>
|
|
+<% test_frameworks = Hash.new
|
|
+ docdirfiles = []
|
|
+ format.file_entries.each do |entry|
|
|
+ # new rubygems version has it different
|
|
+ if entry.kind_of?(Array)
|
|
+ path=entry[0]['path']
|
|
+ else
|
|
+ path=entry
|
|
+ end
|
|
+ path.gsub!(%r{^\./}, '')
|
|
+ %w(test spec).each { |framework|
|
|
+ test_frameworks[framework] = 1 if path.index(framework + "/") == 0
|
|
+ }
|
|
+ %w(changes copying history legal license mit-license changelog readme).each { |file|
|
|
+ bpath = path.downcase.gsub(%r{\.rdoc$}, '').gsub(%r{\.txt$}, '').gsub(%r{\.md$}, '')
|
|
+ #$stderr.puts "PATH #{path} #{bpath} #{file}"
|
|
+ docdirfiles << path if bpath == file
|
|
+ }
|
|
+ end
|
|
+
|
|
+ test_frameworks = test_frameworks.keys.sort
|
|
+-%>
|
|
+<% unless test_frameworks.empty? -%>
|
|
+%package testsuite
|
|
+Summary: Test suite for %{mod_name}
|
|
+Group: Development/Languages/Ruby
|
|
+Requires: %{name} = %{version}
|
|
+
|
|
+%description testsuite
|
|
+Test::Unit or RSpec files, useful for developers.
|
|
+
|
|
+<% end -%>
|
|
%prep
|
|
+#gem_unpack
|
|
+#if you need patches, apply them here and replace the # with a % sign in the surrounding lines
|
|
+#gem_build
|
|
+
|
|
%build
|
|
+
|
|
%install
|
|
-%gem_install %{S:0}
|
|
-<% unless spec.extensions.empty? %>
|
|
+%gem_install -f
|
|
+<% unless spec.extensions.empty? -%>
|
|
%gem_cleanup
|
|
-<% end %>
|
|
+<% end -%>
|
|
+<% spec.executables.each do |executable| -%>
|
|
+mv %{buildroot}%{_bindir}/<%= executable %>{,%{mod_branch}}
|
|
+ln -s <%= executable %>%{mod_branch} %{buildroot}%{_bindir}/<%= executable %>
|
|
+<% end -%>
|
|
+<% unless docdirfiles.empty? -%>
|
|
+mkdir -p %{buildroot}%{_docdir}/%{name}
|
|
+<% docdirfiles.each do |file| -%>
|
|
+ln -s %{_libdir}/ruby/gems/%{rb_ver}/gems/%{mod_full_name}/<%= file %> %buildroot/%{_docdir}/%{name}/<%= file %>
|
|
+<% end -%>
|
|
+<% end -%>
|
|
+<% unless spec.executables.empty? -%>
|
|
+
|
|
+%post
|
|
+<% spec.executables.each do |executable| -%>
|
|
+/usr/sbin/update-alternatives --force --install \
|
|
+ %{_bindir}/<%= executable %> <%= executable %> %{_bindir}/<%= executable %>%{mod_branch} %{mod_weight}
|
|
+<% end -%>
|
|
|
|
-%clean
|
|
-%{__rm} -rf %{buildroot}
|
|
+%preun
|
|
+<% spec.executables.each do |executable| -%>
|
|
+if [ "$1" = 0 ] ; then
|
|
+ /usr/sbin/update-alternatives --remove <%= executable %> %{_bindir}/<%= executable %>%{mod_branch}
|
|
+fi
|
|
+<% end -%>
|
|
+<% end -%>
|
|
|
|
%files
|
|
%defattr(-,root,root,-)
|
|
-<% spec.executables.each do |executable| %>
|
|
-%{_bindir}/<%= executable %>
|
|
-<% end %>
|
|
-%{_libdir}/ruby/gems/%{rb_ver}/cache/%{mod_name}-%{version}.gem
|
|
-%{_libdir}/ruby/gems/%{rb_ver}/gems/%{mod_name}-%{version}/
|
|
-%{_libdir}/ruby/gems/%{rb_ver}/specifications/%{mod_name}-%{version}.gemspec
|
|
-%doc %{_libdir}/ruby/gems/%{rb_ver}/doc/%{mod_name}-%{version}/
|
|
+<% unless docdirfiles.empty? -%>
|
|
+%{_docdir}/%{name}
|
|
+<% end -%>
|
|
+<% spec.executables.each do |executable| -%>
|
|
+%{_bindir}/<%= executable %>%{mod_branch}
|
|
+%ghost %{_bindir}/<%= executable %>
|
|
+<% end -%>
|
|
+%{_libdir}/ruby/gems/%{rb_ver}/cache/%{mod_full_name}.gem
|
|
+%{_libdir}/ruby/gems/%{rb_ver}/gems/%{mod_full_name}/
|
|
+<% test_frameworks.each do |framework| -%>
|
|
+%exclude %{_libdir}/ruby/gems/%{rb_ver}/gems/%{mod_full_name}/<%= framework %>
|
|
+<% end -%>
|
|
+%{_libdir}/ruby/gems/%{rb_ver}/specifications/%{mod_full_name}.gemspec
|
|
|
|
+<% if spec.has_rdoc -%>
|
|
+%files doc
|
|
+%defattr(-,root,root,-)
|
|
+%doc %{_libdir}/ruby/gems/%{rb_ver}/doc/%{mod_full_name}/
|
|
+
|
|
+<% end -%>
|
|
+<% unless test_frameworks.empty? -%>
|
|
+%files testsuite
|
|
+%defattr(-,root,root,-)
|
|
+<% test_frameworks.each do |framework| -%>
|
|
+%{_libdir}/ruby/gems/%{rb_ver}/gems/%{mod_full_name}/<%= framework %>
|
|
+<% end -%>
|
|
+
|
|
+<% end -%>
|
|
%changelog
|
|
Nur in gem2rpm-0.9.2/templates: opensuse.spec.erb~.
|