rpm 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ef796d682ecf5ae0bd191f27269a1bb167bd4411
4
+ data.tar.gz: ba843e7692331def95b92e742a36770ee9685d10
5
+ SHA512:
6
+ metadata.gz: cdfdfa2a44542aec13d3fa4c4cb1043730969355a3f849a33dc28955a8a63805b145bf44e6a710e119213626764c271bdbfaea5122a503cdc83daf14e0d1a082
7
+ data.tar.gz: c6286f572699c6815219a79e5aa6e5c7716746b2bd93a9a5cfcad7297bbecfc5530cb9497bf4539aff823b020bf8d9a393a80f7668ff9d71ad5f361ef92ea7da
@@ -1,10 +1,20 @@
1
- language: ruby
1
+ sudo: required
2
+ services:
3
+ - docker
4
+
2
5
  before_install:
3
- - sudo apt-get install rpm
4
- - sudo apt-get install -y -q fakeroot fakechroot
5
- - sudo apt-get install -y -q locales
6
- - sudo locale-gen es_ES.utf8
7
- rvm:
8
- - 1.9.3
9
- script: fakechroot rake
6
+ - sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
7
+ - sudo sh -c 'echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" > /etc/apt/sources.list.d/docker.list'
8
+ - sudo apt-get update
9
+ - sudo apt-get purge lxc-docker*
10
+ - sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" install docker-engine
11
+ - sudo sh -c "echo 'DOCKER_OPTS=\"--storage-driver=devicemapper\"' >> /etc/default/docker"
12
+ - sudo cat /etc/default/docker
13
+ - sudo service docker restart
14
+ - docker info
15
+ - sudo DEBIAN_FRONTEND=noninteractive apt-get install -y dash rake
16
+
17
+ script:
18
+ - rake docker_images
19
+ - rake docker_test
10
20
 
data/Gemfile CHANGED
@@ -2,3 +2,10 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in rpm.gemspec
4
4
  gemspec
5
+
6
+ group :test do
7
+ gem 'minitest'
8
+ gem 'rake'
9
+ end
10
+
11
+
@@ -0,0 +1,342 @@
1
+
2
+ # RPM bindings for ruby
3
+
4
+ ![maintained](https://img.shields.io/maintenance/yes/2016.svg) [![Build Status](https://travis-ci.org/dmacvicar/ruby-rpm-ffi.svg?branch=master)](https://travis-ci.org/dmacvicar/ruby-rpm-ffi)
5
+
6
+ * http://github.com/dmacvicar/ruby-rpm-ffi
7
+
8
+ # WARNING
9
+
10
+ This is an alpha release! There is still work to be done
11
+
12
+ # Quickstart
13
+
14
+ ## Working with RPM package files
15
+
16
+ ```ruby
17
+ require 'rpm'
18
+
19
+ pkg = RPM::Package.open("file.rpm")
20
+ pkg.arch => "x86_64"
21
+
22
+ pkg.files.each do |file|
23
+ puts file.path
24
+ end
25
+
26
+ pkg.changelog.each do |entry|
27
+ puts "#{entry.name} #{entry.time} #{entry.text}"
28
+ end
29
+ ```
30
+
31
+ ## Querying the rpm database
32
+
33
+ ```ruby
34
+ require 'rpm'
35
+
36
+ RPM.transaction do |ts|
37
+ ts.each do |pkg|
38
+ puts pkg
39
+ end
40
+ end
41
+ ```
42
+
43
+ ## Install a package
44
+
45
+ ```ruby
46
+ require 'rpm'
47
+
48
+ pkg = RPM::Package.open('foo.rpm')
49
+
50
+ RPM.transaction(rootdir) do |t|
51
+ t.install(pkg, 'foo.rpm')
52
+ t.commit
53
+ end
54
+ ```
55
+
56
+ ## Introduction
57
+
58
+ This library is a replacement for the ruby-rpm gem, originally
59
+ writen by Kenta Murata around 2002 for the Kondara distribution. Later
60
+ mantained by David Lutterkort and myself.
61
+
62
+ Why?
63
+
64
+ * The original gem supports ancient rpm versions not in use anymore
65
+ * The original gem was written in C using MRI API
66
+ * The #ifdef'ing required to support multiple rpm versions made the code
67
+ hard to maintain
68
+
69
+ This gem:
70
+
71
+ * Is pure ruby
72
+ * Is documented
73
+ * Has as a goal to support only the latest rpm version plus the ones in
74
+ use some releases back in popular rpm based distros
75
+ * Uses FFI, so it should work with other interpreters
76
+ (Because https://github.com/rubinius/rubinius/issues/682 it currently does
77
+ not work on Rubinius)
78
+ * Does not target rpm5, but it may support it someday
79
+
80
+ As an example the code that implements RPM::Package was reduced
81
+ from 1130 lines of code to 320.
82
+
83
+ # Architecture
84
+
85
+ The gem is divided in two modules:
86
+
87
+ * RPM::C:: which contains the 1:1 mapping to the librpm API
88
+ Not all functions are attached, only the ones we actually use.
89
+ * RPM:: contains the actual higher level API
90
+
91
+ # Status, Compatibility and Differences with ruby-rpm
92
+
93
+ * Tested rpm 4.9 only
94
+ * You can use symbols: instead of RPM::TAG_DESCRIPTION you
95
+ can use just :description. 'rpm/compat' is by default loaded
96
+ and provides compatibility with the RPM::TAG_* style constants
97
+ * RPM::DB is not supported. Use RPM::Transaction
98
+ * Spec and Source classes are not implemented yet
99
+
100
+ ## TESTING
101
+
102
+ Unit tests can be run using the `rake test` command.
103
+
104
+ ### Docker tests
105
+
106
+ In order to not damage your system, you can run the testsuite under docker:
107
+
108
+ * Build the docker images:
109
+
110
+ ```console
111
+ rake docker_images
112
+ ```
113
+
114
+ * Run the testsuite under Docker
115
+
116
+ ```console
117
+ rake docker_test
118
+ ```
119
+
120
+ ## TODO
121
+
122
+ * Check Package#signature should return String?
123
+ => ruby-rpm seems to return symbol
124
+ * Food for thought: Package dependencies and changelog
125
+ methods could just use []. Calling headerGet directly saves
126
+ us from doing one iteration per attribute
127
+ * Not sure if Spec can be implemented as it was before with
128
+ newer rpms.
129
+
130
+ ## API Checklist and TODO
131
+
132
+ ### RPM
133
+
134
+ - [ ] RPM#expand
135
+ - [X] RPM#[]
136
+ - [X] RPM#[]=
137
+ - [ ] RPM#readrc
138
+ - [ ] RPM#init_macros
139
+ - [ ] RPM#verbosity
140
+ - [ ] RPM#verbosity=
141
+
142
+ ### RPM::Package
143
+
144
+ - [X] Package#open
145
+ - [X] Package#new
146
+ - [X] Package#create
147
+ - [ ] Package#load
148
+ - [ ] Package#clear_cache
149
+ - [ ] Package#use_cache
150
+ - [X] Package#[]
151
+ - [ ] Package#delete_tag
152
+ - [X] Package#sprintf
153
+ [?] Package#signature
154
+ - [X] Package#arch
155
+ - [X] Package#name
156
+ - [X] Package#version
157
+ - [X] Package#files
158
+ - [X] Package#provides
159
+ - [X] Package#requires
160
+ - [X] Package#conflicts
161
+ - [X] Package#obsoletes
162
+ - [X] Package#changelog
163
+ - [ ] Package#add_dependency
164
+ - [ ] Package#add_string
165
+ - [ ] Package#add_string_array
166
+ - [ ] Package#add_int32
167
+ - [ ] Package#dump
168
+ - [X] Package#to_s
169
+ - [ ] Package#inspect
170
+ - [ ] Package#copy_to
171
+
172
+ ### RPM::Dependency
173
+
174
+ - [X] Dependency#initialize
175
+ - [X] Dependency#name
176
+ - [X] Dependency#version
177
+ - [X] Dependency#flags
178
+ - [X] Dependency#owner
179
+ - [X] Dependency#lt?
180
+ - [X] Dependency#gt?
181
+ - [X] Dependency#eq?
182
+ - [X] Dependency#le?
183
+ - [X] Dependency#ge?
184
+ - [X] Dependency#satisfy?
185
+ - [X] Dependency#nametag
186
+ - [X] Dependency#versiontag
187
+ - [X] Dependency#flagstag
188
+
189
+ ### RPM::Provide
190
+
191
+ - [X] Provide#initialize
192
+
193
+ ### RPM::Require
194
+
195
+ - [X] Require#initialize
196
+ - [ ] Require#pre?
197
+
198
+ ### RPM::Conflict
199
+
200
+ - [X] Conflict#initialize
201
+
202
+ ### RPM::Obsolete
203
+
204
+ - [X] Obsolete#initialize
205
+
206
+ ### RPM::ChangeLog
207
+
208
+ - [X] ChangeLog#time
209
+ - [X] ChangeLog#name
210
+ - [X] ChangeLog#text
211
+
212
+ ### RPM::Version
213
+
214
+ - [X] Version (Comparable)
215
+ - [X] Version#initialize
216
+ - [X] Version#<=>
217
+ - [X] Version#newer?
218
+ - [X] Version#older?
219
+ - [X] Version#v
220
+ - [X] Version#r
221
+ - [X] Version#e
222
+ - [X] Version#to_s
223
+ - [X] Version#to_vre
224
+ - [X] Version#inspect
225
+ - [X] Version#hash
226
+
227
+ ### RPM::File
228
+
229
+ - [X] File#initialize
230
+ - [X] File#path
231
+ - [ ] File#to_s (alias path)
232
+ - [X] File#md5sum
233
+ - [X] File#link_to
234
+ - [X] File#size
235
+ - [X] File#mtime
236
+ - [X] File#owner
237
+ - [X] File#group
238
+ - [X] File#rdev
239
+ - [X] File#mode
240
+ - [X] File#attr
241
+ - [X] File#state
242
+ - [X] File#symlink?
243
+ - [X] File#config?
244
+ - [X] File#doc?
245
+ - [X] File#donotuse?
246
+ - [X] File#missingok?
247
+ - [X] File#specfile?
248
+ - [X] File#ghost?
249
+ - [X] File#license?
250
+ - [X] File#readme?
251
+ - [X] File#exclude?
252
+ - [X] File#replaced?
253
+ - [X] File#notinstalled?
254
+ - [X] File#netshared?
255
+
256
+ ### RPM::DB
257
+
258
+ - [ ] DB (Enumerable)
259
+ - [ ] DB#new
260
+ - [ ] DB#open
261
+ - [ ] DB#init
262
+ - [ ] DB#rebuild
263
+ - [ ] DB#close
264
+ - [ ] DB#closed?
265
+ - [ ] DB#root
266
+ - [ ] DB#home
267
+ - [ ] DB#writable?
268
+ - [ ] DB#each_match
269
+ - [ ] DB#each
270
+ - [ ] DB#transaction
271
+ - [ ] DB#init_iterator
272
+ - [ ] DB#dup
273
+ - [ ] DB#clone
274
+
275
+ ### RPM::MatchIterator
276
+
277
+ - [X] MatchIterator (Enumerable)
278
+ - [X] MatchIterator#each
279
+ - [X] MatchIterator#next_iterator
280
+ - [X] MatchIterator#offset
281
+ - [X] MatchIterator#set_iterator_re
282
+ - [X] MatchIterator#regexp
283
+ - [X] MatchIterator#set_iterator_version
284
+ - [X] MatchIterator#version
285
+ - [X] MatchIterator#get_iterator_count
286
+ - [X] MatchIterator#length
287
+
288
+ ### RPM::Transaction
289
+
290
+ - [ ] Transaction#db
291
+ - [ ] Transaction#script_file
292
+ - [ ] Transaction#script_file=
293
+ - [ ] Transaction#install
294
+ - [ ] Transaction#upgrade
295
+ - [ ] Transaction#available
296
+ - [ ] Transaction#delete
297
+ - [ ] Transaction#check
298
+ - [ ] Transaction#order
299
+ - [ ] Transaction#keys
300
+ - [ ] Transaction#commit
301
+ - [ ] Transaction#abort
302
+ - [ ] Transaction#dup
303
+ - [ ] Transaction#clone
304
+
305
+ ### RPM::Source
306
+
307
+ - [ ] Source#initialize
308
+ - [ ] Source#fullname
309
+ - [ ] Source#to_s (alias fullname)
310
+ - [ ] Source#num
311
+ - [ ] Source#no?
312
+
313
+ ### RPM::Patch
314
+
315
+ ### RPM::Icon
316
+
317
+ ### RPM::Spec
318
+
319
+ - [ ] Spec#open
320
+ - [ ] Spec#new
321
+ - [ ] Spec#buildroot
322
+ - [ ] Spec#buildsubdir
323
+ - [ ] Spec#buildarchs
324
+ - [ ] Spec#buildrequires
325
+ - [ ] Spec#build_restrictions
326
+ - [ ] Spec#sources
327
+ - [ ] Spec#packages
328
+ - [ ] Spec#build
329
+ - [ ] Spec#expand_macros
330
+ - [ ] Spec#dup
331
+ - [ ] Spec#clone
332
+
333
+ # LICENSE
334
+
335
+ * Copyright © 2011 Duncan Mac-Vicar Prett <dmacvicar@suse.de>
336
+ * Copyright © 2011 SUSE Linux Products GmbH
337
+
338
+ * This gem is a pure-ruby rewrite of ruby-rpm:
339
+ Copyright © 2002 Kenta Murata. Relicensed with his permission.
340
+
341
+ Licensed under the MIT license. See MIT-LICENSE for details.
342
+
data/Rakefile CHANGED
@@ -23,10 +23,30 @@ begin
23
23
  end
24
24
  rescue LoadError
25
25
  STDERR.puts "Install yard if you want prettier docs"
26
- require 'rdoc/task'
27
- Rake::RDocTask.new(:doc) do |rdoc|
28
- rdoc.rdoc_dir = "doc"
29
- rdoc.title = "rpm for Ruby #{RPM::GEM_VERSION}"
30
- extra_docs.each { |ex| rdoc.rdoc_files.include ex }
26
+ begin
27
+ require 'rdoc/task'
28
+ Rake::RDocTask.new(:doc) do |rdoc|
29
+ rdoc.rdoc_dir = "doc"
30
+ rdoc.title = "rpm for Ruby #{RPM::GEM_VERSION}"
31
+ extra_docs.each { |ex| rdoc.rdoc_files.include ex }
32
+ end
33
+ rescue LoadError
34
+ STDERR.puts "rdoc not available"
31
35
  end
32
- end
36
+ end
37
+
38
+ task :docker_images do
39
+ Dir.chdir('_docker') do
40
+ Dir.glob('Dockerfile.*').each do |dockerfile|
41
+ tag = 'ruby-rpm-ffi:' + File.extname(dockerfile).delete('.')
42
+ sh %(docker build -f #{dockerfile} -t #{tag} .)
43
+ end
44
+ end
45
+ end
46
+
47
+ task :docker_test do
48
+ Dir.glob('_docker/Dockerfile.*').each do |dockerfile|
49
+ tag = 'ruby-rpm-ffi:' + File.extname(dockerfile).delete('.')
50
+ sh %(docker run -ti -v #{Dir.pwd}:/src #{tag} rake test)
51
+ end
52
+ end
@@ -0,0 +1,4 @@
1
+ FROM opensuse/amd64:leap
2
+ RUN zypper -n install --no-recommends ruby2.1-rubygem-ffi ruby2.1-rubygem-rake ruby2.1-rubygem-bundler git-core
3
+ VOLUME /src
4
+ WORKDIR /src
@@ -0,0 +1,4 @@
1
+ FROM opensuse/amd64:tumbleweed
2
+ RUN zypper -n install --no-recommends ruby2.2-rubygem-ffi ruby2.2-rubygem-bundler git-core
3
+ VOLUME /src
4
+ WORKDIR /src
@@ -7,7 +7,9 @@ module RPM
7
7
  extend ::FFI::Library
8
8
 
9
9
  begin
10
- ffi_lib ['rpm', 'librpm.so.2', 'librpm.so.1']
10
+ ffi_lib ['rpm',
11
+ 'librpm.so.7', # fedora 23
12
+ 'librpm.so.3', 'librpm.so.2', 'librpm.so.1']
11
13
  rescue LoadError => e
12
14
  raise(
13
15
  "Can't find rpm libs on your system: #{e.message}"
@@ -44,4 +46,4 @@ module RPM
44
46
  end
45
47
 
46
48
  end
47
- end
49
+ end
@@ -70,12 +70,12 @@ module RPM
70
70
 
71
71
  # @return [Boolean] true if '=<' is used to compare the version
72
72
  def le?
73
- (flags & RPM::SENSE[:less]) && (flags & RPMSENSE[:equal])
73
+ (flags & RPM::SENSE[:less]) && (flags & RPM::SENSE[:equal])
74
74
  end
75
75
 
76
76
  # @return [Boolean] true if '>=' is used to compare the version
77
77
  def ge?
78
- (flags & RPM::SENSE[:greater]) && (flags & RPMSENSE[:equal])
78
+ (flags & RPM::SENSE[:greater]) && (flags & RPM::SENSE[:equal])
79
79
  end
80
80
 
81
81
  # @return [Boolean] true if this is a pre-requires
@@ -43,8 +43,11 @@ module RPM
43
43
  end
44
44
 
45
45
  # @return [Boolean] True if the file is marked as do not use
46
+ # @deprecated RPMFILE_DONOTUSE was removed in recent versions of RPM.
46
47
  def donotuse?
47
- ! (@attr & RPM::C::FileAttrs[:donotuse]).zero?
48
+ msg = "RPMFILE_DONOTUSE was removed in recent versions of RPM."
49
+ warn "#{Kernel.caller.first} #{msg}"
50
+ raise NotImplementedError
48
51
  end
49
52
 
50
53
  # @return [Boolean] True if the file is marked that can be missing on disk
@@ -91,9 +94,12 @@ module RPM
91
94
  ! (@attr & RPM::C::FileAttrs[:readme]).zero?
92
95
  end
93
96
 
94
- # @return [Boolean] True if the file is listed in the exlude section
97
+ # @raise NotImplementedError
98
+ # @deprecated RPMFILE_EXCLUDE was removed in recent versions of RPM.
95
99
  def exclude?
96
- ! (@attr & RPM::C::FileAttrs[:exclude]).zero?
100
+ msg = "RPMFILE_EXCLUDE was removed in recent versions of RPM."
101
+ warn "#{Kernel.caller.first} #{msg}"
102
+ raise NotImplementedError
97
103
  end
98
104
 
99
105
  # @return [Boolean] True if the file is replaced during installation
@@ -3,5 +3,5 @@
3
3
  # is because it conflicts with the version.rb class
4
4
  module RPM
5
5
  PKG_NAME = "ruby-rpm"
6
- GEM_VERSION = "0.0.4"
6
+ GEM_VERSION = "0.0.5"
7
7
  end
@@ -291,21 +291,7 @@ module RPM
291
291
  end
292
292
 
293
293
  def self.open(filename)
294
- # it sucks not using the std File.open here
295
- hdr = ::FFI::MemoryPointer.new(:pointer)
296
- fd = nil
297
- begin
298
- fd = RPM::C.Fopen(filename, 'r')
299
- if RPM::C.Ferror(fd) != 0
300
- raise "#{filename} : #{RPM::C.Fstrerror(fd)}"
301
- end
302
- RPM.transaction do |ts|
303
- rc = RPM::C.rpmReadPackageFile(ts.ptr, fd, filename, hdr)
304
- end
305
- ensure
306
- RPM::C.Fclose(fd) unless fd.nil?
307
- end
308
- Package.new(hdr.get_pointer(0))
294
+ Package.new(filename)
309
295
  end
310
296
 
311
297
  # @visibility private
@@ -319,7 +305,15 @@ module RPM
319
305
  end
320
306
 
321
307
  # @visibility private
322
- def initialize(hdr=nil)
308
+ def initialize(what)
309
+ case what
310
+ when String then initialize_from_filename(what)
311
+ else initialize_from_header(what)
312
+ end
313
+ end
314
+
315
+ # @visibility private
316
+ def initialize_from_header(hdr=nil)
323
317
  if hdr.nil?
324
318
  @hdr = ::FFI::AutoPointer.new(RPM::C.headerNew, Header.method(:release))
325
319
  elsif hdr.is_a?(::FFI::Pointer)
@@ -331,6 +325,24 @@ module RPM
331
325
  end
332
326
  end
333
327
 
328
+ def initialize_from_filename(filename)
329
+ # it sucks not using the std File.open here
330
+ hdr = ::FFI::MemoryPointer.new(:pointer)
331
+ fd = nil
332
+ begin
333
+ fd = RPM::C.Fopen(filename, 'r')
334
+ if RPM::C.Ferror(fd) != 0
335
+ raise "#{filename} : #{RPM::C.Fstrerror(fd)}"
336
+ end
337
+ RPM.transaction do |ts|
338
+ rc = RPM::C.rpmReadPackageFile(ts.ptr, fd, filename, hdr)
339
+ end
340
+ ensure
341
+ RPM::C.Fclose(fd) unless fd.nil?
342
+ end
343
+ initialize_from_header(hdr.get_pointer(0))
344
+ end
345
+
334
346
  # @return [RPM::C::Header] header pointer
335
347
  # @visibility private
336
348
  def ptr
@@ -1,7 +1,7 @@
1
1
  $: << File.join(File.dirname(__FILE__), "..", "lib")
2
- require 'test/unit'
2
+ require "minitest/autorun"
3
3
  require 'rpm'
4
4
 
5
5
  def fixture(name)
6
6
  File.expand_path(File.join(File.dirname(__FILE__), 'data', name))
7
- end
7
+ end
@@ -1,8 +1,8 @@
1
1
  require_relative('helper')
2
2
  require 'rpm/compat'
3
3
 
4
- class RPM_Dependency_Tests < Test::Unit::TestCase
5
-
4
+ class RPMDependencyTests < MiniTest::Unit::TestCase
5
+
6
6
  EQ = RPM::SENSE_EQUAL
7
7
  LT = RPM::SENSE_LESS
8
8
  GT = RPM::SENSE_GREATER
@@ -12,7 +12,7 @@ class RPM_Dependency_Tests < Test::Unit::TestCase
12
12
  req = requires("foo", "1", "1", 0, EQ|GT)
13
13
  assert(req.satisfy?(prv))
14
14
  assert(prv.satisfy?(req))
15
-
15
+
16
16
  # Different names don't overlap
17
17
  prv = provides("foo", "2", "1", 0, EQ)
18
18
  req = requires("bar", "1", "1", 0, EQ|GT)
@@ -1,6 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), 'helper')
2
2
 
3
- class RPM_File_Tests < Test::Unit::TestCase
3
+ class RPMFileTests < MiniTest::Unit::TestCase
4
4
  def test_link_to
5
5
  f = RPM::File.new("path", "md5sum", nil, 42, 1,
6
6
  "owner", "group", 43, 0777, 44, 45)
@@ -15,17 +15,23 @@ class RPM_File_Tests < Test::Unit::TestCase
15
15
  "owner", "group", 43, 0777, 44, 45)
16
16
  f.config?
17
17
  f.doc?
18
- f.donotuse?
19
18
  f.is_missingok?
20
19
  f.is_noreplace?
21
20
  f.is_specfile?
22
21
  f.ghost?
23
22
  f.license?
24
23
  f.readme?
25
- f.exclude?
26
24
  f.replaced?
27
25
  f.notinstalled?
28
26
  f.netshared?
27
+
28
+ assert_raises NotImplementedError do
29
+ f.exclude?
30
+ end
31
+
32
+ assert_raises NotImplementedError do
33
+ f.donotuse?
34
+ end
29
35
  end
30
36
 
31
37
 
@@ -1,6 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), 'helper')
2
2
 
