Class: FPM::Fry::Plugin::Systemd::Callback Private

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

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#script_helperObject

Returns the value of attribute script_helper

Returns:

  • (Object)

    the current value of script_helper



19
20
21
# File 'lib/fpm/fry/plugin/systemd.rb', line 19

def script_helper
  @script_helper
end

Instance Method Details

#call(_, package) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

def call(_, package)
  chroot = FPM::Fry::Chroot.new(package.staging_path)
  files = chroot.entries('lib/systemd/system') - ['.','..']
  valid, invalid = files.partition{|file| VALID_UNITS =~ file }
  if invalid.any?
    package.logger.warning("Found #{invalid.size} files in systemd unit path that are no systemd units", files: invalid)
  end
  units = valid.grep_v(INSTANTIATED_UNITS)
  return if units.none?
  package.logger.info("Added #{units.size} systemd units", units: valid)
  script_helper.after_install_or_upgrade install(units)
  script_helper.before_remove_entirely before_remove(units)
  script_helper.after_remove_entirely after_remove(units)
end