class Rupert::RPM::Lead
Constants
- LEAD_FORMAT
:nodoc The format string passed to
unpack
to parse the lead- LEAD_LENGTH
Lead
has a fixed length- MAGIC
The magic header that identifies an
RPM
beyond a shadow of a doubt, as every goodRPM
starts with hex +ed ab ee db+.- SIGNATURE_TYPE_HEADER
Only valid and recognized signature type
- TYPE_BINARY
RPM
of type binary- TYPE_SOURCE
RPM
of type source
Public Class Methods
Chomps given IO, producing a {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 {Rupert::RPM::Lead::LEAD_LENGTH} bytes.
@param io [IO] IO object containing lead data at its start, possibly
with additional bytes at the end
@return [Rupert::RPM::Lead, IO] the lead object corresponding to the
data at the beginning of the IO, and the part of the input remaining after parsing.
# File lib/rupert/rpm/lead.rb, line 41 def self.chomp(io) [ self.new(io), io ] end
Initializes a lead section, parsing given IO
@param lead [IO] An IO containing the lead information at the start
# File lib/rupert/rpm/lead.rb, line 48 def initialize(lead) lead_data = lead.read(LEAD_LENGTH) parse(lead_data) if lead_data end
Public Instance Methods
The architecture the package was built for. A list of supported architectures can be found in /usr/lib/rpm/rpmrc on RedHat based systems.
@return [String] a string representing the architecture name(s)
# File lib/rupert/rpm/lead.rb, line 97 def arch @@arch_map[@archnum] end
@return true
if lead reports RPM
as of binary type
# File lib/rupert/rpm/lead.rb, line 83 def binary_type? @type == TYPE_BINARY end
The name of the package
@return [String] package name in the form <name>-<version>-<rev>.<suffix>
# File lib/rupert/rpm/lead.rb, line 104 def name @name end
OS for which the package was built
@return [String] OS canonical name as defined in /usr/lib/rpm/rpmrc
# File lib/rupert/rpm/lead.rb, line 111 def os @@os_map[@osnum] end
String of reserved bits. It’s here for completeness of the lead’s implementation but it isn’t intended to be actually used
@return [String] the raw 16 bytes long reserved string at the end of
the lead
# File lib/rupert/rpm/lead.rb, line 125 def reserved @reserved end
Tells if the file is recognized as an RPM
or not
@return true
if magic number is found at lead’s start, false
otherwise
# File lib/rupert/rpm/lead.rb, line 78 def rpm? @magic == MAGIC end
@return true
if the RPM
is recognized as being signed, false
otherwise
# File lib/rupert/rpm/lead.rb, line 116 def signed? @signature_type == SIGNATURE_TYPE_HEADER end
@return true
if lead reports RPM
as of source type
# File lib/rupert/rpm/lead.rb, line 88 def source_type? @type == TYPE_SOURCE end
Private Instance Methods
:nodoc Unpacks lead raw bytes into its semantic components
# File lib/rupert/rpm/lead.rb, line 137 def parse(lead_data) @magic, @rpm_major, @rpm_minor, @type, @archnum, @name, @osnum, @signature_type, @reserved = lead_data.unpack(LEAD_FORMAT) end