3
- class RPM_Lib_Tests < Test::Unit::TestCase
3
+ class RPMLibTests < MiniTest::Unit::TestCase
4
4
 
5
5
  def test_lib_lib
6
6
  assert_kind_of String, RPM::C.RPMVERSION
@@ -1,6 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), 'helper')
2
2
 
3
- class RPM_Header_Tests < Test::Unit::TestCase
3
+ class RPMHeaderTests < MiniTest::Unit::TestCase
4
4
 
5
5
  def test_create
6
6
 
@@ -10,9 +10,9 @@ class RPM_Header_Tests < Test::Unit::TestCase
10
10
  end
11
11
 
12
12
  def test_open
13
-
13
+
14
14
  pkg = RPM::Package.open(fixture('simple-1.0-0.i586.rpm'))
15
-
15
+
16
16
  req = RPM::Require.new("simple", RPM::Version.new("1.0", "0"), RPM::SENSE_GREATER|RPM::SENSE_EQUAL, nil)
17
17
  assert req.satisfy?(pkg)
18
18
 
@@ -26,18 +26,18 @@ class RPM_Header_Tests < Test::Unit::TestCase
26
26
  assert_kind_of RPM::Version, pkg.version
27
27
  assert_equal '1.0-0', pkg.version.to_s
28
28
 
