diff --git a/sdk_container/src/third_party/portage-stable/eclass/acct-group.eclass b/sdk_container/src/third_party/portage-stable/eclass/acct-group.eclass index b309d36432..f55c9f4c95 100644 --- a/sdk_container/src/third_party/portage-stable/eclass/acct-group.eclass +++ b/sdk_container/src/third_party/portage-stable/eclass/acct-group.eclass @@ -1,9 +1,10 @@ -# Copyright 2019-2021 Gentoo Authors +# Copyright 2019-2022 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: acct-group.eclass # @MAINTAINER: # Michał Górny +# Mike Gilbert # @AUTHOR: # Michael Orlitzky # Michał Górny @@ -40,7 +41,7 @@ case ${EAPI:-0} in *) die "EAPI=${EAPI:-0} not supported";; esac -inherit user +inherit user-info [[ ${CATEGORY} == acct-group ]] || die "Ebuild error: this eclass can be used only in acct-group category!" @@ -48,7 +49,7 @@ inherit user # << Eclass variables >> -# @ECLASS-VARIABLE: ACCT_GROUP_NAME +# @ECLASS_VARIABLE: ACCT_GROUP_NAME # @INTERNAL # @DESCRIPTION: # The name of the group. This is forced to ${PN} and the policy @@ -56,7 +57,7 @@ inherit user ACCT_GROUP_NAME=${PN} readonly ACCT_GROUP_NAME -# @ECLASS-VARIABLE: ACCT_GROUP_ID +# @ECLASS_VARIABLE: ACCT_GROUP_ID # @REQUIRED # @DESCRIPTION: # Preferred GID for the new group. This variable is obligatory, and its @@ -66,7 +67,7 @@ readonly ACCT_GROUP_NAME # Overlays should set this to -1 to dynamically allocate GID. Using -1 # in ::gentoo is prohibited by policy. -# @ECLASS-VARIABLE: ACCT_GROUP_ENFORCE_ID +# @ECLASS_VARIABLE: ACCT_GROUP_ENFORCE_ID # @DESCRIPTION: # If set to a non-null value, the eclass will require the group to have # specified GID. If the group already exists with another GID, or @@ -77,7 +78,7 @@ readonly ACCT_GROUP_NAME # << Boilerplate ebuild variables >> : ${DESCRIPTION:="System group: ${ACCT_GROUP_NAME}"} : ${SLOT:=0} -: ${KEYWORDS:=alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 ~riscv s390 sparc x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris} +: ${KEYWORDS:=alpha amd64 arm arm64 hppa ia64 ~loong m68k ~mips ppc ppc64 ~riscv s390 sparc x86 ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris} S=${WORKDIR} @@ -156,8 +157,30 @@ acct-group_src_install() { acct-group_pkg_preinst() { debug-print-function ${FUNCNAME} "${@}" - enewgroup ${ACCT_GROUP_ENFORCE_ID:+-F} "${ACCT_GROUP_NAME}" \ - "${_ACCT_GROUP_ID}" + if [[ ${EUID} -ne 0 || -n ${EPREFIX} ]]; then + einfo "Insufficient privileges to execute ${FUNCNAME[0]}" + return + fi + + if egetent group "${ACCT_GROUP_NAME}" >/dev/null; then + elog "Group ${ACCT_GROUP_NAME} already exists" + return + fi + + local opts=( --system ) + + if [[ ${_ACCT_GROUP_ID} -ne -1 ]] && + ! egetent group "${_ACCT_GROUP_ID}" >/dev/null + then + opts+=( --gid "${_ACCT_GROUP_ID}" ) + fi + + if [[ -n ${ROOT} ]]; then + opts+=( --prefix "${ROOT}" ) + fi + + elog "Adding group ${ACCT_GROUP_NAME}" + groupadd "${opts[@]}" "${ACCT_GROUP_NAME}" || die } fi