Resolves 518418 - Package rename shuts down server, results in unconfigured

package rewrite perm/owner preservation code to use lua VS:
    ----------------------------------------------------------------------
This commit is contained in:
Richard Allen Megginson 2009-08-25 20:05:59 +00:00
commit 8d26ffc8c0

View file

@ -3,7 +3,7 @@
Summary: 389 Administration Server (admin)
Name: 389-admin
Version: 1.1.8
Release: 5%{?dist}
Release: 6%{?dist}
License: GPLv2 and ASL 2.0
URL: http://port389.org/
Group: System Environment/Daemons
@ -79,54 +79,25 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/%{pkgname}/modules/*.la
%clean
rm -rf $RPM_BUILD_ROOT
%pre
# save permission info in temp file
# if upgrading
if [ "$1" -gt 1 ] ; then
set -x
mydt=`date +%Y%m%d`
mytmpfile=${TMPDIR:-/tmp}/$mydt.$PPID
perm1=`stat --format=%%a %{_sysconfdir}/%{pkgname}/admin-serv 2> /dev/null`
if [ -z "$perm1" ] ; then
perm1=0
fi
own1=`stat --format=%%U:%%G %{_sysconfdir}/%{pkgname}/admin-serv 2> /dev/null`
if [ -z "$own1" ] ; then
own1=0
fi
perm2=`stat --format=%%a %{_sysconfdir}/%{pkgname}/admin-serv/console.conf 2> /dev/null`
if [ -z "$perm2" ] ; then
perm2=0
fi
own2=`stat --format=%%U:%%G %{_sysconfdir}/%{pkgname}/admin-serv/console.conf 2> /dev/null`
if [ -z "$own2" ] ; then
own2=0
fi
echo $perm1 $own1 $perm2 $own2 > $mytmpfile
fi
%pre -p <lua>
-- save ownership/permissions on the dirs/files that rpm changes
-- if these don't exist, the vars will be nil
%{pkgname}admin_adminserv = posix.stat('%{_sysconfdir}/%{pkgname}/admin-serv')
%{pkgname}admin_consoleconf = posix.stat('%{_sysconfdir}/%{pkgname}/admin-serv/console.conf')
%post
/sbin/chkconfig --add %{pkgname}-admin
/sbin/ldconfig
# if installing for the first time, make sure the config
# directory and file have the correct permissions
# the setup script is used to "fix" these
if [ "$1" -gt 1 ]; then
set -x
mydt=`date +%Y%m%d`
mytmpfile=${TMPDIR:-/tmp}/$mydt.$PPID
if [ ! -f $mytmpfile ] ; then
echo Error: upgrade temp file $mytmpfile not found
exit 1
fi
cat $mytmpfile | while read perm1 own1 perm2 own2 ; do
chmod $perm1 %{_sysconfdir}/%{pkgname}/admin-serv
chown $own1 %{_sysconfdir}/%{pkgname}/admin-serv
chmod $perm2 %{_sysconfdir}/%{pkgname}/admin-serv/console.conf
chown $own2 %{_sysconfdir}/%{pkgname}/admin-serv/console.conf
done
rm -f $mytmpfile
fi
%post -p <lua>
-- do the usual daemon post setup stuff
os.execute('/sbin/chkconfig --add %{pkgname}-admin')
os.execute('/sbin/ldconfig')
-- restore permissions if upgrading
if %{pkgname}admin_adminserv then
posix.chmod('%{_sysconfdir}/%{pkgname}/admin-serv', %{pkgname}admin_adminserv.mode)
posix.chown('%{_sysconfdir}/%{pkgname}/admin-serv', %{pkgname}admin_adminserv.uid, %{pkgname}admin_adminserv.gid)
end
if %{pkgname}admin_consoleconf then
posix.chmod('%{_sysconfdir}/%{pkgname}/admin-serv/console.conf', %{pkgname}admin_consoleconf.mode)
posix.chown('%{_sysconfdir}/%{pkgname}/admin-serv/console.conf', %{pkgname}admin_consoleconf.uid, %{pkgname}admin_consoleconf.gid)
end
%preun
if [ $1 = 0 ]; then
@ -150,7 +121,10 @@ fi
%{_mandir}/man8/*
%changelog
* Wed Aug 12 2009 Rich Megginson <rmeggins@redhat.com> - 1.1.8-4
* Tue Aug 25 2009 Rich Megginson <rmeggins@redhat.com> - 1.1.8-6
- rewrite perm/owner preservation code to use lua
* Wed Aug 12 2009 Rich Megginson <rmeggins@redhat.com> - 1.1.8-5
- final rebuild for 1.1.8 release
* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.1.8-4