29
- backup_lang = ENV['LANG']
29
+ backup_lang = ENV['LC_ALL']
30
30
 
31
- ENV['LANG'] = 'C'
31
+ ENV['LC_ALL'] = 'C'
32
32
  assert_equal 'Simple dummy package', pkg[:summary]
33
33
  assert_equal 'Dummy package', pkg[:description]
34
-
35
- ENV['LANG'] = 'es'
34
+
35
+ ENV['LC_ALL'] = 'es_ES.UTF-8'
36
36
  assert_equal 'Paquete simple de muestra', pkg[:summary]
37
37
  assert_equal 'Paquete de muestra', pkg[:description]
38
38
 
39
- ENV['LANG'] = backup_lang
40
-
39
+ ENV['LC_ALL'] = backup_lang
40
+
41
41
  # Arrays
42
42
  assert_equal ["root", "root"], pkg[:fileusername]
43
43
  assert_equal [6, 5], pkg[:filesizes]
@@ -68,7 +68,7 @@ class RPM_Header_Tests < Test::Unit::TestCase
68
68
 
69
69
  assert pkg.requires.map(&:name).include?("a")
70
70
  b = pkg.requires.find {|x| x.name == 'b'}
71
- assert_not_nil b
71
+ assert b
72
72
  assert_equal '1.0', b.version.to_s
