ruby-rpm 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +340 -0
- data/ChangeLog +434 -0
- data/NEWS +14 -0
- data/README +38 -0
- data/Rakefile +107 -0
- data/doc/refm.rd.ja +913 -0
- data/ext/rpm/MANIFEST +13 -0
- data/ext/rpm/db.c +1128 -0
- data/ext/rpm/dependency.c +330 -0
- data/ext/rpm/extconf.rb +78 -0
- data/ext/rpm/file.c +281 -0
- data/ext/rpm/package.c +800 -0
- data/ext/rpm/private.h +114 -0
- data/ext/rpm/rpm.c +660 -0
- data/ext/rpm/rpm40_compat.c +28 -0
- data/ext/rpm/rpm40_compat.h +9 -0
- data/ext/rpm/ruby-rpm.h +181 -0
- data/ext/rpm/source.c +152 -0
- data/ext/rpm/spec.c +346 -0
- data/ext/rpm/version.c +341 -0
- data/install.rb +1015 -0
- data/lib/rpm.rb +143 -0
- data/spec/fedora/ruby-rpm.spec +226 -0
- data/tests/runner.rb +15 -0
- data/tests/test_db.rb +44 -0
- data/tests/test_dependency.rb +29 -0
- data/tests/test_file.rb +13 -0
- data/tests/test_rpm.rb +13 -0
- data/tests/test_source.rb +31 -0
- data/tests/test_ts.rb +169 -0
- data/tests/test_version.rb +51 -0
- metadata +77 -0
data/lib/rpm.rb
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
### -*- mode: ruby; indent-tabs-mode: nil; -*-
|
2
|
+
### Ruby/RPM
|
3
|
+
###
|
4
|
+
### Copyright (C) 2002 Kenta MURATA <muraken2@nifty.com>.
|
5
|
+
|
6
|
+
### $Id: rpm.rb 22 2004-03-29 03:42:35Z zaki $
|
7
|
+
|
8
|
+
require 'rpmmodule'
|
9
|
+
|
10
|
+
module RPM
|
11
|
+
|
12
|
+
def vercmp(ver1, ver2)
|
13
|
+
unless String === ver1 and String === ver2 then
|
14
|
+
raise TypeError, 'illegal argument type'
|
15
|
+
end
|
16
|
+
RPM::Version.new(ver1) <=> RPM::Version.new(ver2)
|
17
|
+
end # def vercmp(ver1, ver2)
|
18
|
+
module_function :vercmp
|
19
|
+
|
20
|
+
class DB
|
21
|
+
|
22
|
+
def DB.each_match(tag, val)
|
23
|
+
begin
|
24
|
+
db = RPM::DB.new
|
25
|
+
db.each_match(tag, val) {|*a| yield a}
|
26
|
+
end
|
27
|
+
GC.start
|
28
|
+
end # def DB.each_match(tag, val)
|
29
|
+
|
30
|
+
def DB.packages
|
31
|
+
packages = nil
|
32
|
+
begin
|
33
|
+
db = RPM::DB.new
|
34
|
+
packages = db.packages
|
35
|
+
end
|
36
|
+
GC.start
|
37
|
+
packages
|
38
|
+
end # def DB.packages
|
39
|
+
|
40
|
+
def DB.packages(label=nil)
|
41
|
+
packages = []
|
42
|
+
if label then
|
43
|
+
DB.each_match(RPM::DBI_LABEL, label) {|a| packages.push a}
|
44
|
+
else
|
45
|
+
packages = DB.packages
|
46
|
+
end
|
47
|
+
packages
|
48
|
+
end # def DB.package(label=nil)
|
49
|
+
|
50
|
+
end # class DB
|
51
|
+
|
52
|
+
end # module RPM
|
53
|
+
|
54
|
+
class RPMdb
|
55
|
+
|
56
|
+
def RPMdb.open(root='')
|
57
|
+
RPMdb.new root
|
58
|
+
end # def RPMdb.open(root='')
|
59
|
+
|
60
|
+
def close
|
61
|
+
@db = nil
|
62
|
+
GC.start
|
63
|
+
end # def close
|
64
|
+
|
65
|
+
def file(filespec)
|
66
|
+
raise RuntimeError, 'closed DB' if @db.nil?
|
67
|
+
pkgs = []
|
68
|
+
@db.each_match(RPM::TAG_BASENAMES, filespec) do |pkg|
|
69
|
+
[pkg.name, pkg.version.v, pkg.version.r]
|
70
|
+
end
|
71
|
+
pkgs
|
72
|
+
end # def file(filespec)
|
73
|
+
|
74
|
+
def group(groupname)
|
75
|
+
raise RuntimeError, 'closed DB' if @db.nil?
|
76
|
+
pkgs = []
|
77
|
+
@db.each_match(RPM::TAG_GROUP, groupname) do |pkg|
|
78
|
+
pkgs << [pkg.name, pkg.version.v, pkg.version.r]
|
79
|
+
end
|
80
|
+
pkgs
|
81
|
+
end # def group(groupname)
|
82
|
+
|
83
|
+
def package(packagename)
|
84
|
+
raise RuntimeError, 'closed DB' if @db.nil?
|
85
|
+
pkgs = []
|
86
|
+
@db.each_match(RPM::DBI_LABEL, packagename) do |pkg|
|
87
|
+
pkgs << [pkg.name, pkg.version.v, pkg.version.r]
|
88
|
+
end
|
89
|
+
pkgs
|
90
|
+
end # def package(packagename)
|
91
|
+
|
92
|
+
def whatprovides(caps)
|
93
|
+
raise RuntimeError, 'closed DB' if @db.nil?
|
94
|
+
pkgs = []
|
95
|
+
@db.each_match(RPM::TAG_PROVIDENAME, caps) do |pkg|
|
96
|
+
pkgs << [pkg.name, pkg.version.v, pkg.version.r]
|
97
|
+
end
|
98
|
+
pkgs
|
99
|
+
end # def whatprovides(caps)
|
100
|
+
|
101
|
+
def whatrequires(caps)
|
102
|
+
raise RuntimeError, 'closed DB' if @db.nil?
|
103
|
+
pkgs = []
|
104
|
+
@db.each_match(RPM::TAG_REQUIRENAME, caps) do |pkg|
|
105
|
+
pkgs << [pkg.name, pkg.version.v, pkg.version.r]
|
106
|
+
end
|
107
|
+
pkgs
|
108
|
+
end # def whatrequires(caps)
|
109
|
+
|
110
|
+
def provides(name)
|
111
|
+
raise RuntimeError, 'closed DB' if @db.nil?
|
112
|
+
pkg = nil
|
113
|
+
@db.each_match(RPM::DBI_LABEL, name) {|p| pkg = p}
|
114
|
+
if pkg then
|
115
|
+
pkg.provides.collect {|prov| prov.name }
|
116
|
+
else
|
117
|
+
[]
|
118
|
+
end
|
119
|
+
end # def provides(name)
|
120
|
+
|
121
|
+
def requires(name)
|
122
|
+
raise RuntimeError, 'closed DB' if @db.nil?
|
123
|
+
pkg = nil
|
124
|
+
@db.each_match(RPM::DBI_LABEL, name) {|p| pkg = p; break}
|
125
|
+
if pkg then
|
126
|
+
pkg.requires.collect {|req| [req.name, req.version.v, req.version.r] }
|
127
|
+
else
|
128
|
+
[]
|
129
|
+
end
|
130
|
+
end # def requires(name)
|
131
|
+
|
132
|
+
def each
|
133
|
+
raise RuntimeError, 'closed DB' if @db.nil?
|
134
|
+
@db.each do |pkg|
|
135
|
+
yield pkg.name, pkg.version.v, pkg.version.r
|
136
|
+
end
|
137
|
+
end # def each
|
138
|
+
|
139
|
+
def initialize(root='')
|
140
|
+
@db = RPM::DB.new false, root
|
141
|
+
end # def initialize(root='')
|
142
|
+
|
143
|
+
end # class RPMdb
|
@@ -0,0 +1,226 @@
|
|
1
|
+
%{!?ruby_sitelib: %define ruby_sitelib %(ruby -rrbconfig -e "puts Config::CONFIG['sitelibdir']")}
|
2
|
+
%{!?ruby_sitearch: %define ruby_sitearch %(ruby -rrbconfig -e "puts Config::CONFIG['sitearchdir']")}
|
3
|
+
|
4
|
+
Summary: Ruby bindings for RPM
|
5
|
+
Name: ruby-rpm
|
6
|
+
|
7
|
+
Version: 1.2.2
|
8
|
+
Release: 1%{?dist}
|
9
|
+
Group: Development/Languages
|
10
|
+
License: GPL
|
11
|
+
URL: http://rubyforge.org/projects/ruby-rpm/
|
12
|
+
Source0: %{name}-%{version}.tgz
|
13
|
+
BuildRoot: %{_tmppath}/%{name}-%{version}-root
|
14
|
+
Requires: ruby >= 1.8.1
|
15
|
+
BuildRequires: ruby >= 1.8.1
|
16
|
+
BuildRequires: ruby-devel >= 1.8.1
|
17
|
+
BuildRequires: rpm-devel >= 4.2.1
|
18
|
+
BuildRequires: db4-devel
|
19
|
+
|
20
|
+
%description
|
21
|
+
Bindings for accessing RPM packages and databases from Ruby.
|
22
|
+
|
23
|
+
%prep
|
24
|
+
%setup -q
|
25
|
+
|
26
|
+
%build
|
27
|
+
ruby install.rb config \
|
28
|
+
--bin-dir=%{_bindir} \
|
29
|
+
--rb-dir=%{ruby_sitelib} \
|
30
|
+
--so-dir=%{ruby_sitearch} \
|
31
|
+
--data-dir=%{_datadir}
|
32
|
+
|
33
|
+
ruby install.rb setup
|
34
|
+
|
35
|
+
%install
|
36
|
+
[ "%{buildroot}" != "/" ] && %__rm -rf %{buildroot}
|
37
|
+
ruby install.rb config \
|
38
|
+
--bin-dir=%{buildroot}%{_bindir} \
|
39
|
+
--rb-dir=%{buildroot}%{ruby_sitelib} \
|
40
|
+
--so-dir=%{buildroot}%{ruby_sitearch} \
|
41
|
+
--data-dir=%{buildroot}%{_datadir}
|
42
|
+
ruby install.rb install
|
43
|
+
chmod 0755 %{buildroot}%{ruby_sitearch}/rpmmodule.so
|
44
|
+
|
45
|
+
%clean
|
46
|
+
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}
|
47
|
+
|
48
|
+
%files
|
49
|
+
%defattr(-, root, root)
|
50
|
+
%doc NEWS README COPYING ChangeLog doc
|
51
|
+
%{ruby_sitelib}/rpm.rb
|
52
|
+
%{ruby_sitearch}/rpmmodule.so
|
53
|
+
|
54
|
+
%changelog
|
55
|
+
* Tue Nov 14 2006 David Lutterkort <dlutter@redhat.com> - 1.2.1-1
|
56
|
+
- Adapted for Fedora
|
57
|
+
|
58
|
+
* Fri Jul 02 2004 Pascal Terjan <pterjan@mandrake.org> 1.2.0-1mdk
|
59
|
+
- Adapt for Mandrakelinux
|
60
|
+
- Patch for a segfault when TMP or TEMP or TMPDIR exist but does not contain =
|
61
|
+
|
62
|
+
* Sun Mar 14 2004 Toru Hoshina <t@momonga-linux.org>
|
63
|
+
- (1.2.0-1m)
|
64
|
+
- for rpm 4.2.1.
|
65
|
+
|
66
|
+
* Tue Jan 20 2004 YAMAZAKI Makoto <zaki@zakky.org>
|
67
|
+
- (1.1.12-2m)
|
68
|
+
- add patch to fix SEGV if TMP or TEMP or TMPDIR environment variable exists. [bug:#19]
|
69
|
+
|
70
|
+
* Sun Jan 11 2004 Kenta MURATA <muraken2@nifty.com>
|
71
|
+
- (1.1.12-1m)
|
72
|
+
- version up.
|
73
|
+
|
74
|
+
* Sat Nov 01 2003 Kenta MURATA <muraken2@nifty.com>
|
75
|
+
- (1.1.11-1m)
|
76
|
+
- version up.
|
77
|
+
|
78
|
+
* Mon Aug 04 2003 Kenta MURATA <muraken2@nifty.com>
|
79
|
+
- (1.1.10-3m)
|
80
|
+
- merge from ruby-1_8-branch.
|
81
|
+
|
82
|
+
* Sun Aug 03 2003 Kenta MURATA <muraken2@nifty.com>
|
83
|
+
- (1.1.10-2m)
|
84
|
+
- rebuild against ruby-1.8.0.
|
85
|
+
|
86
|
+
* Sun May 4 2003 Kenta MURATA <muraken2@nifty.com>
|
87
|
+
- (1.1.10-1m)
|
88
|
+
- version up.
|
89
|
+
|
90
|
+
* Tue Mar 4 2003 Shingo Akagaki <dora@kitty.dnsalias.org>
|
91
|
+
- (1.1.9-1m)
|
92
|
+
- version up.
|
93
|
+
|
94
|
+
* Sat Jan 18 2003 Shingo Akagaki <dora@kitty.dnsalias.org>
|
95
|
+
- (1.1.8-1m)
|
96
|
+
- version up.
|
97
|
+
|
98
|
+
* Wed Dec 25 2002 Shingo Akagaki <dora@kitty.dnsalias.org>
|
99
|
+
- (1.1.7-1m)
|
100
|
+
- version up.
|
101
|
+
|
102
|
+
* Tue Dec 17 2002 Shingo Akagaki <dora@kitty.dnsalias.org>
|
103
|
+
- (1.1.6-1m)
|
104
|
+
- version up.
|
105
|
+
|
106
|
+
* Tue Dec 10 2002 Shingo Akagaki <dora@kitty.dnsalias.org>
|
107
|
+
- (1.1.5-1m)
|
108
|
+
- version up.
|
109
|
+
|
110
|
+
* Fri Dec 6 2002 Shingo Akagaki <dora@kitty.dnsalias.org>
|
111
|
+
- (1.1.4-2m)
|
112
|
+
- bug fix.
|
113
|
+
|
114
|
+
* Fri Dec 6 2002 Shingo Akagaki <dora@kitty.dnsalias.org>
|
115
|
+
- (1.1.4-1m)
|
116
|
+
- version up.
|
117
|
+
|
118
|
+
* Thu Dec 5 2002 Shingo Akagaki <dora@kitty.dnsalias.org>
|
119
|
+
- (1.1.3-2m)
|
120
|
+
- bug fix.
|
121
|
+
|
122
|
+
* Thu Dec 5 2002 Shingo Akagaki <dora@kitty.dnsalias.org>
|
123
|
+
- (1.1.3-1m)
|
124
|
+
- version up.
|
125
|
+
|
126
|
+
* Thu Dec 5 2002 Shingo Akagaki <dora@kitty.dnsalias.org>
|
127
|
+
- (1.1.2-1m)
|
128
|
+
- version up.
|
129
|
+
|
130
|
+
* Fri May 31 2002 Kenta MURATA <muraken@kondara.org>
|
131
|
+
- (1.1.1-2k)
|
132
|
+
- version up.
|
133
|
+
|
134
|
+
* Fri May 31 2002 Kenta MURATA <muraken@kondara.org>
|
135
|
+
- (1.1.0-2k)
|
136
|
+
- version up.
|
137
|
+
|
138
|
+
* Tue May 7 2002 Kenta MURATA <muraken@kondara.org>
|
139
|
+
- (1.0.1-2k)
|
140
|
+
- version up.
|
141
|
+
|
142
|
+
* Fri May 3 2002 Kenta MURATA <muraken@kondara.org>
|
143
|
+
- (1.0.0-2k)
|
144
|
+
- version up.
|
145
|
+
|
146
|
+
* Wed May 1 2002 Kenta MURATA <muraken@kondara.org>
|
147
|
+
- (0.3.13-2k)
|
148
|
+
- version up.
|
149
|
+
|
150
|
+
* Mon Apr 29 2002 Kenta MURATA <muraken@kondara.org>
|
151
|
+
- (0.3.12-2k)
|
152
|
+
- version up.
|
153
|
+
|
154
|
+
* Sun Apr 28 2002 Kenta MURATA <muraken@kondara.org>
|
155
|
+
- (0.3.11-2k)
|
156
|
+
- version up.
|
157
|
+
|
158
|
+
* Wed Apr 24 2002 Kenta MURATA <muraken@kondara.org>
|
159
|
+
- (0.3.10-2k)
|
160
|
+
- version up.
|
161
|
+
|
162
|
+
* Sun Apr 21 2002 Toru Hoshina <t@kondara.org>
|
163
|
+
- (0.3.9-6k)
|
164
|
+
- i586tega... copytega...
|
165
|
+
|
166
|
+
* Sun Apr 21 2002 Kenta MURATA <muraken@kondara.org>
|
167
|
+
- (0.3.9-4k)
|
168
|
+
- applyed patch basenames and dirindexes.
|
169
|
+
|
170
|
+
* Sun Apr 21 2002 Kenta MURATA <muraken@kondara.org>
|
171
|
+
- (0.3.9-2k)
|
172
|
+
- version up.
|
173
|
+
|
174
|
+
* Sun Apr 21 2002 Kenta MURATA <muraken@kondara.org>
|
175
|
+
- (0.3.8-4k)
|
176
|
+
- ukekeke.
|
177
|
+
|
178
|
+
* Fri Apr 19 2002 Kenta MURATA <muraken@kondara.org>
|
179
|
+
- (0.3.8-2k)
|
180
|
+
- version up.
|
181
|
+
- devel merge to main.
|
182
|
+
|
183
|
+
* Fri Apr 19 2002 Kenta MURATA <muraken@kondara.org>
|
184
|
+
- (0.3.7-2k)
|
185
|
+
- version up.
|
186
|
+
- append package devel for neomph. fufufu.
|
187
|
+
|
188
|
+
* Fri Apr 19 2002 Kenta MURATA <muraken@kondara.org>
|
189
|
+
- (0.3.6-2k)
|
190
|
+
- version up.
|
191
|
+
|
192
|
+
* Fri Apr 19 2002 Kenta MURATA <muraken@kondara.org>
|
193
|
+
- (0.3.5-4k)
|
194
|
+
- defattr
|
195
|
+
|
196
|
+
* Thu Apr 18 2002 Kenta MURATA <muraken@kondara.org>
|
197
|
+
- (0.3.5-2k)
|
198
|
+
- version up.
|
199
|
+
|
200
|
+
* Thu Apr 18 2002 Kenta MURATA <muraken@kondara.org>
|
201
|
+
- (0.3.4-2k)
|
202
|
+
- version up.
|
203
|
+
|
204
|
+
* Thu Apr 18 2002 Kenta MURATA <muraken@kondara.org>
|
205
|
+
- (0.3.3-4k)
|
206
|
+
- apply patch to DB#each_match
|
207
|
+
|
208
|
+
* Thu Apr 18 2002 Kenta MURATA <muraken@kondara.org>
|
209
|
+
- (0.3.3-2k)
|
210
|
+
- version up.
|
211
|
+
|
212
|
+
* Wed Apr 17 2002 Kenta MURATA <muraken@kondara.org>
|
213
|
+
- (0.3.2-2k)
|
214
|
+
- version up.
|
215
|
+
|
216
|
+
* Wed Apr 17 2002 Kenta MURATA <muraken@kondara.org>
|
217
|
+
- (0.3.1-6k)
|
218
|
+
- apply patch version_parse.
|
219
|
+
|
220
|
+
* Wed Apr 17 2002 Kenta MURATA <muraken@kondara.org>
|
221
|
+
- (0.3.1-4k)
|
222
|
+
- apply patch Init_hoge.
|
223
|
+
|
224
|
+
* Wed Apr 17 2002 Kenta MURATA <muraken@kondara.org>
|
225
|
+
- (0.3.1-2k)
|
226
|
+
- first release.
|
data/tests/runner.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
rootdir = "#{File::dirname($0)}/.."
|
5
|
+
$:.unshift( "#{rootdir}/tests", "#{rootdir}/lib", "#{rootdir}/ext/rpm" )
|
6
|
+
|
7
|
+
require 'test_db'
|
8
|
+
require 'test_rpm'
|
9
|
+
require 'test_source'
|
10
|
+
#require 'test_ts'
|
11
|
+
require 'test_version'
|
12
|
+
require 'test_file'
|
13
|
+
require 'test_dependency'
|
14
|
+
|
15
|
+
exit Test::Unit::AutoRunner.run(false, File.dirname($0))
|
data/tests/test_db.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'tmpdir'
|
4
|
+
require 'rpm'
|
5
|
+
|
6
|
+
class RPM_DB_Tests < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@work_dir = "#{Dir.tmpdir}/.ruby-rpm-test"
|
9
|
+
unless File.directory?(@work_dir) then
|
10
|
+
Dir.mkdir(@work_dir, 0777)
|
11
|
+
end
|
12
|
+
## create database directory
|
13
|
+
FileUtils.mkdir_p( "#{@work_dir}#{RPM['_dbpath']}" )
|
14
|
+
RPM::DB.init( @work_dir )
|
15
|
+
@a = RPM::DB.open( true, @work_dir )
|
16
|
+
end # def setup
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
@a.close
|
20
|
+
FileUtils.rm_rf(@work_dir)
|
21
|
+
end # def teardown
|
22
|
+
|
23
|
+
def test_init
|
24
|
+
assert( File.exist?( "#{@tmppath}/#{RPM['_dbpath']}/Packages" ) )
|
25
|
+
end # def test_initdb
|
26
|
+
|
27
|
+
def test_rebuild
|
28
|
+
RPM::DB.rebuild( @work_dir )
|
29
|
+
assert( File.exist?( "#{@tmppath}/#{RPM['_dbpath']}/Packages" ) )
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_open
|
33
|
+
assert( @a )
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_root
|
37
|
+
assert_equal( @a.root, @work_dir )
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_home
|
41
|
+
assert_equal( @a.home, RPM['_dbpath'] )
|
42
|
+
end
|
43
|
+
|
44
|
+
end # class RPM_DB_Tests < Test::Unit::TestCase
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'rpm'
|
3
|
+
|
4
|
+
class RPM_Dependency_Tests < Test::Unit::TestCase
|
5
|
+
|
6
|
+
EQ = RPM::SENSE_EQUAL
|
7
|
+
LT = RPM::SENSE_LESS
|
8
|
+
GT = RPM::SENSE_GREATER
|
9
|
+
|
10
|
+
def test_satisfy
|
11
|
+
prv = provide("foo", "2", "1", 0, EQ)
|
12
|
+
req = require("foo", "1", "1", 0, EQ|GT)
|
13
|
+
assert(req.satisfy?(prv))
|
14
|
+
assert(prv.satisfy?(req))
|
15
|
+
|
16
|
+
# Different names don't overlap
|
17
|
+
prv = provide("foo", "2", "1", 0, EQ)
|
18
|
+
req = require("bar", "1", "1", 0, EQ|GT)
|
19
|
+
assert(! req.satisfy?(prv))
|
20
|
+
end
|
21
|
+
|
22
|
+
def provide(name, v, r, e, sense)
|
23
|
+
RPM::Provide.new(name, RPM::Version.new(v, r, e), sense, nil)
|
24
|
+
end
|
25
|
+
|
26
|
+
def require(name, v, r, e, sense)
|
27
|
+
RPM::Require.new(name, RPM::Version.new(v, r, e), sense, nil)
|
28
|
+
end
|
29
|
+
end
|