Class: Dr::DebPackage

Inherits:
Package show all
Defined in:
lib/dr/debpackage.rb

Instance Attribute Summary

Attributes inherited from Package

#name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Package

#<=>, #build_exists?, #get_configuration, #history, #remove_build, #set_configuration

Methods included from Logger

#log, log, set_logfile, set_verbosity, #tag

Constructor Details

#initialize(name, repo) ⇒ DebPackage

Returns a new instance of DebPackage.



36
37
38
# File 'lib/dr/debpackage.rb', line 36

def initialize(name, repo)
  super name, repo
end

Class Method Details

.setup(repo, deb_file, force = false) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/dr/debpackage.rb', line 8

def self.setup(repo, deb_file, force=false)
  dpkg = ShellCmd.new "dpkg-deb --field #{deb_file} Source", :tag => "dpkg"
  src_name = dpkg.out.chomp
  if src_name == ""
    dpkg = ShellCmd.new "dpkg-deb --field #{deb_file} Package", :tag => "dpkg"
    src_name = dpkg.out.chomp
  end

  deb_file_name = File.basename(deb_file)
  log :info, "Adding the #{deb_file_name.style "subpkg-name"} package"

  dpkg = ShellCmd.new "dpkg-deb --field #{deb_file} Version", :tag => "dpkg"
  version = dpkg.out.chomp

  deb_dir = "#{repo.location}/packages/#{src_name}/builds/#{version}"

  if File.exists?("#{deb_dir}/#{deb_file_name}") && !force
    raise "This deb file is already in the repo"
  end

  log :info, "Adding a build to the #{src_name.style "pkg-name"} source package"
  FileUtils.mkdir_p deb_dir
  FileUtils.cp "#{deb_file}", "#{deb_dir}/"

  log :info, "Signing the deb file"
  repo.sign_deb "#{deb_dir}/#{deb_file_name}"
end

Instance Method Details

#build(branch = nil, force = false) ⇒ Object



40
41
42
43
44
# File 'lib/dr/debpackage.rb', line 40

def build(branch=nil, force=false)
  log :warn, "The sources of the #{@name.style "pkg-name"} package are " +
             "not managed by #{"dr".bright}"
  raise UnableToBuild.new "Unable to build the package"
end