Class: FPM::Cookery::Package::Package

Inherits:
Object
  • Object
show all
Defined in:
lib/fpm/cookery/package/package.rb

Direct Known Subclasses

CPAN, Dir, Gem, NPM, PEAR, Python, Virtualenv

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(recipe, config = {}) ⇒ Package

Returns a new instance of Package.



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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fpm/cookery/package/package.rb', line 9

def initialize(recipe, config = {})
  @recipe = recipe
  @config = config
  @fpm = fpm_object

  @fpm.name = recipe.name
  @fpm.url = recipe.homepage
  @fpm.category = recipe.section || 'optional'
  @fpm.description = recipe.description.strip if recipe.description
  @fpm.architecture = recipe.arch.to_s if recipe.arch

  @fpm.dependencies += recipe.depends
  @fpm.conflicts += recipe.conflicts
  @fpm.provides += recipe.provides
  @fpm.replaces += recipe.replaces
  @fpm.config_files += recipe.config_files
  @fpm.directories += recipe.directories

  @fpm.attributes[:deb_compression] = 'gz'
  @fpm.attributes[:deb_user] = 'root'
  @fpm.attributes[:deb_group] = 'root'
  @fpm.attributes[:rpm_compression] = 'gzip'
  @fpm.attributes[:rpm_digest] = 'md5'
  @fpm.attributes[:rpm_user] = 'root'
  @fpm.attributes[:rpm_group] = 'root'
  @fpm.attributes[:rpm_defattrfile] = '-'
  @fpm.attributes[:rpm_defattrdir] = '-'
  @fpm.attributes[:rpm_dist] = recipe.rpm_dist.to_s if recipe.rpm_dist
  @fpm.attributes[:excludes] = recipe.exclude

  # Package type specific code should be called in package_setup.
  package_setup

  # combine recipe specific fpm attributes. here allows to
  # overwrite the values from package_setup().
  @fpm.attributes.merge!(recipe.fpm_attributes)

  # The input for the FPM package will be set here.
  package_input

  # The call to input() overwrites the license and vendor attributes.
  # XXX Needs to be fixed in fpm/package/dir.rb.
  fpm.license = recipe.license if recipe.license
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/fpm/cookery/package/package.rb', line 7

def config
  @config
end

#fpmObject (readonly)

Returns the value of attribute fpm.



7
8
9
# File 'lib/fpm/cookery/package/package.rb', line 7

def fpm
  @fpm
end

#recipeObject (readonly)

Returns the value of attribute recipe.



7
8
9
# File 'lib/fpm/cookery/package/package.rb', line 7

def recipe
  @recipe
end

Instance Method Details

#add_script(type, content) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/fpm/cookery/package/package.rb', line 76

def add_script(type, content)
  case type.to_sym
  when :pre_install
    fpm.scripts[:before_install] = content
  when :post_install
    fpm.scripts[:after_install] = content
  when :pre_uninstall
    fpm.scripts[:before_remove] = content
  when :post_uninstall
    fpm.scripts[:after_remove] = content
  end
end

#cleanupObject



72
73
74
# File 'lib/fpm/cookery/package/package.rb', line 72

def cleanup
  fpm.cleanup
end

#convert(output_class) ⇒ Object



68
69
70
# File 'lib/fpm/cookery/package/package.rb', line 68

def convert(output_class)
  fpm.convert(output_class)
end

#epoch=(value) ⇒ Object



104
105
106
# File 'lib/fpm/cookery/package/package.rb', line 104

def epoch=(value)
  fpm.epoch = value
end

#fpm_objectObject



54
55
56
57
# File 'lib/fpm/cookery/package/package.rb', line 54

def fpm_object
  # Has to be overwritten in a subclass.
  raise Error::MethodNotImplemented, "The #fpm_object method has not been implemented in #{self.class}"
end

#maintainer=(value) ⇒ Object



96
97
98
# File 'lib/fpm/cookery/package/package.rb', line 96

def maintainer=(value)
  fpm.maintainer = value
end

#package_inputObject



63
64
65
66
# File 'lib/fpm/cookery/package/package.rb', line 63

def package_input
  # Has to be overwritten in a subclass.
  raise Error::MethodNotImplemented, "The #package_input method has not been implemented in #{self.class}"
end

#package_setupObject



59
60
61
# File 'lib/fpm/cookery/package/package.rb', line 59

def package_setup
  # Can be overwritten in a subclass.
end

#vendor=(value) ⇒ Object



100
101
102
# File 'lib/fpm/cookery/package/package.rb', line 100

def vendor=(value)
  fpm.vendor = value
end

#version=(version) ⇒ Object

XXX should go away and set in initializer



90
91
92
93
94
# File 'lib/fpm/cookery/package/package.rb', line 90

def version=(version)
  fpm.version = version.version
  fpm.iteration = version.revision
  fpm.vendor = version.vendor
end