From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-893493-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id CFB2F13832E
	for <garchives@archives.gentoo.org>; Mon, 25 Jul 2016 16:21:41 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 361E9E0A6C;
	Mon, 25 Jul 2016 16:21:38 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id A5CA5E0A6C
	for <gentoo-commits@lists.gentoo.org>; Mon, 25 Jul 2016 16:21:37 +0000 (UTC)
Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 91A83340C74
	for <gentoo-commits@lists.gentoo.org>; Mon, 25 Jul 2016 16:21:35 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 8631D7E2
	for <gentoo-commits@lists.gentoo.org>; Mon, 25 Jul 2016 16:21:33 +0000 (UTC)
From: "Ian Stakenvicius" <axs@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Ian Stakenvicius" <axs@gentoo.org>
Message-ID: <1469463687.739172f697490fcb8eff44e3d94ff94b867cfaa2.axs@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-fs/eudev/
X-VCS-Repository: repo/gentoo
X-VCS-Files: sys-fs/eudev/eudev-1.10-r2.ebuild sys-fs/eudev/eudev-1.9-r2.ebuild sys-fs/eudev/eudev-3.1.2.ebuild sys-fs/eudev/eudev-3.1.5.ebuild sys-fs/eudev/eudev-3.2.ebuild sys-fs/eudev/eudev-4.9999.ebuild sys-fs/eudev/eudev-9999.ebuild
X-VCS-Directories: sys-fs/eudev/
X-VCS-Committer: axs
X-VCS-Committer-Name: Ian Stakenvicius
X-VCS-Revision: 739172f697490fcb8eff44e3d94ff94b867cfaa2
X-VCS-Branch: master
Date: Mon, 25 Jul 2016 16:21:33 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Archives-Salt: 3fb22e2c-6958-497a-851e-48857b1dc328
X-Archives-Hash: a47470c94ddebe2177673d89bbf0e1d4

commit:     739172f697490fcb8eff44e3d94ff94b867cfaa2
Author:     Ian Stakenvicius <axs <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 25 16:15:27 2016 +0000
Commit:     Ian Stakenvicius <axs <AT> gentoo <DOT> org>
CommitDate: Mon Jul 25 16:21:27 2016 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=739172f6

sys-fs/eudev: ensure REPLACING_VERSIONS is processed as a list

REPLACING_VERSIONS is used in eudev ebuilds during pkg_postinst to determine
when udevadm control --reload should be called:
- when it is a new installation of udev
- when it is a re-emerge of the same version (or a revision-only upgrade)

REPLACING_VERSIONS *should* only ever have zero or one values, but it is
theoretically possible for it to have more than that if, for instance, a previous
upgrade failed to complete during qmerge.  If this is the case, and only one of
the multiple versions match the version of the ebuild, then we also abort as we
don't know which one is the "good" one.

Also removed duplicate code that reloads the hwdb (looks like it was a copy-paste
from sys-fs/udev)

Bug: http://bugs.gentoo.org/589530

Package-Manager: portage-2.2.28

 sys-fs/eudev/eudev-1.10-r2.ebuild | 51 ++++++++++++++++++++-------------------
 sys-fs/eudev/eudev-1.9-r2.ebuild  | 51 ++++++++++++++++++++-------------------
 sys-fs/eudev/eudev-3.1.2.ebuild   | 51 ++++++++++++++++++++-------------------
 sys-fs/eudev/eudev-3.1.5.ebuild   | 51 ++++++++++++++++++++-------------------
 sys-fs/eudev/eudev-3.2.ebuild     | 51 ++++++++++++++++++++-------------------
 sys-fs/eudev/eudev-4.9999.ebuild  | 51 ++++++++++++++++++++-------------------
 sys-fs/eudev/eudev-9999.ebuild    | 51 ++++++++++++++++++++-------------------
 7 files changed, 182 insertions(+), 175 deletions(-)

diff --git a/sys-fs/eudev/eudev-1.10-r2.ebuild b/sys-fs/eudev/eudev-1.10-r2.ebuild
index 83d33b8..122087f 100644
--- a/sys-fs/eudev/eudev-1.10-r2.ebuild
+++ b/sys-fs/eudev/eudev-1.10-r2.ebuild
@@ -248,22 +248,41 @@ pkg_postinst() {
 		ewarn "else losetup may be confused when looking for unused devices."
 	fi
 
+	# https://cgit.freedesktop.org/systemd/systemd/commit/rules/50-udev-default.rules?id=3dff3e00e044e2d53c76fa842b9a4759d4a50e69
+	# https://bugs.gentoo.org/246847
+	# https://bugs.gentoo.org/514174
+	enewgroup input
+
+	# REPLACING_VERSIONS should only ever have zero or 1 values but in case it doesn't,
+	# process it as a list.  We only care about the zero case (new install) or the case where
+	# the same version is being re-emerged.  If there is a second version, allow it to abort.
+	local rv rvres=doitnew
+	for rv in ${REPLACING_VERSIONS} ; do
+		if [[ ${rvres} == doit* ]]; then
+			if [[ ${rv%-r*} == ${PV} ]]; then
+				rvres=doit
+			else
+				rvres=${rv}
+			fi
+		fi
+	done
+
 	if use hwdb && has_version 'sys-apps/hwids[udev]'; then
 		udevadm hwdb --update --root="${ROOT%/}"
 
 		# https://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
 		# reload database after it has be rebuilt, but only if we are not upgrading
 		# also pass if we are -9999 since who knows what hwdb related changes there might be
-		if [[ ${REPLACING_VERSIONS%-r*} == ${PV} || -z ${REPLACING_VERSIONS} ]] && \
-		[[ ${ROOT%/} == "" ]] && [[ ${PV} != "9999" ]]; then
+		if [[ ${rvres} == doit* ]] && [[ ${ROOT%/} == "" ]] && [[ ${PV} != "9999" ]]; then
 			udevadm control --reload
 		fi
 	fi
-
-	ewarn
-	ewarn "You need to restart eudev as soon as possible to make the"
-	ewarn "upgrade go into effect:"
-	ewarn "\t/etc/init.d/udev --nodeps restart"
+	if [[ ${rvres} != doitnew ]]; then
+		ewarn
+		ewarn "You need to restart eudev as soon as possible to make the"
+		ewarn "upgrade go into effect:"
+		ewarn "\t/etc/init.d/udev --nodeps restart"
+	fi
 
 	if use rule-generator && use openrc && \
 	[[ -x $(type -P rc-update) ]] && rc-update show | grep udev-postmount | grep -qsv 'boot\|default\|sysinit'; then
@@ -279,22 +298,4 @@ pkg_postinst() {
 	elog "fixing known issues visit:"
 	elog "         https://www.gentoo.org/doc/en/udev-guide.xml"
 	elog
-
-	# https://cgit.freedesktop.org/systemd/systemd/commit/rules/50-udev-default.rules?id=3dff3e00e044e2d53c76fa842b9a4759d4a50e69
-	# https://bugs.gentoo.org/246847
-	# https://bugs.gentoo.org/514174
-	enewgroup input
-
-	# Update hwdb database in case the format is changed by udev version.
-	if has_version 'sys-apps/hwids[udev]'; then
-		udevadm hwdb --update --root="${ROOT%/}"
-		# Only reload when we are not upgrading to avoid potential race w/ incompatible hwdb.bin and the running udevd
-		if [[ -z ${REPLACING_VERSIONS} ]]; then
-			# https://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
-			if [[ ${ROOT} != "" ]] && [[ ${ROOT} != "/" ]]; then
-				return 0
-			fi
-			udevadm control --reload
-		fi
-	fi
 }

diff --git a/sys-fs/eudev/eudev-1.9-r2.ebuild b/sys-fs/eudev/eudev-1.9-r2.ebuild
index 23f027b..1f77052 100644
--- a/sys-fs/eudev/eudev-1.9-r2.ebuild
+++ b/sys-fs/eudev/eudev-1.9-r2.ebuild
@@ -250,22 +250,41 @@ pkg_postinst() {
 		ewarn "else losetup may be confused when looking for unused devices."
 	fi
 
+	# https://cgit.freedesktop.org/systemd/systemd/commit/rules/50-udev-default.rules?id=3dff3e00e044e2d53c76fa842b9a4759d4a50e69
+	# https://bugs.gentoo.org/246847
+	# https://bugs.gentoo.org/514174
+	enewgroup input
+
+	# REPLACING_VERSIONS should only ever have zero or 1 values but in case it doesn't,
+	# process it as a list.  We only care about the zero case (new install) or the case where
+	# the same version is being re-emerged.  If there is a second version, allow it to abort.
+	local rv rvres=doitnew
+	for rv in ${REPLACING_VERSIONS} ; do
+		if [[ ${rvres} == doit* ]]; then
+			if [[ ${rv%-r*} == ${PV} ]]; then
+				rvres=doit
+			else
+				rvres=${rv}
+			fi
+		fi
+	done
+
 	if use hwdb && has_version 'sys-apps/hwids[udev]'; then
 		udevadm hwdb --update --root="${ROOT%/}"
 
 		# https://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
 		# reload database after it has be rebuilt, but only if we are not upgrading
 		# also pass if we are -9999 since who knows what hwdb related changes there might be
-		if [[ ${REPLACING_VERSIONS%-r*} == ${PV} || -z ${REPLACING_VERSIONS} ]] && \
-		[[ ${ROOT%/} == "" ]] && [[ ${PV} != "9999" ]]; then
+		if [[ ${rvres} == doit* ]] && [[ ${ROOT%/} == "" ]] && [[ ${PV} != "9999" ]]; then
 			udevadm control --reload
 		fi
 	fi
-
-	ewarn
-	ewarn "You need to restart eudev as soon as possible to make the"
-	ewarn "upgrade go into effect:"
-	ewarn "\t/etc/init.d/udev --nodeps restart"
+	if [[ ${rvres} != doitnew ]]; then
+		ewarn
+		ewarn "You need to restart eudev as soon as possible to make the"
+		ewarn "upgrade go into effect:"
+		ewarn "\t/etc/init.d/udev --nodeps restart"
+	fi
 
 	if use rule-generator && use openrc && \
 	[[ -x $(type -P rc-update) ]] && rc-update show | grep udev-postmount | grep -qsv 'boot\|default\|sysinit'; then
@@ -281,22 +300,4 @@ pkg_postinst() {
 	elog "fixing known issues visit:"
 	elog "         https://www.gentoo.org/doc/en/udev-guide.xml"
 	elog
-
-	# https://cgit.freedesktop.org/systemd/systemd/commit/rules/50-udev-default.rules?id=3dff3e00e044e2d53c76fa842b9a4759d4a50e69
-	# https://bugs.gentoo.org/246847
-	# https://bugs.gentoo.org/514174
-	enewgroup input
-
-	# Update hwdb database in case the format is changed by udev version.
-	if has_version 'sys-apps/hwids[udev]'; then
-		udevadm hwdb --update --root="${ROOT%/}"
-		# Only reload when we are not upgrading to avoid potential race w/ incompatible hwdb.bin and the running udevd
-		if [[ -z ${REPLACING_VERSIONS} ]]; then
-			# https://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
-			if [[ ${ROOT} != "" ]] && [[ ${ROOT} != "/" ]]; then
-				return 0
-			fi
-			udevadm control --reload
-		fi
-	fi
 }

diff --git a/sys-fs/eudev/eudev-3.1.2.ebuild b/sys-fs/eudev/eudev-3.1.2.ebuild
index e061076..f17bcba 100644
--- a/sys-fs/eudev/eudev-3.1.2.ebuild
+++ b/sys-fs/eudev/eudev-3.1.2.ebuild
@@ -230,44 +230,45 @@ pkg_postinst() {
 		ewarn "else losetup may be confused when looking for unused devices."
 	fi
 
+	# https://cgit.freedesktop.org/systemd/systemd/commit/rules/50-udev-default.rules?id=3dff3e00e044e2d53c76fa842b9a4759d4a50e69
+	# https://bugs.gentoo.org/246847
+	# https://bugs.gentoo.org/514174
+	enewgroup input
+
+	# REPLACING_VERSIONS should only ever have zero or 1 values but in case it doesn't,
+	# process it as a list.  We only care about the zero case (new install) or the case where
+	# the same version is being re-emerged.  If there is a second version, allow it to abort.
+	local rv rvres=doitnew
+	for rv in ${REPLACING_VERSIONS} ; do
+		if [[ ${rvres} == doit* ]]; then
+			if [[ ${rv%-r*} == ${PV} ]]; then
+				rvres=doit
+			else
+				rvres=${rv}
+			fi
+		fi
+	done
+
 	if use hwdb && has_version 'sys-apps/hwids[udev]'; then
 		udevadm hwdb --update --root="${ROOT%/}"
 
 		# https://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
 		# reload database after it has be rebuilt, but only if we are not upgrading
 		# also pass if we are -9999 since who knows what hwdb related changes there might be
-		if [[ ${REPLACING_VERSIONS%-r*} == ${PV} || -z ${REPLACING_VERSIONS} ]] && \
-		[[ ${ROOT%/} == "" ]] && [[ ${PV} != "9999" ]]; then
+		if [[ ${rvres} == doit* ]] && [[ ${ROOT%/} == "" ]] && [[ ${PV} != "9999" ]]; then
 			udevadm control --reload
 		fi
 	fi
-
-	ewarn
-	ewarn "You need to restart eudev as soon as possible to make the"
-	ewarn "upgrade go into effect:"
-	ewarn "\t/etc/init.d/udev --nodeps restart"
+	if [[ ${rvres} != doitnew ]]; then
+		ewarn
+		ewarn "You need to restart eudev as soon as possible to make the"
+		ewarn "upgrade go into effect:"
+		ewarn "\t/etc/init.d/udev --nodeps restart"
+	fi
 
 	elog
 	elog "For more information on eudev on Gentoo, writing udev rules, and"
 	elog "fixing known issues visit:"
 	elog "         https://www.gentoo.org/doc/en/udev-guide.xml"
 	elog
-
-	# https://cgit.freedesktop.org/systemd/systemd/commit/rules/50-udev-default.rules?id=3dff3e00e044e2d53c76fa842b9a4759d4a50e69
-	# https://bugs.gentoo.org/246847
-	# https://bugs.gentoo.org/514174
-	enewgroup input
-
-	# Update hwdb database in case the format is changed by udev version.
-	if has_version 'sys-apps/hwids[udev]'; then
-		udevadm hwdb --update --root="${ROOT%/}"
-		# Only reload when we are not upgrading to avoid potential race w/ incompatible hwdb.bin and the running udevd
-		if [[ -z ${REPLACING_VERSIONS} ]]; then
-			# https://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
-			if [[ ${ROOT} != "" ]] && [[ ${ROOT} != "/" ]]; then
-				return 0
-			fi
-			udevadm control --reload
-		fi
-	fi
 }

diff --git a/sys-fs/eudev/eudev-3.1.5.ebuild b/sys-fs/eudev/eudev-3.1.5.ebuild
index 0cb7025..a36ee54 100644
--- a/sys-fs/eudev/eudev-3.1.5.ebuild
+++ b/sys-fs/eudev/eudev-3.1.5.ebuild
@@ -190,22 +190,41 @@ pkg_postinst() {
 		ewarn "else losetup may be confused when looking for unused devices."
 	fi
 
+	# https://cgit.freedesktop.org/systemd/systemd/commit/rules/50-udev-default.rules?id=3dff3e00e044e2d53c76fa842b9a4759d4a50e69
+	# https://bugs.gentoo.org/246847
+	# https://bugs.gentoo.org/514174
+	enewgroup input
+
+	# REPLACING_VERSIONS should only ever have zero or 1 values but in case it doesn't,
+	# process it as a list.  We only care about the zero case (new install) or the case where
+	# the same version is being re-emerged.  If there is a second version, allow it to abort.
+	local rv rvres=doitnew
+	for rv in ${REPLACING_VERSIONS} ; do
+		if [[ ${rvres} == doit* ]]; then
+			if [[ ${rv%-r*} == ${PV} ]]; then
+				rvres=doit
+			else
+				rvres=${rv}
+			fi
+		fi
+	done
+
 	if use hwdb && has_version 'sys-apps/hwids[udev]'; then
 		udevadm hwdb --update --root="${ROOT%/}"
 
 		# https://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
 		# reload database after it has be rebuilt, but only if we are not upgrading
 		# also pass if we are -9999 since who knows what hwdb related changes there might be
-		if [[ ${REPLACING_VERSIONS%-r*} == ${PV} || -z ${REPLACING_VERSIONS} ]] && \
-		[[ ${ROOT%/} == "" ]] && [[ ${PV} != "9999" ]]; then
+		if [[ ${rvres} == doit* ]] && [[ ${ROOT%/} == "" ]] && [[ ${PV} != "9999" ]]; then
 			udevadm control --reload
 		fi
 	fi
-
-	ewarn
-	ewarn "You need to restart eudev as soon as possible to make the"
-	ewarn "upgrade go into effect:"
-	ewarn "\t/etc/init.d/udev --nodeps restart"
+	if [[ ${rvres} != doitnew ]]; then
+		ewarn
+		ewarn "You need to restart eudev as soon as possible to make the"
+		ewarn "upgrade go into effect:"
+		ewarn "\t/etc/init.d/udev --nodeps restart"
+	fi
 
 	if use rule-generator && \
 	[[ -x $(type -P rc-update) ]] && rc-update show | grep udev-postmount | grep -qsv 'boot\|default\|sysinit'; then
@@ -221,22 +240,4 @@ pkg_postinst() {
 	elog "fixing known issues visit:"
 	elog "         https://www.gentoo.org/doc/en/udev-guide.xml"
 	elog
-
-	# https://cgit.freedesktop.org/systemd/systemd/commit/rules/50-udev-default.rules?id=3dff3e00e044e2d53c76fa842b9a4759d4a50e69
-	# https://bugs.gentoo.org/246847
-	# https://bugs.gentoo.org/514174
-	enewgroup input
-
-	# Update hwdb database in case the format is changed by udev version.
-	if has_version 'sys-apps/hwids[udev]'; then
-		udevadm hwdb --update --root="${ROOT%/}"
-		# Only reload when we are not upgrading to avoid potential race w/ incompatible hwdb.bin and the running udevd
-		if [[ -z ${REPLACING_VERSIONS} ]]; then
-			# https://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
-			if [[ ${ROOT} != "" ]] && [[ ${ROOT} != "/" ]]; then
-				return 0
-			fi
-			udevadm control --reload
-		fi
-	fi
 }

diff --git a/sys-fs/eudev/eudev-3.2.ebuild b/sys-fs/eudev/eudev-3.2.ebuild
index 52c351c..e70d954 100644
--- a/sys-fs/eudev/eudev-3.2.ebuild
+++ b/sys-fs/eudev/eudev-3.2.ebuild
@@ -190,22 +190,41 @@ pkg_postinst() {
 		ewarn "else losetup may be confused when looking for unused devices."
 	fi
 
+	# https://cgit.freedesktop.org/systemd/systemd/commit/rules/50-udev-default.rules?id=3dff3e00e044e2d53c76fa842b9a4759d4a50e69
+	# https://bugs.gentoo.org/246847
+	# https://bugs.gentoo.org/514174
+	enewgroup input
+
+	# REPLACING_VERSIONS should only ever have zero or 1 values but in case it doesn't,
+	# process it as a list.  We only care about the zero case (new install) or the case where
+	# the same version is being re-emerged.  If there is a second version, allow it to abort.
+	local rv rvres=doitnew
+	for rv in ${REPLACING_VERSIONS} ; do
+		if [[ ${rvres} == doit* ]]; then
+			if [[ ${rv%-r*} == ${PV} ]]; then
+				rvres=doit
+			else
+				rvres=${rv}
+			fi
+		fi
+	done
+
 	if use hwdb && has_version 'sys-apps/hwids[udev]'; then
 		udevadm hwdb --update --root="${ROOT%/}"
 
 		# https://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
 		# reload database after it has be rebuilt, but only if we are not upgrading
 		# also pass if we are -9999 since who knows what hwdb related changes there might be
-		if [[ ${REPLACING_VERSIONS%-r*} == ${PV} || -z ${REPLACING_VERSIONS} ]] && \
-		[[ ${ROOT%/} == "" ]] && [[ ${PV} != "9999" ]]; then
+		if [[ ${rvres} == doit* ]] && [[ ${ROOT%/} == "" ]] && [[ ${PV} != "9999" ]]; then
 			udevadm control --reload
 		fi
 	fi
-
-	ewarn
-	ewarn "You need to restart eudev as soon as possible to make the"
-	ewarn "upgrade go into effect:"
-	ewarn "\t/etc/init.d/udev --nodeps restart"
+	if [[ ${rvres} != doitnew ]]; then
+		ewarn
+		ewarn "You need to restart eudev as soon as possible to make the"
+		ewarn "upgrade go into effect:"
+		ewarn "\t/etc/init.d/udev --nodeps restart"
+	fi
 
 	if use rule-generator && \
 	[[ -x $(type -P rc-update) ]] && rc-update show | grep udev-postmount | grep -qsv 'boot\|default\|sysinit'; then
@@ -221,22 +240,4 @@ pkg_postinst() {
 	elog "fixing known issues visit:"
 	elog "         https://www.gentoo.org/doc/en/udev-guide.xml"
 	elog
-
-	# https://cgit.freedesktop.org/systemd/systemd/commit/rules/50-udev-default.rules?id=3dff3e00e044e2d53c76fa842b9a4759d4a50e69
-	# https://bugs.gentoo.org/246847
-	# https://bugs.gentoo.org/514174
-	enewgroup input
-
-	# Update hwdb database in case the format is changed by udev version.
-	if has_version 'sys-apps/hwids[udev]'; then
-		udevadm hwdb --update --root="${ROOT%/}"
-		# Only reload when we are not upgrading to avoid potential race w/ incompatible hwdb.bin and the running udevd
-		if [[ -z ${REPLACING_VERSIONS} ]]; then
-			# https://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
-			if [[ ${ROOT} != "" ]] && [[ ${ROOT} != "/" ]]; then
-				return 0
-			fi
-			udevadm control --reload
-		fi
-	fi
 }

diff --git a/sys-fs/eudev/eudev-4.9999.ebuild b/sys-fs/eudev/eudev-4.9999.ebuild
index 57d3d76..2d29640 100644
--- a/sys-fs/eudev/eudev-4.9999.ebuild
+++ b/sys-fs/eudev/eudev-4.9999.ebuild
@@ -184,44 +184,45 @@ pkg_postinst() {
 		ewarn "else losetup may be confused when looking for unused devices."
 	fi
 
+	# https://cgit.freedesktop.org/systemd/systemd/commit/rules/50-udev-default.rules?id=3dff3e00e044e2d53c76fa842b9a4759d4a50e69
+	# https://bugs.gentoo.org/246847
+	# https://bugs.gentoo.org/514174
+	enewgroup input
+
+	# REPLACING_VERSIONS should only ever have zero or 1 values but in case it doesn't,
+	# process it as a list.  We only care about the zero case (new install) or the case where
+	# the same version is being re-emerged.  If there is a second version, allow it to abort.
+	local rv rvres=doitnew
+	for rv in ${REPLACING_VERSIONS} ; do
+		if [[ ${rvres} == doit* ]]; then
+			if [[ ${rv%-r*} == ${PV} ]]; then
+				rvres=doit
+			else
+				rvres=${rv}
+			fi
+		fi
+	done
+
 	if use hwdb && has_version 'sys-apps/hwids[udev]'; then
 		udevadm hwdb --update --root="${ROOT%/}"
 
 		# https://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
 		# reload database after it has be rebuilt, but only if we are not upgrading
 		# also pass if we are -9999 since who knows what hwdb related changes there might be
-		if [[ ${REPLACING_VERSIONS%-r*} == ${PV} || -z ${REPLACING_VERSIONS} ]] && \
-		[[ ${ROOT%/} == "" ]] && [[ ${PV} != "9999" ]]; then
+		if [[ ${rvres} == doit* ]] && [[ ${ROOT%/} == "" ]] && [[ ${PV} != "9999" ]]; then
 			udevadm control --reload
 		fi
 	fi
-
-	ewarn
-	ewarn "You need to restart eudev as soon as possible to make the"
-	ewarn "upgrade go into effect:"
-	ewarn "\t/etc/init.d/udev --nodeps restart"
+	if [[ ${rvres} != doitnew ]]; then
+		ewarn
+		ewarn "You need to restart eudev as soon as possible to make the"
+		ewarn "upgrade go into effect:"
+		ewarn "\t/etc/init.d/udev --nodeps restart"
+	fi
 
 	elog
 	elog "For more information on eudev on Gentoo, writing udev rules, and"
 	elog "fixing known issues visit:"
 	elog "         https://www.gentoo.org/doc/en/udev-guide.xml"
 	elog
-
-	# https://cgit.freedesktop.org/systemd/systemd/commit/rules/50-udev-default.rules?id=3dff3e00e044e2d53c76fa842b9a4759d4a50e69
-	# https://bugs.gentoo.org/246847
-	# https://bugs.gentoo.org/514174
-	enewgroup input
-
-	# Update hwdb database in case the format is changed by udev version.
-	if has_version 'sys-apps/hwids[udev]'; then
-		udevadm hwdb --update --root="${ROOT%/}"
-		# Only reload when we are not upgrading to avoid potential race w/ incompatible hwdb.bin and the running udevd
-		if [[ -z ${REPLACING_VERSIONS} ]]; then
-			# https://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
-			if [[ ${ROOT} != "" ]] && [[ ${ROOT} != "/" ]]; then
-				return 0
-			fi
-			udevadm control --reload
-		fi
-	fi
 }

diff --git a/sys-fs/eudev/eudev-9999.ebuild b/sys-fs/eudev/eudev-9999.ebuild
index 52c351c..e70d954 100644
--- a/sys-fs/eudev/eudev-9999.ebuild
+++ b/sys-fs/eudev/eudev-9999.ebuild
@@ -190,22 +190,41 @@ pkg_postinst() {
 		ewarn "else losetup may be confused when looking for unused devices."
 	fi
 
+	# https://cgit.freedesktop.org/systemd/systemd/commit/rules/50-udev-default.rules?id=3dff3e00e044e2d53c76fa842b9a4759d4a50e69
+	# https://bugs.gentoo.org/246847
+	# https://bugs.gentoo.org/514174
+	enewgroup input
+
+	# REPLACING_VERSIONS should only ever have zero or 1 values but in case it doesn't,
+	# process it as a list.  We only care about the zero case (new install) or the case where
+	# the same version is being re-emerged.  If there is a second version, allow it to abort.
+	local rv rvres=doitnew
+	for rv in ${REPLACING_VERSIONS} ; do
+		if [[ ${rvres} == doit* ]]; then
+			if [[ ${rv%-r*} == ${PV} ]]; then
+				rvres=doit
+			else
+				rvres=${rv}
+			fi
+		fi
+	done
+
 	if use hwdb && has_version 'sys-apps/hwids[udev]'; then
 		udevadm hwdb --update --root="${ROOT%/}"
 
 		# https://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
 		# reload database after it has be rebuilt, but only if we are not upgrading
 		# also pass if we are -9999 since who knows what hwdb related changes there might be
-		if [[ ${REPLACING_VERSIONS%-r*} == ${PV} || -z ${REPLACING_VERSIONS} ]] && \
-		[[ ${ROOT%/} == "" ]] && [[ ${PV} != "9999" ]]; then
+		if [[ ${rvres} == doit* ]] && [[ ${ROOT%/} == "" ]] && [[ ${PV} != "9999" ]]; then
 			udevadm control --reload
 		fi
 	fi
-
-	ewarn
-	ewarn "You need to restart eudev as soon as possible to make the"
-	ewarn "upgrade go into effect:"
-	ewarn "\t/etc/init.d/udev --nodeps restart"
+	if [[ ${rvres} != doitnew ]]; then
+		ewarn
+		ewarn "You need to restart eudev as soon as possible to make the"
+		ewarn "upgrade go into effect:"
+		ewarn "\t/etc/init.d/udev --nodeps restart"
+	fi
 
 	if use rule-generator && \
 	[[ -x $(type -P rc-update) ]] && rc-update show | grep udev-postmount | grep -qsv 'boot\|default\|sysinit'; then
@@ -221,22 +240,4 @@ pkg_postinst() {
 	elog "fixing known issues visit:"
 	elog "         https://www.gentoo.org/doc/en/udev-guide.xml"
 	elog
-
-	# https://cgit.freedesktop.org/systemd/systemd/commit/rules/50-udev-default.rules?id=3dff3e00e044e2d53c76fa842b9a4759d4a50e69
-	# https://bugs.gentoo.org/246847
-	# https://bugs.gentoo.org/514174
-	enewgroup input
-
-	# Update hwdb database in case the format is changed by udev version.
-	if has_version 'sys-apps/hwids[udev]'; then
-		udevadm hwdb --update --root="${ROOT%/}"
-		# Only reload when we are not upgrading to avoid potential race w/ incompatible hwdb.bin and the running udevd
-		if [[ -z ${REPLACING_VERSIONS} ]]; then
-			# https://cgit.freedesktop.org/systemd/systemd/commit/?id=1fab57c209035f7e66198343074e9cee06718bda
-			if [[ ${ROOT} != "" ]] && [[ ${ROOT} != "/" ]]; then
-				return 0
-			fi
-			udevadm control --reload
-		fi
-	fi
 }