Skip to content

rpm: fix systemd scriptlet failures in Anaconda/Kickstart installs#1020

Open
cpuguy83 wants to merge 1 commit intoproject-dalec:mainfrom
cpuguy83:fix_rpm_systemd_macros
Open

rpm: fix systemd scriptlet failures in Anaconda/Kickstart installs#1020
cpuguy83 wants to merge 1 commit intoproject-dalec:mainfrom
cpuguy83:fix_rpm_systemd_macros

Conversation

@cpuguy83
Copy link
Copy Markdown
Collaborator

@cpuguy83 cpuguy83 commented Apr 3, 2026

RPM %post and %preun scriptlets used raw systemctl commands that exit non-zero when systemd is installed but not running, causing Anaconda to abort package installation (libdnf5 treats scriptlet errors as fatal).

%post: Replace raw 'systemctl enable [--now]' with 'systemctl enable || :' gated on $1 == 1. For Start: true, use a separate systemctl start || : guarded by /run/systemd/system. We intentionally avoid %systemd_post because it calls systemctl preset which defers to system preset policy and would break the Enable: true contract.

%preun: Replace raw systemctl disable --now with %systemd_preun macro, which handles the $1 == 0 check and /run/systemd/system guard internally.

Fixes: #1017

RPM %post and %preun scriptlets used raw systemctl commands that exit
non-zero when systemd is installed but not running, causing Anaconda to
abort package installation (libdnf5 treats scriptlet errors as fatal).

%post: Replace raw 'systemctl enable [--now]' with 'systemctl enable || :'
gated on $1 == 1. For Start: true, use a separate 'systemctl start || :'
guarded by /run/systemd/system. We intentionally avoid %systemd_post
because it calls 'systemctl preset' which defers to system preset policy
and would break the Enable: true contract.

%preun: Replace raw 'systemctl disable --now' with %systemd_preun macro,
which handles the $1 == 0 check and /run/systemd/system guard internally.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Copilot AI review requested due to automatic review settings April 3, 2026 00:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the RPM spec template’s systemd scriptlets to avoid fatal failures during installs in environments where systemd is installed but not running (e.g., Anaconda/Kickstart chroots), aligning with issue #1017.

Changes:

  • Switch %preun handling from raw systemctl disable --now to %systemd_preun.
  • Adjust %post handling to use systemctl enable ... || : (install-only) and, when Start: true, a guarded systemctl start ... || :.
  • Update RPM template unit tests to match the new scriptlet output.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packaging/linux/rpm/template.go Reworks systemd %post/%preun scriptlet generation to be non-fatal when systemd isn’t running and to use macros where appropriate.
packaging/linux/rpm/template_test.go Updates expected rendered spec output for systemd scriptlets.

@cpuguy83 cpuguy83 enabled auto-merge (rebase) April 7, 2026 16:55
@cpuguy83 cpuguy83 self-assigned this Apr 8, 2026
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.

rpm: systemd scriptlets should use macros

2 participants