Class: Rupert::RPM::Lead
- Inherits:
-
Object
- Object
- Rupert::RPM::Lead
- Defined in:
- lib/rupert/rpm/lead.rb
Constant Summary collapse
- LEAD_LENGTH =
Lead has a fixed length
96.freeze
- MAGIC =
The magic header that identifies an RPM beyond a shadow of a doubt, as every good RPM starts with hex ed ab ee db.
"\xed\xab\xee\xdb".force_encoding(Encoding::ASCII_8BIT).freeze
- TYPE_BINARY =
RPM of type binary
0.freeze
- TYPE_SOURCE =
RPM of type source
1.freeze
- SIGNATURE_TYPE_HEADER =
Only valid and recognized signature type
5.freeze
- @@arch_map =
{ 1 => "i386/x86_64" }.freeze
- @@os_map =
{ 1 => "Linux" }.freeze
Class Method Summary collapse
-
.chomp(io) ⇒ Rupert::RPM::Lead, IO
Chomps given IO, producing a Lead object and returning the remaining part for subsequent processing.
Instance Method Summary collapse
-
#arch ⇒ String
The architecture the package was built for.
-
#binary_type? ⇒ Boolean
true
if lead reports RPM as of binary type. -
#initialize(lead) ⇒ Lead
constructor
Initializes a lead section, parsing given IO.
-
#name ⇒ String
The name of the package.
-
#os ⇒ String
OS for which the package was built.
-
#reserved ⇒ String
String of reserved bits.
-
#rpm? ⇒ Boolean
Tells if the file is recognized as an RPM or not.
-
#rpm_version ⇒ String
RPM version used to format the package.
-
#rpm_version_major ⇒ Fixnum
Major number of the RPM version used to format the package.
-
#rpm_version_minor ⇒ Fixnum
Minor number of the RPM version used to format the package.
-
#signed? ⇒ Boolean
true
if the RPM is recognized as being signed,false
otherwise. -
#source_type? ⇒ Boolean
true
if lead reports RPM as of source type.
Constructor Details
#initialize(lead) ⇒ Lead
Initializes a lead section, parsing given IO
48 49 50 51 |
# File 'lib/rupert/rpm/lead.rb', line 48 def initialize(lead) lead_data = lead.read(LEAD_LENGTH) parse(lead_data) if lead_data end |
Class Method Details
.chomp(io) ⇒ Rupert::RPM::Lead, IO
Chomps given IO, producing a Rupert::RPM::Lead object and returning the remaining part for subsequent processing.
Lead data is expected to begin at IO start, so returned scrap is basically the input IO without its first LEAD_LENGTH bytes.
41 42 43 |
# File 'lib/rupert/rpm/lead.rb', line 41 def self.chomp(io) [ self.new(io), io ] end |
Instance Method Details
#arch ⇒ String
The architecture the package was built for. A list of supported architectures can be found in /usr/lib/rpm/rpmrc on RedHat based systems.
97 98 99 |
# File 'lib/rupert/rpm/lead.rb', line 97 def arch @@arch_map[@archnum] end |
#binary_type? ⇒ Boolean
Returns true
if lead reports RPM as of binary type.
83 84 85 |
# File 'lib/rupert/rpm/lead.rb', line 83 def binary_type? @type == TYPE_BINARY end |
#name ⇒ String
The name of the package
104 105 106 |
# File 'lib/rupert/rpm/lead.rb', line 104 def name @name end |
#os ⇒ String
OS for which the package was built
111 112 113 |
# File 'lib/rupert/rpm/lead.rb', line 111 def os @@os_map[@osnum] end |
#reserved ⇒ String
String of reserved bits. It’s here for completeness of the lead’s implementation but it isn’t intended to be actually used
125 126 127 |
# File 'lib/rupert/rpm/lead.rb', line 125 def reserved @reserved end |
#rpm? ⇒ Boolean
Tells if the file is recognized as an RPM or not
78 79 80 |
# File 'lib/rupert/rpm/lead.rb', line 78 def rpm? @magic == MAGIC end |
#rpm_version ⇒ String
RPM version used to format the package
70 71 72 |
# File 'lib/rupert/rpm/lead.rb', line 70 def rpm_version "#{rpm_version_major}.#{rpm_version_minor}" end |
#rpm_version_major ⇒ Fixnum
Major number of the RPM version used to format the package
56 57 58 |
# File 'lib/rupert/rpm/lead.rb', line 56 def rpm_version_major @rpm_major end |
#rpm_version_minor ⇒ Fixnum
Minor number of the RPM version used to format the package
63 64 65 |
# File 'lib/rupert/rpm/lead.rb', line 63 def rpm_version_minor @rpm_minor end |
#signed? ⇒ Boolean
Returns true
if the RPM is recognized as being signed, false
otherwise.
116 117 118 |
# File 'lib/rupert/rpm/lead.rb', line 116 def signed? @signature_type == SIGNATURE_TYPE_HEADER end |
#source_type? ⇒ Boolean
Returns true
if lead reports RPM as of source type.
88 89 90 |
# File 'lib/rupert/rpm/lead.rb', line 88 def source_type? @type == TYPE_SOURCE end |