Class: FPM::Fry::Plugin::Apt

Inherits:
Object
  • Object
show all
Defined in:
lib/fpm/fry/plugin/apt.rb

Overview

Note:

experimental

Allows adding a debian repository.

Examples:

in a recipe

plugin 'apt' do |apt|
  apt.repository "https://repo.varnish-cache.org/#{distribution}", "trusty", "varnish-4.1"
end

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.apply(builder, &block) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fpm/fry/plugin/apt.rb', line 33

def self.apply(builder, &block)
  if builder.flavour != "debian"
    builder.logger.info('skipped apt plugin')
    return
  end
  dsl = self.new(builder)
  if block.arity == 1
    block.call(dsl)
  else
    dsl.instance_eval(&block)
  end
end

Instance Method Details

#repository(url, distribution, components, options = {}) ⇒ Object

Adds a debian repository

Parameters:

  • url (String)
  • distribution (String)
  • components (String, Array<String>)
  • options (Hash) (defaults to: {})


21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fpm/fry/plugin/apt.rb', line 21

def repository(url, distribution, components, options = {} )
  name = "#{url}-#{distribution}".gsub(/[^a-zA-Z0-9_\-]/,'-')
  source = ['deb']
  source << '[trusted=yes]'
  source << url
  source << distribution
  source << Array(components).join(' ')
  @builder.before_dependencies do
    @builder.bash "echo '#{source.join(' ')}' >> /etc/apt/sources.list.d/#{name}.list && apt-get update -o Dir::Etc::sourcelist='sources.list.d/#{name}.list' -o Dir::Etc::sourceparts='-' -o APT::Get::List-Cleanup='0'"
  end
end