Bug 850355 - Introduce new systemd-rpm macros in util-linux spec file
Introduce new systemd-rpm macros in util-linux spec file
Product: Fedora
Classification: Fedora
Component: util-linux (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Karel Zak
Fedora Extras Quality Assurance
Depends On:
Blocks: 850016
  Show dependency treegraph
Reported: 2012-08-21 10:14 EDT by Lukáš Nykrýn
Modified: 2014-05-12 05:35 EDT (History)
5 users (show)

See Also:
Fixed In Version: util-linux-2.24.2-2.fc21
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2014-05-07 06:36:28 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Lukáš Nykrýn 2012-08-21 10:14:45 EDT
Fedora 18 changes the way how to work with services in spec files. It introduces new macros - %systemd_post, %systemd_preun and %systemd_postun; which replace scriptlets from Fedora 17 and older (see https://fedoraproject.org/wiki/Packaging:ScriptletSnippets#Systemd, https://bugzilla.redhat.com/show_bug.cgi?id=850016).
Comment 1 Christopher Meng 2013-11-18 08:40:25 EST
Ping for this easyfix bug.
Comment 2 Karel Zak 2013-11-19 05:00:46 EST
Hmm... not sure if the macros are really replacement to the stuff used in the spec file.

We have to *start* the uuidd service after installation, but it seems that %systemd_post uses "systemctl preset" only, so the service is only enabled, but no started. That's unexpected behaviour.

The uuidd service is mostly (or only) used by SAP users and they explicitly asked for this feature (start after installation) -- note that uuidd package is not installed by default.

It seems I have to use:

%post -n uuidd
%systemd_post uuidd.service
%systemd_postun_with_restart uuidd.service
if [ $1 -eq 1 ]; then
        # Package install
        /bin/systemctl start uuidd.service > /dev/null 2>&1 || :
%preun -n uuidd     
%systemd_preun uuidd.service

Comment 3 Fedora End Of Life 2013-12-21 03:47:31 EST
This message is a reminder that Fedora 18 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 18. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '18'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 18's end of life.

Thank you for reporting this issue and we are sorry that we may not be 
able to fix it before Fedora 18 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior to Fedora 18's end of life.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.
Comment 4 Christopher Meng 2013-12-27 07:11:00 EST
(In reply to Karel Zak from comment #2)
> %post -n uuidd
> %systemd_post uuidd.service
> %systemd_postun_with_restart uuidd.service
> if [ $1 -eq 1 ]; then
>         # Package install
>         /bin/systemctl start uuidd.service > /dev/null 2>&1 || :
> fi     
> %preun -n uuidd     
> %systemd_preun uuidd.service
> Right?

Well, new systemd macros just introduce simpler way.

Currently the spec contains:

%post -n uuidd
if [ $1 -eq 1 ]; then
	# Package install,
	/bin/systemctl enable uuidd.service >/dev/null 2>&1 || :
	/bin/systemctl start uuidd.service > /dev/null 2>&1 || :
	# Package upgrade
	if /bin/systemctl --quiet is-enabled uuidd.service ; then
		/bin/systemctl reenable uuidd.service >/dev/null 2>&1 || :

%preun -n uuidd
if [ "$1" = 0 ]; then
	/bin/systemctl stop uuidd.service > /dev/null 2>&1 || :
	/bin/systemctl disable uuidd.service > /dev/null 2>&1 || :


New systemd macro:

[rpmaker@fab requisite]$ rpm -E %systemd_post && rpm -E %systemd_preun && rpm -E %systemd_postun_with_restart:

if [ $1 -eq 1 ] ; then 
        # Initial installation 
        /usr/bin/systemctl preset  >/dev/null 2>&1 || : 

if [ $1 -eq 0 ] ; then 
        # Package removal, not upgrade 
        /usr/bin/systemctl --no-reload disable  > /dev/null 2>&1 || : 
        /usr/bin/systemctl stop  > /dev/null 2>&1 || : 

/usr/bin/systemctl daemon-reload >/dev/null 2>&1 || : 
if [ $1 -ge 1 ] ; then 
        # Package upgrade, not uninstall 
        /usr/bin/systemctl try-restart  >/dev/null 2>&1 || : 



1. Packages without exception shouldn't be enabled as default, I'm not familiar with uuiddd's situation, if you are right, keep the %post section as normal.

2. As you can see from the rpm eval output, %systemd_preun is the same like what you are doing in the spec, so change.

3. You don't have a %systemd_postun_with_restart command in %postun section of uuidd, you should add it, so change.

2 of 3 needs modification.
Comment 5 Karel Zak 2014-05-07 06:36:28 EDT
Thanks Christopher!

Added %systemd_postun_with_restart and %systemd_preun, %post is unchanged.
Comment 6 Karel Zak 2014-05-12 05:35:25 EDT
Note that I have also added %systemd_post as uuidd is now in the list of the "present" services. (see #1094935)

Note You need to log in before you can comment on or make changes to this bug.