73
73
 
74
74
  assert pkg.conflicts.map(&:name).include?('c')
@@ -1,6 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), 'helper')
2
2
 
3
- class RPM_Header_Tests < Test::Unit::TestCase
3
+ class RPMHeaderTests < MiniTest::Unit::TestCase
4
4
 
5
5
  def test_create
6
6
  problem = RPM::Problem.create(:requires, "foo-1.0-0", "foo.rpm", "bar-1.0-0", "Hello", 1)
@@ -15,6 +15,6 @@ class RPM_Header_Tests < Test::Unit::TestCase
15
15
  assert_equal problem.type, problem2.type
16
16
  assert_equal problem.str, problem2.str
17
17
  assert_equal problem.to_s, problem2.to_s
18
-
18
+
19
19
  end
20
20
  end
@@ -1,6 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), 'helper')
2
2
 
3
- class RPM_RPM_Tests < Test::Unit::TestCase
3
+ class RPMRPMTests < MiniTest::Unit::TestCase
4
4
 
5
5
  def test_enum
6
6
  assert RPM::TAG[:not_found]
@@ -11,7 +11,8 @@ class RPM_RPM_Tests < Test::Unit::TestCase
11
11
  #assert_raise(NameError) { RPM::LOG_ALERT }
12
12
 
