Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37713970
en ru br
ALT Linux repos
S:1.1.0-alt1
5.0: 0.0.4-alt1
4.1: 0.0.3-alt0.M41.1

Group :: Development/Ruby
RPM: rpm-build-ruby

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

pax_global_header00006660000000000000000000000064123102202710014500gustar00rootroot0000000000000052 comment=68af8507ed67c2fcb38464e68a8c94c90b1a21f9
rpm-build-ruby-0.1.3/000075500000000000000000000000001231022027100143515ustar00rootroot00000000000000rpm-build-ruby-0.1.3/.gear/000075500000000000000000000000001231022027100153455ustar00rootroot00000000000000rpm-build-ruby-0.1.3/.gear/rules000064400000000000000000000000071231022027100164170ustar00rootroot00000000000000tar: .
rpm-build-ruby-0.1.3/README.ru000064400000000000000000000020651231022027100156610ustar00rootroot00000000000000Макросы объявленые в /etc/rpm/macros.d/ruby:

%ruby_sitearchdir - бинарные локальные модули
%ruby_sitelibdir - локальные модули не зависящие от архитектуры
%ruby_archdir - бинарные модули
%ruby_libdir - модули не зависящие от архитектуры
%ruby_includedir - заголовочные файлы

%ruby_configure - конфигурирование модуля, сборка которого завязана на extconf.rb
%_ruby_setup_rb - путь до setup.rb
%ruby_setup_rb - вызов setup.rb
%ruby_config - конфигурирование модуля, сборка которого завязана на setup.rb
%ruby_build - сборка модуля с помощью setup.rb
%ruby_install - установка модуля с помощью setup.rb
%ruby_build_std - конфигурирование и сборка модуля с помощью setup.rb
%rake - вызов rake
%rake_install - вызов цели install в rakefile
rpm-build-ruby-0.1.3/rpm-build-ruby.spec000064400000000000000000000054711231022027100201060ustar00rootroot00000000000000%def_disable check

Name: rpm-build-ruby
Epoch: 1
Version: 0.1.3
Release: alt1
Summary: RPM helper scripts to calculate Ruby dependencies
License: GPLv2
Group: Development/Other
Source: %name-%version.tar
BuildArch: noarch
Requires: ruby >= 1.9
Conflicts: rpm-build <= 4.0.4-alt24
AutoReq: yes,noruby
Requires: ruby >= 1.9
Requires: ruby-stdlibs >= 1.9
Requires: %_bindir/rdoc
Requires: %_bindir/testrb
Requires: %_bindir/rake

%{!?_disable_check:BuildRequires: ruby >= 1.9 ruby-stdlibs >= 1.9}

%description
These herlper scripts will look at ruby source files in your package, and will
use this information to generate automatic Requires and Provides tags for the
package.


%prep
%setup -q


%install
install -d -m 0755 %buildroot{%_rpmlibdir,%_rpmmacrosdir}
install -p -m 0755 ruby.{req,prov}* %buildroot%_rpmlibdir/
install -p -m 0644 rubyreq.rb %buildroot%_rpmlibdir/
install -p -m 0644 ruby.macros %buildroot%_rpmmacrosdir/ruby
install -p -m 0644 ruby.env %buildroot%_rpmmacrosdir/


%check
./test.sh


