vanagon 0.41.0 → 0.43.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: db6bbca78a910b41075dc50bccc92e3088ffc4a076b58543feff84ec809b59dc
4
+ data.tar.gz: ada82f3362eaab0c8ee9b5248c3f3e17d1660276ed9c6328a1a9d38a9575fe38
5
5
  SHA512:
6
- metadata.gz: 9166d82bf7623a2423ac6bd10becdc2c0bd1dd98808abf098b91c2818f7742152d8109fc778155646c36cb4295cab960fa60ae74d1e53ca1748cf4e9b049fac1
7
- data.tar.gz: 63175335e9f35857aebd80da28d7777d40b13050136b62290acc54217b71dfbf3deb03f03d6c6af2bf6eb8ebc15d22ae64bef89e3f94425506c0e64f485d6838
6
+ metadata.gz: 5271dfd756bf4ca321b56124402d81e0ab235aca51554b278b770a9942a0a251307141f58b6d0f7ea92fa969c72b4f21e67f5e353dcdfb2eab0fb22b5d9f50fd
7
+ data.tar.gz: 30ff287725847bb4949d3f782724163169e2f3e42eb3de04c6ff42ca1260c11f728b2073d7e1dda9b8c91109b8af1bb50a46b6c7ffd254e21f7557e4f805e02c
@@ -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 = []
@@ -380,6 +380,13 @@ class Vanagon
380
380
  return !!@name.match(/^fedora-.*$/)
381
381
  end
382
382
 
383
+ # Utility matcher to determine is the platform is a amazon linux variety
384
+ #
385
+ # @return [true, false] true if it is a amazon linux variety, false otherwise
386
+ def is_amazon?
387
+ return !!@name.match(/^amazon-.*$/)
388
+ end
389
+
383
390
  # Utility matcher to determine is the platform is a debian variety
384
391
  #
385
392
  # @return [true, false] true if it is a debian variety, false otherwise
@@ -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
  #
@@ -81,7 +81,7 @@ Requires: <%= requires.requirement %><%= requires.version ? " #{requires.versio
81
81
  # did not specify a dependency on these.
82
82
  # In the future, we will supress pre/post scripts completely if there's nothing
83
83
  # specified by the project or the components.
84
- <%- if @platform.is_fedora? || (@platform.is_el? && @platform.os_version.to_i >= 9) -%>
84
+ <%- if @platform.is_fedora? || @platform.is_amazon? || (@platform.is_el? && @platform.os_version.to_i >= 9) -%>
85
85
  Requires(pre): /usr/bin/mkdir
86
86
  Requires(pre): /usr/bin/touch
87
87
  Requires(post): /usr/bin/mkdir
@@ -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.43.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-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt