commit:     d18f8f70b9d8d712a7a71b78091b407a9dd5bb92
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Mon Feb  7 02:20:12 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Feb  7 02:21:17 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d18f8f70

sys-apps/man-db: fix use of REPLACING_VERSIONS

Closes: https://bugs.gentoo.org/589514
Signed-off-by: Sam James <sam <AT> gentoo.org>

 sys-apps/man-db/man-db-2.10.0.ebuild | 19 ++++++++++++++-----
 sys-apps/man-db/man-db-9999.ebuild   | 19 ++++++++++++++-----
 2 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/sys-apps/man-db/man-db-2.10.0.ebuild 
b/sys-apps/man-db/man-db-2.10.0.ebuild
index 6948c20167a5..f49d58338bd1 100644
--- a/sys-apps/man-db/man-db-2.10.0.ebuild
+++ b/sys-apps/man-db/man-db-2.10.0.ebuild
@@ -163,8 +163,8 @@ pkg_preinst() {
        # see bug  #602588 comment 18
        local _replacing_version=
        local _setgid_vuln=0
-       for _replacing_version in ${REPLACING_VERSIONS}; do
-               if ver_test '2.7.6.1-r2' -le "${_replacing_version}"; then
+       for _replacing_version in ${REPLACING_VERSIONS} ; do
+               if ver_test '2.7.6.1-r2' -le "${_replacing_version}" ; then
                        debug-print "Skipping security bug #602588 ... existing 
installation (${_replacing_version}) should not be affected!"
                else
                        _setgid_vuln=1
@@ -189,8 +189,17 @@ pkg_preinst() {
 pkg_postinst() {
        tmpfiles_process man-db.conf
 
-       if [[ $(ver_cut 2 ${REPLACING_VERSIONS}) -lt 7 ]] ; then
-               einfo "Rebuilding man-db from scratch with new database format!"
-               su man -s /bin/sh -c 'mandb --quiet --create' 2>/dev/null
+       if [[ -n "${REPLACING_VERSIONS}" ]] ; then
+               local _replacing_version=
+
+               for _replacing_version in ${REPLACING_VERSIONS} ; do
+                       if [[ $(ver_cut 2 ${_replacing_version}) -lt 7 ]] ; then
+                               einfo "Rebuilding man-db from scratch with new 
database format!"
+                               su man -s /bin/sh -c 'mandb --quiet --create' 
2>/dev/null
+
+                               # No need to run it again if we hit one
+                               break
+                       fi
+               done
        fi
 }

diff --git a/sys-apps/man-db/man-db-9999.ebuild 
b/sys-apps/man-db/man-db-9999.ebuild
index c0406d043a09..0c5780d1e7bf 100644
--- a/sys-apps/man-db/man-db-9999.ebuild
+++ b/sys-apps/man-db/man-db-9999.ebuild
@@ -161,8 +161,8 @@ pkg_preinst() {
        # see bug  #602588 comment 18
        local _replacing_version=
        local _setgid_vuln=0
-       for _replacing_version in ${REPLACING_VERSIONS}; do
-               if ver_test '2.7.6.1-r2' -le "${_replacing_version}"; then
+       for _replacing_version in ${REPLACING_VERSIONS} ; do
+               if ver_test '2.7.6.1-r2' -le "${_replacing_version}" ; then
                        debug-print "Skipping security bug #602588 ... existing 
installation (${_replacing_version}) should not be affected!"
                else
                        _setgid_vuln=1
@@ -187,8 +187,17 @@ pkg_preinst() {
 pkg_postinst() {
        tmpfiles_process man-db.conf
 
-       if [[ $(ver_cut 2 ${REPLACING_VERSIONS}) -lt 7 ]] ; then
-               einfo "Rebuilding man-db from scratch with new database format!"
-               su man -s /bin/sh -c 'mandb --quiet --create' 2>/dev/null
+       if [[ -n "${REPLACING_VERSIONS}" ]] ; then
+               local _replacing_version=
+
+               for _replacing_version in ${REPLACING_VERSIONS} ; do
+                       if [[ $(ver_cut 2 ${_replacing_version}) -lt 7 ]] ; then
+                               einfo "Rebuilding man-db from scratch with new 
database format!"
+                               su man -s /bin/sh -c 'mandb --quiet --create' 
2>/dev/null
+
+                               # No need to run it again if we hit one
+                               break
+                       fi
+               done
        fi
 }

Reply via email to