%files
%lang(ru) %doc README.ru
%_rpmlibdir/ruby*
%_rpmmacrosdir/*


%changelog
* Thu Mar 13 2014 Led <led@altlinux.ru> 1:0.1.3-alt1
- 0.1.3:
+ ruby.macros: fix %%ruby_ri_sitedir macro

* Wed Dec 12 2012 Led <led@altlinux.ru> 1:0.1.2-alt4
- removed temp symlink

* Wed Dec 12 2012 Led <led@altlinux.ru> 1:0.1.2-alt3
- temporarily added symlink for rebuild ruby

* Sun Dec 09 2012 Led <led@altlinux.ru> 1:0.1.2-alt2
- added requires of %%_bindir/testrb and %%_bindir/rake

* Sat Dec 08 2012 Led <led@altlinux.ru> 1:0.1.2-alt1
- 0.1.2:
+ cleaned up
+ dropped ruby 1.8 support
- cleaned up spec
- updated Requires
- added README.ru
- disabled check

* Fri Apr 08 2011 Timur Aitov <timonbl4@altlinux.org> 1:0.1.1-alt1
- Supported both 1.8.7 and 1.9.2 versions of ruby
- Make difference between 1.8 and 1.9

* Wed Sep 09 2009 Alexey I. Froloff <raorn@altlinux.org> 1:0.1.0-alt2
- Tests moved to %%check section (bootstrap-friendly)

* Mon Jul 06 2009 Alexey I. Froloff <raorn@altlinux.org> 1:0.1.0-alt1
- Updated for ruby 1.9
- Fixed typo in description (closes: #20624)
- Stop processing on syntax error
- Macros moved to %%_rpmmacrosdir

* Sat Nov 01 2008 Sir Raorn <raorn@altlinux.ru> 1:0.0.4-alt1
- Parser rewritten without recursion (Kirill A. Shutemov)

* Sun Aug 31 2008 Sir Raorn <raorn@altlinux.ru> 1:0.0.3-alt1
- Strip '.rb' extension from requires/provides to reduce apt
cache size
- Process "weak provides" for *.so modules too
- Use files.req mechanism for directory requires (needs recent
libruby)
- New macros:
+ %%update_setup_rb: update setup.rb script from ruby-tool-setup package
+ %%ruby_test_unit: run tests with testrb script

* Wed Apr 02 2008 Sir Raorn <raorn@altlinux.ru> 1:0.0.2-alt1
- "class << <var>" block support (kas@)

* Fri Mar 28 2008 Sir Raorn <raorn@altlinux.ru> 1:0.0.1-alt1
- Initial build, based on rpm-build-perl

rpm-build-ruby-0.1.3/ruby.env000064400000000000000000000006131231022027100160440ustar00rootroot00000000000000%{?__ruby:export RPM_RUBY="%__ruby"}
%{?__ruby_req:export RPM_RUBY_REQ="%__ruby_req"}
%{?_ruby_req_method:export RPM_RUBY_REQ_METHOD="%_ruby_req_method"}
%{?_ruby_lib_path:export RPM_RUBY_LIB_PATH="%_ruby_lib_path"}
%{?_ruby_weakprov_path:export RPM_RUBY_WEAKPROV_PATH="%_ruby_weakprov_path"}
%{?ruby_arch:export RPM_RUBY_ARCH="%ruby_arch"}
%{?ruby_libdir:export RPM_RUBY_LIBDIR="%ruby_libdir"}
rpm-build-ruby-0.1.3/ruby.macros000064400000000000000000000027301231022027100165420ustar00rootroot00000000000000%_ruby_req_method normal
%set_ruby_req_method() %global _ruby_req_method %*

%__ruby %_bindir/ruby
#__ruby_req %_bindir/ruby-tool-ripper

%ruby_vendor %__ruby -rvendor-specific
%ruby_rbconfig %ruby_vendor -rrbconfig

%ruby_rubyconf() %ruby_rbconfig -e 'print RbConfig::CONFIG["%*"]'
%ruby_sitearchdir %(%ruby_rubyconf sitearchdir)
%ruby_sitelibdir %(%ruby_rubyconf sitelibdir)
%ruby_archdir %(%ruby_rubyconf archdir)
%ruby_libdir %(%ruby_rubyconf rubylibdir)
%ruby_siteincludedir %(%ruby_rubyconf vendorhdrdir)
%ruby_sitearchdir %(%ruby_rubyconf sitearchdir)
%ruby_includedir %(%ruby_rubyconf rubyhdrdir)
%ruby_arch %(%ruby_rubyconf arch)
%ruby_ridir %(%ruby_rubyconf ridir)

%_ruby_lib_path %ruby_libdir
%add_ruby_lib_path() %global _ruby_lib_path %{?_ruby_lib_path:%_ruby_lib_path} %*
%add_ruby_weakprov_path() %global _ruby_weakprov_path %{?_ruby_weakprov_path:%_ruby_weakprov_path} %*

%ruby_ri_sitedir %ruby_ridir/site

%rdoc rdoc -o %buildroot%ruby_ri_sitedir --ri --all
%ruby_configure %ruby_vendor extconf.rb --ruby=/usr/bin/ruby

%_ruby_setup_rb setup.rb
%update_setup_rb cp %_datadir/ruby-setup/setup.rb %_ruby_setup_rb
%ruby_setup_rb %ruby_vendor %_ruby_setup_rb
%ruby_config %ruby_setup_rb config
%ruby_build %ruby_setup_rb setup
%ruby_install %ruby_setup_rb install --prefix=%buildroot

%ruby_test_unit %_bindir/testrb

%ruby_build_std() \
%ruby_config %* \
%ruby_build \
%nil

%rake %ruby_vendor %_bindir/rake
%rake_install DESTDIR=%buildroot %rake install
rpm-build-ruby-0.1.3/ruby.prov000075500000000000000000000004411231022027100162440ustar00rootroot00000000000000#!/bin/sh

while read -r f; do
for p in $RPM_RUBY_LIB_PATH; do
F="${f#${RPM_BUILD_ROOT-}${p%/}/}"
if [ "x$f" != "x$F" ]; then
echo "$F"
break
fi
done
done | sed -r "s|//|/|g;s/^(site|vendor)_ruby\///;s|^$RPM_RUBY_ARCH/||;s/^(.*)\.so$/&)\nruby(\1/;s/\.rb$//;s/^.*$/ruby(&)/"
rpm-build-ruby-0.1.3/ruby.prov.files000075500000000000000000000001301231022027100173400ustar00rootroot00000000000000#!/bin/sh

[ -n "$RPM_RUBY_LIB_PATH" ] || exit 0

sed -n -r 's/^(.*\.(rb|so)) .*$/\1/p'
rpm-build-ruby-0.1.3/ruby.req000075500000000000000000000002111231022027100160400ustar00rootroot00000000000000#!/bin/sh -efu

ruby="${RPM_RUBY:-/usr/bin/ruby}"

# No hands - no jam
[ -x "$ruby" ] || exit 0

LC_ALL=C exec "$ruby" "$0".rb ${1+"$@"}
rpm-build-ruby-0.1.3/ruby.req.files000075500000000000000000000000641231022027100171470ustar00rootroot00000000000000#!/bin/sh -efu

sed -n '/^.*\.rb .* text/s/ .*$//p'
rpm-build-ruby-0.1.3/ruby.req.rb000075500000000000000000000105021231022027100164460ustar00rootroot00000000000000#!/usr/bin/ruby -w

require File.join(File.dirname(__FILE__), 'rubyreq')

class DynStr < RuntimeError; end

class String
attr_accessor :node
end

def string_parse(node)
case node.type
when :str
node.nd_lit
when :call
case node.nd_mid
when :<<, :+
string_parse(node.nd_recv) + string_parse(node.nd_args.nd_1st)
else
raise DynStr
end
else
raise DynStr
end
end

def string(node)
str = string_parse(node)
str.node = node
str
rescue DynStr => e
node
end

def get_arg(node, arg)
return nil unless node.class == RubyVM::Node
return nil unless node.type == :array
return nil if node.nd_alen < arg

(arg - 1).times{ node = node.nd_next }

node.nd_head
end

def parse(node)
req = []
perh_req = []
cur_req = req

stack = [node]

while not stack.empty?
node = stack.pop

cur_req = req if node == :req
next unless node.kind_of? RubyVM::Node

case node.type
when :newline
stack.push node.nd_next
when :fcall
cur_req << case node.nd_mid
when :require, :load
string get_arg(node.nd_args, 1)
when :autoload
string get_arg(node.nd_args, 2)
end
when :call
cur_req << case node.nd_recv.nd_vid
when :Kernel
case node.nd_mid
when :require, :load
string get_arg(node.nd_args, 1)
end
else
string get_arg(node.nd_args, 2) if node.nd_mid == :autoload
end
when :module, :class, :sclass, :scope
stack.push node.nd_body
when :block
stack.push node.nd_next, node.nd_head
else
if cur_req.equal? req
stack.push :req
cur_req = perh_req
end
stack.push node.u3_node, node.u2_node, node.u1_node
end
end

return req, perh_req
end

def process_file(f)
prefix, name = RubyReq::explode f
ext = File.extname(f)

if ext != '.so'
raise SyntaxError, "#{f}: syntax check failed" unless RubyReq::system($ruby, '-c', f) == 0
end
if prefix and name
prefix = RubyReq::split_canon(prefix.sub(/^#{RubyReq::root}/, ''))[0]
$weakprov_path.each do |w|
if name.index(w) == 0 and name[w.length].chr == File::SEPARATOR
file = name[w.length+1..-1]
basename, ext = RubyReq::base_ext(file)
$weak_prov[file] = f unless ext == '.rb'
$weak_prov[basename] = f if ['.rb', '.so'].include? ext
break
end
end
else
file = RubyReq::split_canon(f.sub(/^#{RubyReq::root}/, ''))[0]
begin
file = file[file.index(File::SEPARATOR)+1..-1]
basename, ext = RubyReq::base_ext(file)
$weak_prov[file] = f unless ext == '.rb'
$weak_prov[basename] = f if ['.rb', '.so'].include? ext
end while file.index(File::SEPARATOR) != nil
end
return [] if ext == '.so'

node = File.read(f).parse_to_nodes

req, perh_req = parse(node)

perh_req.to_a.flatten.compact.uniq.each do |r|
if r.class == RubyVM::Node
RubyReq.warn "#{f}:#{r.line} perhaps depends on module pointed by dynamic string"
else
RubyReq.warn "#{f}:#{r.node.line} perhaps depends on 'ruby(#{r})'"
end
end

req.to_a.flatten.compact.delete_if do |r|
if r.class == RubyVM::Node
RubyReq.warn "#{f}:#{r.line} depends on module pointed by dynamic string"
true
end
end
end

req = Array.new
$weak_prov = Hash.new
$ruby = ENV['RPM_RUBY'] || '/usr/bin/ruby'
$weakprov_path = (ENV['RPM_RUBY_WEAKPROV_PATH'] || '').split.sort { |a,b| b.length <=> a.length }

RubyReq::argv.each do |f|
begin
req += process_file(f)
rescue SyntaxError => err
RubyReq::warn err.message
exit 1
rescue => err
RubyReq::warn err.message
RubyReq::warn err.backtrace.join("\n")
exit 1 if RubyReq::method == 'strict'
end
end

req.sort.uniq.each do |r|
rb, ext = RubyReq::base_ext(r)
rb = r unless ext == '.rb'
rn, rs = RubyReq::split_canon(rb)
if $weak_prov.has_key?(rn)
RubyReq::warn "#{rn} internally povided by #{$weak_prov[rn]}"
next
end
if rs[0] == ''
RubyReq::warn "absolute requires: #{rn}"
exit 1 if RubyReq::method == 'strict'
puts rn
elsif rs.include?('..')
RubyReq::warn "relative requires: #{rn}"
exit 1 unless RubyReq::method == 'relaxed'
elsif rs.include?('.')
RubyReq::warn "dot-slash requires: #{rn}"
exit 1 unless RubyReq::method == 'relaxed'
else
puts "ruby(#{rn})"
end
end

# vim: set ft=ruby ts=2 sts=2 sw=2 et:
rpm-build-ruby-0.1.3/rubyreq.rb000064400000000000000000000035071231022027100163740ustar00rootroot00000000000000module RubyReq

def self.argv
f = ARGV
f = ($stdin.readlines.collect { |l| l.chomp }).find_all { |l| l.length > 0 } if f.empty?
raise "#{$0}: no files" unless f and not f.empty?
f.collect { |l| if File.exists? l then File.expand_path l else raise "#{$0}: #{l} does not exists" end }
end

@@method = ENV['RPM_RUBY_REQ_METHOD'] || 'relaxed'
def self.method
@@method
end

@@root = ENV['RPM_BUILD_ROOT']
@@root &&= File.expand_path(@@root)
def self.root
@@root
end

@@inc = nil
def self.inc
unless @@inc
@@inc = Array.new
@@inc.unshift(($:.select{ |p| p != '.' }).collect{ |p| File.expand_path(p) }).flatten!
@@inc.unshift(((ENV['RPM_RUBY_LIB_PATH'] || '').split).collect{ |p| File.expand_path(p) }).flatten!
@@inc.unshift(@@inc.collect{ |p| File.join(@@root, p) }).flatten! if @@root
@@inc.reject! { |p| not File.directory?(p) }
@@inc.uniq!
end
@@inc
end

def self.split_canon(fname)
fs = fname.split(/#{File::SEPARATOR}+/)
fc = File.join(fs)
return [fc, fs]
end

def self.base_ext(fname)
ext = File.extname(fname)
basename = File.basename(fname, ext)
basename = File.join(File.dirname(fname), basename) unless File.dirname(fname) == "."
[basename, ext]
end

def self.explode(fname)
prefix = (inc().sort { |a,b| b.length <=> a.length }).find { |p| fname.index(p) == 0 and fname[p.length].chr == File::SEPARATOR }
return unless prefix
basename = fname[prefix.length+1..-1]
return unless basename
return [prefix, basename]
end

def self.warn(str)
$stderr.puts "#{File.basename($0)}: #{str}"
end

def self.system(*args)
Process.fork do
$stdout.reopen("/dev/null", "w")
Kernel.exec(*args)
end
Process.wait
return $?.exitstatus
end
end
# vim: set ft=ruby ts=2 sts=2 sw=2 et:
rpm-build-ruby-0.1.3/test.sh000075500000000000000000000042201231022027100156650ustar00rootroot00000000000000#!/bin/sh -efu

RC=0
TestReq()
{
code="$1" modules="$2"
echo "$code" >.tmp.rb
out=$(./ruby.req .tmp.rb 2>&1 | sed -e 's|^ruby.req.rb: ||' | sed -e 's|/[^:]\+:[0-9]\+ ||')
out=$(echo $out)
if [ "$out" != "$modules" ]; then
echo FAIL code="'$code'" expected="'$modules'" got="'$out'"
RC=1
else
echo OK code="'$code'" result="'$out'"
fi
}

export RPM_RUBY_REQ_METHOD="relaxed"

TestReq 'require "mod"' 'ruby(mod)'
TestReq 'require "m#{o}d"' 'depends on module pointed by dynamic string'
TestReq 'require "m" + "o" << "d"' 'ruby(mod)'
TestReq 'require "m" << "o" + d' 'depends on module pointed by dynamic string'
TestReq 'require("mod")' 'ruby(mod)'
TestReq 'Kernel.require "mod"' 'ruby(mod)'
TestReq 'Kernel.require("mod")' 'ruby(mod)'
TestReq 'load "mod"' 'ruby(mod)'
TestReq 'load "mod", true' 'ruby(mod)'
TestReq 'Kernel.load "mod"' 'ruby(mod)'
TestReq 'Kernel.load("mod", true)' 'ruby(mod)'
TestReq 'Gem.require "mod"' ''
TestReq 'autoload :Mod, "mod"' 'ruby(mod)'
TestReq 'autoload(:Mod, "mod")' 'ruby(mod)'
TestReq 'module M; require "mod"; end' 'ruby(mod)'
TestReq 'class C; require "mod"; end' 'ruby(mod)'
TestReq 'class C < S; require "mod"; end' 'ruby(mod)'
TestReq 'def m; require "mod"; end' "perhaps depends on 'ruby(mod)'"
TestReq 'module M; end; M.autoload :N, "mod"' 'ruby(mod)'
TestReq 'module M; end; m=M.new; m.autoload :N, "mod"' 'ruby(mod)'
TestReq 'module M; end; M.autoload(:N, "mod")' 'ruby(mod)'
TestReq 'begin; require "mod"; rescue nil; end' "perhaps depends on 'ruby(mod)'"
TestReq 'begin; require "m#{o}d"; rescue nil; end' 'perhaps depends on module pointed by dynamic string'
TestReq 'require "/some/absolute/path"' 'absolute requires: /some/absolute/path /some/absolute/path'
TestReq 'require "some/../path"' 'relative requires: some/../path'
TestReq 'require "./path"' 'dot-slash requires: ./path'
TestReq 'a.b ||= c' '' # rubynode bug
TestReq 'class << self; require "mod"; end' 'ruby(mod)'
TestReq 'require "mod.rb"' 'ruby(mod)'
TestReq 'require "mod.so"' 'ruby(mod.so)'
TestReq "$(ruby -e 'p Array.new(1000, 0)')" ''
TestReq 'def m' "$(pwd)/.tmp.rb:1: syntax error, unexpected \$end $(pwd)/.tmp.rb: syntax check failed" # syntax error

exit $RC
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin