Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PA-5786) Add ability to execute direct post installation scriptlets #820

Merged
merged 1 commit into from
Oct 23, 2023

Conversation

tvpartytonight
Copy link
Contributor

The existing #add_postinstall_action adds actions to the %posttrans section of an rpm spec file. This can mean that the action could fail, but the installation/upgrade could still succeed. This commit adds the ability to add actions that must succeed post installation for rpm installations by adding the action to the %post section.

Please add all notable changes to the "Unreleased" section of the CHANGELOG.

@tvpartytonight
Copy link
Contributor Author

This might be preferable to #819 as it should be safer and would only affect projects using #add_postinstall_required_action.

Copy link
Contributor

@e-gris e-gris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of ignorable nitpicky style comments but otherwise LGTM.

I actually liked the previous one better because if the cleanliness it introduced, but understand the reasoning to head this way to avoid breaking things.

Comment on lines 512 to 513
pkg_state = Array(pkg_state)
scripts = Array(scripts)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style only: don't mutate caller-supplied arguments; create new variables instead.

scripts = components.flat_map(&:postinstall_required_actions).compact.select { |s| s.pkg_state.include? pkg_state }.map(&:scripts)
if scripts.empty?
return ': no postinstall required scripts provided'
else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style only: else is redundant. Favor a guardian clause:

return ': no postinstall required scripts provided' if scripts.empty?

[return] scripts.join("\n")

The 2nd return is optional depending on your aesthetic preferences.

@@ -485,7 +485,7 @@ def get_activate_triggers()
# Can be one of 'install' or 'upgrade'
# @return [String] string of Bourne shell compatible scriptlets to execute during the postinstall
# phase of packaging during the state of the system defined by pkg_state (either install or upgrade)
def get_postinstall_actions(pkg_state)
def get_postinstall_required_actions(pkg_state)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is titled incorrectly and should be the name of the function below.

@tvpartytonight tvpartytonight force-pushed the PA-5786_alt branch 2 times, most recently from 898dfaf to 1f169dc Compare October 23, 2023 19:25
@e-gris
Copy link
Contributor

e-gris commented Oct 23, 2023

Also, when ready, please add a CHANGELOG update.

@tvpartytonight
Copy link
Contributor Author

@e-gris I think I have address all comments, let me know if there is anything I missed.

@e-gris
Copy link
Contributor

e-gris commented Oct 23, 2023

Put an '### Added' header above the changelog entry and all will be well.

The existing `#add_postinstall_action` adds actions to the `%posttrans`
section of an rpm spec file. This can mean that the action could fail,
but the installation/upgrade could still succeed. This commit adds the
ability to add actions that must succeed post installation for rpm
installations by adding the action to the `%post` section.
@tvpartytonight tvpartytonight merged commit 985f192 into puppetlabs:main Oct 23, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants