1
0
mirror of https://github.com/jordansissel/fpm synced 2025-04-29 14:58:00 +02:00

move to deb-trigger

Signed-off-by: morph027 <stefan.heitmueller@gmx.com>
This commit is contained in:
morph027 2023-01-04 10:44:43 +01:00
parent f3b1a03abb
commit 0bc1b67616
No known key found for this signature in database
GPG Key ID: BF17A54BB873BE58
5 changed files with 20 additions and 13 deletions

@ -210,6 +210,9 @@ General Options
* ``--deb-templates FILEPATH``
- (deb only) Add FILEPATH as debconf templates file.
* ``--deb-trigger FILEPATH``
- (deb only) Add FILEPATH as trigger script
* ``--deb-upstart FILEPATH``
- (deb only) Add FILEPATH as an upstart script

@ -27,7 +27,7 @@ Install trigger
The following fpm command installs the trigger:
fpm --triggered /path/to/triggers.sh
fpm --deb-trigger /path/to/triggers.sh
The resulting postinst-script in the packages looks like this:

@ -212,14 +212,6 @@ class FPM::Command < Clamp::Command
"Currently only supports deb, rpm and pacman packages." do |val|
File.expand_path(val) # Get the full path to the script
end # --before-upgrade
option "--triggered", "FILE",
"A script snippets to define and run package triggers, see\n" \
"https://wiki.debian.org/DpkgTriggers and\n" \
"https://stackoverflow.com/questions/15276535/dpkg-how-to-use-trigger\n" do |val|
File.expand_path(val) # Get the full path to the script
end # --triggered
option "--template-scripts", :flag,
"Allow scripts to be templated. This lets you use ERB to template your " \
"packaging scripts (for --after-install, etc). For example, you can do " \
@ -473,7 +465,6 @@ class FPM::Command < Clamp::Command
setscript.call(:after_remove)
setscript.call(:before_upgrade)
setscript.call(:after_upgrade)
setscript.call(:triggered)
# Bail if any setscript calls had errors. We don't need to log
# anything because we've already logged the error(s) above.

@ -200,6 +200,13 @@ class FPM::Package::Deb < FPM::Package
next File.expand_path(file)
end
option "--trigger", "FILEPATH", "Add FILEPATH as trigger script. " \
"See https://wiki.debian.org/DpkgTriggers and " \
"https://stackoverflow.com/questions/15276535/dpkg-how-to-use-trigger",
:multivalued => true do |file|
next File.expand_path(file)
end # --trigger
option "--upstart", "FILEPATH", "Add FILEPATH as an upstart script",
:multivalued => true do |file|
next File.expand_path(file)

@ -61,9 +61,15 @@ $debsystemctl start <%= service %> >/dev/null || true
}
triggered() {
: # Ensure this if-clause is not empty. If it were empty, and we had an 'else', then it is an error in shell syntax
<% if script?(:triggered) -%>
<%= script(:triggered) %>
<%# Making sure that at least one command is in the function -%>
<%# avoids a lot of potential errors, including the case that -%>
<%# the script is non-empty, but just whitespace and/or comments -%>
:
<%# if any trigger specified, loop through and start them -%>
<% if attributes[:trigger].any? -%>
<% attributes[:trigger].each do |trigger| -%>
<%= trigger %>
<% end -%>
<% end -%>
}