Re: Accidentally disabling units with systemd scriptlets

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 16, 2017 at 08:46:50PM +0000, Jeremy Cline wrote:
> Hey folks,
> 
> I recently did a large re-write of a specfile in order to provide a
> Python 3 version and to make it easier to maintain.
> 
> Prior to this re-write the specfile produced a number of subpackages
> that each provided a service file (fedmsg-hub, fedmsg-relay, ...). In
> my re-write I had the python2-fedmsg sub-package provide all these
> packages. There weren't any systemd scriptlets, either, so I added
> those.
> 
> The problem is that now when you upgrade, the service is disabled even
> if you have it enabled before the upgrade. I believe this is happening
> because now the python2-fedmsg package provides the unit file and the
> installation scriptlet calls "systemctl --no-reload preset" due it being
> an initial install (since it's a new subpackage that is a merge of the
> old subpackages).
> 
> Has anyone run into this problem before? What are my options for fixing
> this?
> 
> The original specfile
> 
> https://src.fedoraproject.org/rpms/fedmsg/blob/ceae21bababb90802c22461846d30653a2d98bc1/f/fedmsg.spec
> 
> The new specfile
> 
> https://src.fedoraproject.org/rpms/fedmsg/blob/7b1c384562e7664d2b912b9f2eebd336b4658480/f/fedmsg.spec
> 
> Thanks!

I think your best bet is to generate a temporary preset override
in %pre. Something along the lines of (completely untested):

%pre -n python2-fedmsg
if $1 == 1; then # initial install
   for i in fedmsg-hub.service fedmsg-relay.service fedmsg-irc.service fedmsg-gateway.service; do
       if systemctl is-enabled -q $i 2>/dev/null; then
           echo "enable $i" >>/run/systemd/system-preset/fedmsg.preset
       fi
   done
fi

Another note: you can coalesce all %systemd_* macro invocations to put
multiple units on the same line. It's a bit more compact and faster.

Zbyszek
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux