# 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"}
# 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
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
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
}