Class: FRM::Deb

Inherits:
Base
  • Object
show all
Defined in:
lib/frm/deb.rb

Instance Method Summary collapse

Methods inherited from Base

#compute_md5, #compute_sha1, #compute_sha2, #generate_gzip_pipe, #gpg_clearsign, #gpg_detached, #gpg_export_pubkey, #gunzip_pipe, #handle_errors, #run

Constructor Details

#initializeDeb

Returns a new instance of Deb.



6
7
# File 'lib/frm/deb.rb', line 6

def initialize()
end

Instance Method Details

#generate_package_file(in_packages = []) ⇒ Object



9
10
11
12
13
14
# File 'lib/frm/deb.rb', line 9

def generate_package_file(in_packages=[])
  packages = in_packages.sort { |a,b| a['Package'] <=> b['Package'] }
  package_file = ''
  packages.each { |package| package_file << generate_package_stub(package) }
  return package_file
end

#generate_package_line(key = '', value = '') ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/frm/deb.rb', line 45

def generate_package_line(key='',value='')
  valid_options = %w{Package Version Architecture Maintainer Standards-Version Homepage Priority Depends Filename Size SHA256 SHA1 MD5sum Description}
  raise "Bogus option passed: #{key}" unless valid_options.include?(key)                
  
  case key
  when 'Depends'
    return "Depends: #{value.join(', ')}\n"
  when 'Maintainer'
    return "Maintainer: <#{value}>\n"
  else
    return "#{key}: #{value}\n"
  end
end

#generate_package_releaseObject



35
36
37
38
39
40
41
42
# File 'lib/frm/deb.rb', line 35

def generate_package_release
  return "Component: main
Origin: apt.cloudscaling.com
Label: apt repository natty
Architecture: amd64
Description: Cloudscaling APT repository
"
end

#generate_package_stub(in_package = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/frm/deb.rb', line 17

def generate_package_stub(in_package={})
  package = in_package.dup
  package_stub = ''
  description = package.delete('Description') || "no description given"
  path_to_deb = package.delete 'path_to_deb'
  section = package.delete 'section'
  package["Filename"] = "pool/#{section}/#{package['Package'][0]}/#{package['Package']}/#{package['Package']}_#{package['Version']}_#{package['Architecture']}.deb"
  package["Size"] = File.new(path_to_deb).size
  package["MD5sum"] = self.compute_md5 File.read path_to_deb
  package["SHA1"] = compute_sha1 File.read path_to_deb
  package["SHA256"] = compute_sha2 File.read path_to_deb
  package["Description"] = description
  package.each { |key,value| package_stub << generate_package_line(key,value) }
  package_stub << "\n"
  return package_stub
end