From a19a33365e44683f37b95862b3c95222909ddf5f Mon Sep 17 00:00:00 2001 From: William Brown Date: Wed, 21 Feb 2018 14:43:57 +1000 Subject: [PATCH] Ticket 49571 - perl subpackage and python installer by default Bug Description: With 1.4.0 fast coming, we need to split the legacy perl out to a subpackage, and coerce our tests to python installer by default. Fix Description: Add a legacy tools subpackage, and make lib389 detect python3 and trigger the py installer. https://pagure.io/389-ds-base/issue/49571 Author: wibrown Review by: ??? --- rpm/389-ds-base.spec.in | 246 +++++++++++++++++++++++++++++------------- src/lib389/lib389/__init__.py | 2 +- 2 files changed, 173 insertions(+), 75 deletions(-) diff --git a/rpm/389-ds-base.spec.in b/rpm/389-ds-base.spec.in index 7a93ee35b..f987cc45e 100644 --- a/rpm/389-ds-base.spec.in +++ b/rpm/389-ds-base.spec.in @@ -128,8 +128,6 @@ Requires: policycoreutils-python Requires: libsemanage-python # the following are needed for some of our scripts Requires: openldap-clients -# use_openldap assumes perl-Mozilla-LDAP is built with openldap support -Requires: perl-Mozilla-LDAP # this is needed to setup SSL if you are not using the # administration server package Requires: nss-tools @@ -147,19 +145,8 @@ Requires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $ver # Needed by logconv.pl Requires: perl-DB_File Requires: perl-Archive-Tar -# for the init script -Requires(post): systemd-units -Requires(preun): systemd-units -Requires(postun): systemd-units -# for setup-ds.pl -Requires: bind-utils -# for setup-ds.pl to support ipv6 -%if %{use_Socket6} -Requires: perl-Socket6 -%else -Requires: perl-Socket -%endif -Requires: perl-NetAddr-IP +# Picks up our systemd deps. +%{?systemd_requires} Source0: http://www.port389.org/sources/%{name}-%{version}%{?prerel}.tar.bz2 # 389-ds-git.sh should be used to generate the source tarball from git @@ -202,6 +189,32 @@ are used by the main package and the -devel package. This allows the -devel package to be installed with just the -libs package and without the main package. +%package legacy-tools +Summary: Legacy utilities for 389 Directory Server (%{variant}) +Group: System Environment/Daemons +Requires: %{name}= %{version}-%{release} +%if %{use_perl} +# for setup-ds.pl to support ipv6 +%if %{use_Socket6} +Requires: perl-Socket6 +%else +Requires: perl-Socket +%endif +Requires: perl-NetAddr-IP +# use_openldap assumes perl-Mozilla-LDAP is built with openldap support +Requires: perl-Mozilla-LDAP +# for setup-ds.pl +Requires: bind-utils +%endif +# End use perl + +%description legacy-tools +Legacy (and deprecated) utilities for 389 Directory Server. This includes +the old account management and task scripts. These are deprecated in favour of +the dscreate, dsctl, dsconf and dsidm tools. + + + %package devel Summary: Development libraries for 389 Directory Server (%{variant}) Group: Development/Libraries @@ -403,6 +416,29 @@ fi # Reload our sysctl before we restart (if we can) sysctl --system &> $output; true +%preun +if [ $1 -eq 0 ]; then # Final removal + # remove instance specific service files/links + rm -rf %{_sysconfdir}/systemd/system/%{groupname}.wants/* > /dev/null 2>&1 || : +fi + +%postun +/sbin/ldconfig +if [ $1 = 0 ]; then # Final removal + rm -rf /var/run/%{pkgname} +fi + +%post snmp +%systemd_post %{pkgname}-snmp.service + +%preun snmp +%systemd_preun %{pkgname}-snmp.service %{groupname} + +%postun snmp +%systemd_postun_with_restart %{pkgname}-snmp.service + +%post legacy-tools + %if %{use_perl} # START UPGRADE SCRIPT echo looking for instances in %{_sysconfdir}/%{pkgname} > $output 2>&1 || : @@ -414,6 +450,15 @@ for dir in $instbase/slapd-* ; do basename=`basename $dir` inst="%{pkgname}@`echo $basename | sed -e 's/slapd-//g'`" echo found instance $inst - getting status >> $output 2>&1 || : + if /bin/systemctl -q is-active $inst ; then + echo instance $inst is running >> $output 2>&1 || : + instances="$instances $inst" + else + echo instance $inst is not running >> $output 2>&1 || : + case "$dir" in *.removed) continue ;; esac + basename=`basename $dir` + inst="%{pkgname}@`echo $basename | sed -e 's/slapd-//g'`" + echo found instance $inst - getting status >> $output 2>&1 || : if /bin/systemctl -q is-active $inst ; then echo instance $inst is running >> $output 2>&1 || : instances="$instances $inst" @@ -448,31 +493,10 @@ for inst in $instances ; do echo restarting instance $inst >> $output 2>&1 || : /bin/systemctl start $inst >> $output 2>&1 || : done -#END UPGRADE +#END UPGRADE %endif - exit 0 -%preun -if [ $1 -eq 0 ]; then # Final removal - # remove instance specific service files/links - rm -rf %{_sysconfdir}/systemd/system/%{groupname}.wants/* > /dev/null 2>&1 || : -fi - -%postun -/sbin/ldconfig -if [ $1 = 0 ]; then # Final removal - rm -rf /var/run/%{pkgname} -fi - -%post snmp -%systemd_post %{pkgname}-snmp.service - -%preun snmp -%systemd_preun %{pkgname}-snmp.service %{groupname} - -%postun snmp -%systemd_postun_with_restart %{pkgname}-snmp.service %files %defattr(-,root,root,-) @@ -490,61 +514,56 @@ fi %{_datadir}/%{pkgname} %{_datadir}/gdb/auto-load/* %{_unitdir} -%{_bindir}/* +%{_bindir}/cl-dump +%{_mandir}/man1/cl-dump.1.gz +%{_bindir}/dbscan +%{_mandir}/man1/dbscan.1.gz +%{_bindir}/ds-replcheck +%{_mandir}/man1/ds-replcheck.1.gz +%{_bindir}/ds-logpipe.py +%{_mandir}/man1/ds-logpipe.py.1.gz +%{_bindir}/ldclt +%{_mandir}/man1/ldclt.1.gz +%{_sbindir}/ldif2ldap +%{_mandir}/man8/ldif2ldap.8.gz +%{_bindir}/logconv.pl +%{_mandir}/man1/logconv.pl.1.gz +%{_bindir}/pwdhash +%{_mandir}/man1/pwdhash.1.gz +%{_bindir}/readnsstate +%{_mandir}/man1/readnsstate.1.gz +%{_bindir}/repl-monitor +%{_mandir}/man1/repl-monitor.1.gz # We have to seperate this from being a glob to ensure the caps are applied. %caps(CAP_NET_BIND_SERVICE=pe) %{_sbindir}/ns-slapd +%{_mandir}/man8/ns-slapd.8.gz %if 0%{?rhel} >= 8 || 0%{?fedora} %{_sbindir}/dsconf %{_sbindir}/dscreate %{_sbindir}/dsctl %{_sbindir}/dsidm %{_sbindir}/ds-cockpit-setup +%{_mandir}/man1/ds-cockpit-setup.1.gz %endif %{_sbindir}/ds_selinux_enabled %{_sbindir}/ds_selinux_port_query %{_sbindir}/ds_systemd_ask_password_acl -%if %{use_perl} -%{_sbindir}/monitor %{_sbindir}/bak2db -%{_sbindir}/bak2db.pl -%{_sbindir}/cleanallruv.pl +%{_mandir}/man8/bak2db.8.gz %{_sbindir}/db2bak -%{_sbindir}/db2bak.pl +%{_mandir}/man8/db2bak.8.gz %{_sbindir}/db2index -%{_sbindir}/db2index.pl +%{_mandir}/man8/db2index.8.gz %{_sbindir}/db2ldif -%{_sbindir}/db2ldif.pl -%{_sbindir}/dbmon.sh +%{_mandir}/man8/db2ldif.8.gz %{_sbindir}/dbverify -%{_sbindir}/dn2rdn -%{_sbindir}/fixup-linkedattrs.pl -%{_sbindir}/fixup-memberof.pl +%{_mandir}/man8/dbverify.8.gz %{_sbindir}/ldif2db -%{_sbindir}/ldif2db.pl -%{_sbindir}/ldif2ldap -%{_sbindir}/migrate-ds.pl -%{_sbindir}/ns-accountstatus.pl -%{_sbindir}/ns-activate.pl -%{_sbindir}/ns-inactivate.pl -%{_sbindir}/ns-newpwpolicy.pl -%{_sbindir}/remove-ds.pl -%{_sbindir}/restart-dirsrv -%{_sbindir}/restoreconfig -%{_sbindir}/saveconfig -%{_sbindir}/schema-reload.pl -%{_sbindir}/setup-ds.pl -%{_sbindir}/start-dirsrv -%{_sbindir}/status-dirsrv -%{_sbindir}/stop-dirsrv -%{_sbindir}/suffix2instance -%{_sbindir}/syntax-validate.pl +%{_mandir}/man8/ldif2db.8.gz %{_sbindir}/upgradedb -%{_sbindir}/upgradednformat -%{_sbindir}/usn-tombstone-cleanup.pl -%{_sbindir}/verify-db.pl +%{_mandir}/man8/upgradedb.8.gz %{_sbindir}/vlvindex -%{_libdir}/%{pkgname}/perl -%endif +%{_mandir}/man8/vlvindex.8.gz %{_libdir}/%{pkgname}/python %dir %{_libdir}/%{pkgname}/plugins %{_libdir}/%{pkgname}/plugins/*.so @@ -554,8 +573,6 @@ fi %dir %{_localstatedir}/lib/%{pkgname} %dir %{_localstatedir}/log/%{pkgname} %ghost %dir %{_localstatedir}/lock/%{pkgname} -%{_mandir}/man1/* -%{_mandir}/man8/* %exclude %{_sbindir}/ldap-agent* %exclude %{_mandir}/man1/ldap-agent.1.gz %exclude %{_unitdir}/%{pkgname}-snmp.service @@ -585,6 +602,87 @@ fi %{_libdir}/%{pkgname}/librsds.so %endif +%files legacy-tools +%defattr(-,root,root,-) +%doc LICENSE LICENSE.GPLv3+ LICENSE.openssl README.devel +%{_bindir}/infadd +%{_mandir}/man1/infadd.1.gz +%{_bindir}/ldif +%{_mandir}/man1/ldif.1.gz +%{_bindir}/migratecred +%{_mandir}/man1/migratecred.1.gz +%{_bindir}/mmldif +%{_mandir}/man1/mmldif.1.gz +%{_bindir}/rsearch +%{_mandir}/man1/rsearch.1.gz +%{_sbindir}/monitor +%{_mandir}/man8/monitor.8.gz +%{_sbindir}/dbmon.sh +%{_mandir}/man8/dbmon.sh.8.gz +%{_sbindir}/dn2rdn +%{_mandir}/man8/dn2rdn.8.gz +%{_sbindir}/restart-dirsrv +%{_mandir}/man8/restart-dirsrv.8.gz +%{_sbindir}/restoreconfig +%{_mandir}/man8/restoreconfig.8.gz +%{_sbindir}/saveconfig +%{_mandir}/man8/saveconfig.8.gz +%{_sbindir}/start-dirsrv +%{_mandir}/man8/start-dirsrv.8.gz +%{_sbindir}/status-dirsrv +%{_mandir}/man8/status-dirsrv.8.gz +%{_sbindir}/stop-dirsrv +%{_mandir}/man8/stop-dirsrv.8.gz +%{_sbindir}/suffix2instance +%{_mandir}/man8/suffix2instance.8.gz +%{_sbindir}/upgradednformat +%{_mandir}/man8/upgradednformat.8.gz +%if %{use_perl} +%{_mandir}/man1/dbgen.pl.1.gz +%{_bindir}/repl-monitor.pl +%{_bindir}/cl-dump.pl +%{_bindir}/dbgen.pl +%{_mandir}/man8/bak2db.pl.8.gz +%{_sbindir}/bak2db.pl +%{_sbindir}/cleanallruv.pl +%{_mandir}/man8/cleanallruv.pl.8.gz +%{_sbindir}/db2bak.pl +%{_mandir}/man8/db2bak.pl.8.gz +%{_sbindir}/db2index.pl +%{_mandir}/man8/db2index.pl.8.gz +%{_sbindir}/db2ldif.pl +%{_mandir}/man8/db2ldif.pl.8.gz +%{_sbindir}/fixup-linkedattrs.pl +%{_mandir}/man8/fixup-linkedattrs.pl.8.gz +%{_sbindir}/fixup-memberof.pl +%{_mandir}/man8/fixup-memberof.pl.8.gz +%{_sbindir}/ldif2db.pl +%{_mandir}/man8/ldif2db.pl.8.gz +%{_sbindir}/migrate-ds.pl +%{_mandir}/man8/migrate-ds.pl.8.gz +%{_sbindir}/ns-accountstatus.pl +%{_mandir}/man8/ns-accountstatus.pl.8.gz +%{_sbindir}/ns-activate.pl +%{_mandir}/man8/ns-activate.pl.8.gz +%{_sbindir}/ns-inactivate.pl +%{_mandir}/man8/ns-inactivate.pl.8.gz +%{_sbindir}/ns-newpwpolicy.pl +%{_mandir}/man8/ns-newpwpolicy.pl.8.gz +%{_sbindir}/remove-ds.pl +%{_mandir}/man8/remove-ds.pl.8.gz +%{_sbindir}/schema-reload.pl +%{_mandir}/man8/schema-reload.pl.8.gz +%{_sbindir}/setup-ds.pl +%{_mandir}/man8/setup-ds.pl.8.gz +%{_sbindir}/syntax-validate.pl +%{_mandir}/man8/syntax-validate.pl.8.gz +%{_sbindir}/usn-tombstone-cleanup.pl +%{_mandir}/man8/usn-tombstone-cleanup.pl.8.gz +%{_sbindir}/verify-db.pl +%{_mandir}/man8/verify-db.pl.8.gz +%{_libdir}/%{pkgname}/perl +%endif + %files snmp %defattr(-,root,root,-) %doc LICENSE LICENSE.GPLv3+ LICENSE.openssl README.devel diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py index f15e1837e..33365c201 100644 --- a/src/lib389/lib389/__init__.py +++ b/src/lib389/lib389/__init__.py @@ -952,7 +952,7 @@ class DirSrv(SimpleLDAPObject, object): raise ValueError("SER_SERVERID_PROP is missing, " + "it is required to create an instance") # Time to create the instance and retrieve the effective sroot - if (not self.ds_paths.perl_enabled or pyinstall): + if MAJOR >= 3 or (not self.ds_paths.perl_enabled or pyinstall): self._createPythonDirsrv(version) else: self._createDirsrv() -- 2.14.3