[packages/rpm: 1/4] add gem_helper.rb from rpm-5.4.15/scripts/gem_helper.rb
glen
glen at pld-linux.org
Thu Dec 18 20:17:26 CET 2014
commit 63194730d5c6853e7e29d5390e93cbf6e7e8fb5b
Author: Elan Ruusamäe <glen at delfi.ee>
Date: Thu Dec 18 20:09:46 2014 +0200
add gem_helper.rb from rpm-5.4.15/scripts/gem_helper.rb
gem_helper.rb | 173 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
rpm.spec | 2 +
2 files changed, 175 insertions(+)
---
diff --git a/rpm.spec b/rpm.spec
index 9318d86..e2c401f 100644
--- a/rpm.spec
+++ b/rpm.spec
@@ -90,6 +90,7 @@ 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
@@ -979,6 +980,7 @@ 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
%{__mv} -f scripts/perl.req{,.in}
diff --git a/gem_helper.rb b/gem_helper.rb
new file mode 100755
index 0000000..6661575
--- /dev/null
+++ b/gem_helper.rb
@@ -0,0 +1,173 @@
+#!/usr/bin/env ruby
+#--
+# Copyright 2010 Per Øyvind Karlsen <peroyvind at mandriva.org>
+# 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'
+
+if ARGV[0] == "build" or ARGV[0] == "install"
+ 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.. </lameworkaround>
+ 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")
+ header = YAML::load(file_data)
+ file_data.close()
+ body = header.instance_variable_get :@ivars
+
+ require 'rubygems'
+ spec = Gem::Specification.from_yaml(YAML.dump(header))
+
+ 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
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/rpm.git/commitdiff/cffc13fad6e80c8609fe8a53e372acacaef98d41
More information about the pld-cvs-commit
mailing list