X-Git-Url: http://gitweb.michael.orlitzky.com/?p=mjo-overlay.git;a=blobdiff_plain;f=eclass%2Fsys-user.eclass;h=e14cdfb733ec1a5947f8f681f1ef341b449c917d;hp=bf2f7a7a61419c8ab104e842762157d7742bd1b1;hb=ad88c75318cc9173a5959ca329ccf16f2ac73553;hpb=403461c39300685b87c9b6c43f220a9f675be974 diff --git a/eclass/sys-user.eclass b/eclass/sys-user.eclass index bf2f7a7..e14cdfb 100644 --- a/eclass/sys-user.eclass +++ b/eclass/sys-user.eclass @@ -12,10 +12,11 @@ # 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"} +: ${LICENSE="GPL-2"} # If you want a different username, use a different package name. This # prevents different people from claiming the same username. @@ -224,11 +225,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,35 +265,25 @@ 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 # We have successfully done nothing. ewarn "Tried to remove nonexistent user ${SYS_USER_NAME}." elif [[ -z "${REPLACING_VERSIONS}" ]]; then - # The user to remove exists, and this is not an upgrade, so - # we really do remove him. - userdel "${SYS_USER_NAME}" || \ - die "failed to remove user ${SYS_USER_NAME}" - einfo "Removed user ${SYS_USER_NAME} from the system." + # The user to remove exists, and this is not an upgrade. For + # Phase 1, we maintain the status quo and simply refuse to + # remove him (unless you know what you are doing). + if [[ "${I_KNOW_WHAT_I_AM_DOING}" == "yes" ]]; then + userdel "${SYS_USER_NAME}" || \ + die "failed to remove user ${SYS_USER_NAME}" + einfo "Removed user ${SYS_USER_NAME} from the system." + else + die "refusing to remove package for system user ${SYS_USER_NAME}" + fi - # 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 }