Add postttrans support

This commit is contained in:
Remi Hakim 2014-03-17 19:55:29 -04:00
parent 2bb380d931
commit 9c5815e96e
5 changed files with 12 additions and 0 deletions

View File

@ -178,6 +178,10 @@ class FPM::Command < Clamp::Command
option "--verify_script", "FILE",
"a script to be run on verification" do |val|
File.expand_path(val) # Get the full path to the script
end # --verify_script
option "--posttrans", "FILE",
"post trans script" do |val|
File.expand_path(val) # Get the full path to the script
end # --verify_script
option "--template-scripts", :flag,
"Allow scripts to be templated. This lets you use ERB to template your " \
@ -367,6 +371,7 @@ class FPM::Command < Clamp::Command
setscript.call(:before_remove)
setscript.call(:after_remove)
setscript.call(:verify_script)
setscript.call(:posttrans)
# Bail if any setscript calls had errors. We don't need to log
# anything because we've already logged the error(s) above.

View File

@ -270,6 +270,7 @@ class FPM::Package::RPM < FPM::Package
self.scripts[:before_remove] = tags[:preun]
self.scripts[:after_remove] = tags[:postun]
self.scripts[:verify_script] = tags[:verifyscript]
self.scripts[:posttrans] = tags[:posttrans]
# TODO(sissel): prefix these scripts above with a shebang line if there isn't one?
# Also taking into account the value of tags[preinprog] etc, something like:
# #!#{tags[:preinprog]}

View File

@ -134,6 +134,7 @@ describe FPM::Package::RPM do
subject.scripts[:before_remove] = "example before_remove"
subject.scripts[:after_remove] = "example after_remove"
subject.scripts[:verify_script] = "example verify_script"
subject.scripts[:posttrans] = "example posttrans"
# Write the rpm out
subject.output(@target)

View File

@ -169,6 +169,7 @@ describe FPM::Package do
subject.scripts[:after_remove] = "<%= name %>"
subject.scripts[:before_remove] = "<%= name %>"
subject.scripts[:verify_script] = "<%= name %>"
subject.scripts[:posttrans] = "<%= name %>"
subject.attributes[:template_scripts?] = true
subject.name = "Example"
insist { subject.script(:after_install) } == subject.name
@ -176,6 +177,7 @@ describe FPM::Package do
insist { subject.script(:after_remove) } == subject.name
insist { subject.script(:before_remove) } == subject.name
insist { subject.script(:verify_script) } == subject.name
insist { subject.script(:posttrans) } == subject.name
end
it "should not template when :template_scripts? is false" do
@ -184,12 +186,14 @@ describe FPM::Package do
subject.scripts[:after_remove] = "<%= name %>"
subject.scripts[:after_install] = "<%= name %>"
subkect.scripts[:verify_script] = "<%= name %>"
subkect.scripts[:posttrans] = "<%= name %>"
subject.attributes[:template_scripts?] = false
insist { subject.script(:after_install) } == subject.scripts[:after_install]
insist { subject.script(:before_install) } == subject.scripts[:before_install]
insist { subject.script(:after_remove) } == subject.scripts[:after_remove]
insist { subject.script(:before_remove) } == subject.scripts[:before_remove]
insist { subject.script(:verify_script) } == subject.scripts[:verify_script]
insist { subject.script(:posttrans) } == subject.scripts[:posttrans]
end
it "should not template by default" do

View File

@ -117,6 +117,7 @@ Obsoletes: <%= repl %>
:before_remove => "preun",
:after_remove => "postun",
:verify_script => "verifyscript",
:posttrans => "posttrans"
}
scriptmap.each do |name, rpmname|
-%>