Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 850355 - Introduce new systemd-rpm macros in util-linux spec file
Summary: Introduce new systemd-rpm macros in util-linux spec file
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: util-linux
Version: rawhide
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Karel Zak
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 850016
TreeView+ depends on / blocked
 
Reported: 2012-08-21 14:14 UTC by Lukáš Nykrýn
Modified: 2014-05-12 09:35 UTC (History)
5 users (show)

Fixed In Version: util-linux-2.24.2-2.fc21
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-05-07 10:36:28 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Lukáš Nykrýn 2012-08-21 14:14:45 UTC
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 13:40:25 UTC
Ping for this easyfix bug.

Comment 2 Karel Zak 2013-11-19 10:00:46 UTC
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 || :
fi     
       
%preun -n uuidd     
%systemd_preun uuidd.service

Right?

Comment 3 Fedora End Of Life 2013-12-21 08:47:31 UTC
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 12:11:00 UTC
(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 || :
else
	# Package upgrade
	if /bin/systemctl --quiet is-enabled uuidd.service ; then
		/bin/systemctl reenable uuidd.service >/dev/null 2>&1 || :
	fi
fi

%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 || :
fi

----------------

New systemd macro:

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

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

%systemd_preun
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 || : 
fi 

%systemd_postun_with_restart
/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 || : 
fi 

-----------------

Conclusion:

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 10:36:28 UTC
Thanks Christopher!

Added %systemd_postun_with_restart and %systemd_preun, %post is unchanged.

Comment 6 Karel Zak 2014-05-12 09:35:25 UTC
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.