This commit is contained in:
parent
e96f0e3337
commit
6e886a6048
@ -4,6 +4,8 @@ if [ ${#*} = 1 ] ; then
|
||||
find $1 \
|
||||
\( -name \*.o -o -name Makefile -o -name config.log -o -name config.status -o -name Makefile.html -o -name gem_make.out -o -name mkmf.log -o -name \*.bak -o -name .deps -o -name .libs -o -name CVS \) \
|
||||
-print0 | xargs -r0 rm -rv || :
|
||||
# remove more strict in the docu
|
||||
find $1/doc \( -name Makefile.ri -o -name ext \) -print0 | xargs -r0 rm -rv || :
|
||||
else
|
||||
echo "'$1' does not exists or is not a directory! Exiting." >&2
|
||||
exit 1
|
||||
|
@ -42,10 +42,11 @@ set -x
|
||||
$gem_binary install --verbose --local $otheropts
|
||||
if test -d $RPM_BUILD_ROOT/usr/bin; then
|
||||
cd $RPM_BUILD_ROOT/usr/bin
|
||||
bins=`ls -1 *1.9 2> /dev/null`
|
||||
# backward compat
|
||||
bins=`ls -1 *1.9 *2.0 2> /dev/null` || true
|
||||
if test -n "$bins"; then
|
||||
for bin in $bins; do
|
||||
mv -v $bin $(echo "$bin" | sed -e 's,1.9$,,')
|
||||
mv -v $bin $(echo "$bin" | sed -e 's,2.0$,,; s,1.9$,,')
|
||||
done
|
||||
fi
|
||||
fi
|
||||
@ -55,4 +56,10 @@ if [ -d "$buildroot" ]; then
|
||||
# TODO: scripts in ruby/1.9.1 should call ruby1.9 for consistency
|
||||
sed -i -e 's,^#!/usr/bin/env ruby,#!/usr/bin/ruby,; s,^#! *[^ ]*/ruby,#!/usr/bin/ruby,' "$file"
|
||||
done
|
||||
# some windows made gems are broken
|
||||
find $buildroot -type d | xargs ls -ld || :
|
||||
find $buildroot -type f | xargs ls -l || :
|
||||
chmod -R u+w $buildroot
|
||||
chmod -R o-w $buildroot
|
||||
fi
|
||||
|
||||
|
208
generate_buildrequires.sh
Normal file
208
generate_buildrequires.sh
Normal file
@ -0,0 +1,208 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# In the current package's specfile, updates a block delimited
|
||||
# by "# BEGIN" / "# END" lines to contain BuildRequires: lines
|
||||
# for each rubygem rpm (or rpm matching a given pattern) which
|
||||
# has been built by the project.
|
||||
#
|
||||
# This gives us project-build-time dependency checking without the
|
||||
# performance impact that specifying BuildRequires lines within
|
||||
# each gem would cause. For more information, see:
|
||||
#
|
||||
# http://en.opensuse.org/openSUSE:Packaging_Ruby#Compensating_for_lack_of_BuildRequires
|
||||
#
|
||||
# Usage:
|
||||
# ------
|
||||
#
|
||||
# 1. Ensure you have an "all-rubygems-good" package or similar
|
||||
# in your project. If in doubt, copy the one from
|
||||
# devel:languages:ruby:extensions.
|
||||
#
|
||||
# 2. cd to a working copy
|
||||
#
|
||||
# If you're feeling lazy, you are probably fine skipping the next two
|
||||
# steps.
|
||||
#
|
||||
# 3. Run this script with the -l option and make sure you understand
|
||||
# any differences between each repository/arch combination in the
|
||||
# numbers of matching gems found.
|
||||
#
|
||||
# 4. If you don't, run with -l REPO ARCH to compare individual lists
|
||||
# of matching gems.
|
||||
#
|
||||
# 5. If you want a BuildRequires: list of matching gems from *all*
|
||||
# repo/arch combinations, run again with no arguments.
|
||||
#
|
||||
# OR
|
||||
#
|
||||
# If you want a BuildRequires: list of matching gems from a specific
|
||||
# repo/arch combinations, run again with REPO ARCH as arguments.
|
||||
#
|
||||
# 6. osc diff to review the changes to the spec file, then osc commit.
|
||||
|
||||
me=`basename $0`
|
||||
|
||||
DEFAULT_PATTERN="rubygem-"
|
||||
|
||||
main () {
|
||||
parse_opts "$@"
|
||||
|
||||
if [ -z "$project" ]; then
|
||||
project=$( osc info | sed -ne '/^Project name: / { s///; p }' )
|
||||
if [ -z "$project" ]; then
|
||||
echo "Couldn't establish build service project name." >&2
|
||||
echo "Are you inside a package working directory?" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
echo "Project: $project"
|
||||
|
||||
case "$project" in
|
||||
home:*:branches:*)
|
||||
cat <<EOF >&2
|
||||
|
||||
WARNING: you are running this in a branch.
|
||||
|
||||
You probably need to specify the parent project via -P,
|
||||
otherwise you may not get the dependencies you want.
|
||||
|
||||
EOF
|
||||
;;
|
||||
esac
|
||||
|
||||
specfile=$( ls -1 *.spec )
|
||||
if ! [ -f "$specfile" ]; then
|
||||
echo "Couldn't find spec file." >&2
|
||||
echo "Are you inside a package working directory?" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -n "$list" ]; then
|
||||
if [ -n "$repo" ]; then
|
||||
get_buildrequires_lines "$repo" "$arch"
|
||||
else
|
||||
list_matches
|
||||
fi
|
||||
else
|
||||
if [ -n "$repo" ]; then
|
||||
get_buildrequires_lines "$repo" "$arch" | update_spec
|
||||
else
|
||||
find_all_matches | update_spec
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
usage () {
|
||||
# Call as: usage [EXITCODE] [USAGE MESSAGE]
|
||||
exit_code=1
|
||||
if [[ "$1" == [0-9] ]]; then
|
||||
exit_code="$1"
|
||||
shift
|
||||
fi
|
||||
if [ -n "$1" ]; then
|
||||
echo "$*" >&2
|
||||
echo
|
||||
fi
|
||||
|
||||
cat <<EOF >&2
|
||||
Usage: $me [options] [REPOSITORY ARCH]
|
||||
Options:
|
||||
-h, --help Show this help and exit
|
||||
-l, --list List matching rpms for the given repository / arch.
|
||||
If no repository specified, show counts of matching
|
||||
rpms per repository / arch.
|
||||
-P, --project=PROJ Retrieve rpm lists from PROJ, not the current project.
|
||||
-p, --pattern=PAT Set the pattern to match rpms by [$DEFAULT_PATTERN]
|
||||
EOF
|
||||
exit "$exit_code"
|
||||
}
|
||||
|
||||
parse_opts () {
|
||||
list=
|
||||
project=
|
||||
pattern="$DEFAULT_PATTERN"
|
||||
|
||||
while [ $# != 0 ]; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage 0
|
||||
;;
|
||||
-l|--list)
|
||||
list=y
|
||||
shift
|
||||
;;
|
||||
-p|--pattern)
|
||||
pattern="$2"
|
||||
shift 2
|
||||
;;
|
||||
-P|--project)
|
||||
project="$2"
|
||||
shift 2
|
||||
;;
|
||||
-*)
|
||||
usage "Unrecognised option: $1"
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ $# = 1 ]; then
|
||||
usage "Insufficient arguments."
|
||||
fi
|
||||
|
||||
if [ $# -gt 2 ]; then
|
||||
usage "Too many arguments."
|
||||
fi
|
||||
|
||||
repo="$1"
|
||||
arch="$2"
|
||||
}
|
||||
|
||||
get_buildrequires_lines () {
|
||||
repo="$1" arch="$2"
|
||||
osc api "/build/$project/$repo/$arch/_repository" | \
|
||||
grep "binary .*filename=\"$pattern" | \
|
||||
sed -e 's,.* <binary filename=",,; s,\.rpm".*,,; s,^,BuildRequires: ,' | \
|
||||
grep -v debuginfo
|
||||
}
|
||||
|
||||
list_matches () {
|
||||
echo
|
||||
echo "Matching rpms per repository/arch:"
|
||||
echo
|
||||
osc repos | while read repo arch; do
|
||||
count=$( get_buildrequires_lines "$repo" "$arch" | wc -l )
|
||||
printf "%-17s %-8s %d\n" "$repo" "$arch" "$count"
|
||||
done
|
||||
echo
|
||||
}
|
||||
|
||||
find_all_matches () {
|
||||
osc repos "$project" | while read repo arch; do
|
||||
echo "Obtaining BuildRequires from $repo $arch ..." >&2
|
||||
get_buildrequires_lines "$repo" "$arch"
|
||||
done | sort -u
|
||||
}
|
||||
|
||||
edit_spec () {
|
||||
sed -n -e '1,/BEGIN/p' $specfile
|
||||
echo "# Automatically generated by $0"
|
||||
echo "# on `date`"
|
||||
echo "# See http://en.opensuse.org/openSUSE:Packaging_Ruby#Compensating_for_lack_of_BuildRequires"
|
||||
cat
|
||||
sed -n -e '/END/,$p' $specfile
|
||||
}
|
||||
|
||||
update_spec () {
|
||||
if edit_spec > $specfile.new; then
|
||||
mv $specfile.new $specfile
|
||||
echo "Updated spec: $specfile"
|
||||
else
|
||||
echo "Failed to generate new spec file contents; aborting." >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
@ -1,3 +1,149 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Feb 4 14:03:13 UTC 2014 - kkaempf@suse.com
|
||||
|
||||
- make %gem_extensions and %gem_doc_ext not fail on Ruby < 2.1
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sun Jan 12 19:05:13 UTC 2014 - coolo@suse.com
|
||||
|
||||
- remove 2.0 and 1.9 as binary suffix
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sun Jan 12 16:43:47 UTC 2014 - coolo@suse.com
|
||||
|
||||
- increase the version and make gem_base generic
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Jan 6 16:57:37 UTC 2014 - coolo@suse.com
|
||||
|
||||
- switch to 2.1 as default
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Sep 12 21:49:33 UTC 2013 - mrueckert@suse.de
|
||||
|
||||
- fixed bootstrap problem by ignoring ruby-common at build time
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sat Sep 7 20:27:22 UTC 2013 - coolo@suse.com
|
||||
|
||||
- do no longer buildrequire rubygems_with_buildroot_patch, that's
|
||||
history long enough - ruby-devel will do
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Jun 6 14:41:53 UTC 2013 - coolo@suse.com
|
||||
|
||||
- fixed ~> 3.4 to actually require 3
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Apr 29 07:59:35 UTC 2013 - coolo@suse.com
|
||||
|
||||
- switch to ruby 2.0 as default
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sun Apr 14 08:30:10 UTC 2013 - coolo@suse.com
|
||||
|
||||
- fix permissions
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Apr 9 09:23:00 UTC 2013 - coolo@suse.com
|
||||
|
||||
- do not remove ext completely, e.g. passenger extensions require
|
||||
some files from there
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sat Mar 23 13:32:13 UTC 2013 - coolo@suse.com
|
||||
|
||||
- remove ext too, it only causes problems - as far as I can see
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 8 16:22:44 UTC 2013 - rhafer@suse.com
|
||||
|
||||
- Some enhancements to rubygemsdeps.rb:
|
||||
- Add --file-match option to rubygemsdeps.rb to allow
|
||||
specifying and alternate regex to match the input files
|
||||
against. This is useful to generate dependencies from gemspec
|
||||
files which do not endup being installed in the default
|
||||
locations
|
||||
- Default rubyabi to a non-nil value (basically the version of
|
||||
of the ruby interpreter that runs the script)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Jan 9 18:05:38 GMT 2013 - aspiers@suse.com
|
||||
|
||||
- Fix it to work even if all-good has just been created locally
|
||||
via mkpac and doesn't exist server-side yet.
|
||||
- Improve support for running within a branch of the original
|
||||
project. This allows submitreqs which change all-good.spec.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Jan 8 11:00:24 UTC 2013 - idonmez@suse.com
|
||||
|
||||
- Bump version to 2.0 so we don't get a version downgrade when
|
||||
updating from 12.2
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Dec 28 13:38:59 UTC 2012 - coolo@suse.com
|
||||
|
||||
- always provide the full version string as people use
|
||||
~> 1.2 even if the version is 1.2
|
||||
The old logic assumed people would always require one digit
|
||||
less than the actual version
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Dec 19 19:17:46 GMT 2012 - aspiers@suse.com
|
||||
|
||||
- Import an enhanced version of d:l:r:e/all-good/update-sources.sh
|
||||
which can be reused for any project, and allows more thorough
|
||||
handling of BuildRequires from different repository / arch
|
||||
combinations.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Dec 4 10:57:13 UTC 2012 - nkrinner@suse.com
|
||||
|
||||
- Bring back fix from submit request 140568 (Revision 23):
|
||||
Fix gemspec filtering on SLE_11_SP2:
|
||||
+ Only gemspec files resulting of the built gem matter, not other
|
||||
gemspec found in-tree
|
||||
+ Newer RPM uses rubygem.attr, which filters correctly
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Nov 30 16:24:19 UTC 2012 - coolo@suse.com
|
||||
|
||||
- require rubygems for old ruby versions
|
||||
- strip trailing .0 for ~> operator
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Nov 23 12:36:58 GMT 2012 - aspiers@suse.com
|
||||
|
||||
- Add -g option to rubygemsdeps.rb to allow preview / review
|
||||
of automatically generated dependencies from:
|
||||
+ gemspecs in packages which have already been installed
|
||||
+ gems/gemspecs which have not yet been packaged
|
||||
This is useful for learning / debugging the dependency generator.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Nov 7 14:46:27 UTC 2012 - saschpe@suse.de
|
||||
|
||||
- Fix gemspec filtering on SLE_11_SP2:
|
||||
+ Only gemspec files resulting of the built gem matter, not other
|
||||
gemspec found in-tree
|
||||
+ Newer RPM uses rubygem.attr, which filters correctly
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Nov 5 11:08:05 UTC 2012 - coolo@suse.com
|
||||
|
||||
- fix build on fedora
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Aug 2 05:23:31 UTC 2012 - coolo@suse.com
|
||||
|
||||
- "~> 2" doesn't have any meaning, but we still need to handle it
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Aug 1 10:20:32 UTC 2012 - coolo@suse.com
|
||||
|
||||
- fixing the pessimistic operator
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Jul 30 10:39:16 UTC 2012 - coolo@suse.com
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package ruby
|
||||
# spec file for package ruby-common
|
||||
#
|
||||
# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2014 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
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
|
||||
Name: ruby-common
|
||||
Version: 1.0
|
||||
Version: 3
|
||||
Release: 0
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
Source1: gem_build_cleanup
|
||||
@ -25,19 +25,21 @@ Source3: ruby.common-macros
|
||||
Source4: rubygems.attr
|
||||
Source5: rubygemsdeps.rb
|
||||
Source6: gem_install.sh
|
||||
Source7: generate_buildrequires.sh
|
||||
Summary: Collection of scripts and macros for ruby packaging
|
||||
License: MIT
|
||||
Group: Development/Languages/Ruby
|
||||
Requires: rubygems_with_buildroot_patch
|
||||
Requires: rubygems > 1.8
|
||||
Requires: /usr/bin/getopt
|
||||
Requires: fdupes
|
||||
Requires: ruby-devel
|
||||
Requires: rubygems > 1.8
|
||||
BuildArch: noarch
|
||||
Provides: ruby-macros = %{version}
|
||||
%if %suse_version < 1140
|
||||
%if 0%{?suse_version} < 1140
|
||||
# we need a patched rpm
|
||||
Requires: rpm-with-ruby-provide-hook
|
||||
%endif
|
||||
|
||||
#!BuildIgnore: ruby-common
|
||||
%description
|
||||
This package is needed for (generated) ruby gems. It provides hooks for
|
||||
automatic rpm provides and requires and macros that gem2rpm uses.
|
||||
@ -53,6 +55,7 @@ install -D -m 0644 %{S:4} $RPM_BUILD_ROOT/usr/lib/rpm/fileattrs/rubygems.attr
|
||||
install -D -m 0755 %{S:5} $RPM_BUILD_ROOT/usr/lib/rpm/rubygemsdeps.rb
|
||||
install -D -m 0755 %{S:6} $RPM_BUILD_ROOT/usr/lib/rpm/gem_install.sh
|
||||
install -D -m 0755 %{S:1} $RPM_BUILD_ROOT/usr/lib/rpm/gem_build_cleanup.sh
|
||||
install -D -m 0755 %{S:7} $RPM_BUILD_ROOT/usr/lib/rpm/generate_buildrequires.sh
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
@ -62,5 +65,6 @@ install -D -m 0755 %{S:1} $RPM_BUILD_ROOT/usr/lib/rpm/gem_build_cleanup.sh
|
||||
/usr/lib/rpm/rubygemsdeps.rb
|
||||
/usr/lib/rpm/gem_install.sh
|
||||
/usr/lib/rpm/gem_build_cleanup.sh
|
||||
/usr/lib/rpm/generate_buildrequires.sh
|
||||
|
||||
%changelog
|
||||
|
@ -10,7 +10,7 @@
|
||||
%{?gem_binary}%{!?gem_binary:/usr/bin/gem} unpack --verbose $source \
|
||||
cd %{mod_name}-%{version} \
|
||||
chmod og-w -R . \
|
||||
%{?gem_binary}%{!?gem_binary:/usr/bin/gem} unpack --spec $source \
|
||||
%{?gem_binary}%{!?gem_binary:/usr/bin/gem} specification --ruby $source > %{mod_name}-%{version}.gemspec \
|
||||
%{nil}
|
||||
|
||||
# %%gem_build macro ...
|
||||
@ -27,9 +27,27 @@ cd $GEMSPEC_SOURCE_DIR && %{?gem_binary}%{!?gem_binary:/usr/bin/gem} build --ver
|
||||
#
|
||||
%gem_install /usr/lib/rpm/gem_install.sh --default-gem %{mod_name}-%{version}.gem --build-root %{buildroot} %{?gem_binary:--gem-binary %{gem_binary}}
|
||||
|
||||
# we need to copy parts of the %fdupes macro as rpm can't expand parameters in macro "calls" ;(
|
||||
%gem_cleanup() \
|
||||
/usr/lib/rpm/gem_build_cleanup.sh %{buildroot}%{_libdir}/ruby/gems/%{rb_ver}/ \
|
||||
fdupes -q -p -n -r %{buildroot}%{gem_base} | \
|
||||
while read _file; do \
|
||||
if test -z "$_target" ; then \
|
||||
_target="$_file"; \
|
||||
else \
|
||||
if test -z "$_file" ; then \
|
||||
_target=""; \
|
||||
continue ; \
|
||||
fi ; \
|
||||
ln -sf "${_target#%{buildroot}}" "$_file"; \
|
||||
fi ; \
|
||||
done \
|
||||
%{nil}
|
||||
|
||||
# this is used in older gems - but it's pointless with newer ruby/rpm versions
|
||||
%rubygems_requires %{nil}
|
||||
|
||||
%gem_base %(%{rb_binary} -rrubygems -e 'print Gem::Specification.new.base_dir' )
|
||||
%gem_extensions %(%{rb_binary} -rrubygems -e 'bs = Gem::Specification.new; if bs.respond_to?(:extensions_dir) then print bss.extensions_dir else exit 1 end' || echo %{_libdir}/ruby/gems/%{rb_ver}/gems )
|
||||
%gem_doc_ext %(%{rb_binary} -rrubygems -e 'bs = Gem::Specification.new; if bs.respond_to?(:extensions_dir) then rp = bs.extensions_dir.rpartition(bs.base_dir); print rp[1]+"/doc"+rp[2] else exit 1 end' || echo %{_libdir}/ruby/gems/%{rb_ver}/doc )
|
||||
%gem_platform %(%{rb_binary} -rrubygems -r rbconfig -e 'print Gem::Platform.new(RbConfig::CONFIG["arch"]).to_s' )
|
||||
|
@ -23,17 +23,30 @@
|
||||
|
||||
require 'optparse'
|
||||
require 'rubygems'
|
||||
#require 'rubygems/format'
|
||||
require 'rubygems/specification'
|
||||
|
||||
opts = OptionParser.new("Usage: #{$0}")
|
||||
|
||||
provides=false
|
||||
opts.on("-P", "--provides", "Output the provides of the package") do |val|
|
||||
provides=true
|
||||
provides=true
|
||||
end
|
||||
requires=false
|
||||
opts.on("-R", "--requires", "Output the requires of the package") do |val|
|
||||
requires=true
|
||||
requires=true
|
||||
end
|
||||
file_match=".*/gems/[^/]*/specifications/.*\.gemspec$"
|
||||
opts.on("-m", "--file-match REGEX", String,
|
||||
"Override the regex against which the input file names",
|
||||
"matched with the supplied regex") do |val|
|
||||
file_match=val
|
||||
end
|
||||
in_file=nil
|
||||
opts.on("-g", "--gemspec FILE", String,
|
||||
"Take gemspec from FILE, not filename in STDIN",
|
||||
"Can be a .gem file or a .gemspec file") do |file|
|
||||
in_file=file
|
||||
end
|
||||
rest = opts.permute(ARGV)
|
||||
|
||||
@ -41,17 +54,53 @@ unless provides || requires
|
||||
exit(0)
|
||||
end
|
||||
|
||||
gemspecs=Array.new
|
||||
|
||||
$stdin.each_line do |line|
|
||||
m = line.match(%r{.*/specifications/.*\.gemspec$})
|
||||
gemspecs << [m[0], Gem::Specification.load(m[0])] if m
|
||||
def fatal(msg)
|
||||
$stderr.puts msg
|
||||
exit 1
|
||||
end
|
||||
|
||||
gemspecs.each do |file, spec|
|
||||
rubyabi=nil
|
||||
m = file.match(%r{.*/gems/([^/]*)/.*})
|
||||
rubyabi=m[1] if m
|
||||
def register_gemspec_from_file(gemspecs, rubyabi, file)
|
||||
fatal "Couldn't read '#{file}'" unless File.readable? file
|
||||
|
||||
case file
|
||||
when /\.gem$/
|
||||
gem = Gem::Format.from_file_by_path(file)
|
||||
fatal "Failed to load gem from '#{file}'" unless gem
|
||||
spec = gem.spec
|
||||
when /\.gemspec$/
|
||||
spec = Gem::Specification.load(file)
|
||||
fatal "Failed to load gem spec from '#{file}'" unless spec
|
||||
else
|
||||
fatal "'#{file}' must be a .gem or .gemspec file"
|
||||
end
|
||||
|
||||
gemspecs << [ rubyabi, spec ]
|
||||
end
|
||||
|
||||
def rubyabi_from_path(path)
|
||||
m = path.match(%r{.*/gems/([^/]*)/.*})
|
||||
return m ? m[1] : RbConfig::CONFIG["ruby_version"]
|
||||
end
|
||||
|
||||
gemspecs = Array.new
|
||||
|
||||
if in_file
|
||||
# This mode will not be used during actual rpm builds, but only by
|
||||
# gem packagers for debugging / diagnostics, so that they can
|
||||
# predict in advance what the dependencies will look like.
|
||||
rubyabi = rubyabi_from_path(in_file) || '$RUBYABI'
|
||||
register_gemspec_from_file(gemspecs, rubyabi, in_file)
|
||||
else
|
||||
$stdin.each_line do |line|
|
||||
line.chomp!
|
||||
m = line.match(%r{#{file_match}$})
|
||||
if m
|
||||
register_gemspec_from_file(gemspecs, rubyabi_from_path(line), line)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
gemspecs.each do |rubyabi, spec|
|
||||
if provides
|
||||
# old forms
|
||||
puts "rubygem-#{spec.name} = #{spec.version}"
|
||||
@ -62,17 +111,32 @@ gemspecs.each do |file, spec|
|
||||
|
||||
# version without ruby version - asking for trouble
|
||||
puts "rubygem(#{spec.name}) = #{spec.version}"
|
||||
puts "rubygem(#{rubyabi}:#{spec.name}) = #{spec.version}" if rubyabi
|
||||
if rubyabi
|
||||
puts "rubygem(#{rubyabi}:#{spec.name}) = #{spec.version}"
|
||||
puts "rubygem(#{rubyabi}:#{spec.name}:#{versions[0]}) = #{spec.version}" if versions.length > 0
|
||||
puts "rubygem(#{rubyabi}:#{spec.name}:#{versions[0]}.#{versions[1]}) = #{spec.version}" if versions.length > 1
|
||||
puts "rubygem(#{rubyabi}:#{spec.name}:#{versions[0]}.#{versions[1]}.#{versions[2]}) = #{spec.version}" if versions.length > 2
|
||||
end
|
||||
end
|
||||
|
||||
if requires
|
||||
puts "ruby(abi) = #{rubyabi}" if rubyabi
|
||||
puts "rubygems" if rubyabi.to_f < 1.9
|
||||
spec.runtime_dependencies.each do |dep|
|
||||
dep.requirement.requirements.each do |r|
|
||||
if r.first == '~>'
|
||||
next_version = Gem::Version.create(r.last).bump
|
||||
puts "rubygem(#{rubyabi}:#{dep.name}) >= #{r.last}"
|
||||
puts "rubygem(#{rubyabi}:#{dep.name}) < #{next_version}"
|
||||
minversion = r.last.to_s.split('.')
|
||||
versions = minversion[0,minversion.length-1]
|
||||
# ~> 2 is pretty nonsense, so avoid being tricked
|
||||
if versions.length > 0
|
||||
if minversion[minversion.length-1] == '0'
|
||||
# ~> 1.2.0 is the same as >= 1.2 for rpm and it avoids problems when 1.2 is followed by 1.2.1
|
||||
minversion = versions
|
||||
end
|
||||
puts "rubygem(#{rubyabi}:#{dep.name}:#{versions.join('.')}) >= #{minversion.join('.')}"
|
||||
else
|
||||
puts "rubygem(#{rubyabi}:#{dep.name}) >= #{minversion.join('.')}"
|
||||
end
|
||||
elsif r.first == '!='
|
||||
# this is purely guessing, but we can't generate conflicts here ;(
|
||||
puts "rubygem(#{rubyabi}:#{dep.name}) > #{r.last}"
|
||||
|
Loading…
Reference in New Issue
Block a user