Class: Rupert::RPM
- Inherits:
-
Object
- Object
- Rupert::RPM
- Defined in:
- lib/rupert/rpm.rb,
lib/rupert/rpm/lead.rb,
lib/rupert/rpm/signature.rb,
lib/rupert/rpm/signature/entry.rb,
lib/rupert/rpm/signature/index.rb,
lib/rupert/rpm/signature/store.rb
Defined Under Namespace
Class Method Summary collapse
-
.load(filename) ⇒ Rupert::RPM
Loads a RPM file and parses its structure.
-
.rpm?(filename) ⇒ Boolean
Tells whether given filename points to a valid RPM or not.
Instance Method Summary collapse
-
#binary? ⇒ Boolean
‘true` if the RPM is of type binary, `false` otherwise.
-
#initialize(lead, signature, content) ⇒ RPM
constructor
Initialize the RPM object, given its components.
-
#intact? ⇒ Boolean
Verifies package integrity.
-
#md5 ⇒ String
MD5 checksum stored in the package (base64 encoded).
-
#name ⇒ String
Full package name.
-
#os ⇒ String
OS for which the package was built.
-
#rpm_arch ⇒ String
Which architecture the package was built for, e.g.
-
#rpm_version ⇒ String
RPM version used to encode the package.
-
#signed? ⇒ Boolean
‘true` if the package is signed, `false` otherwise.
-
#source? ⇒ Boolean
‘true` if the RPM is of type source, `false` otherwise.
Constructor Details
#initialize(lead, signature, content) ⇒ RPM
Initialize the RPM object, given its components.
This method is not intended to be used to instantiate RPM objects directly. Instead, use Rupert::RPM::load for a more straightforward alternative.
44 45 46 47 48 |
# File 'lib/rupert/rpm.rb', line 44 def initialize(lead, signature, content) @lead = lead @signature = signature @content = content end |
Class Method Details
.load(filename) ⇒ Rupert::RPM
Loads a RPM file and parses its structure
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rupert/rpm.rb', line 15 def load(filename) raise NotAnRPM, "File #{filename} isn't a valid RPM" unless rpm?(filename) raw_io = File.open(filename, 'r') rpm = Parser.new(raw_io).parse raw_io.close return rpm end |
Instance Method Details
#binary? ⇒ Boolean
Returns ‘true` if the RPM is of type binary, `false` otherwise.
58 59 60 |
# File 'lib/rupert/rpm.rb', line 58 def binary? @lead.binary_type? end |
#intact? ⇒ Boolean
Verifies package integrity. Compares MD5 checksum stored in the package with checksum calculated over header(s) and payload (archive).
payload) is corrupted
114 115 116 |
# File 'lib/rupert/rpm.rb', line 114 def intact? @signature.verify_checksum(@content) end |
#md5 ⇒ String
MD5 checksum stored in the package (base64 encoded). To be used to check package integrity.
NOTE: This is not the MD5 of the whole package; rather, the digest is calculated over the header and payload, leaving out the lead and the signature header. I.e., running ‘md5sum <myrpm>` won’t held the same result as ‘Rupert::RPM.load(’<myrpm>‘).md5`.
105 106 107 |
# File 'lib/rupert/rpm.rb', line 105 def md5 Base64.strict_encode64(@signature.md5) end |
#name ⇒ String
Full package name
78 79 80 |
# File 'lib/rupert/rpm.rb', line 78 def name @lead.name end |
#os ⇒ String
OS for which the package was built
86 87 88 |
# File 'lib/rupert/rpm.rb', line 86 def os @lead.os end |
#rpm_arch ⇒ String
Which architecture the package was built for, e.g. ‘i386/x86_64` or `arm`
71 72 73 |
# File 'lib/rupert/rpm.rb', line 71 def rpm_arch @lead.arch end |
#rpm_version ⇒ String
RPM version used to encode the package.
53 54 55 |
# File 'lib/rupert/rpm.rb', line 53 def rpm_version @lead.rpm_version end |
#signed? ⇒ Boolean
Returns ‘true` if the package is signed, `false` otherwise.
91 92 93 |
# File 'lib/rupert/rpm.rb', line 91 def signed? @lead.signed? end |
#source? ⇒ Boolean
Returns ‘true` if the RPM is of type source, `false` otherwise.
63 64 65 |
# File 'lib/rupert/rpm.rb', line 63 def source? @lead.source_type? end |