Class: Pkgr::Distributions::Debian

Inherits:
Base
  • Object
show all
Defined in:
lib/pkgr/distributions/debian.rb

Overview

Contains the various components required to make a packaged app integrate well with a Debian system.

Direct Known Subclasses

Ubuntu

Defined Under Namespace

Classes: DebianFpmCommand

Instance Attribute Summary

Attributes inherited from Base

#config

Instance Method Summary collapse

Methods inherited from Base

#build_dependencies, #buildpacks, #check, #crons_dir, #default_buildpack_list, #dependencies, #initialize, #initializers_for, #os, #postinstall_file, #postuninstall_file, #preinstall_file, #preuninstall_file, #slug, #target, #templates

Constructor Details

This class inherits a constructor from Pkgr::Distributions::Base

Instance Method Details

#debconfigObject



52
53
54
55
56
57
58
59
60
# File 'lib/pkgr/distributions/debian.rb', line 52

def debconfig
  @debconfig ||= begin
    tmpfile = Tempfile.new("debconfig")
    tmpfile.puts "#!/bin/bash"
    tmpfile.rewind
    tmpfile
  end
  @debconfig
end

#debtemplatesObject



62
63
64
# File 'lib/pkgr/distributions/debian.rb', line 62

def debtemplates
  @debtemplates ||= Tempfile.new("debtemplates")
end

#fpm_command(build_dir) ⇒ Object



36
37
38
# File 'lib/pkgr/distributions/debian.rb', line 36

def fpm_command(build_dir)
  DebianFpmCommand.new(self, build_dir).command
end

#installer_dependenciesObject



32
33
34
# File 'lib/pkgr/distributions/debian.rb', line 32

def installer_dependencies
  super.push("debianutils").uniq
end

#package_install_command(packages) ⇒ Object



28
29
30
# File 'lib/pkgr/distributions/debian.rb', line 28

def package_install_command(packages)
  "sudo apt-get update && sudo apt-get install --force-yes -y #{packages.map{|package| "\"#{package}\""}.join(" ")}"
end

#package_test_command(package) ⇒ Object



24
25
26
# File 'lib/pkgr/distributions/debian.rb', line 24

def package_test_command(package)
  "dpkg -s '#{package}' > /dev/null 2>&1"
end

#releaseObject

Only keep major digits



11
12
13
# File 'lib/pkgr/distributions/debian.rb', line 11

def release
  @release[/^[0-9]+/]
end

#runnerObject



15
16
17
18
19
20
21
22
# File 'lib/pkgr/distributions/debian.rb', line 15

def runner
  @runner ||= case release
  when /^8/
    Runner.new("systemd", "default", "systemctl")
  else
    Runner.new("sysv", "lsb-3.1", "update-rc.d")
  end
end

#verify(output_dir) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/pkgr/distributions/debian.rb', line 40

def verify(output_dir)
  Dir.glob(File.join(output_dir, "*deb")).each do |package|
    puts "-----> Verifying package #{File.basename(package)}"
    Dir.mktmpdir do |dir|
      verify_package = Mixlib::ShellOut.new %{dpkg-deb -x #{package} #{dir}}
      verify_package.logger = Pkgr.logger
      verify_package.run_command
      verify_package.error!
    end
  end
end