From 9c6088654813d05b60d9b40f8f779ac81004bc38 Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Feb 25 2011 19:29:18 +0000 Subject: do not create /var/run/dirsrv - setup will create it instead do not create /var/run/dirsrv - setup will create it instead remove the fedora-ds initscript upgrade stuff - we do not support that anymore convert the remaining lua stuff to plain old shell script Reviewed by: nkinder, nhosoi (Thanks!) (cherry picked from commit 31909e6aa2f3550fd87fb316c95bb43752035b49) (cherry picked from commit 36b41d533e48a56782567185f71b30f201439124) --- diff --git a/389-ds-base.spec b/389-ds-base.spec index d1f3a68..d9cb224 100644 --- a/389-ds-base.spec +++ b/389-ds-base.spec @@ -18,7 +18,7 @@ Summary: 389 Directory Server (base) Name: 389-ds-base Version: 1.2.8 -Release: %{?relprefix}3%{?prerel}%{?dist} +Release: %{?relprefix}4%{?prerel}%{?dist} License: GPLv2 with exceptions URL: http://port389.org/ Group: System Environment/Daemons @@ -199,53 +199,10 @@ cd - %clean rm -rf $RPM_BUILD_ROOT -%pre -p --- see if fedora-ds-base exists - if so, save the run level configuration --- and set a flag that tells us to restore that config in %posttrans --- and restart the server --- we can get rid of this code once Fedora 11 becomes obsolete -rc = os.execute('rpm --quiet -q fedora-ds-base') -if rc == 0 then - %{pkgname}_exists = true - %{pkgname}_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}") 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 -os.execute('/sbin/chkconfig --add %{pkgname}') -os.execute('/sbin/ldconfig') -os.execute('/sbin/chkconfig --add %{pkgname}-snmp') --- this has been problematic - if this directory --- does not exist, the server will silently fail to --- start - however, if the user has already created --- it, we don't want to overwrite the permissions --- on it - so we can't list it explicitly in the --- files section - we list it as a ghost so that --- it will be removed when the rpm is removed -if not posix.access("%{_localstatedir}/run/%{pkgname}") then - posix.mkdir("%{_localstatedir}/run/%{pkgname}") -end --- since posttrans is not passed the upgrade status, we get --- it here -if (arg[2] > 1) or %{pkgname}_exists then --- print("in %{pkgname} post - upgrading") - %{pkgname}_upgrading = true -else --- print("in %{pkgname} post - installing") - %{pkgname}_upgrading = false -end +%post +/sbin/chkconfig --add %{pkgname} +/sbin/ldconfig +/sbin/chkconfig --add %{pkgname}-snmp -- load the selinux policy module variants = "%{selinux_variants}" for selinuxvariant in string.gfind(variants, "%a+") do @@ -254,7 +211,6 @@ end -- label the files installed by this package os.execute('fixfiles -R %{name} restore > /dev/null 2>&1') - %preun if [ $1 = 0 ]; then # Final removal /sbin/service %{pkgname} stop >/dev/null 2>&1 || : @@ -275,57 +231,49 @@ do semodule -s ${selinuxvariant} -i %{_datadir}/selinux/${selinuxvariant}/%{pkgname}.pp 2>/dev/null || : done fi +if [ $1 = 0 ]; then # Final removal + rm -rf /var/run/%{pkgname} +fi -%posttrans -p --- 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}_savelinks then - for fullpath,link in pairs(%{pkgname}_savelinks) do - posix.symlink(link,fullpath) --- print("posttrans - restored run level "..fullpath.." to "..link) - end -end -if %{pkgname}_upgrading then - instbase = "%{_sysconfdir}/%{pkgname}" --- print("posttrans - upgrading - looking for instances in "..instbase) --- find all instances - instances = {} -- instances that require a restart after upgrade - for dir in posix.files(instbase) do --- print("dir="..dir) - if string.find(dir,"^slapd-") and not string.find(dir,"\.removed$") then - inst = string.gsub(dir,"^slapd[-]", "") --- print("found instance "..inst.." getting status") - rc = os.execute('/sbin/service %{pkgname} status '..inst..' >/dev/null 2>&1') --- if instance is running, we must restart it after upgrade - if rc == 0 then - instances[inst] = inst --- print("instance "..inst.." is running") --- else --- print("instance "..inst.." is shutdown") - end - end - end --- shutdown all instances --- print("shutting down all instances . . .") - os.execute('/sbin/service %{pkgname} stop > /dev/null 2>&1') --- do the upgrade --- print("upgrading instances . . .") - os.execute('%{_sbindir}/setup-ds.pl -l /dev/null -u -s General.UpdateMode=offline > /dev/null 2>&1') --- restart instances that require it - for inst,dummy in pairs(instances) do --- print("restarting instance "..inst) - os.execute('/sbin/service %{pkgname} start '..inst..' >/dev/null 2>&1') - end --- restart the snmp subagent if needed - os.execute('/sbin/service %{pkgname}-snmp condrestart > /dev/null 2>&1') -end --- if we upgraded from fedora to 389, the upgrade will shutdown --- all old running instances, so we have to start them here -if %{pkgname}_exists then --- print("restarting all instances due to package rename") - os.execute('/sbin/service %{pkgname} start >/dev/null 2>&1') -end - +%posttrans +instbase="%{_sysconfdir}/%{pkgname}" +# echo posttrans - upgrading - looking for instances in $instbase +# find all instances +instances="" # instances that require a restart after upgrade +ninst=0 # number of instances found in total +for dir in $instbase/slapd-* ; do +# echo dir = $dir + if [ ! -d "$dir" ] ; then continue ; fi + case "$dir" in *.removed) continue ;; esac + basename=`basename $dir` + inst=`echo $basename | sed -e 's/slapd-//g'` +# echo found instance $inst - getting status + if /sbin/service %{pkgname} status $inst >/dev/null 2>&1 ; then +# echo instance $inst is running + instances="$instances $inst" + else +# echo instance $inst is not running + : + fi + ninst=`expr $ninst + 1` +done +if [ $ninst -eq 0 ] ; then + exit 0 # have no instances to upgrade - just skip the rest +fi +# shutdown all instances +# echo shutting down all instances . . . +/sbin/service %{pkgname} stop > /dev/null 2>&1 +# do the upgrade +# echo upgrading instances . . . +%{_sbindir}/setup-ds.pl -l /dev/null -u -s General.UpdateMode=offline > /dev/null 2>&1 +# restart instances that require it +for inst in $instances ; do +# echo restarting instance $inst + /sbin/service %{pkgname} start $inst >/dev/null 2>&1 +done +# restart the snmp subagent if needed +/sbin/service %{pkgname}-snmp condrestart > /dev/null 2>&1 +exit 0 %files %defattr(-,root,root,-) @@ -368,6 +316,11 @@ end %{_datadir}/%{pkgname}-selinux %changelog +* Thu Feb 24 2011 Rich Megginson - 1.2.8-0.4.a3 +- do not create /var/run/dirsrv - setup will create it instead +- remove the fedora-ds initscript upgrade stuff - we do not support that anymore +- convert the remaining lua stuff to plain old shell script + * Wed Feb 9 2011 Rich Megginson - 1.2.8-0.3.a3 - 1.2.8.a3 release - git tag 389-ds-base-1.2.8.a3 - Bug 675320 - empty modify operation with repl on or lastmod off will crash server