class Akabei::Package

Attributes

path[R]

Public Class Methods

new(path) click to toggle source
# File lib/akabei/package.rb, line 22
def initialize(path)
  @path = Pathname.new(path)
end

Public Instance Methods

base() click to toggle source
# File lib/akabei/package.rb, line 99
def base
  pkginfo.pkgbase
end
compute_checksum(algo) click to toggle source
# File lib/akabei/package.rb, line 55
def compute_checksum(algo)
  Digest(algo).file(@path).hexdigest
end
csize() click to toggle source
# File lib/akabei/package.rb, line 39
def csize
  @path.size
end
desc() click to toggle source
# File lib/akabei/package.rb, line 107
def desc
  pkginfo.pkgdesc
end
extract_pkginfo() click to toggle source
# File lib/akabei/package.rb, line 30
def extract_pkginfo
  ArchiveUtils.each_entry(@path.to_s) do |entry, archive|
    if entry.pathname == '.PKGINFO'
      return PackageInfo.parse(archive.read_data)
    end
  end
  raise NotFound.new(@path, '.PKGINFO')
end
filename() click to toggle source
# File lib/akabei/package.rb, line 91
def filename
  @path.basename.to_s
end
files() click to toggle source
# File lib/akabei/package.rb, line 118
def files
  xs = []
  ArchiveUtils.each_entry(@path) do |entry|
    unless entry.pathname.start_with?('.')
      xs << entry.pathname
    end
  end
  xs.sort
end
isize() click to toggle source
# File lib/akabei/package.rb, line 43
def isize
  pkginfo.size
end
md5sum() click to toggle source
# File lib/akabei/package.rb, line 47
def md5sum
  @md5sum ||= compute_checksum('MD5')
end
name() click to toggle source
# File lib/akabei/package.rb, line 95
def name
  pkginfo.pkgname
end
pgpsig() click to toggle source
# File lib/akabei/package.rb, line 111
def pgpsig
  sig_file = @path.parent.join("#{filename}.sig")
  if sig_file.readable?
    Base64.strict_encode64(sig_file.binread)
  end
end
pkginfo() click to toggle source
# File lib/akabei/package.rb, line 26
def pkginfo
  @pkginfo ||= extract_pkginfo
end
sha256sum() click to toggle source
# File lib/akabei/package.rb, line 51
def sha256sum
  @sha256sum ||= compute_checksum('SHA256')
end
to_entry() click to toggle source
# File lib/akabei/package.rb, line 128
def to_entry
  entry = PackageEntry.new
  %w[
    filename
    name
    base
    version
    desc
    groups
    csize
    isize

    md5sum
    sha256sum

    pgpsig

    url
    license
    builddate
    packager
    replaces

    provides
    optdepends
    makedepends
    checkdepends

    files
  ].each do |attr|
    val = send(attr)
    if val.is_a?(Array)
      val.each do |v|
        entry.add(attr, v)
      end
    else
      entry.add(attr, val)
    end
  end
  entry
end
version() click to toggle source
# File lib/akabei/package.rb, line 103
def version
  pkginfo.pkgver
end