Class: RepoMate::Package
- Inherits:
-
Object
- Object
- RepoMate::Package
- Defined in:
- lib/repomate/package.rb
Overview
Class for reading debian packages
Instance Attribute Summary collapse
-
#architecture ⇒ Object
readonly
Returns the value of attribute architecture.
-
#basename ⇒ Object
readonly
Returns the value of attribute basename.
-
#component ⇒ Object
readonly
Returns the value of attribute component.
-
#controlfile ⇒ Object
readonly
Returns the value of attribute controlfile.
-
#fullname ⇒ Object
readonly
Returns the value of attribute fullname.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#newbasename ⇒ Object
readonly
Returns the value of attribute newbasename.
-
#suitename ⇒ Object
readonly
Returns the value of attribute suitename.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#create_checksums ⇒ Object
Creates the checksums for a package.
-
#create_table ⇒ Object
Create the package table.
-
#delete_checksums ⇒ Object
Gets checksums for the given package.
-
#initialize(fullname, suitename, component) ⇒ Package
constructor
Init.
-
#load_checksums ⇒ Object
Gets checksums for the given package.
Constructor Details
#initialize(fullname, suitename, component) ⇒ Package
Init
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/repomate/package.rb', line 17 def initialize(fullname, suitename, component) @fullname = fullname @suitename = suitename @component = component @basename = File.basename(fullname) @mtime = File.mtime(fullname) @pkgdbfile = File.join(Cfg.rootdir, "packages.db") @pkgdb = Database.new(@pkgdbfile) check_package create_table @controlfile = read_controlfile @name = @controlfile['Package'] @version = @controlfile['Version'] @architecture = @controlfile['Architecture'] @newbasename = "#{@name}-#{@version}_#{@architecture}.deb" end |
Instance Attribute Details
#architecture ⇒ Object (readonly)
Returns the value of attribute architecture.
14 15 16 |
# File 'lib/repomate/package.rb', line 14 def architecture @architecture end |
#basename ⇒ Object (readonly)
Returns the value of attribute basename.
14 15 16 |
# File 'lib/repomate/package.rb', line 14 def basename @basename end |
#component ⇒ Object (readonly)
Returns the value of attribute component.
14 15 16 |
# File 'lib/repomate/package.rb', line 14 def component @component end |
#controlfile ⇒ Object (readonly)
Returns the value of attribute controlfile.
14 15 16 |
# File 'lib/repomate/package.rb', line 14 def controlfile @controlfile end |
#fullname ⇒ Object (readonly)
Returns the value of attribute fullname.
14 15 16 |
# File 'lib/repomate/package.rb', line 14 def fullname @fullname end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/repomate/package.rb', line 14 def name @name end |
#newbasename ⇒ Object (readonly)
Returns the value of attribute newbasename.
14 15 16 |
# File 'lib/repomate/package.rb', line 14 def newbasename @newbasename end |
#suitename ⇒ Object (readonly)
Returns the value of attribute suitename.
14 15 16 |
# File 'lib/repomate/package.rb', line 14 def suitename @suitename end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
14 15 16 |
# File 'lib/repomate/package.rb', line 14 def version @version end |
Instance Method Details
#create_checksums ⇒ Object
Creates the checksums for a package
61 62 63 64 65 66 67 |
# File 'lib/repomate/package.rb', line 61 def create_checksums # puts "Ins: #{@basename}" md5 = Digest::MD5.file(@fullname).to_s sha1 = Digest::SHA1.file(@fullname).to_s sha256 = Digest::SHA2.new(256).file(@fullname).to_s @pkgdb.query("insert into checksums values ( datetime('now'), '#{@basename}', '#{@suitename}', '#{@mtime.iso8601}', '#{md5}', '#{sha1}', '#{sha256}' )") end |
#create_table ⇒ Object
Create the package table
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/repomate/package.rb', line 37 def create_table sql = "create table if not exists checksums ( date varchar(25), basename varchar(70), suitename varchar(20), mtime varchar(25), md5 varchar(32), sha1 varchar(40), sha256 varchar(64) )" @pkgdb.query(sql) end |
#delete_checksums ⇒ Object
Gets checksums for the given package
70 71 72 73 |
# File 'lib/repomate/package.rb', line 70 def delete_checksums # puts "Del: #{@basename}" @pkgdb.query("delete from checksums where basename = '#{@basename}'") end |
#load_checksums ⇒ Object
Gets checksums for the given package
51 52 53 54 55 56 57 58 |
# File 'lib/repomate/package.rb', line 51 def load_checksums result = [] @pkgdb.query("select md5, sha1, sha256 from checksums where basename = '#{@basename}' and mtime = '#{@mtime.iso8601}' and suitename = '#{@suitename}'").each do |row| result = row end result end |