+sys-user_modify() {
+ # Modify the existing user named $SYS_USER_NAME to match the values
+ # contained in the following variables:
+ #
+ # * SYS_USER_UID
+ # * SYS_USER_SHELL
+ # * SYS_USER_HOME
+ # * SYS_USER_GROUPS
+ #
+ usermod ${SYS_USER_UID:+--uid }"${SYS_USER_UID}" \
+ ${SYS_USER_GROUPS:+--append --groups }"${SYS_USER_GROUPS}" \
+ --shell "${SYS_USER_SHELL}" \
+ --home "${SYS_USER_HOME}" \
+ "${SYS_USER_NAME}"
+}
+
+sys-user_pkg_pretend() {
+ # Sanity checks that would otherwise run code in global scope.
+ if [[ "${SYS_USER_UID_IMPORTANT}" == "true" ]]; then
+
+ # 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 [[ -n "${oldname}" ]] && \
+ [[ "${SYS_USER_NAME}" != "${oldname}" ]]; then
+ die "important UID ${SYS_USER_UID} already belongs to ${oldname}"
+ fi
+
+ # 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.
+ die "user ${SYS_USER_NAME} already exists with UID ${olduid}"
+ fi
+ fi
+}
+
+sys-user_src_configure() {
+ local current_uid=$(sys-user_getuid "${SYS_USER_NAME}")
+ if [[ -n "${current_uid}" ]]; then