[net-nds/389-ds-base] bump

This commit is contained in:
2023-12-24 16:04:31 +01:00
parent 5259c2f9d1
commit 4410ffc5ad
9 changed files with 781 additions and 0 deletions

View File

@@ -0,0 +1,167 @@
https://bugs.gentoo.org/899702
https://github.com/389ds/389-ds-base/commit/c0e2f68423ddde9bb91250d3f96dfc8617889514
From c0e2f68423ddde9bb91250d3f96dfc8617889514 Mon Sep 17 00:00:00 2001
From: Viktor Ashirov <vashirov@redhat.com>
Date: Mon, 13 Feb 2023 18:39:20 +0100
Subject: [PATCH] Issue 5642 - Build fails against setuptools 67.0.0
Bug Description:
`setuptools` 67.0.0 vendors `packaging` 23.0 which dropped `LegacyVersion`.
Fix Description:
Replace `LegacyVersion` with `DSVersion` to compare version strings that are
not compatible with PEP 440 and PEP 508.
Reviewed by: @mreynolds389, @progier389
Fixes: https://github.com/389ds/389-ds-base/issues/5642
--- a/src/lib389/lib389/nss_ssl.py
+++ b/src/lib389/lib389/nss_ssl.py
@@ -23,16 +23,9 @@
from lib389.passwd import password_generate
from lib389._mapped_object_lint import DSLint
from lib389.lint import DSCERTLE0001, DSCERTLE0002
-from lib389.utils import ensure_str, format_cmd_list
+from lib389.utils import ensure_str, format_cmd_list, DSVersion
import uuid
-# Setuptools ships with 'packaging' module, let's use it from there
-try:
- from pkg_resources.extern.packaging.version import LegacyVersion
-# Fallback to a normal 'packaging' module in case 'setuptools' is stripped
-except:
- from packaging.version import LegacyVersion
-
KEYBITS = 4096
CA_NAME = 'Self-Signed-CA'
CERT_NAME = 'Server-Cert'
@@ -249,7 +242,7 @@ def openssl_rehash(self, certdir):
openssl_version = check_output(['/usr/bin/openssl', 'version']).decode('utf-8').strip()
except subprocess.CalledProcessError as e:
raise ValueError(e.output.decode('utf-8').rstrip())
- rehash_available = LegacyVersion(openssl_version.split(' ')[1]) >= LegacyVersion('1.1.0')
+ rehash_available = DSVersion(openssl_version.split(' ')[1]) >= DSVersion('1.1.0')
if rehash_available:
cmd = ['/usr/bin/openssl', 'rehash', certdir]
--- /dev/null
+++ b/src/lib389/lib389/tests/dsversion_test.py
@@ -0,0 +1,12 @@
+from lib389.utils import DSVersion
+import pytest
+
+versions = [('1.3.10.1', '1.3.2.1'),
+ ('2.3.2', '1.4.4.4'),
+ ('2.3.2.202302121950git1b4f5a5bf', '2.3.2'),
+ ('1.1.0a', '1.1.0')]
+
+@pytest.mark.parametrize("x,y", versions)
+def test_dsversion(x, y):
+ assert DSVersion(x) > DSVersion(y)
+
--- a/src/lib389/lib389/utils.py
+++ b/src/lib389/lib389/utils.py
@@ -42,12 +42,6 @@ def wait(self):
import subprocess
import math
import errno
-# Setuptools ships with 'packaging' module, let's use it from there
-try:
- from pkg_resources.extern.packaging.version import LegacyVersion
-# Fallback to a normal 'packaging' module in case 'setuptools' is stripped
-except:
- from packaging.version import LegacyVersion
from socket import getfqdn
from ldapurl import LDAPUrl
from contextlib import closing
@@ -1218,6 +1212,76 @@ def generate_ds_params(inst_num, role=ReplicaRole.STANDALONE):
return instance_data
+class DSVersion():
+ def __init__(self, version):
+ self._version = str(version)
+ self._key = _cmpkey(self._version)
+
+ def __str__(self):
+ return self._version
+
+ def __repr__(self):
+ return f"<DSVersion('{self}')>"
+
+ def __hash__(self):
+ return hash(self._key)
+
+ def __lt__(self, other):
+ if not isinstance(other, DSVersion):
+ return NotImplemented
+
+ return self._key < other._key
+
+ def __le__(self, other):
+ if not isinstance(other, DSVersion):
+ return NotImplemented
+
+ return self._key <= other._key
+
+ def __eq__(self, other):
+ if not isinstance(other, DSVersion):
+ return NotImplemented
+
+ return self._key == other._key
+
+ def __ge__(self, other):
+ if not isinstance(other, DSVersion):
+ return NotImplemented
+
+ return self._key >= other._key
+
+ def __gt__(self, other):
+ if not isinstance(other, DSVersion):
+ return NotImplemented
+
+ return self._key > other._key
+
+ def __ne__(self, other):
+ if not isinstance(other, DSVersion):
+ return NotImplemented
+
+ return self._key != other._key
+
+
+def _parse_version_parts(s):
+ for part in re.compile(r"(\d+ | [a-z]+ | \. | -)", re.VERBOSE).split(s):
+
+ if not part or part == ".":
+ continue
+
+ if part[:1] in "0123456789":
+ # pad for numeric comparison
+ yield part.zfill(8)
+ else:
+ yield "*" + part
+
+def _cmpkey(version):
+ parts = []
+ for part in _parse_version_parts(version.lower()):
+ parts.append(part)
+
+ return tuple(parts)
+
def get_ds_version(paths=None):
"""
@@ -1245,9 +1309,9 @@ def ds_is_related(relation, *ver, instance=None):
if len(ver) > 1:
for cmp_ver in ver:
if cmp_ver.startswith(ds_ver[:3]):
- return ops[relation](LegacyVersion(ds_ver),LegacyVersion(cmp_ver))
+ return ops[relation](DSVersion(ds_ver), DSVersion(cmp_ver))
else:
- return ops[relation](LegacyVersion(ds_ver), LegacyVersion(ver[0]))
+ return ops[relation](DSVersion(ds_ver), DSVersion(ver[0]))
def ds_is_older(*ver, instance=None):

View File

@@ -0,0 +1,17 @@
diff --git a/m4/db.m4 b/m4/db.m4
index c916c2b83..a9dd5ef2b 100644
--- a/m4/db.m4
+++ b/m4/db.m4
@@ -96,9 +96,9 @@ if test -z "$db_inc"; then
fi
dnl figure out which version of db we're using from the header file
-db_ver_maj=`grep DB_VERSION_MAJOR $db_incdir/db.h | awk '{print $3}'`
-db_ver_min=`grep DB_VERSION_MINOR $db_incdir/db.h | awk '{print $3}'`
-db_ver_pat=`grep DB_VERSION_PATCH $db_incdir/db.h | awk '{print $3}'`
+db_ver_maj=`gcc -E -fdirectives-only $db_incdir/db.h | grep DB_VERSION_MAJOR | awk '{print $3}'`
+db_ver_min=`gcc -E -fdirectives-only $db_incdir/db.h | grep DB_VERSION_MINOR | awk '{print $3}'`
+db_ver_pat=`gcc -E -fdirectives-only $db_incdir/db.h | grep DB_VERSION_PATCH | awk '{print $3}'`
dnl Ensure that we have libdb at least 4.7, older versions aren't supported
if test ${db_ver_maj} -lt 4; then

View File

@@ -0,0 +1,3 @@
d /var/log/dirsrv 0700 dirsrv dirsrv -
d /var/lib/dirsrv 0700 dirsrv dirsrv -
d /run/lock/dirsrv 0770 dirsrv dirsrv -

View File

@@ -0,0 +1,43 @@
#!/sbin/openrc-run
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
PIDFILE="/run/ldap-agent.pid"
CONFIGFILE="/etc/dirsrv/config/ldap-agent.conf"
# instance support in progress
depend() {
need net
use logger snmpd
}
start() {
ebegin "Starting 389 Directory Server ldap-snmp agent"
start-stop-daemon --start --quiet -b \
--pidfile ${PIDFILE} --exec /usr/sbin/ldap-agent -- ${CONFIGFILE}
eend ${?}
if [ "${?}" != "0" ]; then
local entries=/etc/dirsrv/slapd-*
if [ -n "${entries}" ]; then
ewarn "Please make sure that ${CONFIGFILE} contains at least"
ewarn "one of the following entries:"
for entry in ${entries}; do
entry=$(basename ${entry})
ewarn "server ${entry}"
done
fi
fi
}
stop() {
ebegin "Stopping 389 Directory Server ldap-snmp agent"
start-stop-daemon --stop --quiet --pidfile ${PIDFILE}
eend ${?}
}
restart() {
svc_stop
sleep 2
svc_start
}

View File

@@ -0,0 +1,89 @@
#!/sbin/openrc-run
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
DIRSRV_EXEC="/usr/sbin/ns-slapd"
PID_DIRECTORY="/run/dirsrv"
LOCK_DIRECTORY="/var/lock/dirsrv"
DIRSRV_CONF_DIR="/etc/dirsrv"
DS_INSTANCES=${DIRSRV_CONF_DIR}/slapd-*
depend() {
need net logger
use dns
provide dirsrv ldap
}
checkconfig() {
if [ -z "${DS_INSTANCES}" ]; then
eerror "389 Directory Server has not been configured."
eend 1
return 1
fi
}
start() {
checkconfig || return 1
for instance in ${DS_INSTANCES}; do
instance=$(basename ${instance})
# skip .removed instances, bug #338133
if [ "${instance%%.removed}" != "${instance}" ]; then
continue
fi
# Create the required directories in case they got nuked
mkdir -p ${PID_DIRECTORY}
mkdir -p ${LOCK_DIRECTORY}/${instance}
# This will probably break one day, we should be pulling out the suitespotuser from dse.ldif
chown dirsrv: ${PID_DIRECTORY}
chown dirsrv: ${LOCK_DIRECTORY}/${instance}
ebegin "Starting 389 Directory Server: instance ${instance}"
start-stop-daemon --start --quiet -m \
--pidfile ${PID_DIRECTORY}/${instance}.startpid \
--exec ${DIRSRV_EXEC} -- -D ${DIRSRV_CONF_DIR}/${instance} \
-i ${PID_DIRECTORY}/${instance}.pid \
-w ${PID_DIRECTORY}/${instance}.startpid
sts=${?}
eend ${sts}
if [ "${sts}" != "0" ]; then
return 1
fi
done
}
stop() {
checkconfig || return 1
for instance in ${DS_INSTANCES}; do
instance=$(basename ${instance})
if [ "${instance%%.removed}" != "${instance}" ]; then
continue
fi
ebegin "Stopping 389 Directory Server: instance ${instance}"
start-stop-daemon --stop --quiet \
--pidfile ${PID_DIRECTORY}/${instance}.pid \
--exec ${DIRSRV_EXEC}
eend ${?}
done
}
status() {
for instance in ${DS_INSTANCES}; do
instance=$(basename ${instance})
if [ "${instance%%.removed}" != "${instance}" ]; then
continue
fi
if [ -e ${PID_DIRECTORY}/${instance}.pid ]; then
pid=$(cat ${PID_DIRECTORY}/${instance}.pid)
if [ $(echo "$pid" | grep -c $pid) -ge 1 ]; then
einfo "389 Directory Server: instance ${instance} (pid $pid) running."
else
ewarn "389 Directory Server: instance ${instance} (pid $pid) NOT running."
fi
else
eerror "389 Directory Server: instance ${instance} is NOT running."
fi
done
}

View File

@@ -0,0 +1,10 @@
If you are planning to use 389-ds-snmp (ldap-agent),
make sure to properly configure: /etc/dirsrv/config/ldap-agent.conf
adding proper 'server' entries, and adding the lines below to
=> /etc/snmp/snmpd.conf
master agent
agentXSocket /var/agentx/master"
To start 389 Directory Server (LDAP service) at boot:"
rc-update add 389-ds default"