13
13
  #require 'rpm/compat'
14
- assert_nothing_raised { RPM::LOG_ALERT }
14
+ # Nothing should be raised by the following statement
15
+ RPM::LOG_ALERT
15
16
  assert_equal RPM::LOG_ALERT, RPM::LOG[:alert]
16
17
  end
17
18
 
@@ -2,7 +2,7 @@ require_relative('helper')
2
2
  require 'tmpdir'
3
3
  require 'pathname'
4
4
 
5
- class RPM_Transaction_Tests < Test::Unit::TestCase
5
+ class RPMTransactionTests < MiniTest::Unit::TestCase
6
6
 
7
7
  PACKAGE_FILENAME = 'simple-1.0-0.i586.rpm'
8
8
 
@@ -68,7 +68,7 @@ class RPM_Transaction_Tests < Test::Unit::TestCase
68
68
  t.install(pkg, fixture(filename))
69
69
  t.commit
70
70
 
71
- assert File.exist?(File.join(dir, '/var/lib/rpm/Packages')),
71
+ assert File.exist?(File.join(dir, RPM['_dbpath'], 'Packages')),
72
72
  "rpm db exists"
73
73
 
74
74
  assert !File.exist?('/usr/share/simple/README'),
@@ -86,7 +86,7 @@ class RPM_Transaction_Tests < Test::Unit::TestCase
86
86
  t.install(pkg, fixture(PACKAGE_FILENAME))
87
87
  t.commit
88
88
 
89
- assert File.exist?(File.join(dir, '/var/lib/rpm/Packages')),
89
+ assert File.exist?(File.join(dir, RPM['_dbpath'], 'Packages')),
90
90
  "rpm db exists"
91
91
 
92
92
  assert File.exist?(File.join(dir, '/usr/share/simple/README')),
@@ -101,7 +101,7 @@ class RPM_Transaction_Tests < Test::Unit::TestCase
101
101
  RPM.transaction(dir) do |t|
102
102
  begin
103
103
 
104
- assert_raise TypeError do
104
+ assert_raises TypeError do
105
105
  t.delete(Object.new)
106
106
  end
107
107
 
@@ -1,6 +1,6 @@
1
1
  require File.join(File.dirname(__FILE__), 'helper')
2
2
 
3
- class RPM_Version_Tests < Test::Unit::TestCase
3
+ class RPMVersionTests < MiniTest::Unit::TestCase
4
4
  def setup
5
5
  @a = RPM::Version.new( '1.0.0-0.1m' )
6
6
  @b = RPM::Version.new( '0.9.0-1m' )
metadata CHANGED
@@ -1,38 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
5
- prerelease:
4
+ version: 0.0.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Duncan Mac-Vicar P.
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-10-24 00:00:00.000000000 Z
11
+ date: 2016-07-09 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
- requirement: &20015700 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
- version_requirements: *20015700
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: ffi
27
- requirement: &20034180 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ! '>='
31
+ - - ">="
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *20034180
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
36
41
  description: Ruby bindings for rpm. Almost a drop-in replacement for ruby-rpm. Uses
37
42
  FFI.
38
43
  email:
@@ -41,13 +46,15 @@ executables: []
41
46
  extensions: []
42
47
  extra_rdoc_files: []
43
48
  files:
44
- - .gitignore
45
- - .travis.yml
49
+ - ".gitignore"
50
+ - ".travis.yml"
46
51
  - ChangeLog
47
52
  - Gemfile
48
53
  - MIT-LICENSE
49
- - README.rdoc
54
+ - README.md
50
55
  - Rakefile
56
+ - _docker/Dockerfile.leap
57
+ - _docker/Dockerfile.tumbleweed
51
58
  - lib/rpm.rb
52
59
  - lib/rpm/c.rb
53
60
  - lib/rpm/c/header.rb
@@ -94,27 +101,26 @@ files:
94
101
  - test/test_version.rb
95
102
  homepage: ''
96
103
  licenses: []
