1
0

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
This commit is contained in:
Marcus Rückert 2019-02-25 20:38:37 +00:00 committed by Git OBS Bridge
commit 2b0624657b
6 changed files with 145 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -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

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.osc

View File

@ -0,0 +1,15 @@
-------------------------------------------------------------------
Fri Feb 8 02:57:39 UTC 2019 - Marcus Rueckert <mrueckert@suse.de>
- handle all gemspecs found under specification
-------------------------------------------------------------------
Fri Feb 8 01:30:20 UTC 2019 - Marcus Rueckert <mrueckert@suse.de>
- do not anchor on string start
- properly name the items in the attr file
-------------------------------------------------------------------
Fri Feb 8 00:02:01 UTC 2019 - Marcus Rueckert <mrueckert@suse.de>
- initial package

View File

@ -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

2
ruby_bundled_gems.attr Normal file
View File

@ -0,0 +1,2 @@
%__ruby_bundled_gems_provides %{_rpmconfigdir}/ruby_bundled_gems.pl
%__ruby_bundled_gems_path /usr/lib.*/ruby/gems/.*/specifications/.*\.gemspec$

58
ruby_bundled_gems.pl Normal file
View File

@ -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\/(?<ruby_abi_version>[^\/]+)\/specifications(\/default)?\/(?<gem_name>.+)-(?<gem_version>\d+\.[^-]+)\.gemspec\n\z/) {
handle_line($line, 'ruby', $+{ruby_abi_version}, $+{gem_name}, $+{gem_version});
};
}