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:
parent
453defedc5
commit
e89a822f7a
1 changed files with 56 additions and 48 deletions
104
389-admin.spec
104
389-admin.spec
|
|
@ -3,7 +3,7 @@
|
|||
Summary: 389 Administration Server (admin)
|
||||
Name: 389-admin
|
||||
Version: 1.1.8
|
||||
Release: 3%{?dist}
|
||||
Release: 4%{?dist}
|
||||
License: GPLv2 and ASL 2.0
|
||||
URL: http://port389.org/
|
||||
Group: System Environment/Daemons
|
||||
|
|
@ -79,54 +79,44 @@ 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')
|
||||
-- save the run level configuration, if any
|
||||
rc = os.execute('rpm --quiet -q fedora-ds-admin')
|
||||
if rc == 0 then
|
||||
%{pkgname}admin_exists = true
|
||||
%{pkgname}admin_savelinks = {}
|
||||
for dir in posix.files("%{_sysconfdir}/rc.d") do
|
||||
if string.find(dir, "rc%d.d") then
|
||||
-- print("looking in %{_sysconfdir}/rc.d/"..dir)
|
||||
for link in posix.files("%{_sysconfdir}/rc.d/"..dir) do
|
||||
if string.find(link, "[SK]%d%d%{pkgname}-admin") then
|
||||
fullname = "%{_sysconfdir}/rc.d/"..dir.."/"..link
|
||||
linked = posix.readlink(fullname)
|
||||
-- print(fullname.." is linked to "..linked)
|
||||
%{pkgname}_savelinks[fullname] = linked
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
%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
|
||||
|
|
@ -136,6 +126,19 @@ fi
|
|||
|
||||
%postun -p /sbin/ldconfig
|
||||
|
||||
%posttrans -p <lua>
|
||||
-- if we saved the run level configuration in %pre, restore it now
|
||||
-- we can get rid of this code once Fedora 11 becomes obsolete
|
||||
if %{pkgname}admin_savelinks then
|
||||
for fullpath,link in pairs(%{pkgname}admin_savelinks) do
|
||||
posix.symlink(link,fullpath)
|
||||
-- print("posttrans - restored run level "..fullpath.." to "..link)
|
||||
end
|
||||
end
|
||||
if %{pkgname}admin_exists then
|
||||
os.execute('/sbin/service %{pkgname}-admin start >/dev/null 2>&1')
|
||||
end
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
%doc LICENSE
|
||||
|
|
@ -150,6 +153,11 @@ fi
|
|||
%{_mandir}/man8/*
|
||||
|
||||
%changelog
|
||||
* Tue Aug 25 2009 Rich Megginson <rmeggins@redhat.com> - 1.1.8-4
|
||||
- resolves 518418 - Package rename shuts down server, results in unconfigured package
|
||||
- rewrite perm/owner preservation code to use lua
|
||||
- add lua code to save run level configuration
|
||||
|
||||
* Wed Aug 12 2009 Rich Megginson <rmeggins@redhat.com> - 1.1.8-3
|
||||
- final rebuild for 1.1.8 release
|
||||
|
||||
|
|
|
|||
Reference in a new issue