Class: FPM::Package::PleaseRun

Inherits:
FPM::Package show all
Defined in:
lib/fpm/package/pleaserun.rb

Overview

A pleaserun package.

This does not currently support ‘output’

Instance Attribute Summary

Attributes inherited from FPM::Package

#architecture, #attributes, #attrs, #category, #config_files, #conflicts, #dependencies, #description, #directories, #epoch, #iteration, #license, #maintainer, #name, #provides, #replaces, #scripts, #url, #vendor, #version

Instance Method Summary collapse

Methods inherited from FPM::Package

apply_options, #build_path, #cleanup, #cleanup_build, #cleanup_staging, #convert, #converted_from, default_attributes, #edit_file, #files, inherited, #initialize, option, #output, #script, #staging_path, #to_s, #type, type, types

Methods included from Util

#copied_entries, #copy_entry, #copy_metadata, #default_shell, #execmd, #expand_pessimistic_constraints, #logger, #mknod_w, #program_exists?, #program_in_path?, #safesystem, #safesystemout, #tar_cmd

Constructor Details

This class inherits a constructor from FPM::Package

Instance Method Details

#input(command) ⇒ Object



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
53
54
55
56
57
58
59
60
# File 'lib/fpm/package/pleaserun.rb', line 22

def input(command)
  platforms = [
    ::PleaseRun::Platform::Systemd.new("default"), # RHEL 7, Fedora 19+, Debian 8, Ubuntu 16.04
    ::PleaseRun::Platform::Upstart.new("1.5"), # Recent Ubuntus
    ::PleaseRun::Platform::Upstart.new("0.6.5"), # CentOS 6
    ::PleaseRun::Platform::Launchd.new("10.9"), # OS X
    ::PleaseRun::Platform::SYSV.new("lsb-3.1") # Ancient stuff
  ]

  attributes[:pleaserun_name] ||= File.basename(command.first)
  attributes[:prefix] ||= "/usr/share/pleaserun/#{attributes[:pleaserun_name]}"

  platforms.each do |platform|
    logger.info("Generating service manifest.", :platform => platform.class.name)
    platform.program = command.first
    platform.name = attributes[:pleaserun_name]
    platform.args = command[1..-1]
    platform.description = if attributes[:description_given?]
      attributes[:description]
    else
      platform.name
    end
    base = staging_path(File.join(attributes[:prefix], "#{platform.platform}/#{platform.target_version || "default"}"))
    target = File.join(base, "files")
    actions_script = File.join(base, "install_actions.sh")
    ::PleaseRun::Installer.install_files(platform, target, false)
    ::PleaseRun::Installer.write_actions(platform, actions_script)
  end

  libs = [ "install.sh", "install-path.sh", "generate-cleanup.sh" ]
  libs.each do |file|
    base = staging_path(File.join(attributes[:prefix]))
    File.write(File.join(base, file), template(File.join("pleaserun", file)).result(binding))
    File.chmod(0755, File.join(base, file))
  end

  scripts[:after_install] = template(File.join("pleaserun", "scripts", "after-install.sh")).result(binding)
  scripts[:before_remove] = template(File.join("pleaserun", "scripts", "before-remove.sh")).result(binding)
end