summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gilbert <floppym@gentoo.org>2022-10-17 14:33:13 -0400
committerMichał Górny <mgorny@gentoo.org>2022-10-19 15:30:04 +0200
commitacd0e195b2fba241d5eac52e34676a4a00493c2b (patch)
treee01a09968d6a85b7ca89a6755c06755ec609c7a4 /eclass/acct-group.eclass
parentwww-client/firefox-bin: drop 102.3.0, 105.0.3 (diff)
downloadgentoo-acd0e195b2fba241d5eac52e34676a4a00493c2b.tar.gz
gentoo-acd0e195b2fba241d5eac52e34676a4a00493c2b.tar.bz2
gentoo-acd0e195b2fba241d5eac52e34676a4a00493c2b.zip
acct-group.eclass: inline groupadd
Signed-off-by: Mike Gilbert <floppym@gentoo.org> Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass/acct-group.eclass')
-rw-r--r--eclass/acct-group.eclass30
1 files changed, 27 insertions, 3 deletions
diff --git a/eclass/acct-group.eclass b/eclass/acct-group.eclass
index 3d02e4f713b4..3f38ac36ec4d 100644
--- a/eclass/acct-group.eclass
+++ b/eclass/acct-group.eclass
@@ -40,7 +40,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!"
@@ -156,8 +156,32 @@ 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 ]]; 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 [[ -z ${ACCT_GROUP_ENFORCE_ID} ]]; then
+ opts+=( --force )
+ fi
+
+ if [[ ${_ACCT_GROUP_ID} -ne -1 ]]; 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