rpms/389-admin/F-10 389-admin.spec,1.4,1.5

Richard Allen Megginson rmeggins at fedoraproject.org
Tue Aug 25 20:05:59 UTC 2009


Author: rmeggins

Update of /cvs/extras/rpms/389-admin/F-10
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv19934/F-10

Modified Files:
	389-admin.spec 
Log Message:
Resolves 518418 -  Package rename shuts down server, results in unconfigured package
rewrite perm/owner preservation code to use lua
VS: ----------------------------------------------------------------------



Index: 389-admin.spec
===================================================================
RCS file: /cvs/extras/rpms/389-admin/F-10/389-admin.spec,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -p -r1.4 -r1.5
--- 389-admin.spec	12 Aug 2009 20:00:08 -0000	1.4
+++ 389-admin.spec	25 Aug 2009 20:05:58 -0000	1.5
@@ -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
@@ -77,54 +77,44 @@ rm -f $RPM_BUILD_ROOT%{_libdir}/%{pkgnam
 %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
-
-%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
+%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 -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
@@ -134,6 +124,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
@@ -148,6 +151,13 @@ fi
 %{_mandir}/man8/*
 
 %changelog
+* Tue Aug 25 2009 Rich Megginson <rmeggins at 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
+
+- rewrite perm/owner preservation code to use lua
+- add lua code to save run level configuration
+
 * Wed Aug 12 2009 Rich Megginson <rmeggins at redhat.com> - 1.1.8-3
 - final rebuild for 1.1.8 release
 




More information about the fedora-extras-commits mailing list