mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-15 00:46:58 +02:00
eclass/acct-group: Sync with Gentoo
It's from Gentoo commit 1f755588e9c4d7ee2e0f70f55d0e6029e8d6b160.
This commit is contained in:
parent
383c012aa3
commit
51b160c341
@ -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
|
# Distributed under the terms of the GNU General Public License v2
|
||||||
|
|
||||||
# @ECLASS: acct-group.eclass
|
# @ECLASS: acct-group.eclass
|
||||||
# @MAINTAINER:
|
# @MAINTAINER:
|
||||||
# Michał Górny <mgorny@gentoo.org>
|
# Michał Górny <mgorny@gentoo.org>
|
||||||
|
# Mike Gilbert <floppym@gentoo.org>
|
||||||
# @AUTHOR:
|
# @AUTHOR:
|
||||||
# Michael Orlitzky <mjo@gentoo.org>
|
# Michael Orlitzky <mjo@gentoo.org>
|
||||||
# Michał Górny <mgorny@gentoo.org>
|
# Michał Górny <mgorny@gentoo.org>
|
||||||
@ -40,7 +41,7 @@ case ${EAPI:-0} in
|
|||||||
*) die "EAPI=${EAPI:-0} not supported";;
|
*) die "EAPI=${EAPI:-0} not supported";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
inherit user
|
inherit user-info
|
||||||
|
|
||||||
[[ ${CATEGORY} == acct-group ]] ||
|
[[ ${CATEGORY} == acct-group ]] ||
|
||||||
die "Ebuild error: this eclass can be used only in acct-group category!"
|
die "Ebuild error: this eclass can be used only in acct-group category!"
|
||||||
@ -48,7 +49,7 @@ inherit user
|
|||||||
|
|
||||||
# << Eclass variables >>
|
# << Eclass variables >>
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: ACCT_GROUP_NAME
|
# @ECLASS_VARIABLE: ACCT_GROUP_NAME
|
||||||
# @INTERNAL
|
# @INTERNAL
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# The name of the group. This is forced to ${PN} and the policy
|
# The name of the group. This is forced to ${PN} and the policy
|
||||||
@ -56,7 +57,7 @@ inherit user
|
|||||||
ACCT_GROUP_NAME=${PN}
|
ACCT_GROUP_NAME=${PN}
|
||||||
readonly ACCT_GROUP_NAME
|
readonly ACCT_GROUP_NAME
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: ACCT_GROUP_ID
|
# @ECLASS_VARIABLE: ACCT_GROUP_ID
|
||||||
# @REQUIRED
|
# @REQUIRED
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# Preferred GID for the new group. This variable is obligatory, and its
|
# 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
|
# Overlays should set this to -1 to dynamically allocate GID. Using -1
|
||||||
# in ::gentoo is prohibited by policy.
|
# in ::gentoo is prohibited by policy.
|
||||||
|
|
||||||
# @ECLASS-VARIABLE: ACCT_GROUP_ENFORCE_ID
|
# @ECLASS_VARIABLE: ACCT_GROUP_ENFORCE_ID
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
# If set to a non-null value, the eclass will require the group to have
|
# 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
|
# specified GID. If the group already exists with another GID, or
|
||||||
@ -77,7 +78,7 @@ readonly ACCT_GROUP_NAME
|
|||||||
# << Boilerplate ebuild variables >>
|
# << Boilerplate ebuild variables >>
|
||||||
: ${DESCRIPTION:="System group: ${ACCT_GROUP_NAME}"}
|
: ${DESCRIPTION:="System group: ${ACCT_GROUP_NAME}"}
|
||||||
: ${SLOT:=0}
|
: ${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}
|
S=${WORKDIR}
|
||||||
|
|
||||||
|
|
||||||
@ -156,8 +157,30 @@ acct-group_src_install() {
|
|||||||
acct-group_pkg_preinst() {
|
acct-group_pkg_preinst() {
|
||||||
debug-print-function ${FUNCNAME} "${@}"
|
debug-print-function ${FUNCNAME} "${@}"
|
||||||
|
|
||||||
enewgroup ${ACCT_GROUP_ENFORCE_ID:+-F} "${ACCT_GROUP_NAME}" \
|
if [[ ${EUID} -ne 0 || -n ${EPREFIX} ]]; then
|
||||||
"${_ACCT_GROUP_ID}"
|
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
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user