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

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
# 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[: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



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

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



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

def cleanup
  fpm.cleanup
end

#convert(output_class) ⇒ Object



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

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

#epoch=(value) ⇒ Object



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

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

#fpm_objectObject



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

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



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

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

#package_inputObject



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

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



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

def package_setup
  # Can be overwritten in a subclass.
end

#vendor=(value) ⇒ Object



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

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

#version=(version) ⇒ Object

XXX should go away and set in initializer



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

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