rpm 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +10 -0
- data/ChangeLog +5 -0
- data/README.rdoc +11 -1
- data/lib/rpm/{ffi → c}/header.rb +1 -1
- data/lib/rpm/c/rpmcallback.rb +28 -0
- data/lib/rpm/c/rpmcli.rb +7 -0
- data/lib/rpm/{ffi → c}/rpmdb.rb +1 -1
- data/lib/rpm/{ffi → c}/rpmds.rb +1 -6
- data/lib/rpm/{ffi → c}/rpmfi.rb +1 -1
- data/lib/rpm/c/rpmio.rb +21 -0
- data/lib/rpm/{ffi → c}/rpmlib.rb +1 -1
- data/lib/rpm/{ffi → c}/rpmlog.rb +3 -1
- data/lib/rpm/{ffi → c}/rpmmacro.rb +1 -10
- data/lib/rpm/{ffi → c}/rpmprob.rb +17 -3
- data/lib/rpm/{ffi → c}/rpmps.rb +1 -1
- data/lib/rpm/{ffi → c}/rpmtag.rb +12 -4
- data/lib/rpm/{ffi → c}/rpmtd.rb +1 -1
- data/lib/rpm/{ffi → c}/rpmts.rb +6 -2
- data/lib/rpm/{ffi → c}/rpmtypes.rb +3 -1
- data/lib/rpm/c.rb +47 -0
- data/lib/rpm/db.rb +5 -5
- data/lib/rpm/dependency.rb +10 -10
- data/lib/rpm/gem_version.rb +1 -1
- data/lib/rpm/match_iterator.rb +5 -5
- data/lib/rpm/package.rb +55 -55
- data/lib/rpm/problem.rb +71 -0
- data/lib/rpm/transaction.rb +186 -35
- data/lib/rpm/version.rb +3 -4
- data/lib/rpm.rb +16 -24
- data/rpm.gemspec +1 -1
- data/test/data/simple-1.0-0.i586.rpm +0 -0
- data/test/data/simple.spec +0 -4
- data/test/data/simple_with_deps-1.0-0.i586.rpm +0 -0
- data/test/data/simple_with_deps.spec +41 -0
- data/test/helper.rb +1 -1
- data/test/test_dependency.rb +1 -1
- data/test/test_lib.rb +13 -13
- data/test/test_package.rb +24 -3
- data/test/test_problem.rb +20 -0
- data/test/test_transaction.rb +115 -14
- data/test/test_version.rb +2 -0
- metadata +80 -69
- data/lib/rpm/ffi/rpmcallback.rb +0 -26
- data/lib/rpm/ffi.rb +0 -44
data/.travis.yml
ADDED
data/ChangeLog
ADDED
data/README.rdoc
CHANGED
@@ -34,6 +34,16 @@ This is an alpha release! There is still work to be done
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
== Install a package
|
38
|
+
|
39
|
+
require 'rpm'
|
40
|
+
pkg = RPM::Package.open('foo.rpm')
|
41
|
+
|
42
|
+
RPM.transaction(rootdir) do |t|
|
43
|
+
t.install(pkg, 'foo.rpm')
|
44
|
+
t.commit
|
45
|
+
end
|
46
|
+
|
37
47
|
= Introduction
|
38
48
|
|
39
49
|
This library is a replacement for the ruby-rpm gem, originally
|
@@ -65,7 +75,7 @@ from 1130 lines of code to 320.
|
|
65
75
|
|
66
76
|
The gem is divided in two modules:
|
67
77
|
|
68
|
-
* RPM::
|
78
|
+
* RPM::C:: which contains the 1:1 mapping to the librpm API
|
69
79
|
Not all functions are attached, only the ones we actually use.
|
70
80
|
* RPM:: contains the actual higher level API
|
71
81
|
|
data/lib/rpm/{ffi → c}/header.rb
RENAMED
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
module RPM
|
3
|
+
module C
|
4
|
+
|
5
|
+
CallbackType = enum(:rpmCallbackType, [
|
6
|
+
:unknown, 0,
|
7
|
+
:inst_progress, (1 << 0),
|
8
|
+
:inst_start, (1 << 1),
|
9
|
+
:inst_open_file, (1 << 2),
|
10
|
+
:inst_close_file, (1 << 3),
|
11
|
+
:trans_progress, (1 << 4),
|
12
|
+
:trans_start, (1 << 5),
|
13
|
+
:trans_stop, (1 << 6),
|
14
|
+
:uninst_progress, (1 << 7),
|
15
|
+
:uninst_start, (1 << 8),
|
16
|
+
:uninst_stop, (1 << 9),
|
17
|
+
:repackage_progress, (1 << 10),
|
18
|
+
:repackage_start, (1 << 11),
|
19
|
+
:repackage_stop, (1 << 12),
|
20
|
+
:unpack_error, (1 << 13),
|
21
|
+
:cpio_error, (1 << 14),
|
22
|
+
:script_error, (1 << 15) ])
|
23
|
+
|
24
|
+
typedef :pointer, :rpmCallbackData
|
25
|
+
callback :rpmCallbackFunction, [:pointer, :rpmCallbackType, :rpm_loff_t, :rpm_loff_t, :fnpyKey, :rpmCallbackData], :pointer
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
data/lib/rpm/c/rpmcli.rb
ADDED
data/lib/rpm/{ffi → c}/rpmdb.rb
RENAMED
data/lib/rpm/{ffi → c}/rpmds.rb
RENAMED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
module RPM
|
3
3
|
|
4
|
-
module
|
4
|
+
module C
|
5
5
|
|
6
6
|
typedef :pointer, :rpmds
|
7
7
|
|
@@ -21,11 +21,6 @@ module RPM
|
|
21
21
|
:script_preun, (1 << 11),
|
22
22
|
:script_postun, (1 << 12),
|
23
23
|
:script_verify, (1 << 13),
|
24
|
-
:script_pre, (1 << 9),
|
25
|
-
:script_post, (1 << 10),
|
26
|
-
:script_preun, (1 << 11),
|
27
|
-
:script_postun, (1 << 12),
|
28
|
-
:script_verify, (1 << 13),
|
29
24
|
:find_requires, (1 << 14),
|
30
25
|
:find_provides, (1 << 15),
|
31
26
|
#
|
data/lib/rpm/{ffi → c}/rpmfi.rb
RENAMED
data/lib/rpm/c/rpmio.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module RPM
|
2
|
+
module C
|
3
|
+
|
4
|
+
typedef :pointer, :FD_t
|
5
|
+
# RPMIO
|
6
|
+
attach_function 'Fstrerror', [:FD_t], :string
|
7
|
+
# ...
|
8
|
+
attach_function 'Fclose', [:FD_t], :int
|
9
|
+
# ...
|
10
|
+
attach_function 'Fopen', [:string, :string], :FD_t
|
11
|
+
# ...
|
12
|
+
attach_function 'Ferror', [:FD_t], :int
|
13
|
+
|
14
|
+
attach_function 'fdDup', [:int], :FD_t
|
15
|
+
|
16
|
+
attach_function 'Fstrerror', [:FD_t], :string
|
17
|
+
|
18
|
+
attach_function 'fdLink', [:pointer], :FD_t
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/lib/rpm/{ffi → c}/rpmlib.rb
RENAMED
data/lib/rpm/{ffi → c}/rpmlog.rb
RENAMED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
module RPM
|
3
3
|
|
4
|
-
module
|
4
|
+
module C
|
5
5
|
|
6
6
|
# rpmlog
|
7
7
|
RPMLOG_PRIMASK = 0x07
|
@@ -19,6 +19,8 @@ module RPM
|
|
19
19
|
|
20
20
|
attach_function 'rpmlogSetMask', [:int], :int
|
21
21
|
# TODO: defines to set verbosity
|
22
|
+
# ...
|
23
|
+
attach_function 'rpmlogMessage', [], :string
|
22
24
|
|
23
25
|
end
|
24
26
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
module RPM
|
3
3
|
|
4
|
-
module
|
4
|
+
module C
|
5
5
|
|
6
6
|
attach_variable :MACROFILES, :macrofiles, :string
|
7
7
|
# ...
|
@@ -24,15 +24,6 @@ module RPM
|
|
24
24
|
# ...
|
25
25
|
attach_function 'rpmInitMacros', [:pointer, :string], :void
|
26
26
|
# ...
|
27
|
-
|
28
|
-
# RPMIO
|
29
|
-
attach_function 'Fstrerror', [:pointer], :string
|
30
|
-
# ...
|
31
|
-
attach_function 'Fclose', [:pointer], :int
|
32
|
-
# ...
|
33
|
-
attach_function 'Fopen', [:string, :string], :pointer
|
34
|
-
# ...
|
35
|
-
attach_function 'Ferror', [:pointer], :int
|
36
27
|
end
|
37
28
|
|
38
29
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
module RPM
|
3
3
|
|
4
|
-
module
|
4
|
+
module C
|
5
5
|
|
6
6
|
typedef :pointer, :rpmProblem
|
7
7
|
|
@@ -35,8 +35,22 @@ module RPM
|
|
35
35
|
:obsoletes
|
36
36
|
])
|
37
37
|
|
38
|
+
attach_function 'rpmProblemCreate', [:rpmProblemType, :string, :fnpyKey, :string, :string, :uint64], :rpmProblem
|
39
|
+
attach_function 'rpmProblemFree', [:rpmProblem], :rpmProblem
|
40
|
+
attach_function 'rpmProblemLink', [:rpmProblem], :rpmProblem
|
38
41
|
attach_function 'rpmProblemGetType', [:rpmProblem], :rpmProblemType
|
39
42
|
attach_function 'rpmProblemGetKey', [:rpmProblem], :fnpyKey
|
40
|
-
attach_function '
|
43
|
+
attach_function 'rpmProblemGetStr', [:rpmProblem], :string
|
44
|
+
attach_function 'rpmProblemString', [:rpmProblem], :string
|
45
|
+
|
46
|
+
begin
|
47
|
+
attach_function 'rpmProblemCompare', [:rpmProblem, :rpmProblem], :int
|
48
|
+
rescue ::FFI::NotFoundError
|
49
|
+
# TODO: Implement this for librpm 4.8.
|
50
|
+
def self.rpmProblemCompare(a, b)
|
51
|
+
raise NotImplementedError, "rpmProblemCompare is not present in librpm 4.8 and below"
|
52
|
+
end
|
41
53
|
end
|
42
|
-
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
data/lib/rpm/{ffi → c}/rpmps.rb
RENAMED
data/lib/rpm/{ffi → c}/rpmtag.rb
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
module RPM
|
2
2
|
|
3
|
-
module
|
3
|
+
module C
|
4
4
|
|
5
5
|
Tag = enum(:rpmTag, [
|
6
6
|
:not_found, -1,
|
@@ -70,7 +70,7 @@ module RPM
|
|
70
70
|
:exclude, 1041,
|
71
71
|
:exclusive, 1042,
|
72
72
|
:icon, 1043,
|
73
|
-
:
|
73
|
+
:sourcerpm, 1044,
|
74
74
|
:fileverifyflags, 1045,
|
75
75
|
:archivesize, 1046,
|
76
76
|
:providename, 1047,
|
@@ -90,7 +90,7 @@ module RPM
|
|
90
90
|
:exclusivearch, 1061,
|
91
91
|
:exclusiveos, 1062,
|
92
92
|
:autoreqprov, 1063,
|
93
|
-
:
|
93
|
+
:rpmversion, 1064,
|
94
94
|
:triggerscripts, 1065,
|
95
95
|
:triggername, 1066,
|
96
96
|
:triggerversion, 1067,
|
@@ -293,7 +293,15 @@ module RPM
|
|
293
293
|
)
|
294
294
|
typedef :rpmFlags, :rpmTagReturnType
|
295
295
|
|
296
|
-
|
296
|
+
begin
|
297
|
+
attach_function 'rpmTagGetReturnType', [:rpmTagVal], :rpmTagReturnType
|
298
|
+
rescue ::FFI::NotFoundError
|
299
|
+
attach_function 'rpmTagGetType', [:rpmTagVal], :rpmTagType
|
300
|
+
|
301
|
+
def self.rpmTagGetReturnType(tag)
|
302
|
+
TagReturnType[rpmTagGetType(tag) & TagReturnType[:mask_return_type]]
|
303
|
+
end
|
304
|
+
end
|
297
305
|
|
298
306
|
end
|
299
307
|
end
|
data/lib/rpm/{ffi → c}/rpmtd.rb
RENAMED
data/lib/rpm/{ffi → c}/rpmts.rb
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
module RPM
|
2
2
|
|
3
|
-
module
|
3
|
+
module C
|
4
4
|
|
5
5
|
TransFlags = enum(:rpmtransFlags_e, [
|
6
6
|
:none, 0,
|
@@ -49,6 +49,8 @@ module RPM
|
|
49
49
|
attach_function 'rpmtsInitIterator', [:rpmts, :rpmDbiTagVal, :pointer, :int], :rpmdbMatchIterator
|
50
50
|
# ...
|
51
51
|
attach_function 'rpmtsProblems', [:rpmts], :rpmps
|
52
|
+
# ...
|
53
|
+
attach_function 'rpmtsClean', [:rpmts], :void
|
52
54
|
# more...
|
53
55
|
attach_function 'rpmtsFree', [:rpmts], :pointer
|
54
56
|
#..
|
@@ -62,9 +64,11 @@ module RPM
|
|
62
64
|
attach_function 'rpmtsFlags', [:rpmts], :rpmtransFlags
|
63
65
|
attach_function 'rpmtsSetFlags', [:rpmts, :rpmtransFlags], :rpmtransFlags
|
64
66
|
#...
|
67
|
+
attach_function 'rpmtsSetNotifyCallback', [:rpmts, :rpmCallbackFunction, :rpmCallbackData], :int
|
68
|
+
#...
|
65
69
|
attach_function 'rpmtsCreate', [], :rpmts
|
66
70
|
attach_function 'rpmtsAddInstallElement', [:rpmts, :header, :fnpyKey, :int, :rpmRelocation], :int
|
67
|
-
|
71
|
+
attach_function 'rpmtsAddEraseElement', [:rpmts, :header, :int], :int
|
68
72
|
|
69
73
|
end
|
70
74
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
module RPM
|
3
3
|
|
4
|
-
module
|
4
|
+
module C
|
5
5
|
|
6
6
|
Rc = enum(
|
7
7
|
:ok, 0,
|
@@ -18,6 +18,8 @@ module RPM
|
|
18
18
|
typedef :rpm_tag_t, :rpmDbiTagVal
|
19
19
|
|
20
20
|
typedef :uint32, :rpmFlags
|
21
|
+
typedef :uint32, :rpm_off_t
|
22
|
+
typedef :uint64, :rpm_loff_t
|
21
23
|
|
22
24
|
typedef :pointer, :FD_t
|
23
25
|
typedef :pointer, :fnpyKey
|
data/lib/rpm/c.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'ffi'
|
3
|
+
|
4
|
+
module RPM
|
5
|
+
module C
|
6
|
+
|
7
|
+
extend ::FFI::Library
|
8
|
+
|
9
|
+
begin
|
10
|
+
ffi_lib ['rpm', 'librpm.so.2', 'librpm.so.1']
|
11
|
+
rescue LoadError => e
|
12
|
+
raise(
|
13
|
+
"Can't find rpm libs on your system: #{e.message}"
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'rpm/c/rpmtypes'
|
21
|
+
require 'rpm/c/rpmcallback'
|
22
|
+
require 'rpm/c/rpmtag'
|
23
|
+
require 'rpm/c/rpmlib'
|
24
|
+
require 'rpm/c/rpmlog'
|
25
|
+
require 'rpm/c/rpmmacro'
|
26
|
+
require 'rpm/c/rpmio'
|
27
|
+
require 'rpm/c/header'
|
28
|
+
require 'rpm/c/rpmprob'
|
29
|
+
require 'rpm/c/rpmps'
|
30
|
+
require 'rpm/c/rpmfi'
|
31
|
+
require 'rpm/c/rpmdb'
|
32
|
+
require 'rpm/c/rpmcallback'
|
33
|
+
require 'rpm/c/rpmcli'
|
34
|
+
require 'rpm/c/rpmts'
|
35
|
+
require 'rpm/c/rpmds'
|
36
|
+
require 'rpm/c/rpmtd'
|
37
|
+
|
38
|
+
module RPM
|
39
|
+
module C
|
40
|
+
|
41
|
+
def self.rpm_version_code
|
42
|
+
ver = ::RPM::C.RPMVERSION.split('.', 3)
|
43
|
+
return (ver[0].to_i<<16) + (ver[1].to_i<<8) + (ver[2].to_i<<0)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
data/lib/rpm/db.rb
CHANGED
@@ -12,7 +12,7 @@ module RPM
|
|
12
12
|
opts[:writable] ||= false
|
13
13
|
|
14
14
|
@ts = ts
|
15
|
-
RPM::
|
15
|
+
RPM::C.rpmtsOpenDB(@ts.ptr, opts[:writable] ? Fcntl::O_RDWR | Fcntl::O_CREAT : Fcntl::O_RDONLY )
|
16
16
|
end
|
17
17
|
|
18
18
|
# @return [RPM::MatchIterator] Creates an iterator for +tag+ and +val+
|
@@ -48,11 +48,11 @@ module RPM
|
|
48
48
|
|
49
49
|
# @visibility private
|
50
50
|
def ptr
|
51
|
-
RPM::
|
51
|
+
RPM::C.rpmtsGetRdb(@ts.ptr)
|
52
52
|
end
|
53
53
|
|
54
54
|
def close
|
55
|
-
RPM::
|
55
|
+
RPM::C.rpmtsCloseDB(@ts.ptr)
|
56
56
|
end
|
57
57
|
|
58
58
|
def closed?
|
@@ -98,13 +98,13 @@ module RPM
|
|
98
98
|
|
99
99
|
# @return [String] The root path of the database
|
100
100
|
def root
|
101
|
-
RPM::
|
101
|
+
RPM::C.rpmtsRootDir(@ts.ptr)
|
102
102
|
end
|
103
103
|
|
104
104
|
# @deprecated Use RPM::Transaction#each
|
105
105
|
def self.each
|
106
106
|
DB.open do |db|
|
107
|
-
it = MatchIterator.from_ptr(RPM::
|
107
|
+
it = MatchIterator.from_ptr(RPM::C.rpmdbInitIterator(db.ptr, 0, nil, 0))
|
108
108
|
if block_given?
|
109
109
|
it.each do |pkg|
|
110
110
|
yield pkg
|
data/lib/rpm/dependency.rb
CHANGED
@@ -37,16 +37,16 @@ module RPM
|
|
37
37
|
end
|
38
38
|
return false
|
39
39
|
when RPM::Dependency then
|
40
|
-
RPM::
|
41
|
-
RPM::
|
40
|
+
RPM::C.rpmdsCompare(
|
41
|
+
RPM::C.rpmdsSingle(:providename, other.name,
|
42
42
|
other.version.to_vre, other.flags),
|
43
|
-
RPM::
|
43
|
+
RPM::C.rpmdsSingle(:providename, name,
|
44
44
|
version.to_vre, flags)) != 0
|
45
45
|
when RPM::Version then
|
46
|
-
RPM::
|
47
|
-
RPM::
|
46
|
+
RPM::C.rpmdsCompare(
|
47
|
+
RPM::C.rpmdsSingle(:providename, name,
|
48
48
|
other.to_vre, other.to_vre.empty? ? 0 : :equal),
|
49
|
-
RPM::
|
49
|
+
RPM::C.rpmdsSingle(:providename, name,
|
50
50
|
version.to_vre, flags)) != 0
|
51
51
|
else
|
52
52
|
raise(TypeError, "#{other} is not a Version or Dependency")
|
@@ -118,13 +118,13 @@ module RPM
|
|
118
118
|
|
119
119
|
end
|
120
120
|
|
121
|
-
class
|
121
|
+
class Obsolete < Dependency
|
122
122
|
|
123
123
|
def initialize(name, version, flags, owner)
|
124
124
|
super(name, version, flags, owner)
|
125
|
-
@nametag = RPM::TAG[:
|
126
|
-
@versiontag = RPM::TAG[:
|
127
|
-
@flagstag = RPM::TAG[:
|
125
|
+
@nametag = RPM::TAG[:obsoletename]
|
126
|
+
@versiontag = RPM::TAG[:obsoleteversion]
|
127
|
+
@flagstag = RPM::TAG[:obsoleteflags]
|
128
128
|
end
|
129
129
|
|
130
130
|
end
|