Cross package maker. DEB/RPM generation or conversion. Derived from jordansissel/fpm.

⌈⌋ ⎇ branch:  cross package maker


Artifact [564ed6a149]

Artifact 564ed6a1491f544e5b24023ec8657f15ab150d80:

  • File lib/rpm/lead.rb — part of check-in [35f668b84f] at 2011-05-14 07:49:46 on branch trunk — - factor out the rpm bits into separate class files - include all known rpm 'tag' types (user: jls@semicomplete.com size: 1236)

require File.join(File.dirname(__FILE__), "namespace")

class RPMFile::Lead
  #struct rpmlead {
  attr_accessor :magic #unsigned char magic[4]; 
  attr_accessor :major #unsigned char major;
  attr_accessor :minor #unsigned char minor;
  attr_accessor :type  #short type;
  attr_accessor :archnum #short archnum;
  attr_accessor :name #char name[66];
  attr_accessor :osnum #short osnum;
  attr_accessor :signature_type #short signature_type;
  attr_accessor :reserved #char reserved[16];
  #}
  
  attr_accessor :length

  def initialize(rpm)
    @rpm = rpm
  end

  def type
    case @type
    when 0
      return :binary
    when 1
      return :source
    else
      raise "Unknown package 'type' value #{@type}"
    end
  end # def type
  
  def read
    # Use 'A' here instead of 'a' to trim nulls.
    @length = 96
    data = @rpm.file.read(@length).unpack("A4CCnnA66nnA16")
    @magic, @major, @minor, @type, @archnum, @name, \
      @osnum, @signature_type, @reserved = data

    return nil
  end # def read

  def write(file)
    data = [ @magic, @major, @minor, @type, @archnum, @name, \
             @osnum, @signature_type, @reserved ].pack("a4CCnna66nna16")
    file.write(data)
  end # def write
end # class RPMFile::Lead