From a4cd07b16c6e012fd8c2b98019f97442797d50d7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20R=C4=99korajski?= Date: Thu, 2 Jan 2020 22:21:43 +0900 Subject: [PATCH] - ruby macros and rubyprov moved to rpm-build-macros --- gem_helper.rb | 197 -------------------------------------------------- rpm.spec | 31 +------- rubygems.rb | 128 -------------------------------- 3 files changed, 3 insertions(+), 353 deletions(-) delete mode 100755 gem_helper.rb delete mode 100755 rubygems.rb diff --git a/gem_helper.rb b/gem_helper.rb deleted file mode 100755 index 11de3be..0000000 --- a/gem_helper.rb +++ /dev/null @@ -1,197 +0,0 @@ -#!/usr/bin/env ruby -#-- -# Copyright 2010 Per Øyvind Karlsen -# This program is free software. It may be redistributed and/or modified under -# the terms of the LGPL version 2.1 (or later). -#++ - -require 'optparse' -require 'rubygems' - -# Write the .gemspec specification (in Ruby) -def writespec(spec) - file_name = spec.full_name.untaint + '.gemspec' - File.open(file_name, "w") do |file| - file.puts spec.to_ruby_for_cache - end - print "Wrote: %s\n" % file_name -end - -# make gemspec self-contained -if ARGV[0] == "spec-dump" - spec = eval(File.read(ARGV[1])) - writespec(spec) - exit(0) -end - -if ARGV[0] == "build" or ARGV[0] == "install" or ARGV[0] == "spec" - require 'yaml' - require 'zlib' - - filter = nil - opts = nil - keepcache = false - fixperms = false - gemdir = nil - dry_run = false - files = [] - argv = ARGV[1..-1] - # Push this into some environment variables as the modified classes doesn't - # seem to be able to access our global variables.. - ENV['GEM_MODE'] = ARGV[0] - if ARGV[0] == "build" - opts = OptionParser.new("#{$0} <--filter PATTERN>") - opts.on("-f", "--filter PATTERN", "Filter pattern to use for gem files") do |val| - filter = val - end - opts.on("-j", "--jobs JOBS", "Number of jobs to run simultaneously.") do |val| - ENV['jobs'] = "-j"+val - end - opts.on("--dry-run", "Only show the files the gem will include") do - ARGV.delete("--dry-run") - dry_run = true - end - elsif ARGV[0] == "install" - opts = OptionParser.new("#{$0} <--keep-cache>") - opts.on("--keep-cache", "Don't delete gem copy from cache") do - ARGV.delete("--keep-cache") - keepcache = true - end - opts.on("--fix-permissions", "Force standard permissions for files installed") do - ARGV.delete("--fix-permissions") - fixperms = true - end - opts.on("-i", "--install-dir GEMDIR", "Gem repository directory") do |val| - gemdir = val - end - end - while argv.length > 0 - begin - opts.parse!(argv) - rescue OptionParser::InvalidOption => e - e.recover(argv) - end - argv.delete_at(0) - end - - file_data = Zlib::GzipReader.open("metadata.gz") {|io| io.read} - header = YAML::load(file_data) - body = {} - # I don't know any better.. :/ - header.instance_variables.each do |iv| - body[iv.to_s.sub(/^@/,'')] = header.instance_variable_get(iv) - end - - spec = Gem::Specification.from_yaml(YAML.dump(header)) - - if ARGV[0] == "spec" - writespec(spec) - exit(0) - end - - if ARGV[0] == "install" - system("gem %s %s.gem" % [ARGV.join(' '), spec.full_name]) - if !keepcache - require 'fileutils' - FileUtils.rm_rf("%s/cache" % gemdir) - end - if fixperms - chmod = "chmod u+r,u+w,g-w,g+r,o+r -R %s" % gemdir - print "\nFixing permissions:\n\n%s\n" % chmod - system("%s" % chmod) - print "\n" - end - end - - if body['extensions'].size > 0 - require 'rubygems/ext' - module Gem::Ext - class Builder - def self.make(dest_path, results) - make_program = ENV['make'] - unless make_program then - make_program = (/mswin/ =~ RUBY_PLATFORM) ? 'nmake' : 'make' - end - cmd = make_program - if ENV['GEM_MODE'] == "build" - cmd += " %s" % ENV['jobs'] - elsif ENV['GEM_MODE'] == "install" - cmd += " DESTDIR='%s' install" % ENV['DESTDIR'] - end - results << cmd - results << `#{cmd} #{redirector}` - - raise Gem::ExtensionBuildError, "make failed:\n\n#{results}" unless - $?.success? - end - end - end - - require 'rubygems/installer' - module Gem - class Installer - def initialize(spec, options={}) - @gem_dir = Dir.pwd - @spec = spec - end - end - class ConfigFile - def really_verbose - true - end - end - end - - unless dry_run - Gem::Installer.new(spec).build_extensions - else - for ext in body['extensions'] - files.push(ext[0..ext.rindex("/")-1]+".so") - end - end - - body['extensions'].clear() - end - if ARGV[0] == "build" - body['test_files'].clear() - - # We don't want ext/ in require_paths, it will only contain content for - # building extensions which needs to be installed in sitearchdir anyways.. - idx = 0 - for i in 0..body['require_paths'].size()-1 - if body['require_paths'][idx].match("^ext(/|$)") - body['require_paths'].delete_at(idx) - else - idx += 1 - end - end - - # We'll get rid of all the files we don't really need to install - idx = 0 - for i in 0..body['files'].size()-1 - if filter and body['files'][idx].match(filter) - match = true - else - match = false - for path in body['require_paths'] - if body['files'][idx].match("^%s/" % path) - match = true - end - end - end - if !match - body['files'].delete_at(idx) - else - idx += 1 - end - end - - spec = Gem::Specification.from_yaml(YAML.dump(header)) - unless dry_run - Gem::Builder.new(spec).build - else - files.concat(spec.files) - print "%s\n" % files.join("\n") - end - end -end diff --git a/rpm.spec b/rpm.spec index d43a351..81551ed 100644 --- a/rpm.spec +++ b/rpm.spec @@ -86,8 +86,6 @@ Source26: %{name}db_checkversion.c Source27: macros.lang Source28: %{name}db_reset.c Source29: dbupgrade.sh -Source30: rubygems.rb -Source31: gem_helper.rb Patch0: %{name}-branch.patch Patch1: %{name}-man_pl.patch Patch2: %{name}-popt-aliases.patch @@ -670,7 +668,7 @@ Summary(uk.UTF-8): Скрипти та утиліти, необхідні для Group: Applications/File Requires(pretrans): coreutils Requires(pretrans): findutils -Requires: %{name}-build-macros >= 1.712 +Requires: %{name}-build-macros >= 1.744-3 Requires: %{name}-utils = %{version}-%{release} Requires: /bin/id Requires: awk @@ -798,23 +796,6 @@ packages. Dodatkowe narzędzia do sprawdzenia zależności skryptów PHP PEAR w pakietach RPM. -%package rubyprov -Summary: Ruby tools, which simplify creation of RPM packages with Ruby software -Summary(pl.UTF-8): Makra ułatwiające tworzenie pakietów RPM z programami napisanymi w Ruby -Group: Applications/File -Requires: %{name} = %{version}-%{release} -Requires: ruby -Requires: ruby-modules -Requires: ruby-rubygems - -%description rubyprov -Ruby tools, which simplifies creation of RPM packages with Ruby -software. - -%description rubyprov -l pl.UTF-8 -Makra ułatwiające tworzenie pakietów RPM z programami napisanymi w -Ruby. - %package -n python-rpm Summary: Python interface to RPM library Summary(pl.UTF-8): Pythonowy interfejs do biblioteki RPM-a @@ -1028,8 +1009,6 @@ install %{SOURCE2} macros/pld.in install %{SOURCE8} scripts/php.prov.in install %{SOURCE9} scripts/php.req.in install %{SOURCE11} scripts/perl.prov.in -cp -p %{SOURCE30} scripts/rubygems.rb -cp -p %{SOURCE31} scripts/gem_helper.rb rm scripts/find-php* @@ -1310,6 +1289,8 @@ done # moved to rpm-build-macros 1.699 %{__rm} $RPM_BUILD_ROOT%{_rpmlibdir}/macros.d/kernel +# moved to rpm-build-macros 1.744 +%{__rm} $RPM_BUILD_ROOT%{_rpmlibdir}/macros.d/ruby # for rpm -e|-U --repackage install -d $RPM_BUILD_ROOT/var/{spool/repackage,lock/rpm} @@ -1593,7 +1574,6 @@ find %{_rpmlibdir} -name '*-linux' -type l | xargs rm -f %{_rpmlibdir}/macros.d/php %{_rpmlibdir}/macros.d/pkgconfig %{_rpmlibdir}/macros.d/python -%{_rpmlibdir}/macros.d/ruby %{_rpmlibdir}/macros.d/selinux %{_rpmlibdir}/macros.d/tcl %{_rpmlibdir}/macros.rpmbuild @@ -1626,11 +1606,6 @@ find %{_rpmlibdir} -name '*-linux' -type l | xargs rm -f # needs jar (any jdk), jcf-dump (gcc-java) to work %attr(755,root,root) %{_rpmlibdir}/javadeps.sh -%files rubyprov -%defattr(644,root,root,755) -%attr(755,root,root) %{_rpmlibdir}/gem_helper.rb -%attr(755,root,root) %{_rpmlibdir}/rubygems.rb - %files perlprov %defattr(644,root,root,755) %attr(755,root,root) %{_rpmlibdir}/perl.* diff --git a/rubygems.rb b/rubygems.rb deleted file mode 100755 index a3f63aa..0000000 --- a/rubygems.rb +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/env ruby -#-- -# Copyright 2010 Per Øyvind Karlsen -# This program is free software. It may be redistributed and/or modified under -# the terms of the LGPL version 2.1 (or later). -# -# FIXME: Someone with actual ruby skills should really clean up and sanitize -# this! fugliness obvious... -#++ - -require 'optparse' -require 'rbconfig' - -provides = false -requires = false - -opts = OptionParser.new("#{$0} <--provides|--requires>") -opts.on("-P", "--provides", "Print provides") do |val| - provides = true -end -opts.on("-R", "--requires", "Print requires") do |val| - requires= true -end - -rest = opts.permute(ARGV) - -if rest.size != 0 or (!provides and !requires) or (provides and requires) - $stderr.puts "Use either --provides OR --requires" - $stderr.puts opts - exit(1) -end - -require 'rubygems' -gem_dir = Gem.respond_to?(:default_dirs) ? Gem.default_dirs[:system][:gem_dir] : Gem.path.first -specpatt = "#{gem_dir}/specifications/.*\.gemspec$" -gems = [] -ruby_versioned = false -abi_provide = false -# as ruby_version may be empty, take version from basename of archdir -ruby_version = RbConfig::CONFIG["ruby_version"].empty? ? File.basename(RbConfig::CONFIG["archdir"]) : RbConfig::CONFIG["ruby_version"] - -for path in $stdin.readlines - # way fugly, but we make the assumption that if the package has - # this file, the package is the current ruby version, and should - # therefore provide ruby(abi) = version - if provides and path.match(RbConfig::CONFIG["archdir"] + "/rbconfig.rb") - abi_provide = true - ruby_versioned = true - elsif path.match(specpatt) - gems.push(path.chomp) - # this is quite ugly and lame, but the assumption made is that if any files - # found in any of these directories specific to this ruby version, the - # package is dependent on this specific version. - # FIXME: only supports current ruby version - elsif not ruby_versioned - if path.match(RbConfig::CONFIG["rubylibdir"]) - ruby_versioned = true - elsif path.match(RbConfig::CONFIG["archdir"]) - ruby_versioned = true - elsif path.match(RbConfig::CONFIG["sitelibdir"]) - ruby_versioned = !RbConfig::CONFIG["ruby_version"].empty? - elsif path.match(RbConfig::CONFIG["sitearchdir"]) - ruby_versioned = true - elsif path.match(RbConfig::CONFIG["vendorlibdir"]) - ruby_versioned = !RbConfig::CONFIG["ruby_version"].empty? - elsif path.match(RbConfig::CONFIG["vendorarchdir"]) - ruby_versioned = true - end - end -end - -if requires or abi_provide - abidep = "ruby(abi)" - if ruby_versioned - abidep += " = %s" % ruby_version - end - print abidep + "\n" -end - -if gems.length > 0 - require 'rubygems' - - if requires - - module Gem - class Requirement - def rpm_dependency_transform(name, version) - pessimistic = "" - if version == "> 0.0.0" or version == ">= 0" - version = "" - else - if version[0..1] == "~>" - pessimistic = "rubygem(%s) < %s\n" % [name, Gem::Version.create(version[3..-1]).bump] - version = version.gsub(/\~>/, '=>') - end - if version[0..1] == "!=" - version = version.gsub(/\!=/, '>') - end - version = version.sub(/^/, ' ') - end - version = "rubygem(%s)%s\n%s" % [name, version, pessimistic] - end - - def to_rpm(name) - result = as_list - return result.map { |version| rpm_dependency_transform(name, version) } - end - - end - end - end - - for gem in gems - data = File.read(gem) - spec = eval(data) - if provides - print "rubygem(%s) = %s\n" % [spec.name, spec.version] - end - if requires - for d in spec.dependencies - print d.requirement.to_rpm(d.name)[0] unless d.type != :runtime - end - for d in spec.required_rubygems_version.to_rpm("rubygems") - print d.gsub(/(rubygem\()|(\))/, "") - end - end - end -end -- 2.43.0