]> gitweb.michael.orlitzky.com - mjo-overlay.git/blobdiff - eclass/sys-user.eclass
sys-user.eclass: fix killer typo in variable name.
[mjo-overlay.git] / eclass / sys-user.eclass
index e14cdfb733ec1a5947f8f681f1ef341b449c917d..7cfffaf123a2e67e82ed41297c94e3a2c2ea2adf 100644 (file)
@@ -83,7 +83,7 @@ sys-user_getuid() {
        # Output the real UID of the given user, or the empty string if the
        # user does not exist on the system.
        [[ $# -eq 1 ]] || die "usage: sys-user_getuid <username>"
-       echo $(id --real --user "${1}")
+       echo $(id --real --user "${1}" 2>/dev/null)
 }
 
 sys-user_getname() {
@@ -126,28 +126,26 @@ sys-user_modify() {
        usermod ${SYS_USER_UID:+--uid }"${SYS_USER_UID}" \
                        ${SYS_USER_GROUPS:+--append --groups }"${SYS_USER_GROUPS}" \
                        --shell "${SYS_USER_SHELL}" \
-                       --home-dir "${SYS_USER_HOME}" \
+                       --home "${SYS_USER_HOME}" \
                        "${SYS_USER_NAME}"
 }
 
 sys-user_pkg_pretend() {
        # Sanity checks that would otherwise run code in global scope.
-
-       # Next ensure that no other username owns an important UID.
        if [[ "${SYS_USER_UID_IMPORTANT}" == "true" ]]; then
-               # Ok, the UID is important. Make sure nobody else has it. Or
+
+               # The UID is important, so make sure nobody else has it. Or
                # rather, nobody else *with a different username* has it.
                local oldname=$(sys-user_getname "${SYS_USER_UID}")
-               if [[ "${SYS_USER_NAME}" != "${oldname}" ]]; then
+               if [[ -n "${oldname}" ]] && \
+                          [[ "${SYS_USER_NAME}" != "${oldname}" ]]; then
                        die "important UID ${SYS_USER_UID} already belongs to ${oldname}"
                fi
-       fi
 
-       # Finally, ensure that this username doesn't already exist with
-       # another UID if its UID is supposedly important.
-       local olduid=$(sys-user_getuid "${SYS_USER_NAME}")
-       if [[ -n "${olduid}" ]]; then
-               if [[ "${SYS_USER_UID_IMPORTANT}" == "true" ]] && \
+               # Ensure that this username doesn't already exist with another
+               # UID if its UID is supposedly important.
+               local olduid=$(sys-user_getuid "${SYS_USER_NAME}")
+               if [[ -n "${olduid}" ]] && \
                           [[ "${SYS_USER_UID}" != "${olduid}" ]]; then
                        # The UID is important and specified, but there is already a
                        # system user with this name and a different UID. Halp.
@@ -180,7 +178,8 @@ sys-user_src_configure() {
        fi
 
        local current_name=$(sys-user_getname "${SYS_USER_UID}")
-       if [[ "${current_name}" != "${SYS_USER_NAME}" ]]; then
+       if [[ -n "${current_name}" ]] && \
+                  [[ "${current_name}" != "${SYS_USER_NAME}" ]]; then
                # This UID is already taken by another user, but this
                # specific UID was not important (we checked in
                # pkg_pretend), so fall back to an arbitrary one.
@@ -253,7 +252,7 @@ sys-user_pkg_preinst() {
                        die "home directory conflict for new user: ${SYS_USER_HOME}"
                fi
 
-               if [[ "${oldhshell}" != "${SYS_USER_SHELL}" ]]; then
+               if [[ "${oldshell}" != "${SYS_USER_SHELL}" ]]; then
                        die "shell conflict for new user: ${SYS_USER_SHELL}"
                fi
 
@@ -270,7 +269,7 @@ 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
+       elif [[ -z "${REPLACED_BY_VERSION}" ]]; then
                # 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).
@@ -283,7 +282,6 @@ sys-user_pkg_prerm() {
                fi
 
                # The missing case: if the user exists and this is an upgrade,
-               # we leave the user alone to be modified in
-               # sys-user_pkg_preinst().
+               # we leave him alone to be modified in sys-user_pkg_preinst().
        fi
 }