RHEL-62834 Fix post scriptlet

Resolves: RHEL-62834
This commit is contained in:
Zdenek Dohnal 2024-11-18 15:52:44 +01:00
parent 8cc57f8cf3
commit f901cbd697
2 changed files with 26 additions and 2 deletions

View File

@ -1,3 +1,4 @@
# Default configuration
# multi-queue - Support multiple print queues.
# web-interface - Web UI.
# raw-socket - Provide a raw ("JetDirect") socket for each printer on port 91xx.

View File

@ -3,7 +3,7 @@
Name: lprint
Version: 1.3.1
Release: 6%{?dist}
Release: 7%{?dist}
Summary: A Label Printer Application
License: Apache-2.0
@ -73,16 +73,35 @@ export CC=%{__cc}
install -p -D -m 0644 %{SOURCE1} %{buildroot}/%{_sysconfdir}/lprint.conf
%pre
# migration scriptlet to take care of incorrect conf locations
if [ $1 -gt 1 ]
then
# daemon moved /etc/lprint.conf into /var/lib/lprint.state if the latter was missing and
# no HOME env set - this is incorrect, move it back to /etc (server-options are present only in
# system conf file). It was daemon solution for migration of configuration after fixing the bug
# which gets fixed by next scriptlet (the state was written into /etc)
if test -f /var/lib/lprint.state
then
! grep -q "^server-options" /var/lib/lprint.state || mv -f /var/lib/lprint.state /etc/lprint.conf
fi
# the original issue - state was written into /etc instead of /var/lib - check if the /etc/lprint.conf
# is an actual state file, and if it is, move it into right directory if state file does not exist.
if test ! -f /var/lib/lprint.state -a -f /etc/lprint.conf
then
# if the lprint.conf is the default one from RPM, do not move
grep -q "^# Fedora default configuration" /etc/lprint.conf || mv -f /etc/lprint.conf /var/lib/lprint.state
grep -q "^server-options" /etc/lprint.conf || mv -f /etc/lprint.conf /var/lib/lprint.state
fi
fi
%post
# generate an empty state file to prevent /etc config file being moved into
# /var/lib/
if test ! -f /var/lib/lprint.state
then
touch /var/lib/lprint.state
fi
%systemd_post lprint.service
%preun
@ -113,9 +132,13 @@ fi
%{_mandir}/man1/lprint.1*
%{_mandir}/man5/lprint.conf.5*
%{_unitdir}/lprint.service
%ghost %{_sharedstatedir}/lprint.state
%changelog
* Mon Nov 18 2024 Zdenek Dohnal <zdohnal@redhat.com> - 1.3.1-7
- RHEL-62834 Fix post scriptlet
* Mon Nov 18 2024 Zdenek Dohnal <zdohnal@redhat.com> - 1.3.1-6
- RHEL-67908 lprint requires avahi-daemon.socket, but does not install avahi