From: Michael Orlitzky Date: Mon, 7 Aug 2017 22:27:27 +0000 (-0400) Subject: sys-user.eclass: consolidate the create/modify code paths. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=38d15277464dc08b2f7bbb47008400ab7f141a3c;p=mjo-overlay.git sys-user.eclass: consolidate the create/modify code paths. --- diff --git a/eclass/sys-user.eclass b/eclass/sys-user.eclass index bf2f7a7..56e7bc4 100644 --- a/eclass/sys-user.eclass +++ b/eclass/sys-user.eclass @@ -12,7 +12,7 @@ # Needed for egetshell and egethome. inherit user -EXPORT_FUNCTIONS pkg_pretend src_unpack src_configure src_compile src_install src_test pkg_preinst pkg_postinst pkg_prerm +EXPORT_FUNCTIONS pkg_pretend src_unpack src_configure src_compile src_install src_test pkg_preinst pkg_prerm : ${HOMEPAGE:="https://wiki.gentoo.org/wiki/User:Mjo/GLEP:User_packages"} : ${DESCRIPTION:="The ${PN} system user"} @@ -224,11 +224,10 @@ sys-user_pkg_preinst() { # and create the (new) user. sys-user_create || die "failed to add user ${SYS_USER_NAME}" elif [[ -n "${REPLACING_VERSIONS}" ]]; then - # - # This case is done in pkg_postint() to avoid clobbering a - # new user when we remove the old one. - # - : + # This is an upgrade from a previous version of a sys-user + # package. Modify the existing user (who will not be removed; see + # sys-user_pkg_prerm) rather than creating a new one. + sys-user_modify || die "failed to upgrade user ${SYS_USER_NAME}" else # UPGRADE PATH: Ok, the user exists but this isn't an upgrade of # a sys-user package. This is the upgrade path from the old @@ -265,21 +264,6 @@ sys-user_pkg_preinst() { fi } -sys-user_pkg_postinst() { - if [[ -n "${REPLACING_VERSIONS}" ]]; then - # This is an upgrade from a previous version of a sys-user - # package. This case has to be handled carefully to make sure - # that the pkg_prerm() of the old version doesn't remove the user - # that this new version is going to add. At this point, in our - # pkg_postinst(), the old version's pkg_prerm() phase should have - # already happened. - if [[ -n $(sys-user_getuid "${SYS_USER_NAME}") ]]; then - die "User ${SYS_USER_NAME} already exists during an upgrade." - else - sys-user_modify || die "failed to add user ${SYS_USER_NAME}" - fi - fi -} sys-user_pkg_prerm() { if [[ -z $(sys-user_getuid "${SYS_USER_NAME}") ]]; then @@ -292,8 +276,8 @@ sys-user_pkg_prerm() { die "failed to remove user ${SYS_USER_NAME}" einfo "Removed user ${SYS_USER_NAME} from the system." - # The missing case: if the user exista and this is an upgrade, + # The missing case: if the user exists and this is an upgrade, # we leave the user alone to be modified in - # sys-user_pkg_postinst(). + # sys-user_pkg_preinst(). fi }