RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Per Øyvind Karlsen Root: /v/rpm/cvs Email: pkarl...@rpm5.org Module: rpm Date: 16-Oct-2010 12:03:52 Branch: rpm-5_3 Handle: 2010101610035002 Added files: (Branch: rpm-5_3) rpm/scripts gem_helper.rb Modified files: (Branch: rpm-5_3) rpm CHANGES rpm/macros ruby.in rpm/scripts Makefile.am Log: add gem_helper.rb and it's corresponding macros %gem_unpack, %gem_build & gem_install for simplifying & streamlining ruby gem packaging. Summary: Revision Changes Path 1.3296.2.98 +3 -0 rpm/CHANGES 1.1.2.3 +20 -0 rpm/macros/ruby.in 1.65.2.4 +2 -2 rpm/scripts/Makefile.am 1.1.2.2 +173 -0 rpm/scripts/gem_helper.rb ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/CHANGES ============================================================================ $ cvs diff -u -r1.3296.2.97 -r1.3296.2.98 CHANGES --- rpm/CHANGES 16 Oct 2010 04:56:10 -0000 1.3296.2.97 +++ rpm/CHANGES 16 Oct 2010 10:03:50 -0000 1.3296.2.98 @@ -1,4 +1,7 @@ 5.3.4 -> 5.3.5: + - proyvind: add gem_helper.rb and it's corresponding macros %gem_unpack, + %gem_build & gem_install for simplifying & streamlining ruby gem + packaging. - proyvind: add cmake macros from fedora/mandriva. - proyvind: add tcl macros from mandriva. - proyvind: add ruby macros from mandriva. @@ . patch -p0 <<'@@ .' Index: rpm/macros/ruby.in ============================================================================ $ cvs diff -u -r1.1.2.2 -r1.1.2.3 ruby.in --- rpm/macros/ruby.in 16 Oct 2010 04:50:50 -0000 1.1.2.2 +++ rpm/macros/ruby.in 16 Oct 2010 10:03:52 -0000 1.1.2.3 @@ -21,3 +21,23 @@ %ruby_vendorlibdir %(%{__ruby} -rrbconfig -e 'print Config::CONFIG["vendorlibdir"]') %ruby_gemdir %(%{__ruby} -rrbconfig -e 'include Config; print CONFIG["rubylibdir"].sub(CONFIG["ruby_version"], "gems/#{CONFIG["ruby_version"]}")') %ruby_ridir %(%{__ruby} -rrbconfig -e 'include Config; print File.join(CONFIG["datadir"], "ri", CONFIG["ruby_version"])') + +%gem_unpack(n:a:) \ + %{expand: %%global __tar tar -m} \ +%setup -q -c -T -a0 %{-n:-n %{-n*}} %{-a:-a %{-a*}} \ +%{__tar}zxf data.tar.gz + +%__gem_helper %{_usrlibrpm}/gem_helper.rb + +%gem_build(f:j:) \ + %__gem_helper build \\\ + %{-f:-f%{-f*}} \\\ + %{!-j:%{_smp_mflags}}%{-j:-j%{-j*}} + +%gem_install(i:n:C) \ + DESTDIR=${DESTDIR:-%{buildroot}} \\\ + %__gem_helper install \\\ + --env-shebang --rdoc --ri --force \\\ + %{!-i:--install-dir %{buildroot}%{ruby_gemdir}}%{-i:--install-dir %{-i*}} \\\ + %{!-n:--bindir %{buildroot}%{_bindir}}%{-n:--bindir%{-n*}} \\\ + %{!-C:--fix-permissions} @@ . patch -p0 <<'@@ .' Index: rpm/scripts/Makefile.am ============================================================================ $ cvs diff -u -r1.65.2.3 -r1.65.2.4 Makefile.am --- rpm/scripts/Makefile.am 10 Oct 2010 20:17:44 -0000 1.65.2.3 +++ rpm/scripts/Makefile.am 16 Oct 2010 10:03:51 -0000 1.65.2.4 @@ -17,7 +17,7 @@ find-debuginfo.sh find-lang.sh find-prov.pl find-req.pl \ find-provides.ksyms find-requires.ksyms kmodtool \ cpanflute cpanflute2 Specfile.pm find-provides.perl \ - find-requires.perl freshen.sh gendiff getpo.sh http.req \ + find-requires.perl freshen.sh gendiff gem_helper.rb getpo.sh http.req \ check-java-closure.sh java.prov.sh java.req.sh \ javadeps.sh libtooldeps.sh \ mono-find-provides mono-find-requires \ @@ -50,7 +50,7 @@ check-files cross-build executabledeps.sh \ find-debuginfo.sh find-lang.sh find-prov.pl find-req.pl \ find-provides.perl \ - find-requires.perl getpo.sh http.req \ + find-requires.perl gem_helper.rb getpo.sh http.req \ javadeps.sh libtooldeps.sh \ mono-find-provides mono-find-requires \ osgideps.pl pkgconfigdeps.sh \ @@ . patch -p0 <<'@@ .' Index: rpm/scripts/gem_helper.rb ============================================================================ $ cvs diff -u -r0 -r1.1.2.2 gem_helper.rb --- /dev/null 2010-10-16 12:03:20.000000000 +0200 +++ gem_helper.rb 2010-10-16 12:03:52.083139860 +0200 @@ -0,0 +1,173 @@ +#!/usr/bin/env ruby +#-- +# Copyright 2010 Per Ãyvind Karlsen <peroyv...@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 @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository rpm-cvs@rpm5.org