Bug 2248571

Summary: fedora-review false negative on systemd macro usage
Product: [Fedora] Fedora Reporter: Jerry James <loganjerry>
Component: fedora-reviewAssignee: Neal Gompa <ngompa13>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 38CC: admiller, leamas.alec, michel, ngompa13, pingou
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-05-31 08:58:53 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jerry James 2023-11-07 19:03:19 UTC
I am reviewing bug 2244378.  Fedora-review says:

- systemd_user_post is invoked in %post and systemd_user_preun in %preun
  for Systemd user units service files.
  Note: Systemd user unit service file(s) in xdg-desktop-portal-hyprland
  See: https://docs.fedoraproject.org/en-US/packaging-
  guidelines/Scriptlets/#_user_units

which is wrong, because the spec file has exactly what it is asking for:

%post
%systemd_user_post %{name}.service

%preun
%systemd_user_preun %{name}.service

I stepped through the python code in /usr/share/fedora-review/plugins/generic.py, CheckSystemdUserunitdirScriplets.run.  At the point where the regular expression searches are tried, str(rpmpkg.post) is:

'\n \nif [ $1 -eq 1 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then \n    # Initial installation \n    /usr/lib/systemd/systemd-update-helper install-user-units xdg-desktop-portal-hyprland.service || : \nfi'

The call to rpm.expandMacro("%systemd_user_post .*.service") on the other hand, produces this:

'\n \nif [ $1 -eq 1 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then \n    # Initial installation \n    /usr/lib/systemd/systemd-update-helper install-user-units .*.service || : \nfi \n'

Notice that has an extra ' \n' at the end.  I see that systemd_user_post_re is altered by taking a slice: [2:].  Should that remove the *final* 2 characters instead of the *initial* 2 characters?

Reproducible: Always

Steps to Reproduce:
1. fedora-review -b 2244378 -m fedora-rawhide-x86_64
2.
3.
Actual Results:  
Fedora-review complains about missing systemd scriptlets that are not, in fact, missing.

Expected Results:  
No complaints, since the systemd scripts are present.

Comment 1 Aoife Moloney 2024-05-31 08:58:53 UTC
Fedora Linux 38 entered end-of-life (EOL) status on 2024-05-21.

Fedora Linux 38 is no longer maintained, which means that it
will not receive any further security or bug fix updates. As a result we
are closing this bug.

If you can reproduce this bug against a currently maintained version of Fedora Linux
please feel free to reopen this bug against that version. Note that the version
field may be hidden. Click the "Show advanced fields" button if you do not see
the version field.

If you are unable to reopen this bug, please file a new report against an
active release.

Thank you for reporting this bug and we are sorry it could not be fixed.