From 2b0624657bbb3d575f256938d25c8acacdcb95d52b4ef4f8e1f2105dc3633c7d Mon Sep 17 00:00:00 2001 From: Marcus Rueckert Date: Mon, 25 Feb 2019 20:38:37 +0000 Subject: [PATCH] Accepting request 676551 from home:darix:apps needed for ruby builds from now on OBS-URL: https://build.opensuse.org/request/show/676551 OBS-URL: https://build.opensuse.org/package/show/devel:languages:ruby/ruby-bundled-gems-rpmhelper?expand=0&rev=1 --- .gitattributes | 23 ++++++++++++ .gitignore | 1 + ruby-bundled-gems-rpmhelper.changes | 15 ++++++++ ruby-bundled-gems-rpmhelper.spec | 46 +++++++++++++++++++++++ ruby_bundled_gems.attr | 2 + ruby_bundled_gems.pl | 58 +++++++++++++++++++++++++++++ 6 files changed, 145 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 ruby-bundled-gems-rpmhelper.changes create mode 100644 ruby-bundled-gems-rpmhelper.spec create mode 100644 ruby_bundled_gems.attr create mode 100644 ruby_bundled_gems.pl diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,23 @@ +## Default LFS +*.7z filter=lfs diff=lfs merge=lfs -text +*.bsp filter=lfs diff=lfs merge=lfs -text +*.bz2 filter=lfs diff=lfs merge=lfs -text +*.gem filter=lfs diff=lfs merge=lfs -text +*.gz filter=lfs diff=lfs merge=lfs -text +*.jar filter=lfs diff=lfs merge=lfs -text +*.lz filter=lfs diff=lfs merge=lfs -text +*.lzma filter=lfs diff=lfs merge=lfs -text +*.obscpio filter=lfs diff=lfs merge=lfs -text +*.oxt filter=lfs diff=lfs merge=lfs -text +*.pdf filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text +*.rpm filter=lfs diff=lfs merge=lfs -text +*.tbz filter=lfs diff=lfs merge=lfs -text +*.tbz2 filter=lfs diff=lfs merge=lfs -text +*.tgz filter=lfs diff=lfs merge=lfs -text +*.ttf filter=lfs diff=lfs merge=lfs -text +*.txz filter=lfs diff=lfs merge=lfs -text +*.whl filter=lfs diff=lfs merge=lfs -text +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/ruby-bundled-gems-rpmhelper.changes b/ruby-bundled-gems-rpmhelper.changes new file mode 100644 index 0000000..2fc0f01 --- /dev/null +++ b/ruby-bundled-gems-rpmhelper.changes @@ -0,0 +1,15 @@ +------------------------------------------------------------------- +Fri Feb 8 02:57:39 UTC 2019 - Marcus Rueckert + +- handle all gemspecs found under specification + +------------------------------------------------------------------- +Fri Feb 8 01:30:20 UTC 2019 - Marcus Rueckert + +- do not anchor on string start +- properly name the items in the attr file + +------------------------------------------------------------------- +Fri Feb 8 00:02:01 UTC 2019 - Marcus Rueckert + +- initial package diff --git a/ruby-bundled-gems-rpmhelper.spec b/ruby-bundled-gems-rpmhelper.spec new file mode 100644 index 0000000..a847290 --- /dev/null +++ b/ruby-bundled-gems-rpmhelper.spec @@ -0,0 +1,46 @@ +# +# spec file for package rpm-ruby-bundled-gems +# +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + + +Name: ruby-bundled-gems-rpmhelper +Version: 0.0.2 +Release: 0 +Summary: A little helper to add provides for intree gems during a ruby build +License: MIT +Group: Development/Languages/Ruby +URL: https://github.com/openSUSE/ruby-packaging/ +Source0: ruby_bundled_gems.pl +Source1: ruby_bundled_gems.attr +BuildArch: noarch +# Requires: this-is-only-for-build-envs + +%description +Just a little helper to add provides for intree gems during a ruby build + +%prep + +%build + +%install +install -D -m 0755 %{SOURCE0} %{buildroot}%{_prefix}/lib/rpm/ruby_bundled_gems.pl +install -D -m 0644 %{SOURCE1} %{buildroot}%{_prefix}/lib/rpm/fileattrs/ruby_bundled_gems.attr + +%files +%{_prefix}/lib/rpm/ruby_bundled_gems.pl +%{_prefix}/lib/rpm/fileattrs/ruby_bundled_gems.attr + +%changelog diff --git a/ruby_bundled_gems.attr b/ruby_bundled_gems.attr new file mode 100644 index 0000000..88e3b1f --- /dev/null +++ b/ruby_bundled_gems.attr @@ -0,0 +1,2 @@ +%__ruby_bundled_gems_provides %{_rpmconfigdir}/ruby_bundled_gems.pl +%__ruby_bundled_gems_path /usr/lib.*/ruby/gems/.*/specifications/.*\.gemspec$ diff --git a/ruby_bundled_gems.pl b/ruby_bundled_gems.pl new file mode 100644 index 0000000..899c3be --- /dev/null +++ b/ruby_bundled_gems.pl @@ -0,0 +1,58 @@ +#!/usr/bin/perl +# + +use strict; +sub is_prerelease($) { + my $gem_version = shift; + return ($gem_version =~ /[a-zA-Z]/); +} + +sub get_release($) { + my $gem_version = shift; + my @release; + + my @splitted_version = split(/\./, $gem_version); + push (@release, shift(@splitted_version)); + for my $element (@splitted_version) { + last if $element !~ /\A\d+\z/; + push(@release, $element); + } + return (\@release); +} + +sub get_version_str($$) { + my ($gem_version, $release_ref) = @_; + + my $release_str = join('.', @$release_ref); + + if (is_prerelease($gem_version)) { + $gem_version =~ s/$release_str\./$release_str~/; + }; + return ($gem_version); +} + +sub handle_line($$$$$) { + my ($line, $ruby_abi, $ruby_abi_version, $gem_name, $gem_version ) = @_; + + my $release_ref = get_release($gem_version); + my @release = @$release_ref; + my $gem_version_str = get_version_str($gem_version, $release_ref); + my @gem_sub_version; + + print ("rubygem($gem_name) = $gem_version_str\n"); + print ("rubygem($ruby_abi:$ruby_abi_version:$gem_name) = $gem_version_str\n"); + + for my $element (@release) { + push(@gem_sub_version, $element); + my $gem_sub_version_str = join('.', @gem_sub_version); + print ("rubygem($ruby_abi:$ruby_abi_version:$gem_name:$gem_sub_version_str) = $gem_version_str\n"); + } +} + +my $fh = *STDIN; +while ( ! eof($fh) ) { + defined( my $line = readline $fh ) or die "readline failed: $!"; + if ($line =~ /\/usr\/lib\d*\/ruby\/gems\/(?[^\/]+)\/specifications(\/default)?\/(?.+)-(?\d+\.[^-]+)\.gemspec\n\z/) { + handle_line($line, 'ruby', $+{ruby_abi_version}, $+{gem_name}, $+{gem_version}); + }; +}