vanagon 0.41.0 → 0.42.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbfdc34ac75b70c6f96c6f767426d61ed0140be4e7e0fbee6cf9cf255f6b1c4b
4
- data.tar.gz: 51109a1e790290e27d1b03674601f3209fc17df1431f860768b15b88534bc5aa
3
+ metadata.gz: 6124c941f058f16b94d91df59c931cb9c53717b3968d455ecccb77a47def3374
4
+ data.tar.gz: fcf11d725a1920d08eb5119ef9ada27cafb076ff5e28a2b1cb4e672996a3c656
5
5
  SHA512:
6
- metadata.gz: 9166d82bf7623a2423ac6bd10becdc2c0bd1dd98808abf098b91c2818f7742152d8109fc778155646c36cb4295cab960fa60ae74d1e53ca1748cf4e9b049fac1
7
- data.tar.gz: 63175335e9f35857aebd80da28d7777d40b13050136b62290acc54217b71dfbf3deb03f03d6c6af2bf6eb8ebc15d22ae64bef89e3f94425506c0e64f485d6838
6
+ metadata.gz: f6241005f7a94f68bfd385e00ac25d8ded7bfaa980e61dc1074f54a4c2411c0abda93aa73ecc542a387c88b127e076c8d37a5e907cc96333c3b538c51d4f3730
7
+ data.tar.gz: 9ecf812ede9986b0860e58996072b068acb3f4f6a5cf17ccf52bd09f88ce43dc39b09134ef2c8665998d965670d301a7813dab62997bff8d8163edddd203774e
@@ -503,6 +503,16 @@ class Vanagon
503
503
  @component.activate_triggers << OpenStruct.new(:activate_name => activate_name)
504
504
  end
505
505
 
506
+ # Add post installation action that must exit successfully before restarting the service
507
+ #
508
+ # @param pkg_state [Array] the state in which the scripts should execute. Can be
509
+ # one or multiple of 'install' and 'upgrade'.
510
+ # @param scripts [Array] the Bourne shell compatible scriptlet(s) to execute
511
+ def add_postinstall_required_action(pkg_state, scripts)
512
+ check_pkg_state_array(pkg_state)
513
+ @component.postinstall_required_actions << OpenStruct.new(:pkg_state => Array(pkg_state), :scripts => Array(scripts))
514
+ end
515
+
506
516
  # Adds action to run during the postinstall phase of packaging
507
517
  #
508
518
  # @param pkg_state [Array] the state in which the scripts should execute. Can be
@@ -106,7 +106,7 @@ class Vanagon
106
106
  @clone_options = opts[:clone_options] ||= {}
107
107
 
108
108
  # We can test for Repo existence without cloning
109
- raise Vanagon::InvalidRepo, "url is not a valid Git repo" unless valid_remote?
109
+ raise Vanagon::InvalidRepo, "\"#{url}\" is not a valid Git repo" unless valid_remote?
110
110
  end
111
111
 
112
112
  # Fetch the source. In this case, clone the repository into the workdir
@@ -106,6 +106,9 @@ class Vanagon
106
106
  # activate_triggers is a one-dimentional Array of Strings, describing scripts that
107
107
  # should be executed when a package identifies an activate trigger
108
108
  attr_accessor :activate_triggers
109
+ # postinstall_required_actions is a two-dimensional Array, describing scripts that
110
+ # must be executed successfully after a given component is installed.
111
+ attr_accessor :postinstall_required_actions
109
112
  # postinstall_actions is a two-dimensional Array, describing scripts that
110
113
  # should be executed after a given component is installed.
111
114
  attr_accessor :postinstall_actions
@@ -176,6 +179,7 @@ class Vanagon
176
179
  @install_triggers = []
177
180
  @interest_triggers = []
178
181
  @activate_triggers = []
182
+ @postinstall_required_actions = []
179
183
  @postinstall_actions = []
180
184
  @preremove_actions = []
181
185
  @postremove_actions = []
@@ -494,6 +494,18 @@ class Vanagon
494
494
  end
495
495
  end
496
496
 
497
+ # Collects the postinstall packaging actions that must exit successfully for the project and it's components
498
+ # for the specified packaging state
499
+ #
500
+ # @param pkg_state [String] the package state we want to run the given scripts for.
501
+ # Can be one of 'install' or 'upgrade'
502
+ # @return [String] string of Bourne shell compatible scriptlets to execute during the postinstall
503
+ # phase of packaging during the state of the system defined by pkg_state (either install or upgrade)
504
+ def get_postinstall_required_actions(pkg_state)
505
+ scripts = components.flat_map(&:postinstall_required_actions).compact.select { |s| s.pkg_state.include? pkg_state }.map(&:scripts)
506
+ return ': no postinstall required scripts provided' if scripts.empty?
507
+ scripts.join("\n")
508
+ end
497
509
  # Collects the preremove packaging actions for the project and it's components
498
510
  # for the specified packaging state
499
511
  #
@@ -242,6 +242,15 @@ fi
242
242
 
243
243
 
244
244
  %post
245
+ # Run required postinstall scripts on install if defined
246
+ if [ -e %{_localstatedir}/lib/rpm-state/%{name}/install ] ; then
247
+ <%= get_postinstall_required_actions("install") %>
248
+ fi
249
+
250
+ # Run required postinstall scripts on upgrade if defined
251
+ if [ -e %{_localstatedir}/lib/rpm-state/%{name}/upgrade ] ; then
252
+ <%= get_postinstall_required_actions("upgrade") %>
253
+ fi
245
254
  <%- if @platform.is_aix? || (@platform.is_el? && @platform.os_version.to_i == 4) -%>
246
255
  ## EL-4 and AIX RPM don't have %posttrans, so we'll put them here
247
256
  # Run postinstall scripts on install if defined
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vanagon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.41.0
4
+ version: 0.42.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet By Perforce
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-26 00:00:00.000000000 Z
11
+ date: 2023-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt