Skip to content

Commit

Permalink
Implemented control script commands, removed dummy template scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Knetic committed Dec 29, 2015
1 parent a8eabbe commit 87ce028
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 28 deletions.
36 changes: 22 additions & 14 deletions lib/fpm/package/apk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,29 @@ def write_pkginfo(base_path)
# in the folder given by [base_path]
def write_control_scripts(base_path)

scripts =
[
"pre-install",
"post-install",
"pre-deinstall",
"post-deinstall",
"pre-upgrade",
"post-upgrade"
]

scripts.each do |path|

script_path = "#{base_path}/.#{path}"
File.write(script_path, template("apk/#{path}").result(binding))
scripts = {}

scripts = register_script('post-install', :after_install, scripts)
scripts = register_script('post-install', :before_install, scripts)
scripts = register_script('post-install', :before_upgrade, scripts)
scripts = register_script('post-install', :after_upgrade, scripts)
scripts = register_script('pre-deinstall', :before_remove, scripts)
scripts = register_script('post-deinstall', :after_remove, scripts)

scripts.each do |key, content|

File.write("#{base_path}/.#{key}", content)
end
end

# Convenience method for 'write_control_scripts' to register control scripts
# if they exist.
def register_script(key, value, hash)

if(script?(value))
hash[key] = scripts[value]
end
return hash
end

# Removes the end-of-tar records from the given [target_path].
Expand Down
2 changes: 0 additions & 2 deletions templates/apk/post-deinstall

This file was deleted.

3 changes: 0 additions & 3 deletions templates/apk/post-install

This file was deleted.

2 changes: 0 additions & 2 deletions templates/apk/post-upgrade

This file was deleted.

2 changes: 0 additions & 2 deletions templates/apk/pre-deinstall

This file was deleted.

3 changes: 0 additions & 3 deletions templates/apk/pre-install

This file was deleted.

2 changes: 0 additions & 2 deletions templates/apk/pre-upgrade

This file was deleted.

0 comments on commit 87ce028

Please sign in to comment.