Sync from SUSE:SLFO:Main ruby-common revision abf2cecf1384b889b2223dcad4a909a7
This commit is contained in:
commit
3cf8cda50a
23
.gitattributes
vendored
Normal file
23
.gitattributes
vendored
Normal 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
|
89
bundler-dumpdeps
Normal file
89
bundler-dumpdeps
Normal file
@ -0,0 +1,89 @@
|
||||
#!/usr/bin/ruby
|
||||
# vim: set sw=2 sts=2 et tw=80 :
|
||||
require 'bundler'
|
||||
require 'optparse'
|
||||
require 'optparse/time'
|
||||
require 'logger'
|
||||
|
||||
class BundlerDumpRpmDeps
|
||||
def initialize
|
||||
@requires_text = "BuildRequires: "
|
||||
parse_options
|
||||
process_bundler
|
||||
end
|
||||
|
||||
def process_bundler
|
||||
#
|
||||
# TODO: have a commaldine option to specify those.
|
||||
# e.g. in mastodon you also want to skip the no_docker and heroku group
|
||||
#
|
||||
bad_groups = [:test, :development]
|
||||
bd=Bundler::Dsl.evaluate('Gemfile', 'Gemfile.lock', {})
|
||||
bd.dependencies.each do |dep|
|
||||
next if (dep.groups - bad_groups).empty?
|
||||
# this skips local deps
|
||||
next if dep.source and not(dep.source.path.nil?)
|
||||
dep.requirement.requirements.each do |req|
|
||||
req_str = rpmify(dep.name, *req)
|
||||
puts "#{@requires_text}%{rubygem #{dep.name}#{req_str}}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def parse_options
|
||||
opt_parser = OptionParser.new do |opts|
|
||||
opts.banner = "Usage: bundlerdumpdeps [options]"
|
||||
|
||||
opts.separator ""
|
||||
opts.separator "Specific options:"
|
||||
|
||||
opts.on('-b', "Buildtime Requires (default)") do
|
||||
@requires_text = "BuildRequires: "
|
||||
end
|
||||
|
||||
opts.on('-r', "Runtime Requires") do |args|
|
||||
@requires_text = "Requires: "
|
||||
end
|
||||
end
|
||||
opt_parser.parse!(ARGV)
|
||||
end
|
||||
|
||||
def expand_pessimistic(version)
|
||||
splitted = version.to_s.split('.')
|
||||
sub_version = nil
|
||||
if splitted.length > 1
|
||||
end_index = splitted.length-1
|
||||
end_index = 3 if end_index > 3
|
||||
sub_version = splitted.slice(0,end_index).join('.')
|
||||
else
|
||||
sub_version = splitted[0]
|
||||
end
|
||||
":#{sub_version} >= #{version}"
|
||||
end
|
||||
|
||||
# (python3-prometheus_client >= 0.4.0 with python3-prometheus_client < 0.9.0)
|
||||
def rpmify(dep_name, op, version)
|
||||
case op
|
||||
when '~>'
|
||||
return expand_pessimistic(version)
|
||||
when '>='
|
||||
if version != Gem::Version.new(0)
|
||||
return " #{op} #{version}"
|
||||
end
|
||||
when '!='
|
||||
return " > #{version}"
|
||||
when '='
|
||||
return " #{op} #{version}"
|
||||
when '<'
|
||||
return " #{op} #{version}"
|
||||
when '<='
|
||||
return " =< #{version}"
|
||||
else
|
||||
STDERR.puts "Unknown operator '#{op}' called with version '#{version}'"
|
||||
exit 1
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
BundlerDumpRpmDeps.new
|
5
g2r
Normal file
5
g2r
Normal file
@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
if [ -e gem2rpm.yml ] ; then
|
||||
cfg="--config gem2rpm.yml"
|
||||
fi
|
||||
exec gem2rpm $cfg -o *spec *gem
|
17
gem_build_cleanup
Normal file
17
gem_build_cleanup
Normal file
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
if [ $# = 1 ] ; then
|
||||
if [ -d "$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 -o -name page\*.ri \) -print0 | xargs -r0 rm -rv || :
|
||||
find $1 -type d -name '.gem.*' -print0 | xargs -r0 rm -rv || :
|
||||
else
|
||||
echo "'$1' does not exists or is not a directory! Exiting." >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Please pass exact one argument to this script! Exiting." >&2
|
||||
exit 1
|
||||
fi
|
285
gem_install.sh
Normal file
285
gem_install.sh
Normal file
@ -0,0 +1,285 @@
|
||||
#!/bin/sh
|
||||
# vim: set sw=2 sts=2 et tw=80 ft=ruby:
|
||||
=begin &>/dev/null
|
||||
# workaround for rubinius bug
|
||||
# https://github.com/rubinius/rubinius/issues/2732
|
||||
export LC_ALL="en_US.UTF-8"
|
||||
export LANG="en_US.UTF-8"
|
||||
shopt -s nullglob
|
||||
for ruby in $(/usr/bin/ruby-find-versioned) ; do
|
||||
$ruby -x $0 "$@"
|
||||
done
|
||||
exit $?
|
||||
=end
|
||||
#!/usr/bin/ruby
|
||||
require 'rbconfig'
|
||||
require 'optparse'
|
||||
require 'optparse/time'
|
||||
require 'ostruct'
|
||||
require 'fileutils'
|
||||
require 'find'
|
||||
require 'tempfile'
|
||||
require 'logger'
|
||||
require 'rubygems'
|
||||
require 'rubygems/package'
|
||||
require 'yaml'
|
||||
begin
|
||||
require 'rubygems/format'
|
||||
rescue LoadError => ex
|
||||
end
|
||||
begin
|
||||
require 'rbconfigpackagingsupport'
|
||||
rescue LoadError => ex
|
||||
end
|
||||
|
||||
options=OpenStruct.new
|
||||
options.defaultgem=nil
|
||||
options.gemfile=nil
|
||||
options.otheropts=nil
|
||||
options.buildroot=nil
|
||||
options.docfiles=[]
|
||||
options.gemname=nil
|
||||
options.gemversion=nil
|
||||
options.gemsuffix=nil
|
||||
options.otheropts=[]
|
||||
options.skipped_docs=['always']
|
||||
options.ua_dir='/etc/alternatives'
|
||||
options.docdir='/usr/share/doc/packages'
|
||||
# once we start fixing packages set this to true
|
||||
options.symlinkbinaries=false
|
||||
options.verbose = false
|
||||
options.rpmsourcedir = ENV['RPM_SOURCE_DIR'] || '/home/abuild/rpmbuild/SOURCES'
|
||||
options.rpmbuildroot = ENV['RPM_BUILD_ROOT'] || '/home/abuild/rpmbuild/BUILDROOT/just-testing'
|
||||
options.parsed_config = nil
|
||||
|
||||
GILogger = Logger.new(STDERR)
|
||||
GILogger.level=Logger::DEBUG
|
||||
def bail_out(msg)
|
||||
GILogger.error(msg)
|
||||
exit 1
|
||||
end
|
||||
|
||||
def patchfile(fname, needle, replace)
|
||||
tmpdir = File.dirname(fname)
|
||||
tmp = Tempfile.new('snapshot', tmpdir)
|
||||
begin
|
||||
stat = File.stat(fname)
|
||||
tmp.chmod(stat.mode)
|
||||
fc = File.read(fname)
|
||||
# fc.gsub!(/^(#!\s*.*?)(\s+-.*)?$/, "#!#{ruby} \2")
|
||||
fc.gsub!(needle, replace)
|
||||
tmp.write(fc)
|
||||
tmp.close
|
||||
File.rename(tmp.path, fname)
|
||||
rescue ArgumentError => ex
|
||||
GILogger.error "Exception while patching '#{fname}'. (#{ex}) Skipping ..."
|
||||
ensure
|
||||
tmp.close
|
||||
end
|
||||
end
|
||||
|
||||
def map_executable(options, executable)
|
||||
if not(options.parsed_config.nil? or
|
||||
options.parsed_config[:binary_map].nil? or
|
||||
options.parsed_config[:binary_map][executable].nil?)
|
||||
executable=options.parsed_config[:binary_map][executable]
|
||||
end
|
||||
executable
|
||||
end
|
||||
|
||||
def initialized_gem2rpm_config(options, name)
|
||||
options.config = name
|
||||
options.parsed_config = YAML.load_file(name)
|
||||
end
|
||||
|
||||
opt_parser = OptionParser.new do |opts|
|
||||
opts.banner = "Usage: gem_install.rb [options]"
|
||||
|
||||
opts.separator ""
|
||||
opts.separator "Specific options:"
|
||||
|
||||
opts.on('--config [FILENAME]', 'path to gem2rpm.yml') do |name|
|
||||
initialized_gem2rpm_config(options, name)
|
||||
end
|
||||
|
||||
opts.on('--default-gem [FILENAME]', 'Which filename to use when we dont find another gem file.') do |fname|
|
||||
options.defaultgem=fname
|
||||
end
|
||||
opts.on('--extconf-opts [EXTOPTS]', 'which options to pass to extconf') do |extopts|
|
||||
options.extconfopts=extopts
|
||||
end
|
||||
opts.on('--gem-binary [PATH]', 'Path to gem. By default we loop over all gem binaries we find') do |fname|
|
||||
GILogger.warn("The --gem-binary option is deprecated.")
|
||||
end
|
||||
opts.on('--doc-files [FILES]', 'Whitespace separated list of documentation files we should link to /usr/share/doc/packages/<subpackage>') do |files|
|
||||
options.docfiles = files.split(/\s+/)
|
||||
end
|
||||
opts.on('--gem-name [NAME]', 'Name of them gem') do |name|
|
||||
options.gemname = name
|
||||
end
|
||||
opts.on('--gem-version [VERSION]', 'Version of them gem') do |version|
|
||||
options.gemversion = version
|
||||
end
|
||||
opts.on('--gem-suffix [SUFFIX]', 'Suffix we should append to the subpackage names') do |suffix|
|
||||
options.gemsuffix = suffix
|
||||
end
|
||||
opts.on('--build-root [BUILDROOT]', 'Path to rpm buildroot') do |buildroot|
|
||||
options.buildroot = buildroot
|
||||
end
|
||||
# Boolean switches
|
||||
opts.on('--[no-]symlink-binaries', 'Create all the version symlinks for the binaries') do |v|
|
||||
options.symlinkbinaries = v
|
||||
end
|
||||
opts.on('-d', 'Forwarded to gem install') do |v|
|
||||
options.otheropts << '-d'
|
||||
end
|
||||
opts.on('-f', 'Forwarded to gem install') do |v|
|
||||
options.otheropts << '-f'
|
||||
end
|
||||
opts.on('-E', 'Forwarded to gem install') do |v|
|
||||
options.otheropts << '-E'
|
||||
end
|
||||
opts.on('--no-ri', 'Forwarded to gem install') do |v|
|
||||
options.skipped_docs << 'ri'
|
||||
end
|
||||
opts.on('-N', '--no-document', 'Forwarded to gem install') do |v|
|
||||
options.skipped_docs << 'ri'
|
||||
options.skipped_docs << 'rdoc'
|
||||
end
|
||||
opts.on('--no-rdoc', 'Forwarded to gem install') do |v|
|
||||
options.skipped_docs << 'rdoc'
|
||||
end
|
||||
opts.separator ""
|
||||
opts.separator "Common options:"
|
||||
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
||||
options.verbose = v
|
||||
end
|
||||
opts.on_tail('-h', '--help', 'Show this message') do
|
||||
puts opts
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
||||
options.otheropts+=opt_parser.parse!(ARGV)
|
||||
GILogger.info "unhandled options: #{options.otheropts.inspect}"
|
||||
if options.gemfile.nil?
|
||||
# we are in /home/abuild/rpmbuild/BUILD/
|
||||
# search for rebuild gem files
|
||||
gemlist = Dir['*/*.gem', '*/*/.gem', "#{options.rpmsourcedir}/*.gem"]
|
||||
if gemlist.empty?
|
||||
bail_out("Can not find any gem file")
|
||||
end
|
||||
options.gemfile = gemlist.first
|
||||
GILogger.info "Found gem #{options.gemfile}"
|
||||
end
|
||||
|
||||
if options.config.nil?
|
||||
name = File.join(options.rpmsourcedir, 'gem2rpm.yml')
|
||||
if File.exist?(name)
|
||||
initialized_gem2rpm_config(options, name)
|
||||
end
|
||||
end
|
||||
|
||||
package = Gem::Package.new(options.gemfile) rescue Gem::Format.from_file_by_path(options.gemfile)
|
||||
spec = package.spec
|
||||
gemdir = File.join(Gem.dir, 'gems', "#{options.gemname}-#{options.gemversion}")
|
||||
# TODO: ruby = "#{File.join(RbConfig::CONFIG['bindir'],RbConfig::CONFIG['ruby_install_name'])}mo"
|
||||
ruby = Gem.ruby
|
||||
gembinary = Gem.default_exec_format % "/usr/bin/gem"
|
||||
|
||||
rubysuffix = Gem.default_exec_format % ''
|
||||
case rubysuffix
|
||||
when /\A\d+.\d+\z/
|
||||
options.rubysuffix = ".ruby#{rubysuffix}"
|
||||
options.rubyprefix = "ruby#{rubysuffix}"
|
||||
when /\A\.(.*)\z/
|
||||
options.rubysuffix = ".#{$1}"
|
||||
options.rubyprefix = $1
|
||||
when ''
|
||||
# TODO: case seems broken
|
||||
rb_ver = RbConfig::CONFIG['ruby_version'].gsub(/^(\d+\.\d+).*$/, "\1")
|
||||
options.rubysuffix = ".ruby#{rb_ver}"
|
||||
options.rubyprefix = "ruby#{rb_ver}"
|
||||
else
|
||||
bail_out "unknown binary naming scheme: #{rubysuffix}"
|
||||
end
|
||||
GILogger.info "Using prefix #{options.rubyprefix}"
|
||||
GILogger.info "Using suffix #{options.rubysuffix}"
|
||||
|
||||
cmdline = [gembinary, 'install', '--verbose', '--local', '--build-root', options.buildroot]
|
||||
cmdline += options.otheropts
|
||||
unless options.skipped_docs.empty?
|
||||
cmdline << '--no-document'
|
||||
end
|
||||
cmdline << options.gemfile
|
||||
unless options.extconfopts.nil?
|
||||
cmdline << '--'
|
||||
cmdline << options.extconfopts
|
||||
end
|
||||
GILogger.info "install cmdline: #{cmdline.inspect}"
|
||||
if Process.respond_to? :spawn
|
||||
pid = Process.spawn(*cmdline)
|
||||
pid, status = Process.wait2(pid)
|
||||
else
|
||||
system(*cmdline)
|
||||
status = $?
|
||||
end
|
||||
exit status.exitstatus unless 0 == status.exitstatus
|
||||
|
||||
rpmname="#{options.rubyprefix}-rubygem-#{options.gemname}#{options.gemsuffix}"
|
||||
GILogger.info "RPM name: #{rpmname}"
|
||||
pwd = Dir.pwd
|
||||
bindir = File.join(options.rpmbuildroot, Gem.bindir)
|
||||
GILogger.info "bindir: #{bindir}"
|
||||
if options.symlinkbinaries && File.exist?(bindir)
|
||||
br_ua_dir = File.join(options.rpmbuildroot, options.ua_dir)
|
||||
GILogger.info "Creating upate-alternatives dir: #{br_ua_dir}"
|
||||
FileUtils.mkdir_p(br_ua_dir)
|
||||
begin
|
||||
Dir.chdir(bindir)
|
||||
GILogger.info "executables: #{spec.executables.inspect}"
|
||||
spec.executables.each do |unversioned|
|
||||
default_path = Gem.default_exec_format % unversioned
|
||||
full_versioned = "#{unversioned}#{options.rubysuffix}-#{spec.version}"
|
||||
ruby_versioned = "#{unversioned}#{options.rubysuffix}"
|
||||
gem_versioned = "#{unversioned}-#{spec.version}"
|
||||
unversioned = map_executable(options, unversioned)
|
||||
File.rename(default_path, full_versioned)
|
||||
patchfile(full_versioned, />= 0(\.a)?/, "= #{options.gemversion}")
|
||||
# unversioned
|
||||
[unversioned, ruby_versioned, gem_versioned].each do |linkname|
|
||||
ua_path = File.join(options.ua_dir, linkname)
|
||||
GILogger.info "Symlinking '#{linkname}' -> '#{ua_path}'"
|
||||
File.symlink(ua_path, linkname) unless File.symlink? linkname
|
||||
end
|
||||
end
|
||||
ensure
|
||||
Dir.chdir(pwd)
|
||||
end
|
||||
end
|
||||
|
||||
# shebang line fix
|
||||
Find.find(File.join(options.buildroot, gemdir)) do |fname|
|
||||
if File.file?(fname) && File.executable?(fname)
|
||||
next if fname =~ /\.so$/
|
||||
GILogger.info "Looking at #{fname}"
|
||||
patchfile(fname, /^(#!\s*.*(?:rub|rbx).*?)(\s+-.*)?$/, "#!#{ruby} \\2")
|
||||
else
|
||||
next
|
||||
end
|
||||
end
|
||||
|
||||
unless options.docfiles.empty?
|
||||
GILogger.info "Linking documentation"
|
||||
docdir = File.join(options.rpmbuildroot, options.docdir, rpmname)
|
||||
FileUtils.mkdir_p(docdir)
|
||||
|
||||
options.docfiles.each do |fname|
|
||||
fullpath = File.join(gemdir, fname)
|
||||
GILogger.info "- #{fullpath}"
|
||||
File.symlink(fullpath, File.join(docdir,fname))
|
||||
end
|
||||
end
|
||||
|
||||
system("chmod -R u+w,go+rX,go-w #{options.rpmbuildroot}")
|
||||
#system("find #{options.rpmbuildroot} -ls")
|
61
gem_packages.sh
Normal file
61
gem_packages.sh
Normal file
@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
# we always start in /home/abuild but in older distros we wouldnt find the sources that way.
|
||||
# switch to /usr/src/packages/
|
||||
if [ ! -d $PWD/rpmbuild ] ; then
|
||||
cd /usr/src/packages/
|
||||
fi
|
||||
shopt -s nullglob
|
||||
# options may be followed by one colon to indicate they have a required argument
|
||||
if ! options=$(getopt -o dEf -l default-gem:,build-root:,gem-name:,gem-version:,gem2rpm-config: -- "$@")
|
||||
then
|
||||
# something went wrong, getopt will put out an error message for us
|
||||
exit 1
|
||||
fi
|
||||
|
||||
eval set -- "$options"
|
||||
|
||||
otheropts="--local -t /usr/lib/rpm/gem_packages.template"
|
||||
defaultgem=
|
||||
buildroot=
|
||||
gemfile=
|
||||
gemname=
|
||||
gemversion=
|
||||
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
case $1 in
|
||||
--default-gem) defaultgem=$2 ; shift;;
|
||||
--gem-name) gemname="$2" ; shift;;
|
||||
--gem-version) gemversion="$2" ; shift;;
|
||||
--build-root) buildroot=$2; shift;;
|
||||
--gem2rpm-config) gem_config=$2; shift;;
|
||||
(--) ;;
|
||||
(-*) otheropts="$otheropts $1";;
|
||||
(*) gemfile=$1; otheropts="$otheropts $1"; break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ "x$gem_config" = "x" ] ; then
|
||||
gem_config=$(find $RPM_SOURCE_DIR -name "*gem2rpm.yml")
|
||||
if [ "x$gem_config" != "x" ] ; then
|
||||
otheropts="$otheropts --config=$gem_config"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "x$gemfile" = "x" ] ; then
|
||||
gemfile=$(find . -maxdepth 2 -type f -name "$defaultgem" -not -path \*/.gem/\* | head -n 1)
|
||||
# if still empty, we pick the sources
|
||||
if [ "x$gemfile" = "x" ] ; then
|
||||
gemfile=$(find $RPM_SOURCE_DIR -name "$defaultgem")
|
||||
fi
|
||||
otheropts="$otheropts $gemfile"
|
||||
fi
|
||||
# workaround for rubinius bug
|
||||
# https://github.com/rubinius/rubinius/issues/2732
|
||||
export LC_ALL="en_US.UTF-8"
|
||||
export LANG="en_US.UTF-8"
|
||||
set -x
|
||||
for gr in $(/usr/bin/ruby-find-versioned gem2rpm) ; do
|
||||
$gr $otheropts
|
||||
done
|
276
gem_packages.spec.erb
Normal file
276
gem_packages.spec.erb
Normal file
@ -0,0 +1,276 @@
|
||||
<%
|
||||
|
||||
begin
|
||||
require 'rbconfigpackagingsupport'
|
||||
rescue LoadError => ex
|
||||
end
|
||||
def self.patch_mod_full_name(path, mod_full_name)
|
||||
path.gsub(/\/-/, "/#{mod_full_name}")
|
||||
end
|
||||
|
||||
def self.patch_libdir(path)
|
||||
# path ? path.gsub(/\/usr\/lib(64)?/, '%{_libdir}') : path
|
||||
path
|
||||
end
|
||||
|
||||
def self.get_extension_doc_dir(gem_spec)
|
||||
return nil unless Gem.ruby_engine == 'ruby' && Gem::Requirement.new("~> 2.1.0").satisfied_by?(Gem.ruby_version)
|
||||
if gem_spec.respond_to?(:extensions_dir)
|
||||
rp = gem_spec.extensions_dir.rpartition(gem_spec.base_dir)
|
||||
return File.join(rp[1], 'doc', rp[2])
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
def self.get_mod_weight(spec)
|
||||
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
|
||||
end
|
||||
|
||||
def self.map_executable(config, executable)
|
||||
if not(config[:binary_map].nil? or
|
||||
config[:binary_map][executable].nil?)
|
||||
executable=config[:binary_map][executable]
|
||||
end
|
||||
executable
|
||||
end
|
||||
|
||||
def self.filecontent_or_value(path)
|
||||
(path and File.exists?(path)) ? File.read(path) : path
|
||||
end
|
||||
|
||||
def self.parse_custom_pkgs(env_value)
|
||||
custom_pkgs = {}
|
||||
if env_value
|
||||
list = env_value.split(/\s+/)
|
||||
list.each do |element|
|
||||
pkg_name,filelist_path, preamble, description = element.split(/\|/, 4)
|
||||
filelist = filecontent_or_value(filelist_path)
|
||||
preamble = filecontent_or_value(preamble)
|
||||
description = filecontent_or_value(description)
|
||||
custom_pkgs[pkg_name] = {
|
||||
"filelist" => filelist,
|
||||
"preamble" => preamble,
|
||||
"description" => description,
|
||||
}
|
||||
end
|
||||
end
|
||||
custom_pkgs
|
||||
end
|
||||
|
||||
rb_pkg_abi = "#{RUBY_ENGINE}:#{RUBY_ENGINE_VERSION}:#{spec.name}"
|
||||
|
||||
rb_suffix = RbConfig::CONFIG['ruby_install_name'].gsub(/^ruby/, '')
|
||||
rb_pkgname = RbConfig::CONFIG['ruby_install_name'].gsub(/^ruby\./, '')
|
||||
if rb_suffix =~ /\A\d+\.\d+\z/
|
||||
rb_suffix = '.ruby' + rb_suffix
|
||||
end
|
||||
pkg_basename = rb_pkgname + '-rubygem-' + spec.name
|
||||
|
||||
mod_full_name = "#{spec.name}-#{spec.version}"
|
||||
mod_weight = get_mod_weight(spec)
|
||||
|
||||
gem_platform = Gem::Platform.new(RbConfig::CONFIG["arch"]).to_s
|
||||
rb_bindir = RbConfig::CONFIG['bindir']
|
||||
rb_sysconfdir = RbConfig::CONFIG['sysconfdir']
|
||||
docdir = '/usr/share/doc/packages'
|
||||
gem_spec = Gem::Specification.new
|
||||
gem_base_dir = patch_libdir(gem_spec.base_dir)
|
||||
gem_cache_dir = patch_libdir(gem_spec.cache_dir)
|
||||
gem_build_info_dir = patch_libdir(gem_spec.build_info_dir)
|
||||
gem_gems_dir = patch_libdir(gem_spec.gems_dir)
|
||||
gem_spec_dir = patch_libdir(gem_spec.spec_dir)
|
||||
gem_bin_dir = patch_libdir(patch_mod_full_name(gem_spec.bin_dir , mod_full_name ))
|
||||
gem_doc_dir = patch_libdir(patch_mod_full_name(gem_spec.doc_dir, mod_full_name ))
|
||||
gem_gem_dir = patch_libdir(patch_mod_full_name(gem_spec.gem_dir, mod_full_name ))
|
||||
gem_ri_dir = patch_libdir(patch_mod_full_name(gem_spec.ri_dir, mod_full_name ))
|
||||
#ruby2.1
|
||||
gem_extensions_dir = gem_spec.respond_to?(:extensions_dir) ? patch_libdir(gem_spec.extensions_dir) : nil
|
||||
gem_extension_dir = gem_spec.respond_to?(:extension_dir) ? patch_libdir(patch_mod_full_name(gem_spec.extension_dir, mod_full_name)) : nil
|
||||
gem_extension_doc = patch_libdir(get_extension_doc_dir(gem_spec))
|
||||
#/ruby2.1
|
||||
gem_plugins_dir = Gem.respond_to?(:plugindir) ? Gem.plugindir : nil
|
||||
has_plugins = gem_plugins_dir && not( spec.files.select {|filename| filename =~ /rubygems_plugin#{Gem.suffix_regexp}\z/ }.empty? )
|
||||
if config[:disable_docs].nil?
|
||||
config[:disable_docs] ||= true
|
||||
end
|
||||
if config[:include_testsuite].nil?
|
||||
config[:include_testsuite] ||= false
|
||||
end
|
||||
%>
|
||||
%package -n <%= pkg_basename %><%= config[:version_suffix] %>
|
||||
# MANUAL
|
||||
<% if config[:main] && config[:main][:preamble] -%>
|
||||
<%= config[:main][:preamble] %>
|
||||
<% end -%>
|
||||
# /MANUAL
|
||||
Summary: <%= config[:summary] or spec.summary %>
|
||||
Group: Development/Languages/Ruby
|
||||
<% unless spec.executables.empty? -%>
|
||||
PreReq: update-alternatives
|
||||
<% end -%>
|
||||
<% if has_plugins -%>
|
||||
Conflicts: rubygem(<%= rb_pkg_abi %>)
|
||||
<% end -%>
|
||||
Enhances: <%= rb_pkgname %>
|
||||
|
||||
%description -n <%= pkg_basename %><%= config[:version_suffix] %>
|
||||
<%= config[:description] or spec.description -%>
|
||||
|
||||
<% if spec.has_rdoc? && !(config[:disable_docs]) -%>
|
||||
%package -n <%= pkg_basename %>-doc<%= config[:version_suffix] %>
|
||||
Summary: RDoc documentation for <%= spec.name %>
|
||||
Group: Development/Languages/Ruby
|
||||
Requires: <%= pkg_basename %><%= config[:version_suffix] %> = <%= spec.version %>
|
||||
|
||||
%description -n <%= pkg_basename %>-doc<%= config[:version_suffix] %>
|
||||
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
|
||||
licence
|
||||
license
|
||||
license-mit
|
||||
mit-license
|
||||
changelog
|
||||
news
|
||||
release_notes
|
||||
readme
|
||||
).each { |file|
|
||||
bpath = path.downcase.gsub(%r{\.rdoc$}, '').gsub(%r{\.txt$}, '').gsub(%r{\.md$}, '').gsub(%r{\.markdown$}, '')
|
||||
#$stderr.puts "PATH #{path} #{bpath} #{file}"
|
||||
docdirfiles << path if bpath == file
|
||||
}
|
||||
end
|
||||
|
||||
test_frameworks = test_frameworks.keys.sort
|
||||
-%>
|
||||
<% unless test_frameworks.empty? -%>
|
||||
%package -n <%= pkg_basename %>-testsuite<%= config[:version_suffix] %>
|
||||
Summary: Test suite for <%= spec.name %>
|
||||
Group: Development/Languages/Ruby
|
||||
Requires: <%= pkg_basename %><%= config[:version_suffix] %> = <%= spec.version %>
|
||||
|
||||
%description -n <%= pkg_basename %>-testsuite<%= config[:version_suffix] %>
|
||||
Test::Unit or RSpec files, useful for developers.
|
||||
|
||||
<% end -%>
|
||||
|
||||
<% unless spec.executables.empty? -%>
|
||||
%post -n <%= pkg_basename %><%= config[:version_suffix] %>
|
||||
<% spec.executables.each do |executable| -%>
|
||||
/usr/sbin/update-alternatives --install \
|
||||
<%= rb_bindir %>/<%= map_executable(config, executable) %> <%= map_executable(config, executable) %> <%= rb_bindir %>/<%= "#{executable}#{rb_suffix}-#{spec.version}" %> <%= mod_weight %>
|
||||
/usr/sbin/update-alternatives --install \
|
||||
<%= rb_bindir %>/<%= "#{executable}-#{spec.version}" %> <%= "#{executable}-#{spec.version}" %> <%= rb_bindir %>/<%= "#{executable}#{rb_suffix}-#{spec.version}" %> <%= mod_weight %>
|
||||
/usr/sbin/update-alternatives --install \
|
||||
<%= rb_bindir %>/<%= "#{executable}#{rb_suffix}" %> <%= "#{executable}#{rb_suffix}" %> <%= rb_bindir %>/<%= "#{executable}#{rb_suffix}-#{spec.version}" %> <%= mod_weight %>
|
||||
<% end -%>
|
||||
|
||||
%preun -n <%= pkg_basename %><%= config[:version_suffix] %>
|
||||
if [ "$1" = 0 ] ; then
|
||||
<% spec.executables.each do |executable| -%>
|
||||
/usr/sbin/update-alternatives --remove <%= map_executable(config, executable) %> <%= rb_bindir %>/<%= "#{executable}#{rb_suffix}-#{spec.version}" %>
|
||||
/usr/sbin/update-alternatives --remove <%= "#{executable}-#{spec.version}" %> <%= rb_bindir %>/<%= "#{executable}#{rb_suffix}-#{spec.version}" %>
|
||||
/usr/sbin/update-alternatives --remove <%= "#{executable}#{rb_suffix}" %> <%= rb_bindir %>/<%= "#{executable}#{rb_suffix}-#{spec.version}" %>
|
||||
<% end -%>
|
||||
fi
|
||||
<% end -%>
|
||||
|
||||
%files -n <%= pkg_basename %><%= config[:version_suffix] %>
|
||||
%defattr(-,root,root,-)
|
||||
# MANUAL
|
||||
<% if config[:main] && config[:main][:filelist] -%>
|
||||
<%= config[:main][:filelist] -%>
|
||||
<% end -%>
|
||||
# /MANUAL
|
||||
<% unless docdirfiles.empty? -%>
|
||||
<%= docdir %>/<%= pkg_basename %><%= config[:version_suffix] %>
|
||||
<% end -%>
|
||||
<% spec.executables.each do |executable| -%>
|
||||
<%= rb_bindir %>/<%= "#{executable}#{rb_suffix}-#{spec.version}" %>
|
||||
<%= rb_bindir %>/<%= "#{executable}#{rb_suffix}" %>
|
||||
<%= rb_bindir %>/<%= "#{executable}-#{spec.version}" %>
|
||||
<%= rb_bindir %>/<%= map_executable(config, executable) %>
|
||||
%ghost <%= rb_sysconfdir %>/alternatives/<%= map_executable(config, executable) %>
|
||||
%ghost <%= rb_sysconfdir %>/alternatives/<%= "#{executable}#{rb_suffix}" %>
|
||||
%ghost <%= rb_sysconfdir %>/alternatives/<%= "#{executable}-#{spec.version}" %>
|
||||
<% end -%>
|
||||
# cache file
|
||||
<%= gem_cache_dir %>/<%= mod_full_name %>.gem
|
||||
<%= gem_gem_dir %>
|
||||
<% if has_plugins -%>
|
||||
<%= gem_plugins_dir %>
|
||||
<% end -%>
|
||||
<%= gem_build_info_dir %>
|
||||
<% unless spec.extensions.empty? or gem_extension_dir.nil? -%>
|
||||
<%= gem_extension_dir %>
|
||||
<% end -%>
|
||||
<% test_frameworks.each do |framework| -%>
|
||||
%exclude <%= File.join gem_gem_dir, framework %>
|
||||
<% end -%>
|
||||
<%= gem_spec_dir %>/<%= mod_full_name -%>.gemspec
|
||||
|
||||
<% if spec.has_rdoc? && !(config[:disable_docs]) -%>
|
||||
%files -n <%= pkg_basename %>-doc<%= config[:version_suffix] %>
|
||||
%defattr(-,root,root,-)
|
||||
%doc <%= gem_doc_dir %>
|
||||
<% unless spec.extensions.empty? or gem_extension_doc.nil? -%>
|
||||
%doc <%= gem_extension_doc %>
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
|
||||
<% if config[:include_testsuite] and !test_frameworks.empty? -%>
|
||||
%files -n <%= pkg_basename %>-testsuite<%= config[:version_suffix] %>
|
||||
%defattr(-,root,root,-)
|
||||
<% test_frameworks.each do |framework| -%>
|
||||
<%= File.join gem_gem_dir, framework %>
|
||||
<% end -%>
|
||||
<% end -%>
|
||||
<%
|
||||
if config[:custom_pkgs_ruby_versioned]
|
||||
config[:custom_pkgs_ruby_versioned].each do |custom_pkg_name, data|
|
||||
-%>
|
||||
%package -n <%= pkg_basename %>-<%= custom_pkg_name %><%= config[:version_suffix] %>
|
||||
<% if data[:preamble] and data[:preamble] != '' -%>
|
||||
<%= data[:preamble] %>
|
||||
<% else %>
|
||||
Summary: <%= custom_pkg_name %> sub package for <%= spec.name %>
|
||||
Group: Development/Languages/Ruby
|
||||
<% end %>
|
||||
Requires: <%= pkg_basename %><%= config[:version_suffix] %> = <%= spec.version %>
|
||||
%description -n <%= pkg_basename %>-<%= custom_pkg_name %><%= config[:version_suffix] %>
|
||||
<% if data[:description] and data[:description] != '' -%>
|
||||
<%= data[:description] %>
|
||||
<% else %>
|
||||
<%= spec.description -%>
|
||||
|
||||
This package holds the <%= custom_pkg_name %> sub package for <%= spec.name -%>
|
||||
<% end %>
|
||||
%files -n <%= pkg_basename %>-<%= custom_pkg_name %><%= config[:version_suffix] %>
|
||||
%defattr(-,root,root,-)
|
||||
<%= data['filelist'] -%>
|
||||
<%
|
||||
end
|
||||
end
|
||||
-%>
|
2
gemfile.attr
Normal file
2
gemfile.attr
Normal file
@ -0,0 +1,2 @@
|
||||
%__gemfile_requires %{_rpmconfigdir}/gemfile.rb --requires
|
||||
%__gemfile_path ^/.*\/Gemfile.lock$
|
44
gemfile.rb
Normal file
44
gemfile.rb
Normal file
@ -0,0 +1,44 @@
|
||||
#!/bin/sh
|
||||
=begin &>/dev/null
|
||||
# workaround for rubinius bug
|
||||
# https://github.com/rubinius/rubinius/issues/2732
|
||||
export LC_ALL="en_US.UTF-8"
|
||||
export LANG="en_US.UTF-8"
|
||||
ruby=""
|
||||
for bundler in $(/usr/bin/ruby-find-versioned bundler) ; do
|
||||
if [ -x "$bundler" ] ; then
|
||||
ruby="${bundler//bundler/ruby}"
|
||||
break
|
||||
fi
|
||||
done
|
||||
exec $ruby -x $0 "$@"
|
||||
=end
|
||||
#!/usr/bin/ruby
|
||||
# vim: set sw=2 sts=2 et tw=80 :
|
||||
require 'bundler'
|
||||
require 'yaml'
|
||||
|
||||
app_info_file=".appinfo.yml"
|
||||
gemfile_lock = STDIN.read.chomp
|
||||
|
||||
appdir = File.dirname(gemfile_lock)
|
||||
Dir.chdir(appdir)
|
||||
|
||||
unless File.exist? app_info_file then
|
||||
STDERR.puts "Warning: Skipping Gemfile.lock without appinfo.yaml file"
|
||||
exit 0
|
||||
end
|
||||
|
||||
app_config =YAML.load_file(app_info_file) || {}
|
||||
ruby_abi=app_config[:ruby_abi]
|
||||
|
||||
if ruby_abi.nil? then
|
||||
STDERR.puts "Error: Can not generate requires without a ruby abi. Skipping."
|
||||
exit 0
|
||||
end
|
||||
|
||||
Bundler.definition.specs.each do |dep|
|
||||
# this skips local deps
|
||||
next if dep.source and dep.source.path?
|
||||
puts "rubygem(#{ruby_abi}:#{dep.name}) = #{dep.version}"
|
||||
end
|
13
gemrc
Normal file
13
gemrc
Normal file
@ -0,0 +1,13 @@
|
||||
---
|
||||
:benchmark: false
|
||||
:install: --format-executable --no-user-install
|
||||
install: --format-executable --no-user-install
|
||||
:backtrace: true
|
||||
:update_sources: true
|
||||
:format_executable: true
|
||||
:verbose: true
|
||||
:update: --format-executable --no-user-install
|
||||
update: --format-executable --no-user-install
|
||||
:bulk_threshold: 1000
|
||||
:sources:
|
||||
- https://rubygems.org
|
212
generate_buildrequires.sh
Normal file
212
generate_buildrequires.sh
Normal file
@ -0,0 +1,212 @@
|
||||
#!/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]
|
||||
case "$1" in
|
||||
[0-9])
|
||||
exit_code="$1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
exit_code=1
|
||||
;;
|
||||
esac
|
||||
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 "$@"
|
137
irp.rb
Normal file
137
irp.rb
Normal file
@ -0,0 +1,137 @@
|
||||
#!/usr/bin/ruby
|
||||
# based on my old shell function:
|
||||
# irp () {
|
||||
# name="$1"
|
||||
# suffix="${3:+-$3}"
|
||||
# versioninfo="${2:+-v $2}"
|
||||
# r="rubygem-$name$suffix"
|
||||
# test -d $r && return 1
|
||||
# mkdir $r
|
||||
# pushd $r
|
||||
# cp ../gem2rpm.yml .
|
||||
# if [ -n "$suffix" ]
|
||||
# then
|
||||
# echo ":version_suffix: '$suffix'" >> gem2rpm.yml
|
||||
# fi
|
||||
# touch ${r}.spec
|
||||
# osc vc -m "initial package"
|
||||
# gem fetch --platform=ruby ${2:+-v $2} $name
|
||||
# gem2rpm --config gem2rpm.yml -o *spec *gem
|
||||
# osc add $PWD
|
||||
# ob-tw && osc ci -m "initial package"
|
||||
# popd
|
||||
# }
|
||||
|
||||
require 'optparse'
|
||||
require 'optparse/time'
|
||||
require 'logger'
|
||||
require 'fileutils'
|
||||
|
||||
class InitializeRubyPackage
|
||||
def initialize()
|
||||
@log = Logger.new(STDERR)
|
||||
@log.level = Logger::INFO
|
||||
@log.info("Welcome to IRP aka initialize ruby package")
|
||||
|
||||
@gem_name, @version_info, @version_suffix = nil
|
||||
@build_repository = 'openSUSE_Tumbleweed'
|
||||
@build_results = '../rpms'
|
||||
|
||||
parse_options
|
||||
check_for_existing
|
||||
smash_and_grab
|
||||
end
|
||||
|
||||
def smash_and_grab
|
||||
initial_message="initial package"
|
||||
@log.info("Now starting real work")
|
||||
FileUtils.mkdir(@package_name)
|
||||
Dir.chdir(@package_name)
|
||||
gem2rpm_yml = "../gem2rpm.yml"
|
||||
if File.exist? gem2rpm_yml
|
||||
@log.info("Found gem2rpm.yml default file. Copying...")
|
||||
fc = File.read(gem2rpm_yml)
|
||||
unless @version_suffix.nil?
|
||||
@log.info("Appending version suffix setting.")
|
||||
fc += ":version_suffix: '-#{@version_suffix}'"
|
||||
end
|
||||
File.write("gem2rpm.yml", fc)
|
||||
end
|
||||
|
||||
@log.debug("Creating empty spec file for g2r")
|
||||
FileUtils.touch("#{@package_name}.spec")
|
||||
@log.debug("Creating initial changes file entry")
|
||||
exec_with_fail(["osc", "vc", "-m", initial_message])
|
||||
gem_fetch_cmdline = ["gem", "fetch", "--platform=ruby"]
|
||||
unless @version_info.nil?
|
||||
gem_fetch_cmdline << '-v'
|
||||
gem_fetch_cmdline << @version_info
|
||||
end
|
||||
gem_fetch_cmdline << @gem_name
|
||||
exec_with_fail(gem_fetch_cmdline)
|
||||
exec_with_fail(["g2r"])
|
||||
exec_with_fail(["osc", "add", Dir.pwd])
|
||||
exec_with_fail(["osc", "ar"])
|
||||
exec_with_fail(["osc", "build", "-p", @build_results, '-k', @build_results, @build_repository])
|
||||
exec_with_fail(["osc", "ci", "-m", initial_message])
|
||||
end
|
||||
|
||||
|
||||
def exit_with_error(error_code, error_message)
|
||||
@log.error(error_message)
|
||||
exit(error_code)
|
||||
end
|
||||
|
||||
def exec_with_fail(cmdline)
|
||||
unless(system(*cmdline))
|
||||
exit_with_error(4, "Executing '#{cmdline.join(' ')}' failed.")
|
||||
end
|
||||
end
|
||||
|
||||
def check_for_existing
|
||||
@log.info("Checking for existing #{@package_name}")
|
||||
if File.directory?(@package_name)
|
||||
exit_with_error(3, "Package #{@package_name} already exists")
|
||||
end
|
||||
end
|
||||
|
||||
def parse_options
|
||||
opt_parser = OptionParser.new do |opts|
|
||||
opts.banner = "Usage: irp [options] [gem name]"
|
||||
|
||||
opts.separator ""
|
||||
opts.separator "Specific options:"
|
||||
|
||||
opts.on('-v [version specifier]', 'see gem fetch -v for the parameters') do |version_info|
|
||||
@version_info = version_info
|
||||
end
|
||||
|
||||
opts.on('-s [package suffix]', 'suffix for the package name') do |suffix|
|
||||
@version_suffix = suffix
|
||||
end
|
||||
|
||||
opts.on('-b [build repository]', "repository to use for the test build - default #{@build_repository}") do |repo|
|
||||
@build_repository = repo
|
||||
end
|
||||
|
||||
opts.on('-p [rpms directory]', "directory for built rpms and preferred rpms. default is #{@build_results}") do |args|
|
||||
@build_results = args
|
||||
end
|
||||
end
|
||||
rest = opt_parser.parse!(ARGV)
|
||||
if rest.size == 0
|
||||
exit_with_error(1, "Missing package name")
|
||||
end
|
||||
if rest.size > 1
|
||||
exit_with_error(2, "Too many parameters: #{rest}")
|
||||
end
|
||||
@gem_name = rest.first
|
||||
@package_name = "rubygem-#{@gem_name}"
|
||||
|
||||
unless @version_suffix.nil?
|
||||
@package_name += "-#{@version_suffix}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
InitializeRubyPackage.new()
|
37
rails.macros
Normal file
37
rails.macros
Normal file
@ -0,0 +1,37 @@
|
||||
%rails_save_gemfile() \
|
||||
cp Gemfile{,.upstream} \
|
||||
mv Gemfile.lock{,.upstream} \
|
||||
%{nil}
|
||||
|
||||
%rails_regen_gemfile_lock() \
|
||||
./bin/bundle exec ./bin/rails --version \
|
||||
diff -urN Gemfile.lock{.upstream,} ||: \
|
||||
%{nil}
|
||||
|
||||
%rails_write_appinfo() \
|
||||
echo -e "---\\\n:ruby_abi: %{rb_build_abi}\\\n" > .appinfo.yml \
|
||||
%{nil}
|
||||
|
||||
%rails_fix_ruby_shebang() \
|
||||
for S in $(grep -l '#!.*ruby' %* ) ; do \
|
||||
SB="${S}.backup" \
|
||||
cp ${S} ${SB} \
|
||||
perl -p -i -e 's|#!/usr/bin/env ruby|#!%{_bindir}/ruby.%{rb_suffix}|g' $S \
|
||||
diff -urN ${SB} ${S} || : \
|
||||
rm ${SB} \
|
||||
done \
|
||||
%{nil}
|
||||
|
||||
%rails_fix_ruby_suffix() \
|
||||
for S in $(grep -r -l '@RUBY_SUFFIX@' ${RPM_SOURCE_DIR}/ | grep -v '\.spec$') ; do \
|
||||
SB="${S}.backup" \
|
||||
cp ${S} ${SB} \
|
||||
perl -p -i -e 's|\\\@RUBY_SUFFIX\\\@|%{rb_suffix}|g' "${S}" \
|
||||
diff -urN ${SB} ${S} || : \
|
||||
rm ${SB} \
|
||||
done \
|
||||
%{nil}
|
||||
|
||||
%ruby_fix_shebang() \
|
||||
%{nil} \
|
||||
%{nil}
|
838
ruby-common.changes
Normal file
838
ruby-common.changes
Normal file
@ -0,0 +1,838 @@
|
||||
-------------------------------------------------------------------
|
||||
Sun May 7 00:35:06 UTC 2023 - Marcus Rueckert <mrueckert@suse.de>
|
||||
|
||||
- cleanup irp code
|
||||
- unify error handling using the exit_with_error function
|
||||
- ensure we add generated files
|
||||
- checkin the newly created package
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Mar 21 22:42:33 UTC 2023 - Marcus Rueckert <mrueckert@suse.de>
|
||||
|
||||
- move new tools into a subpackage ruby-packaging-helpers to avoid
|
||||
dependency to /usr/bin/ruby
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Mar 21 18:35:40 UTC 2023 - Marcus Rueckert <mrueckert@suse.de>
|
||||
|
||||
- Add 2 new utilities
|
||||
- irp aka initialize ruby package
|
||||
does exactly what the name says. does all the work to
|
||||
initialize a new ruby package
|
||||
- bundler-dumpdeps: script to generate BR/Requires based on a
|
||||
Gemfile.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Feb 9 16:50:32 UTC 2023 - Marcus Rueckert <mrueckert@suse.de>
|
||||
|
||||
- do not rely on file dependencies for getopt
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Nov 17 12:01:35 UTC 2022 - Marcus Rueckert <mrueckert@suse.de>
|
||||
|
||||
- actually bump the version so we can require the newer version for
|
||||
ruby3.2
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Nov 17 11:49:44 UTC 2022 - Marcus Rueckert <mrueckert@suse.de>
|
||||
|
||||
- replace `File.exists?` with `File.exist?` as the `File.exists?`
|
||||
is no longer supported in 3.2
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sat Aug 20 11:19:16 UTC 2022 - Marcus Rueckert <mrueckert@suse.de>
|
||||
|
||||
- in the dependency generator for Gemfile.lock we now skip vendored
|
||||
deps
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Jun 13 11:43:30 UTC 2022 - Marcus Rueckert <mrueckert@suse.de>
|
||||
|
||||
- make %gem_unpack and %gem_build work when the default system ruby
|
||||
is not installed:
|
||||
|
||||
both macros now use the %{gem_binary} define and we have a common
|
||||
macro %{set_gem_binary} to set this variable. the set macro will
|
||||
use the ruby-find-versioned to find a versioned version of gem.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Feb 23 22:30:46 UTC 2022 - Dirk Müller <dmueller@suse.com>
|
||||
|
||||
- avoid bashism in gem_build_cleanup
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Aug 24 06:46:07 UTC 2021 - Stephan Kulow <coolo@suse.com>
|
||||
|
||||
- Do not create links in /etc/alternatives at all - they are ghosts
|
||||
and rpm database will only be confused if we have some wrong
|
||||
information about them (the link target is defined at runtime)
|
||||
|
||||
This aligns with ruby2.7 package to avoid file conflicts about
|
||||
bundler and other built in gems
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Jul 8 12:10:25 UTC 2021 - Stephan Kulow <coolo@suse.com>
|
||||
|
||||
- Fix the links in /etc/alternatives not to point to themselves
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Jan 26 01:46:30 UTC 2021 - Marcus Rueckert <mrueckert@suse.de>
|
||||
|
||||
- cleanup the .gem.* dirs that rubygems creates on 3.0
|
||||
(boo#1180528)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Jan 25 18:39:35 UTC 2021 - Marcus Rueckert <mrueckert@suse.de>
|
||||
|
||||
- add support to package rubygems plugin dirs
|
||||
as the file is conflicting you can only have one version of the
|
||||
same gem installed if it provides a rubygems plugin. at least for
|
||||
now
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Sep 9 11:51:22 UTC 2019 - chris@computersalat.de
|
||||
|
||||
- fix build for SLE 12 / Leap 42
|
||||
* add define _rpmmacrodir /etc/rpm
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri May 10 09:26:26 UTC 2019 - Dominique Leuenberger <dimstar@opensuse.org>
|
||||
|
||||
- Move RPM macros to %_rpmmacrodir.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sun May 5 00:09:49 UTC 2019 - Marcus Rueckert <mrueckert@suse.de>
|
||||
|
||||
- disable docs and testsuite packaging by default
|
||||
- support --no-document option
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Feb 7 20:30:00 UTC 2019 - Marcus Rueckert <mrueckert@suse.de>
|
||||
|
||||
- rails.macros: add macro to fix ruby shebang line
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Feb 7 20:00:55 UTC 2019 - Marcus Rueckert <mrueckert@suse.de>
|
||||
|
||||
- rails.macros: always use ./bin/* stubs for calling binaries
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Jan 30 14:54:03 UTC 2019 - Marcus Rueckert <mrueckert@suse.de>
|
||||
|
||||
- do not try to delete git files in the rails macros
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Dec 21 16:44:00 UTC 2018 - Marcus Rueckert <mrueckert@suse.de>
|
||||
|
||||
- --no-rdoc/--no-ri are obsolete in, if we get it passed in convert
|
||||
them to --no-document
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Jun 6 15:11:27 UTC 2018 - mrueckert@suse.de
|
||||
|
||||
- rename the gem_packages template from opensuse.spec.erb to
|
||||
gem_packages.spec.erb
|
||||
- add support for binary_map flag in gem2rpm.yml
|
||||
- This can be used to rename the _unversioned_ symlink of the
|
||||
binaries in /usr/bin/ to avoid conflicts with other packages
|
||||
- gem_packages.spec.erb: sync with file in gem2rpm
|
||||
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Jan 24 16:13:42 UTC 2018 - lnussel@suse.de
|
||||
|
||||
- generate bundled(rubygem($name)) = $version provides for bundled
|
||||
gems in the vendor directory.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Dec 12 13:30:27 UTC 2017 - mrueckert@suse.de
|
||||
|
||||
- switch requires of the autogenerated subpackages from
|
||||
rb_suffix-rubygem-gemname = version to
|
||||
rubygem(rb_abi:gemname) = version
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Nov 30 03:40:08 UTC 2017 - mrueckert@suse.de
|
||||
|
||||
- split our the rails part
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Nov 30 03:25:39 UTC 2017 - mrueckert@suse.de
|
||||
|
||||
- we need bundler now. given ruby 2.5 will have it intree anyway,
|
||||
this soon wont be a big burden.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Nov 30 02:40:03 UTC 2017 - mrueckert@suse.de
|
||||
|
||||
- add support to generate requires from Gemfile.lock
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Aug 7 10:20:07 UTC 2017 - mrueckert@suse.de
|
||||
|
||||
- package the buildinfo dir
|
||||
- allow passing options to extconf.rb
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Jun 13 21:11:20 UTC 2017 - bwiedemann@suse.com
|
||||
|
||||
- Call fdupes -o name to make sure we always create symlinks
|
||||
in the same direction to make builds reproducible
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Mar 1 01:01:56 UTC 2016 - mrueckert@suse.de
|
||||
|
||||
- Since rubygems 2.5.0 the default version in the gem bin stub
|
||||
changed from '>= 0' to '>= 0.a'. This was done to allow
|
||||
prerelease versions. Our patching script didn't take the '.a'
|
||||
into account and generated version fields like '= 0.10.1.a'
|
||||
instead of the expected '= 0.10.1'. This fix accounts for the
|
||||
'.a'.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Jun 11 14:33:37 UTC 2015 - lnussel@suse.de
|
||||
|
||||
- help the solver to pick the right gem2rpm for the default ruby
|
||||
version (bnc#934328)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sat May 2 11:55:31 UTC 2015 - mrueckert@suse.de
|
||||
|
||||
- Fix patching of the shebang line
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Apr 16 21:45:29 UTC 2015 - mrueckert@suse.de
|
||||
|
||||
- The script sometimes returned from gem install already although
|
||||
the install wasn't finished yet. This broke e.g. the binary
|
||||
rename part.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 13 18:20:33 UTC 2015 - mrueckert@suse.de
|
||||
|
||||
- Fail early if gem install fails
|
||||
This avoids confusing error messages at the end of the build.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 13 14:56:55 UTC 2015 - mrueckert@suse.de
|
||||
|
||||
- More fixes for ruby 1.8
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 13 14:06:32 UTC 2015 - mrueckert@suse.de
|
||||
|
||||
- Ruby 1.8 insists on the () for the parameter
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 13 13:55:20 UTC 2015 - mrueckert@suse.de
|
||||
|
||||
- Cleaner solution for the extensions doc dir
|
||||
The other solution was also failing on 1.8
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 13 13:28:52 UTC 2015 - mrueckert@suse.de
|
||||
|
||||
- Forgot another option for forwarding
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 13 09:19:52 UTC 2015 - mrueckert@suse.de
|
||||
|
||||
- Do not overwrite options.otheropts
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 13 02:48:50 UTC 2015 - mrueckert@suse.de
|
||||
|
||||
- Fixed forwarding of options to gem install
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 13 02:26:12 UTC 2015 - mrueckert@suse.de
|
||||
|
||||
- Only use the extensions doc dir on MRI 2.1.x
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 13 01:58:02 UTC 2015 - mrueckert@suse.de
|
||||
|
||||
- Fix the ruby suffix for distributions before 13.2
|
||||
- Do not fail with --gem-binary
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 13 01:28:08 UTC 2015 - mrueckert@suse.de
|
||||
|
||||
- switch to ruby version of gem_install.sh
|
||||
- added ruby-find-versioned to make it easier to find versioned
|
||||
binaries.
|
||||
- all for loops in the shell scripts and macros are now using
|
||||
this script
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Mar 12 16:17:20 UTC 2015 - mrueckert@suse.de
|
||||
|
||||
- call ruby with -x from shell wrappers otherwise we run into an
|
||||
endless loop
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Jan 15 10:59:59 UTC 2015 - dmueller@suse.com
|
||||
|
||||
- rubygemsdeps.rb: add shell-launcher to avoid dependency on
|
||||
a fixed ruby version
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Jan 13 17:01:02 UTC 2015 - dmueller@suse.com
|
||||
|
||||
- gem_install.sh: fix ruby shebang patching
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sat Nov 15 23:46:00 UTC 2014 - Led <ledest@gmail.com>
|
||||
|
||||
- fix bashisms in generate_buildrequires.sh script
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Oct 21 15:50:45 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- restore changes lost by the previous change
|
||||
- load rbconfigpackagingsupport if available and fail gracefully
|
||||
if not.
|
||||
- dont use not() it breaks the build on 1.8
|
||||
- remove requires onto the ruby version
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sat Oct 18 05:37:19 UTC 2014 - coolo@suse.com
|
||||
|
||||
- update gem_packages template from git
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Sep 29 21:11:08 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- ignore any files we find in */.gem/*. in some versions of
|
||||
rubygems, gems that are installed are also copied to ~/.gem/.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Sep 26 21:53:30 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- we dont always have /usr/bin/ruby, use perl for patching the
|
||||
version in the bin wrapper. also replaced the sed for patching
|
||||
the shebang line.
|
||||
- fixed a bad bug in the shebang line. we had an additional "."
|
||||
there.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Sep 26 21:22:24 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- install gemrc on all distros
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Sep 26 10:30:56 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- dont delete .a files. there are actually gems where we need them
|
||||
like rubygem-libv8 for rubygem-therubyracer
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Sep 23 15:31:56 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- fix the case where we dont symlink the binaries.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Sep 19 15:10:30 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- gem_cleanup macro was missed when updating for old ruby versions.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Sep 19 14:46:08 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- switch from "ruby -rrubygems -e
|
||||
'print Gem::Specification.new.base_dir'"
|
||||
to "gem env gemdir"
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Sep 19 10:35:57 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- gem_build_cleanup: also delete static library files
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Sep 17 16:33:06 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- ruby 1.8 support:
|
||||
- gem_packages.sh: change to /usr/src/packages when
|
||||
/home/abuild/rpmbuild doesn't exist.
|
||||
- gem_packages template:
|
||||
- require rbconfigpackagingsupport to fix the ruby_install_name
|
||||
dependent variables. we do that for all distros but catch the
|
||||
LoadError and continue.
|
||||
- and dont use not(), we need to use "!" instead.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Sep 17 16:07:09 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- our sle 11 sp3 rpm does provide the support for the automatic
|
||||
rubygems dependency but does not provide
|
||||
rpm-with-ruby-provide-hook. guard the requires with > 1110
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Sep 17 15:56:49 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- remove the handling of spec.required_ruby_version here. this
|
||||
should be handled in rubygemsdeps.rb if at all. we already guard
|
||||
for this in the buildrequires and then have a requires via the
|
||||
$interpreter(abi) requires onto the newer version.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Sep 17 15:32:46 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- invert the logic. only stop shipping /etc/gemrc on 12.3 and 13.1
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Sep 17 15:02:38 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- gem_packages template:
|
||||
Dont allow an suffix with just a plain number. prefix it with
|
||||
ruby.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Sep 17 14:30:49 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- gem_packages also need the rewrite that rewrites a number only
|
||||
suffix into .ruby<numbersuffix>
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Sep 17 13:53:09 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- made the matcher for older versions more strict so we dont pick
|
||||
up gem2rpm.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Sep 17 13:48:54 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- also add support for older versioning in gem_packages.sh
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Sep 17 13:28:15 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- added support for the versioning scheme in 13.1 and older
|
||||
- dont ship gemrc on 13.1
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Sep 15 14:31:22 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- the ruby(abi) = $interpreter:$abiversion was not a good idea. rpm
|
||||
treats the $interpreter part as epoch. instead we use now:
|
||||
$interpreter(abi) = $abiversion
|
||||
|
||||
For MRI it means we are basically back to ruby(abi).
|
||||
Examples for alternative ruby interpreters are rubinius(abi) and
|
||||
jruby(abi) (bnc#896658)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Sep 8 13:03:41 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- disable extensions doc dir on rubinius
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Sep 8 12:29:02 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- workaround https://github.com/rubinius/rubinius/issues/2732
|
||||
for UTF8 locale in gem_packages.sh
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Sep 4 09:12:25 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- we actually need the splitted version in any case. uncomment it
|
||||
again
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Sep 3 13:24:22 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- pass the ruby abi as hash containing :interpreter, :version,
|
||||
:abi as keys. that way we have the full new string but also the
|
||||
version for the 1.8 support
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Sep 3 12:32:35 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- rubygemsdeps.rb:
|
||||
- make the provides/requires also include the ruby interpreter
|
||||
- no longer emit the old package name style provides
|
||||
- rubygems.attr:
|
||||
- make the path a bit more relaxed so we can match other ruby
|
||||
interpreter too
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Jul 16 17:29:51 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- added ruby-common.macros:
|
||||
Holds the common macros for the rpm macro based buildrequires.
|
||||
- merged ruby.macros into ruby.rpm-macros:
|
||||
the later file now carries the rb_* and gem_* macros
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Jul 15 18:37:28 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- ruby.macros: drop the duplicate gem macros
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Jul 15 17:16:19 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- fix small typo in opensuse.spec.erb which broke the formatting.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Jul 15 14:25:35 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- no longer require ruby(-devel). ruby-common is required by
|
||||
rubyX.Y so we should always be installed and this breaks a small
|
||||
loop
|
||||
- opensuse.spec.erb
|
||||
- no longer require the plain ruby package but the versioned
|
||||
named
|
||||
- handle disable_doc and no longer build subpackages for rdoc
|
||||
documentation in that case.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Jul 11 08:12:11 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- remove the set -x from gem_install
|
||||
- moved set -x in gem_packages to the interesting part only
|
||||
- the gem packages template only handles custom_pkgs_ruby_versioned
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Jul 10 15:35:47 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- make use of config file support in gem2rpm (gem2rpm.yml)
|
||||
- gem_install.sh
|
||||
- drop gem-filelist-append and gem-custom-packages params
|
||||
- removed unneeded "-" when appending gem_version_suffix
|
||||
- gem_packages.sh
|
||||
- drop gem-suffix, gem-filelist-append and gem-custom-packages
|
||||
params
|
||||
- added gem2rpm-config param
|
||||
- added code to find gem2rpm.yml in RPM_SOURCE_DIR
|
||||
- opensuse.spec.erb
|
||||
- no longer get variables from the env. this is handled by the
|
||||
config file now
|
||||
- implemented all the gem2rpm.yml hooks
|
||||
- ruby.rpm-macros
|
||||
- removed usage of dropped cmdline arguments
|
||||
- pass mod_version_suffix to gem_install.sh
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Jul 10 14:48:10 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- pass the output of gem_packages through %{expand} so macros and
|
||||
so on work.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Jun 25 19:05:31 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- in the past we had a few spec files were we manually patched the
|
||||
version in the binary wrapper from ">= 0" to "= %version"
|
||||
do this in gem install now.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Jun 25 17:24:36 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- do not have the expanded version of rubygem(gem2rpm) in the spec
|
||||
file. moved to project config.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Jun 25 17:08:30 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- adapt the symlink handling:
|
||||
We will us the versioned names in /etc/alternatives now instead of
|
||||
mapping everything to /etc/alternatives/$binaryname.
|
||||
|
||||
That means we will get:
|
||||
/usr/bin/$binaryname$rubysuffix /etc/alternatives/$binaryname$rubysuffix
|
||||
/usr/bin/$binaryname-$gemversion /etc/alternatives/$binaryname-$gemversion
|
||||
/usr/bin/$binaryname /etc/alternatives/$binaryname
|
||||
|
||||
The subpackage template and gem_install.sh script got adopted to
|
||||
this.
|
||||
- no longer patch files in $buildroot/usr/bin/.
|
||||
If we patch files there, we break the binaries for older ruby
|
||||
versions. we limit the search path to the gem dir.
|
||||
- loop over each gem directory in gem_cleanup macro. so far we only
|
||||
cleaned up the gems for the default ruby
|
||||
- add requires for fdupes. one of the macro is using it.
|
||||
- bump rpm_macros_version to 5
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Jun 25 16:26:58 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- really make gem_install.sh work with more than one ruby version
|
||||
- use pushd/popd instead of cd when creating the symlinks
|
||||
- only create the generic symlinks if they dont exists already
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Jun 23 16:02:37 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- added 2 new options to gem_packages.sh
|
||||
- --gem-filelist-append="arg"
|
||||
This can be either a string or a filename to a filelist that
|
||||
will be appended to the versioned main package
|
||||
- --gem-custom-packages="name|filelist[|preamble[|description]]"
|
||||
filelist, preamble and description can be either filenames or
|
||||
the actual value.
|
||||
|
||||
to use both from the spec file you need to use
|
||||
%define gem_custome_packages ...
|
||||
%define gem_filelist_append ...
|
||||
|
||||
important if you use the filename option, you need to call the
|
||||
tools to generate the files with %(....) so the files are
|
||||
actually available at the time when gem_packages is run. The tool
|
||||
is called at the very beginning of the build, even before %prep.
|
||||
- update the gem_packages template to handle those 2 options and
|
||||
also the --gem-suffix option.
|
||||
they are all passed via environment variables for now.
|
||||
- bumped the rpm_macro_version to 4
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Jun 19 23:31:21 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- as it turns out gem_build_complete_path files are important.
|
||||
Do not delete them in the cleanup script.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Jun 18 18:44:33 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- added gem_packages macro and implementation
|
||||
- fix shebang patching in gem_install
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Jun 18 16:11:07 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- if we dont use --symlink-binaries, let's undo the
|
||||
--format-executable, that we we break less packages
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Jun 18 15:53:28 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- added --symlink-binaries option to gem_install.sh:
|
||||
instead of breaking all the existing rubygem packages lets pass
|
||||
this option until we have all packages fixed and we can turn it
|
||||
on by default
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Jun 18 15:17:28 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- a lot of additions to the gem_install.sh
|
||||
* --doc-files="..." - which files relatively to the installed gem
|
||||
directory should be symlinked to /usr/share/doc/packages/rpmname
|
||||
-> you can move the manual linking of documentation files to
|
||||
the --doc-files option
|
||||
* --gemsuffix="suffix" - if you need more than one version of the
|
||||
same gem.
|
||||
* all the symlinks for the different versioned files are not
|
||||
generated following the same rules that the template is using.
|
||||
-> you can remove the manual code from the spec file
|
||||
- enable format-executable again in the global gemrc
|
||||
- pass gem name and version from the %gem_install macro to the
|
||||
gem_install.sh, avoids parsing the gem file name in the shell
|
||||
script.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Jun 17 19:48:28 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- added opensuse.spec.erb this gem2rpm template should be later
|
||||
used by the gem_packages macro to create the needed file and
|
||||
package sections
|
||||
- make gem_install.sh loop over all /usr/bin/gem[1-9]*
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Jun 17 13:08:35 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- added more patterns to the cleanup script for ruby 2.1
|
||||
- gem.build_complete
|
||||
- page\*.ri
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sun Jun 15 18:55:34 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- installed the wrong file as gemrc
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sat Jun 14 14:55:22 UTC 2014 - mrueckert@suse.de
|
||||
|
||||
- merge files from the ruby 2.1 package
|
||||
- moved gemrc from the ruby wrapper package
|
||||
-------------------------------------------------------------------
|
||||
Tue Apr 29 22:09:38 BST 2014 - aspiers@suse.com
|
||||
|
||||
- eliminate "useless-provides rubygem-foo" rpmlint warning for
|
||||
every gem: "Provides: rubygem-foo = 1.2.3" is not required
|
||||
because rpm implicitly adds "Provides: rubygem-foo = 1.2.3-4"
|
||||
|
||||
-------------------------------------------------------------------
|
||||
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
|
||||
|
||||
- replace all */ruby with /usr/bin/ruby
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Jul 27 14:03:05 UTC 2012 - coolo@suse.com
|
||||
|
||||
- replace /usr/local/bin/ruby with /usr/bin/ruby - a very often mistake
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Jul 26 11:13:13 UTC 2012 - coolo@suse.com
|
||||
|
||||
- fix ruby provides/requires with ruby 1.8
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Jul 26 10:28:30 UTC 2012 - coolo@suse.com
|
||||
|
||||
- old gems do not have a gem unpack --spec, so use gem specification
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Jul 26 09:28:51 UTC 2012 - coolo@suse.com
|
||||
|
||||
- catch unspecified gem_binary
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Jul 26 07:19:37 UTC 2012 - coolo@suse.com
|
||||
|
||||
- split from ruby package for easier backporting
|
||||
|
23
ruby-common.macros
Normal file
23
ruby-common.macros
Normal file
@ -0,0 +1,23 @@
|
||||
#
|
||||
# IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT
|
||||
#
|
||||
# if you change any macros here you have to update the copy in the
|
||||
# prjconf aswell.
|
||||
#
|
||||
# IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT IMPORTANT
|
||||
#
|
||||
%rubygem() %{expand:%%{rubygems%rb_build_versions STOP %*}}
|
||||
%rubygemsSTOP() %nil
|
||||
%rubygemsxSTOP() %{expand:%%rubygemsxxSTOP -a %*}
|
||||
%rubygemsxxSTOP(a:) %{-a*}) %*
|
||||
|
||||
%rubySTOP() %nil
|
||||
%rubyxSTOP() %*
|
||||
|
||||
%ruby() %{expand:%%{ruby%rb_build_versions STOP %*}}
|
||||
|
||||
%rubydevel() %{expand:%%{rubydevel%rb_build_versions STOP %*}}
|
||||
|
||||
%rubydevelSTOP() %nil
|
||||
%rubydevelxSTOP() %*
|
||||
#
|
154
ruby-common.spec
Normal file
154
ruby-common.spec
Normal file
@ -0,0 +1,154 @@
|
||||
#
|
||||
# spec file for package ruby-common
|
||||
#
|
||||
# Copyright (c) 2023 SUSE LLC
|
||||
#
|
||||
# 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/
|
||||
#
|
||||
|
||||
|
||||
### seems that %{_rpmmacrodir} is not known on SLE 12 / Leap 42
|
||||
%if 0%{?suse_version} == 1315
|
||||
%define _rpmmacrodir /etc/rpm
|
||||
%endif
|
||||
|
||||
Name: ruby-common
|
||||
Version: 3.2
|
||||
Release: 0
|
||||
# ruby-macros and ruby-common version
|
||||
%define rpm_macros_version 5
|
||||
%if 0
|
||||
%bcond_with ship_gemrc
|
||||
%else
|
||||
%bcond_without ship_gemrc
|
||||
%endif
|
||||
Source1: gem_build_cleanup
|
||||
Source2: gemrc
|
||||
Source4: rubygems.attr
|
||||
Source5: rubygemsdeps.rb
|
||||
Source6: gem_install.sh
|
||||
Source7: generate_buildrequires.sh
|
||||
Source8: ruby-common.macros
|
||||
Source9: ruby.rpm-macros
|
||||
Source10: gem_packages.sh
|
||||
Source11: gem_packages.spec.erb
|
||||
Source12: ruby-find-versioned
|
||||
Source13: gemfile.attr
|
||||
Source14: gemfile.rb
|
||||
Source15: rails.macros
|
||||
Source16: g2r
|
||||
Source17: rubygems_bundled.attr
|
||||
Source18: irp.rb
|
||||
Source19: bundler-dumpdeps
|
||||
Summary: Collection of scripts and macros for ruby packaging
|
||||
License: MIT
|
||||
Group: Development/Languages/Ruby
|
||||
URL: https://github.com/openSUSE/ruby-packaging/
|
||||
Requires: /usr/bin/getopt
|
||||
Requires: rubygem(gem2rpm)
|
||||
Recommends: rubygem(%{rb_default_ruby_abi}:gem2rpm)
|
||||
Requires: fdupes
|
||||
BuildArch: noarch
|
||||
Provides: ruby-macros = %{rpm_macros_version}
|
||||
%if 0%{?suse_version} < 1140 && 0%{?suse_version} > 1110
|
||||
# we need a patched rpm
|
||||
Requires: rpm-with-ruby-provide-hook
|
||||
%endif
|
||||
# for getopt
|
||||
Requires: util-linux
|
||||
|
||||
%description
|
||||
This package is needed for (generated) ruby gems. It provides hooks for
|
||||
automatic rpm provides and requires and macros that gem2rpm uses.
|
||||
|
||||
%package rails
|
||||
Requires: rubygem(bundler)
|
||||
Recommends: rubygem(%{rb_default_ruby_abi}:bundler)
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
|
||||
Summary: Rails packaging support
|
||||
Group: Development/Languages/Ruby
|
||||
|
||||
%description rails
|
||||
This package is needed for (generated) ruby gems. It provides hooks for
|
||||
automatic rpm provides and requires and macros that gem2rpm uses.
|
||||
|
||||
Rails packaging support files.
|
||||
|
||||
%package -n ruby-packaging-helpers
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
|
||||
Summary: Ruby packaging helpers
|
||||
Group: Development/Languages/Ruby
|
||||
|
||||
%description -n ruby-packaging-helpers
|
||||
This package is needed for (generated) ruby gems. It provides hooks for
|
||||
automatic rpm provides and requires and macros that gem2rpm uses.
|
||||
|
||||
Some helper tools for packaging rubygems and rails apps.
|
||||
|
||||
%prep
|
||||
|
||||
%build
|
||||
|
||||
%install
|
||||
# we need to make sure it overwrites older macro versions and rpm sorts alphabetically
|
||||
%if %{with ship_gemrc}
|
||||
install -D -m 0644 %{S:2} %{buildroot}/etc/gemrc
|
||||
%endif
|
||||
install -D -m 0644 %{S:8} %{buildroot}%{_rpmmacrodir}/macros.ruby-common
|
||||
install -D -m 0644 %{S:9} %{buildroot}%{_rpmmacrodir}/macros.suse-ruby
|
||||
install -D -m 0644 %{S:4} %{buildroot}/usr/lib/rpm/fileattrs/rubygems.attr
|
||||
install -D -m 0755 %{S:5} %{buildroot}/usr/lib/rpm/rubygemsdeps.rb
|
||||
install -D -m 0755 %{S:6} %{buildroot}/usr/lib/rpm/gem_install.sh
|
||||
install -D -m 0755 %{S:1} %{buildroot}/usr/lib/rpm/gem_build_cleanup.sh
|
||||
install -D -m 0755 %{S:7} %{buildroot}/usr/lib/rpm/generate_buildrequires.sh
|
||||
install -D -m 0755 %{S:10} %{buildroot}/usr/lib/rpm/gem_packages.sh
|
||||
install -D -m 0644 %{S:11} %{buildroot}/usr/lib/rpm/gem_packages.template
|
||||
install -D -m 0755 %{S:12} %{buildroot}%{_bindir}/ruby-find-versioned
|
||||
install -D -m 0644 %{S:13} %{buildroot}/usr/lib/rpm/fileattrs/gemfile.attr
|
||||
install -D -m 0755 %{S:14} %{buildroot}/usr/lib/rpm/gemfile.rb
|
||||
install -D -m 0644 %{S:15} %{buildroot}%{_rpmmacrodir}/macros.rails
|
||||
install -D -m 0755 %{S:16} %{buildroot}%{_bindir}/g2r
|
||||
install -D -m 0755 %{S:18} %{buildroot}%{_bindir}/irp
|
||||
install -D -m 0755 %{S:19} %{buildroot}%{_bindir}/bundler-dumpdeps
|
||||
install -D -m 0644 %{S:17} %{buildroot}/usr/lib/rpm/fileattrs/rubygems_bundled.attr
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%if %{with ship_gemrc}
|
||||
%config /etc/gemrc
|
||||
%endif
|
||||
%{_rpmmacrodir}/macros.*ruby*
|
||||
%dir /usr/lib/rpm/fileattrs
|
||||
/usr/lib/rpm/fileattrs/rubygems.attr
|
||||
/usr/lib/rpm/fileattrs/rubygems_bundled.attr
|
||||
/usr/lib/rpm/rubygemsdeps.rb
|
||||
/usr/lib/rpm/gem_install.sh
|
||||
/usr/lib/rpm/gem_build_cleanup.sh
|
||||
/usr/lib/rpm/generate_buildrequires.sh
|
||||
/usr/lib/rpm/gem_packages.*
|
||||
%{_bindir}/ruby-find-versioned
|
||||
%{_bindir}/g2r
|
||||
|
||||
%files -n ruby-packaging-helpers
|
||||
%defattr(-,root,root)
|
||||
%{_bindir}/irp
|
||||
%{_bindir}/bundler-dumpdeps
|
||||
|
||||
%files rails
|
||||
%defattr(-,root,root)
|
||||
%{_rpmmacrodir}/macros.rails
|
||||
/usr/lib/rpm/fileattrs/gemfile.attr
|
||||
/usr/lib/rpm/gemfile.rb
|
||||
|
||||
%changelog
|
7
ruby-find-versioned
Normal file
7
ruby-find-versioned
Normal file
@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
shopt -s nullglob
|
||||
binary="ruby"
|
||||
if [ "x$1" != "x" ] ; then
|
||||
binary="$1"
|
||||
fi
|
||||
ls -1 /usr/bin/$binary.{ruby,rbx,jruby}[0-9].[0-9] /usr/bin/$binary[0-9].[0-9]
|
105
ruby.rpm-macros
Normal file
105
ruby.rpm-macros
Normal file
@ -0,0 +1,105 @@
|
||||
%rb_binary /usr/bin/ruby
|
||||
%rb_arch %(%{rb_binary} -e 'print RUBY_PLATFORM')
|
||||
%rb_ver %(%{rb_binary} -r rbconfig -e 'print RbConfig::CONFIG["ruby_version"]')
|
||||
#
|
||||
|
||||
## Base
|
||||
# "rubylibprefix"=>"/usr/lib64/ruby",
|
||||
%rb_dir %(%{rb_binary} -rrbconfig -e 'puts RbConfig::CONFIG["rubylibprefix"]' )
|
||||
# "rubylibdir" =>"/usr/lib64/ruby/2.1.0",
|
||||
%rb_libdir %(%{rb_binary} -rrbconfig -e 'puts RbConfig::CONFIG["rubylibdir"]' )
|
||||
# "archdir" =>"/usr/lib64/ruby/2.1.0/x86_64-linux",
|
||||
%rb_archdir %(%{rb_binary} -rrbconfig -e 'puts RbConfig::CONFIG["archdir"]' )
|
||||
|
||||
## Site
|
||||
# "sitedir" =>"/usr/lib64/ruby/site_ruby",
|
||||
%rb_sitedir %(%{rb_binary} -rrbconfig -e 'puts RbConfig::CONFIG["sitedir"]' )
|
||||
# "sitelibdir" =>"/usr/lib64/ruby/site_ruby/2.1.0",
|
||||
%rb_sitelibdir %(%{rb_binary} -rrbconfig -e 'puts RbConfig::CONFIG["sitelibdir"]' )
|
||||
# "sitearchdir" =>"/usr/lib64/ruby/site_ruby/2.1.0/x86_64-linux",
|
||||
%rb_sitearchdir %(%{rb_binary} -rrbconfig -e 'puts RbConfig::CONFIG["sitearchdir"]' )
|
||||
|
||||
## Vendor
|
||||
# "vendordir" =>"/usr/lib64/ruby/vendor_ruby",
|
||||
%rb_vendordir %(%{rb_binary} -rrbconfig -e 'puts RbConfig::CONFIG["vendordir"]' )
|
||||
# "vendorlibdir" =>"/usr/lib64/ruby/vendor_ruby/2.1.0",
|
||||
%rb_vendorlibdir %(%{rb_binary} -rrbconfig -e 'puts RbConfig::CONFIG["vendorlibdir"]' )
|
||||
# "vendorarchdir" =>"/usr/lib64/ruby/vendor_ruby/2.1.0/x86_64-linux",
|
||||
%rb_vendorarchdir %(%{rb_binary} -rrbconfig -e 'puts RbConfig::CONFIG["vendorarchdir"]' )
|
||||
|
||||
# backward compat
|
||||
%rb_sitearch %{rb_sitearchdir}
|
||||
%rb_sitelib %{rb_sitelibdir}
|
||||
%rb_vendorlib %{rb_vendorlibdir}
|
||||
%rb_vendorarch %{rb_vendorarchdir}
|
||||
|
||||
%set_gem_binary() \
|
||||
%if "%{?gem_binary}" == "" \
|
||||
%global gem_binary %(/usr/bin/ruby-find-versioned gem|head -n1) \
|
||||
%endif \
|
||||
%if "%{?gem_binary}" == "" \
|
||||
echo "no gem binary found. Exiting." \
|
||||
exit 1 \
|
||||
%endif \
|
||||
%{nil}
|
||||
|
||||
|
||||
# %%gem_unpack macro unpacks a gem file into %%{_builddir}
|
||||
#
|
||||
# example:
|
||||
# %prep
|
||||
# %gem_unpack %{SOURCE0}
|
||||
# %patch1 -p1
|
||||
#
|
||||
%gem_unpack(s:) \
|
||||
source=%{-s:%{-s*}}%{!-s:%{SOURCE0}} \
|
||||
%{set_gem_binary} \
|
||||
%{gem_binary} unpack --verbose $source \
|
||||
cd %{mod_name}-%{version} \
|
||||
chmod og-w -R . \
|
||||
%{gem_binary} specification --ruby $source > %{mod_name}-%{version}.gemspec \
|
||||
%{nil}
|
||||
|
||||
# %%gem_build macro ...
|
||||
#
|
||||
%gem_build() \
|
||||
GEMSPEC_SOURCE_DIR=`find . -maxdepth 2 -type f -name %{mod_name}-%{version}.gemspec | xargs dirname` \
|
||||
%{set_gem_binary} \
|
||||
cd $GEMSPEC_SOURCE_DIR && %{gem_binary} build --verbose %{mod_name}-%{version}.gemspec \
|
||||
%{nil}
|
||||
|
||||
# %%gem_install macro ...
|
||||
#
|
||||
# When invoked with a single parameter, the macro retains the old macro behavior, i.e.
|
||||
# building the upstream gem directly in $RPM_BUILD_ROOT without unpacking to %{_builddir} first.
|
||||
#
|
||||
%gem_install /usr/lib/rpm/gem_install.sh --default-gem %{mod_name}-%{version}.gem --gem-name=%{mod_name} --gem-version=%{version} --build-root %{buildroot} %{?mod_version_suffix:--gem-suffix=%{mod_version_suffix}} %{?gem_binary:--gem-binary %{gem_binary}}
|
||||
%gem_packages %{expand:%(/usr/lib/rpm/gem_packages.sh --default-gem %{mod_name}-%{version}.gem --gem-name=%{mod_name} --gem-version=%{version} --build-root %{buildroot})}
|
||||
|
||||
# we need to copy parts of the %fdupes macro as rpm can't expand parameters in macro "calls" ;(
|
||||
%gem_cleanup() \
|
||||
for gem in $(/usr/bin/ruby-find-versioned gem) ; do \
|
||||
gem_base="$($gem env gemdir)" \
|
||||
/usr/lib/rpm/gem_build_cleanup.sh %{buildroot}${gem_base} \
|
||||
fdupes -q -p -n -r -o name %{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 \
|
||||
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 'print Gem::Specification.new.extensions_dir' || echo %{_libdir}/ruby/gems/%{rb_ver}/gems )
|
||||
%gem_doc_ext %(%{rb_binary} -r rubygems -e 'bs = Gem::Specification.new; rp = bs.extensions_dir.rpartition(bs.base_dir); print rp[1]+"/doc"+rp[2]' )
|
||||
%gem_platform %(%{rb_binary} -r rubygems -r rbconfig -e 'print Gem::Platform.new(RbConfig::CONFIG["arch"]).to_s' )
|
4
rubygems.attr
Normal file
4
rubygems.attr
Normal file
@ -0,0 +1,4 @@
|
||||
%__rubygems_requires %{_rpmconfigdir}/rubygemsdeps.rb --requires
|
||||
%__rubygems_provides %{_rpmconfigdir}/rubygemsdeps.rb --provides
|
||||
%__rubygems_path ^%{_libdir}/.*/gems/[^/]*/specifications
|
||||
|
3
rubygems_bundled.attr
Normal file
3
rubygems_bundled.attr
Normal file
@ -0,0 +1,3 @@
|
||||
%__rubygems_bundled_provides %{_rpmconfigdir}/rubygemsdeps.rb --provides --bundled
|
||||
%__rubygems_bundled_path .*/vendor/bundle/.*/specifications/.*\.gemspec$
|
||||
|
186
rubygemsdeps.rb
Normal file
186
rubygemsdeps.rb
Normal file
@ -0,0 +1,186 @@
|
||||
#!/bin/sh
|
||||
=begin &>/dev/null
|
||||
# workaround for rubinius bug
|
||||
# https://github.com/rubinius/rubinius/issues/2732
|
||||
export LC_ALL="en_US.UTF-8"
|
||||
export LANG="en_US.UTF-8"
|
||||
for ruby in $(/usr/bin/ruby-find-versioned) ; do
|
||||
test -x "$ruby" && break
|
||||
done
|
||||
exec $ruby -x $0 "$@"
|
||||
=end
|
||||
#!/usr/bin/ruby
|
||||
|
||||
# Copyright (c) 2012 Stephan Kulow
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
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
|
||||
end
|
||||
requires=false
|
||||
opts.on("-R", "--requires", "Output the requires of the package") do |val|
|
||||
requires=true
|
||||
end
|
||||
bundled=false
|
||||
opts.on("-b", "--bundled", "Output provides as bundled ones") do |val|
|
||||
bundled=true
|
||||
end
|
||||
|
||||
file_match=nil
|
||||
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)
|
||||
|
||||
unless provides || requires
|
||||
exit(0)
|
||||
end
|
||||
|
||||
if file_match.nil?
|
||||
if bundled
|
||||
file_match = ".*/vendor/bundle/[^/]*/[^/]*/specifications/.*\.gemspec$"
|
||||
else
|
||||
file_match = ".*/gems/[^/]*/specifications/.*\.gemspec$"
|
||||
end
|
||||
end
|
||||
|
||||
$rubyapi_re = %r{.*/([^/]*)/gems/([^/]*)/.*}
|
||||
if bundled
|
||||
$rubyapi_re = %r{.*/vendor/bundle/([^/]*)/([^/]*)/.*}
|
||||
end
|
||||
|
||||
def fatal(msg)
|
||||
$stderr.puts msg
|
||||
exit 1
|
||||
end
|
||||
|
||||
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($rubyapi_re)
|
||||
# return m ? m[1] : RbConfig::CONFIG["ruby_version"]
|
||||
return { :interpreter => m[1], :version => m[2], :abi => "#{m[1]}:#{m[2]}", :requires => "#{m[1]}(abi) = #{m[2]}" }
|
||||
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_hash, spec|
|
||||
rubyabi = rubyabi_hash[:abi]
|
||||
rubyabi_requires = rubyabi_hash[:requires]
|
||||
if provides
|
||||
versions = spec.version.to_s.split('.')
|
||||
# old forms
|
||||
# puts "rubygem-#{spec.name} = #{spec.version}"
|
||||
# puts "rubygem-#{spec.name}-#{versions[0]} = #{spec.version}" if versions.length > 0
|
||||
# puts "rubygem-#{spec.name}-#{versions[0]}_#{versions[1]} = #{spec.version}" if versions.length > 1
|
||||
# puts "rubygem-#{spec.name}-#{versions[0]}_#{versions[1]}_#{versions[2]} = #{spec.version}" if versions.length > 2
|
||||
|
||||
# version without ruby version - asking for trouble
|
||||
if bundled
|
||||
puts "bundled(rubygem(#{spec.name})) = #{spec.version}"
|
||||
else
|
||||
puts "rubygem(#{spec.name}) = #{spec.version}"
|
||||
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
|
||||
end
|
||||
|
||||
if requires
|
||||
puts rubyabi_requires if rubyabi_requires
|
||||
puts "rubygems" if rubyabi_hash[:version].to_f < 1.9
|
||||
spec.runtime_dependencies.each do |dep|
|
||||
dep.requirement.requirements.each do |r|
|
||||
if r.first == '~>'
|
||||
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}"
|
||||
#puts "rubygem(#{rubyabi}:#{dep.name}) < #{r.last}"
|
||||
else
|
||||
puts "rubygem(#{rubyabi}:#{dep.name}) #{r.first} #{r.last}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user