104
+ metadata: {}
97
105
  post_install_message:
98
106
  rdoc_options: []
99
107
  require_paths:
100
108
  - lib
101
109
  required_ruby_version: !ruby/object:Gem::Requirement
102
- none: false
103
110
  requirements:
104
- - - ! '>='
111
+ - - ">="
105
112
  - !ruby/object:Gem::Version
106
113
  version: '0'
107
114
  required_rubygems_version: !ruby/object:Gem::Requirement
108
- none: false
109
115
  requirements:
110
- - - ! '>='
116
+ - - ">="
111
117
  - !ruby/object:Gem::Version
112
118
  version: '0'
113
119
  requirements: []
114
120
  rubyforge_project: rpm
115
- rubygems_version: 1.8.11
121
+ rubygems_version: 2.5.1
116
122
  signing_key:
117
- specification_version: 3
123
+ specification_version: 4
118
124
  summary: Ruby bindings for rpm (package manager)
119
125
  test_files:
120
126
  - test/data/a.spec
@@ -131,4 +137,3 @@ test_files:
131
137
  - test/test_rpm.rb
132
138
  - test/test_transaction.rb
133
139
  - test/test_version.rb
134
- has_rdoc:
@@ -1,308 +0,0 @@
1
-
2
- = RPM bindings for ruby
3
-
4
- * http://github.com/dmacvicar/ruby-rpm
5
-
6
- = WARNING
7
-
8
- This is an alpha release! There is still work to be done
9
-
10
- = Quickstart
11
-
12
- == Working with RPM package files
13
-
14
- require 'rpm'
15
-
16
- pkg = RPM::Package.open("file.rpm")
17
- pkg.arch => "x86_64"
18
-
19
- pkg.files.each do |file|
20
- puts file.path
21
- end
22
-
23
- pkg.changelog.each do |entry|
24
- puts "#{entry.name} #{entry.time} #{entry.text}"
25
- end
26
-
27
- == Querying the rpm database
28
-
29
- require 'rpm'
30
-
31
- RPM.transaction do |ts|
32
- ts.each do |pkg|
33
- puts pkg
34
- end
35
- end
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
-
47
- = Introduction
48
-
49
- This library is a replacement for the ruby-rpm gem, originally
50
- writen by Kenta Murata around 2002 for the Kondara distribution. Later
51
- mantained by David Lutterkort and myself.
52
-
53
- Why?
54
-
55
- * The original gem supports ancient rpm versions not in use anymore
56
- * The original gem was written in C using MRI API
57
- * The #ifdef'ing required to support multiple rpm versions made the code
58
- hard to maintain
59
-
60
- This gem:
61
-
62
- * Is pure ruby
63
- * Is documented
64
- * Has as a goal to support only the latest rpm version plus the ones in
65
- use some releases back in popular rpm based distros
66
- * Uses FFI, so it should work with other interpreters
67
- (Because https://github.com/rubinius/rubinius/issues/682 it currently does
68
- not work on Rubinius)
69
- * Does not target rpm5, but it may support it someday
70
-
71
- As an example the code that implements RPM::Package was reduced
72
- from 1130 lines of code to 320.
73
-
74
- = Architecture
75
-
76
- The gem is divided in two modules:
77
-
78
- * RPM::C:: which contains the 1:1 mapping to the librpm API
79
- Not all functions are attached, only the ones we actually use.
80
- * RPM:: contains the actual higher level API
81
-
82
- = Status, Compatibility and Differences with ruby-rpm
83
-
84
- * Tested rpm 4.9 only
85
- * You can use symbols: instead of RPM::TAG_DESCRIPTION you
86
- can use just :description. 'rpm/compat' is by default loaded
87
- and provides compatibility with the RPM::TAG_* style constants
88
- * RPM::DB is not supported. Use RPM::Transaction
89
- * Spec and Source classes are not implemented yet
90
-
91
- == API Checklist and TODO
92
-
93
- * RPM
94
-
95
- [ ] RPM#expand
96
- [X] RPM#[]
97
- [X] RPM#[]=
98
- [ ] RPM#readrc
99
- [ ] RPM#init_macros
100
- [ ] RPM#verbosity
101
- [ ] RPM#verbosity=
102
-
103
- * RPM::Package
104
-
105
- [X] Package#open
106
- [X] Package#new
107
- [X] Package#create
108
- [ ] Package#load
109
- [ ] Package#clear_cache
110
- [ ] Package#use_cache
111
- [X] Package#[]
112
- [ ] Package#delete_tag
113
- [X] Package#sprintf
114
- [?] Package#signature
115
- [X] Package#arch
116
- [X] Package#name
117
- [X] Package#version
118
- [X] Package#files
119
- [X] Package#provides
120
- [X] Package#requires
121
- [X] Package#conflicts
122
- [X] Package#obsoletes
123
- [X] Package#changelog
124
- [ ] Package#add_dependency
125
- [ ] Package#add_string
126
- [ ] Package#add_string_array
127
- [ ] Package#add_int32
128
- [ ] Package#dump
129
- [X] Package#to_s
130
- [ ] Package#inspect
131
- [ ] Package#copy_to
132
-
133
- * RPM::Dependency
134
-
135
- [X] Dependency#initialize
136
- [X] Dependency#name
137
- [X] Dependency#version
138
- [X] Dependency#flags
139
- [X] Dependency#owner
140
- [X] Dependency#lt?
141
- [X] Dependency#gt?
142
- [X] Dependency#eq?
143
- [X] Dependency#le?
144
- [X] Dependency#ge?
145
- [X] Dependency#satisfy?
146
- [X] Dependency#nametag
147
- [X] Dependency#versiontag
148
- [X] Dependency#flagstag
149
-
150
- * RPM::Provide
151
- [X] Provide#initialize
152
-
153
- * RPM::Require
154
- [X] Require#initialize
155
- [ ] Require#pre?
156
-
157
- * RPM::Conflict
158
- [X] Conflict#initialize
159
-
160
- * RPM::Obsolete
161
- [X] Obsolete#initialize
162
-
163
- * RPM::ChangeLog
164
-
165
- [X] ChangeLog#time
166
- [X] ChangeLog#name
167
- [X] ChangeLog#text
168
-
169
- * RPM::Version
170
-
171
- [X] Version (Comparable)
172
- [X] Version#initialize
173
- [X] Version#<=>
174
- [X] Version#newer?
175
- [X] Version#older?
176
- [X] Version#v
177
- [X] Version#r
178
- [X] Version#e
179
- [X] Version#to_s
180
- [X] Version#to_vre
181
- [X] Version#inspect
182
- [X] Version#hash
183
-
184
- * RPM::File
185
-
186
- [X] File#initialize
187
- [X] File#path
188
- [ ] File#to_s (alias path)
189
- [X] File#md5sum
190
- [X] File#link_to
191
- [X] File#size
192
- [X] File#mtime
193
- [X] File#owner
194
- [X] File#group
195
- [X] File#rdev
196
- [X] File#mode
197
- [X] File#attr
198
- [X] File#state
199
- [X] File#symlink?
200
- [X] File#config?
201
- [X] File#doc?
202
- [X] File#donotuse?
203
- [X] File#missingok?
204
- [X] File#specfile?
205
- [X] File#ghost?
206
- [X] File#license?
207
- [X] File#readme?
208
- [X] File#exclude?
209
- [X] File#replaced?
210
- [X] File#notinstalled?
211
- [X] File#netshared?
212
-
213
- * RPM::DB
214
-
215
- [ ] DB (Enumerable)
216
- [ ] DB#new
217
- [ ] DB#open
218
- [ ] DB#init
219
- [ ] DB#rebuild
220
- [ ] DB#close
221
- [ ] DB#closed?
222
- [ ] DB#root
223
- [ ] DB#home
224
- [ ] DB#writable?
225
- [ ] DB#each_match
226
- [ ] DB#each
227
- [ ] DB#transaction
228
- [ ] DB#init_iterator
229
- [ ] DB#dup
230
- [ ] DB#clone
231
-
232
- * RPM::MatchIterator
233
-
234
- [X] MatchIterator (Enumerable)
235
- [X] MatchIterator#each
236
- [X] MatchIterator#next_iterator
237
- [X] MatchIterator#offset
238
- [X] MatchIterator#set_iterator_re
239
- [X] MatchIterator#regexp
240
- [X] MatchIterator#set_iterator_version
241
- [X] MatchIterator#version
242
- [X] MatchIterator#get_iterator_count
243
- [X] MatchIterator#length
244
-
245
- * RPM::Transaction
246
-
247
- [ ] Transaction#db
248
- [ ] Transaction#script_file
249
- [ ] Transaction#script_file=
250
- [ ] Transaction#install
251
- [ ] Transaction#upgrade
252
- [ ] Transaction#available
253
- [ ] Transaction#delete
254
- [ ] Transaction#check
255
- [ ] Transaction#order
256
- [ ] Transaction#keys
257
- [ ] Transaction#commit
258
- [ ] Transaction#abort
259
- [ ] Transaction#dup
260
- [ ] Transaction#clone
261
-
262
- * RPM::Source
263
-
264
- [ ] Source#initialize
265
- [ ] Source#fullname
266
- [ ] Source#to_s (alias fullname)
267
- [ ] Source#num
268
- [ ] Source#no?
269
-
270
- * RPM::Patch
271
- * RPM::Icon
272
-
273
- * RPM::Spec
274
-
275
- [ ] Spec#open
276
- [ ] Spec#new
277
- [ ] Spec#buildroot
278
- [ ] Spec#buildsubdir
279
- [ ] Spec#buildarchs
280
- [ ] Spec#buildrequires
281
- [ ] Spec#build_restrictions
282
- [ ] Spec#sources
283
- [ ] Spec#packages
284
- [ ] Spec#build
285
- [ ] Spec#expand_macros
286
- [ ] Spec#dup
287
- [ ] Spec#clone
288
-
289
- == TODO
290
-
291
- * Check Package#signature should return String?
292
- => ruby-rpm seems to return symbol
293
- * Food for thought: Package dependencies and changelog
294
- methods could just use []. Calling headerGet directly saves
295
- us from doing one iteration per attribute
296
- * Not sure if Spec can be implemented as it was before with
297
- newer rpms.
298
-
299
- = LICENSE
300
-
301
- * Copyright © 2011 Duncan Mac-Vicar Prett <dmacvicar@suse.de>
302
- * Copyright © 2011 SUSE Linux Products GmbH
303
-
304
- * This gem is a pure-ruby rewrite of ruby-rpm:
305
- Copyright © 2002 Kenta Murata. Relicensed with his permission.
306
-
307
- Licensed under the MIT license. See MIT-LICENSE for details.
308
-