commit:     d6ffd48fbde60f371dd8b763b9ab9a4beecf282a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 17 09:55:25 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Dec 17 09:55:25 2018 +0000
URL:        https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=d6ffd48f

eclass: sync with gx86

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 eclass/autotools.eclass          |  11 +-
 eclass/flag-o-matic.eclass       |   8 +-
 eclass/gnuconfig.eclass          |  99 ---------
 eclass/java-utils-2.eclass       |  23 +-
 eclass/python-utils-r1.eclass    |   1 +
 eclass/toolchain-binutils.eclass |  19 +-
 eclass/toolchain-funcs.eclass    | 145 ++++++++----
 eclass/user.eclass               | 469 ---------------------------------------
 8 files changed, 127 insertions(+), 648 deletions(-)

diff --git a/eclass/autotools.eclass b/eclass/autotools.eclass
index f30ac7414f..5a59c8d2d5 100644
--- a/eclass/autotools.eclass
+++ b/eclass/autotools.eclass
@@ -4,6 +4,7 @@
 # @ECLASS: autotools.eclass
 # @MAINTAINER:
 # [email protected]
+# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 7
 # @BLURB: Regenerates auto* build scripts
 # @DESCRIPTION:
 # This eclass is for safely handling autotooled software packages that need to
@@ -25,6 +26,11 @@ fi
 if [[ -z ${_AUTOTOOLS_ECLASS} ]]; then
 _AUTOTOOLS_ECLASS=1
 
+case ${EAPI:-0} in
+       0|1|2|3|4|5|6|7) ;;
+       *) die "${ECLASS}: EAPI ${EAPI} not supported" ;;
+esac
+
 inherit libtool
 
 # @ECLASS-VARIABLE: WANT_AUTOCONF
@@ -118,7 +124,10 @@ RDEPEND=""
 # their own DEPEND string.
 : ${AUTOTOOLS_AUTO_DEPEND:=yes}
 if [[ ${AUTOTOOLS_AUTO_DEPEND} != "no" ]] ; then
-       DEPEND=${AUTOTOOLS_DEPEND}
+       case ${EAPI:-0} in
+               0|1|2|3|4|5|6) DEPEND=${AUTOTOOLS_DEPEND} ;;
+               7) BDEPEND=${AUTOTOOLS_DEPEND} ;;
+       esac
 fi
 __AUTOTOOLS_AUTO_DEPEND=${AUTOTOOLS_AUTO_DEPEND} # See top of eclass
 

diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
index 3f9fd205c4..cdd63219de 100644
--- a/eclass/flag-o-matic.eclass
+++ b/eclass/flag-o-matic.eclass
@@ -34,6 +34,9 @@ setup-allowed-flags() {
 
                # CPPFLAGS and LDFLAGS
                '-[DUILR]*' '-Wl,*'
+
+               # Linker choice flag
+               '-fuse-ld'
        )
 
        # allow a bunch of flags that negate features / control ABI
@@ -595,11 +598,6 @@ get-flag() {
        return 1
 }
 
-# @FUNCTION: has_m64
-# @DESCRIPTION:
-# This doesn't test if the flag is accepted, it tests if the flag actually
-# WORKS. Non-multilib gcc will take both -m32 and -m64. If the flag works
-# return code is 0, else the return code is 1.
 has_m64() {
        die "${FUNCNAME}: don't use this anymore"
 }

diff --git a/eclass/gnuconfig.eclass b/eclass/gnuconfig.eclass
deleted file mode 100644
index 3c8d98d6a9..0000000000
--- a/eclass/gnuconfig.eclass
+++ /dev/null
@@ -1,99 +0,0 @@
-# Copyright 1999-2012 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-#
-# THIS ECLASS IS DEAD: It has been integrated into portage
-#
-# Author: Will Woods <[email protected]>
-#
-# This eclass is used to automatically update files that typically come with
-# automake to the newest version available on the system. The most common use
-# of this is to update config.guess and config.sub when configure dies from
-# misguessing your canonical system name (CHOST). It can also be used to update
-# other files that come with automake, e.g. depcomp, mkinstalldirs, etc.
-#
-# usage: gnuconfig_update [file1 file2 ...]
-# if called without arguments, config.guess and config.sub will be updated.
-# All files in the source tree ($S) with the given name(s) will be replaced
-# with the newest available versions chosen from the list of locations in
-# gnuconfig_findnewest(), below.
-#
-# gnuconfig_update should generally be called from src_unpack()
-
-
-DEPEND="sys-devel/gnuconfig"
-
-# Wrapper function for gnuconfig_do_update. If no arguments are given, update
-# config.sub and config.guess (old default behavior), otherwise update the
-# named files.
-gnuconfig_update() {
-
-# hmm some packages (like binutils gcc glibc) still use this ...
-#      echo
-#      ewarn "QA Notice: Please stop using me, portage updates files for you."
-#      echo
-
-       local startdir  # declared here ... used in gnuconfig_do_update
-
-       if [[ $1 == /* ]] ; then
-               startdir=$1
-               shift
-       else
-               startdir=${S}
-       fi
-
-       if [[ $# -gt 0 ]] ; then
-               gnuconfig_do_update "$@"
-       else
-               gnuconfig_do_update config.sub config.guess
-       fi
-
-       return $?
-}
-
-# Copy the newest available version of specified files over any old ones in the
-# source dir. This function shouldn't be called directly - use gnuconfig_update
-#
-# Note that since bash using dynamic scoping, startdir is available here from
-# the gnuconfig_update function
-gnuconfig_do_update() {
-       local configsubs_dir target targetlist file
-
-       [[ $# -eq 0 ]] && die "do not call gnuconfig_do_update; use 
gnuconfig_update"
-
-       configsubs_dir=$(gnuconfig_findnewest)
-       einfo "Using GNU config files from ${configsubs_dir}"
-       for file in "$@" ; do
-               if [[ ! -r ${configsubs_dir}/${file} ]] ; then
-                       eerror "Can't read ${configsubs_dir}/${file}, 
skipping.."
-                       continue
-               fi
-               targetlist=$(find "${startdir}" -name "${file}")
-               if [[ -n ${targetlist} ]] ; then
-                       for target in ${targetlist} ; do
-                               [[ -L ${target} ]] && rm -f "${target}"
-                               einfo "  Updating ${target/$startdir\//}"
-                               cp -f "${configsubs_dir}/${file}" "${target}"
-                               eend $?
-                       done
-               else
-                       ewarn "  No ${file} found in ${startdir}, skipping ..."
-               fi
-       done
-
-       return 0
-}
-
-# this searches the standard locations for the newest config.{sub|guess}, and
-# returns the directory where they can be found.
-gnuconfig_findnewest() {
-       has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
-       local locations=(
-               "${EPREFIX}"/usr/share/misc/config.sub
-               "${EPREFIX}"/usr/share/gnuconfig/config.sub
-               "${EPREFIX}"/usr/share/automake*/config.sub
-               "${EPREFIX}"/usr/share/libtool/config.sub
-       )
-       grep -s '^timestamp' "${locations[@]}" | \
-               sort -r -n -t\' -k2 | \
-               sed -n '1{s,/config.sub:.*$,,;p;q}'
-}

diff --git a/eclass/java-utils-2.eclass b/eclass/java-utils-2.eclass
index 31ba721003..da96e04c14 100644
--- a/eclass/java-utils-2.eclass
+++ b/eclass/java-utils-2.eclass
@@ -1,4 +1,4 @@
-# Copyright 2004-2017 Gentoo Foundation
+# Copyright 2004-2018 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: java-utils-2.eclass
@@ -23,16 +23,7 @@ IUSE="elibc_FreeBSD"
 export WANT_JAVA_CONFIG="2"
 
 # Prefix variables are only available for EAPI>=3
-# PREFIX: we always need EPREFIX, as there's still old ebuilds
-#has "${EAPI:-0}" 0 1 2 && ED="${D}" EPREFIX= EROOT="${ROOT}"
-
-# @VARIABLE: JAVA_PKG_PORTAGE_DEP
-# @INTERNAL
-# @DESCRIPTION:
-# The version of portage we need to function properly. Previously it was
-# portage with phase hooks support but now we use a version with proper env
-# saving. For EAPI 2 we have new enough stuff so let's have cleaner deps.
-has "${EAPI}" 0 1 && JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7"
+has "${EAPI:-0}" 0 1 2 && ED="${D}" EPREFIX= EROOT="${ROOT}"
 
 # @VARIABLE: JAVA_PKG_E_DEPEND
 # @INTERNAL
@@ -40,7 +31,7 @@ has "${EAPI}" 0 1 && 
JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7"
 # This is a convience variable to be used from the other java eclasses. This is
 # the version of java-config we want to use. Usually the latest stable version
 # so that ebuilds can use new features without depending on specific versions.
-JAVA_PKG_E_DEPEND="!x86-winnt? ( >=dev-java/java-config-2.2.0-r3 
${JAVA_PKG_PORTAGE_DEP} )"
+JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.2.0-r3"
 has source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? 
( app-arch/zip )"
 
 # @ECLASS-VARIABLE: JAVA_PKG_WANT_BOOTCLASSPATH
@@ -1481,7 +1472,7 @@ java-pkg_ensure-vm-version-sufficient() {
        if ! java-pkg_is-vm-version-sufficient; then
                debug-print "VM is not suffient"
                eerror "Current Java VM cannot build this package"
-               einfo "Please use java-config -S to set the correct one"
+               einfo "Please use \"eselect java-vm set system\" to set the 
correct one"
                die "Active Java VM cannot build this package"
        fi
 }
@@ -1509,7 +1500,7 @@ java-pkg_ensure-vm-version-eq() {
        if ! java-pkg_is-vm-version-eq $@ ; then
                debug-print "VM is not suffient"
                eerror "This package requires a Java VM version = $@"
-               einfo "Please use java-config -S to set the correct one"
+               einfo "Please use \"eselect java-vm set system\" to set the 
correct one"
                die "Active Java VM too old"
        fi
 }
@@ -1556,7 +1547,7 @@ java-pkg_ensure-vm-version-ge() {
        if ! java-pkg_is-vm-version-ge "$@" ; then
                debug-print "vm is not suffient"
                eerror "This package requires a Java VM version >= $@"
-               einfo "Please use java-config -S to set the correct one"
+               einfo "Please use \"eselect java-vm set system\" to set the 
correct one"
                die "Active Java VM too old"
        fi
 }
@@ -2916,7 +2907,7 @@ java-pkg_gen-cp() {
 
        local atom
        for atom in ${CP_DEPEND}; do
-               if [[ ${atom} =~ 
/(([[:alnum:]+_-]+)-[0-9]+(\.[0-9]+)*[a-z]?(_[[:alnum:]]+)?(-r[0-9]*)?|[[:alnum:]+_-]+):([[:alnum:]+_.-]+)
 ]]; then
+               if [[ ${atom} =~ 
/(([[:alnum:]+_-]+)-[0-9]+(\.[0-9]+)*[a-z]?(_[[:alnum:]]+)*(-r[0-9]*)?|[[:alnum:]+_-]+):([[:alnum:]+_.-]+)
 ]]; then
                        atom=${BASH_REMATCH[2]:-${BASH_REMATCH[1]}}
                        [[ ${BASH_REMATCH[6]} != 0 ]] && 
atom+=-${BASH_REMATCH[6]}
                        local regex="(^|\s|,)${atom}($|\s|,)"

diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index ebcced39bf..d72329b30a 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -7,6 +7,7 @@
 # @AUTHOR:
 # Author: Michał Górny <[email protected]>
 # Based on work of: Krzysztof Pawlik <[email protected]>
+# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 7
 # @BLURB: Utility functions for packages with Python parts.
 # @DESCRIPTION:
 # A utility eclass providing functions to query Python implementations,

diff --git a/eclass/toolchain-binutils.eclass b/eclass/toolchain-binutils.eclass
index 095e5d196a..6e3a60f357 100644
--- a/eclass/toolchain-binutils.eclass
+++ b/eclass/toolchain-binutils.eclass
@@ -2,6 +2,7 @@
 # Distributed under the terms of the GNU General Public License v2
 #
 # Maintainer: Toolchain Ninjas <[email protected]>
+# @SUPPORTED_EAPIS: 0 1 2 3 4 5
 #
 # We install binutils into CTARGET-VERSION specific directories.  This lets
 # us easily merge multiple versions for multiple targets (if we wish) and
@@ -15,7 +16,6 @@ if [[ -n ${BINUTILS_TYPE} ]] ; then
        BTYPE=${BINUTILS_TYPE}
 else
        case ${PV} in
-       9999)      BTYPE="git";;
        9999_pre*) BTYPE="snap";;
        *.*.90)    BTYPE="snap";;
        *.*.*.*.*) BTYPE="hjlu";;
@@ -24,11 +24,6 @@ else
 fi
 
 case ${BTYPE} in
-git)
-       BVER="git"
-       EGIT_REPO_URI="git://sourceware.org/git/binutils-gdb.git"
-       inherit git-2
-       ;;
 snap)
        BVER=${PV/9999_pre}
        ;;
@@ -58,7 +53,6 @@ DESCRIPTION="Tools necessary to build programs"
 HOMEPAGE="https://sourceware.org/binutils/";
 
 case ${BTYPE} in
-       git) SRC_URI="" ;;
        snap)
                
SRC_URI="ftp://gcc.gnu.org/pub/binutils/snapshots/binutils-${BVER}.tar.bz2
                        
ftp://sourceware.org/pub/binutils/snapshots/binutils-${BVER}.tar.bz2"; ;;
@@ -112,11 +106,7 @@ if is_cross ; then
        DEPEND+=" >=sys-libs/binutils-libs-${PV}"
 fi
 
-S=${WORKDIR}/binutils
-case ${BVER} in
-git) ;;
-*) S=${S}-${BVER} ;;
-esac
+S=${WORKDIR}/binutils-${BVER}
 
 LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${BVER}
 INCPATH=${LIBPATH}/include
@@ -129,10 +119,7 @@ else
 fi
 
 tc-binutils_unpack() {
-       case ${BTYPE} in
-       git) git-2_src_unpack ;;
-       *)   unpacker ${A} ;;
-       esac
+       unpacker ${A}
        mkdir -p "${MY_BUILDDIR}"
        [[ -d ${WORKDIR}/patch ]] && mkdir "${WORKDIR}"/patch/skip
 }

diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass
index 14d7aea8b4..7b82db8e40 100644
--- a/eclass/toolchain-funcs.eclass
+++ b/eclass/toolchain-funcs.eclass
@@ -167,6 +167,17 @@ tc-getBUILD_OBJCOPY() { tc-getBUILD_PROG OBJCOPY objcopy 
"$@"; }
 # @RETURN: name of the pkg-config tool for building binaries to run on the 
build machine
 tc-getBUILD_PKG_CONFIG() { tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"; }
 
+# @FUNCTION: tc-getTARGET_CPP
+# @USAGE: [toolchain prefix]
+# @RETURN: name of the C preprocessor for the toolchain being built (or used)
+tc-getTARGET_CPP() {
+       if [[ -n ${CTARGET} ]]; then
+               _tc-getPROG CTARGET TARGET_CPP "gcc -E" "$@"
+       else
+               tc-getCPP "$@"
+       fi
+}
+
 # @FUNCTION: tc-export
 # @USAGE: <list of toolchain variables>
 # @DESCRIPTION:
@@ -185,6 +196,93 @@ tc-is-cross-compiler() {
        [[ ${CBUILD:-${CHOST}} != ${CHOST} ]]
 }
 
+# @FUNCTION: tc-cpp-is-true
+# @USAGE: <condition> [cpp flags]
+# @RETURN: Shell true if the condition is true, shell false otherwise.
+# @DESCRIPTION:
+# Evaluate the given condition using the C preprocessor for CTARGET, if
+# defined, or CHOST. Additional arguments are passed through to the cpp
+# command. A typical condition would be in the form defined(__FOO__).
+tc-cpp-is-true() {
+       local CONDITION=${1}
+       shift
+
+       local RESULT=$($(tc-getTARGET_CPP) "${@}" -P - <<-EOF 2>/dev/null
+                       #if ${CONDITION}
+                       true
+                       #endif
+               EOF
+       )
+
+       [[ ${RESULT} == true ]]
+}
+
+# @FUNCTION: tc-detect-is-softfloat
+# @RETURN:
+# Shell true if (positive or negative) detection was possible, shell
+# false otherwise. Also outputs a string when detection succeeds, see
+# tc-is-softfloat for the possible values.
+# @DESCRIPTION:
+# Detect whether the CTARGET (or CHOST) toolchain is a softfloat based
+# one by examining the toolchain's output, if possible.
+tc-detect-is-softfloat() {
+       # If fetching CPP falls back to the default (gcc -E) then fail
+       # detection as this may not be the correct toolchain.
+       [[ $(tc-getTARGET_CPP) == "gcc -E" ]] && return 1
+
+       case ${CTARGET:-${CHOST}} in
+               # Avoid autodetection for bare-metal targets. bug #666896
+               *-newlib|*-elf|*-eabi)
+                       return 1 ;;
+
+               # arm-unknown-linux-gnueabi is ambiguous. We used to treat it as
+               # hardfloat but we now treat it as softfloat like most everyone
+               # else. Check existing toolchains to respect existing systems.
+               arm*)
+                       if tc-cpp-is-true "defined(__ARM_PCS_VFP)"; then
+                               echo "no"
+                       else
+                               # Confusingly __SOFTFP__ is defined only when
+                               # -mfloat-abi is soft, not softfp.
+                               if tc-cpp-is-true "defined(__SOFTFP__)"; then
+                                       echo "yes"
+                               else
+                                       echo "softfp"
+                               fi
+                       fi
+
+                       return 0 ;;
+               *)
+                       return 1 ;;
+       esac
+}
+
+# @FUNCTION: tc-tuple-is-softfloat
+# @RETURN: See tc-is-softfloat for the possible values.
+# @DESCRIPTION:
+# Determine whether the CTARGET (or CHOST) toolchain is a softfloat
+# based one solely from the tuple.
+tc-tuple-is-softfloat() {
+       local CTARGET=${CTARGET:-${CHOST}}
+       case ${CTARGET//_/-} in
+               bfin*|h8300*)
+                       echo "only" ;;
+               *-softfloat-*)
+                       echo "yes" ;;
+               *-softfp-*)
+                       echo "softfp" ;;
+               arm*-hardfloat-*|arm*eabihf)
+                       echo "no" ;;
+               # bare-metal targets have their defaults. bug #666896
+               *-newlib|*-elf|*-eabi)
+                       echo "no" ;;
+               arm*)
+                       echo "yes" ;;
+               *)
+                       echo "no" ;;
+       esac
+}
+
 # @FUNCTION: tc-is-softfloat
 # @DESCRIPTION:
 # See if this toolchain is a softfloat based one.
@@ -199,20 +297,7 @@ tc-is-cross-compiler() {
 # softfloat flags in the case where support is optional, but
 # rejects softfloat flags where the target always lacks an fpu.
 tc-is-softfloat() {
-       local CTARGET=${CTARGET:-${CHOST}}
-       case ${CTARGET} in
-               bfin*|h8300*)
-                       echo "only" ;;
-               *)
-                       if [[ ${CTARGET//_/-} == *-softfloat-* ]] ; then
-                               echo "yes"
-                       elif [[ ${CTARGET//_/-} == *-softfp-* ]] ; then
-                               echo "softfp"
-                       else
-                               echo "no"
-                       fi
-                       ;;
-       esac
+       tc-detect-is-softfloat || tc-tuple-is-softfloat
 }
 
 # @FUNCTION: tc-is-static-only
@@ -856,13 +941,7 @@ gcc-specs-stack-check() {
 # Return truth if the current compiler generates position-independent code 
(PIC)
 # which can be linked into executables.
 tc-enables-pie() {
-       local ret="$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> 
/dev/null | grep '^true$'
-               #if defined(__PIE__)
-               true
-               #endif
-               EOF
-       )"
-       [[ ${ret} == true ]]
+       tc-cpp-is-true "defined(__PIE__)" ${CPPFLAGS} ${CFLAGS}
 }
 
 # @FUNCTION: tc-enables-ssp
@@ -874,13 +953,7 @@ tc-enables-pie() {
 #  -fstack-protector-strong
 #  -fstack-protector-all
 tc-enables-ssp() {
-       local ret="$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> 
/dev/null | grep '^true$'
-               #if defined(__SSP__) || defined(__SSP_STRONG__) || 
defined(__SSP_ALL__)
-               true
-               #endif
-               EOF
-       )"
-       [[ ${ret} == true ]]
+       tc-cpp-is-true "defined(__SSP__) || defined(__SSP_STRONG__) || 
defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
 }
 
 # @FUNCTION: tc-enables-ssp-strong
@@ -891,13 +964,7 @@ tc-enables-ssp() {
 #  -fstack-protector-strong
 #  -fstack-protector-all
 tc-enables-ssp-strong() {
-       local ret="$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> 
/dev/null | grep '^true$'
-               #if defined(__SSP_STRONG__) || defined(__SSP_ALL__)
-               true
-               #endif
-               EOF
-       )"
-       [[ ${ret} == true ]]
+       tc-cpp-is-true "defined(__SSP_STRONG__) || defined(__SSP_ALL__)" 
${CPPFLAGS} ${CFLAGS}
 }
 
 # @FUNCTION: tc-enables-ssp-all
@@ -907,13 +974,7 @@ tc-enables-ssp-strong() {
 # on level corresponding to any of the following options:
 #  -fstack-protector-all
 tc-enables-ssp-all() {
-       local ret="$($(tc-getCC) ${CPPFLAGS} ${CFLAGS} -E -P - <<-EOF 2> 
/dev/null | grep '^true$'
-               #if defined(__SSP_ALL__)
-               true
-               #endif
-               EOF
-       )"
-       [[ ${ret} == true ]]
+       tc-cpp-is-true "defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
 }
 
 

diff --git a/eclass/user.eclass b/eclass/user.eclass
deleted file mode 100644
index 83f13f25f4..0000000000
--- a/eclass/user.eclass
+++ /dev/null
@@ -1,469 +0,0 @@
-# Copyright 1999-2017 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-# @ECLASS: user.eclass
-# @MAINTAINER:
-# [email protected] (Linux)
-# @BLURB: user management in ebuilds
-# @DESCRIPTION:
-# The user eclass contains a suite of functions that allow ebuilds
-# to quickly make sure users in the installed system are sane.
-
-if [[ -z ${_USER_ECLASS} ]]; then
-_USER_ECLASS=1
-
-# @FUNCTION: _assert_pkg_ebuild_phase
-# @INTERNAL
-# @USAGE: <calling func name>
-_assert_pkg_ebuild_phase() {
-       case ${EBUILD_PHASE} in
-       setup|preinst|postinst) ;;
-       *)
-               eerror "'$1()' called from '${EBUILD_PHASE}' phase which is not 
OK:"
-               eerror "You may only call from pkg_{setup,preinst,postinst} 
functions."
-               eerror "Package fails at QA and at life.  Please file a bug."
-               die "Bad package!  $1 is only for use in some pkg_* functions!"
-       esac
-}
-
-# @FUNCTION: egetent
-# @USAGE: <database> <key>
-# @DESCRIPTION:
-# Small wrapper for getent (Linux), nidump (< Mac OS X 10.5),
-# dscl (Mac OS X 10.5), and pw (FreeBSD) used in enewuser()/enewgroup().
-#
-# Supported databases: group passwd
-egetent() {
-       local db=$1 key=$2
-
-       [[ $# -ge 3 ]] && die "usage: egetent <database> <key>"
-
-       case ${db} in
-       passwd|group) ;;
-       *) die "sorry, database '${db}' not yet supported; file a bug" ;;
-       esac
-
-       case ${CHOST} in
-       *-darwin[678])
-               case ${key} in
-               *[!0-9]*) # Non numeric
-                       nidump ${db} . | awk -F: "(\$1 ~ /^${key}\$/) 
{print;exit;}"
-                       ;;
-               *)      # Numeric
-                       nidump ${db} . | awk -F: "(\$3 == ${key}) {print;exit;}"
-                       ;;
-               esac
-               ;;
-       *-darwin*)
-               local mykey
-               case ${db} in
-               passwd) db="Users"  mykey="UniqueID" ;;
-               group)  db="Groups" mykey="PrimaryGroupID" ;;
-               esac
-
-               case ${key} in
-               *[!0-9]*) # Non numeric
-                       dscl . -read /${db}/${key} 2>/dev/null |grep RecordName
-                       ;;
-               *)      # Numeric
-                       dscl . -search /${db} ${mykey} ${key} 2>/dev/null
-                       ;;
-               esac
-               ;;
-       *-freebsd*|*-dragonfly*)
-               case ${db} in
-               passwd) db="user" ;;
-               *) ;;
-               esac
-
-               # lookup by uid/gid
-               local opts
-               if [[ ${key} == [[:digit:]]* ]] ; then
-                       [[ ${db} == "user" ]] && opts="-u" || opts="-g"
-               fi
-
-               pw show ${db} ${opts} "${key}" -q
-               ;;
-       *-netbsd*|*-openbsd*)
-               grep "${key}:\*:" /etc/${db}
-               ;;
-       *)
-               # ignore output if nscd doesn't exist, or we're not running as 
root
-               nscd -i "${db}" 2>/dev/null
-               getent "${db}" "${key}"
-               ;;
-       esac
-}
-
-# @FUNCTION: enewuser
-# @USAGE: <user> [uid] [shell] [homedir] [groups]
-# @DESCRIPTION:
-# Same as enewgroup, you are not required to understand how to properly add
-# a user to the system.  The only required parameter is the username.
-# Default uid is (pass -1 for this) next available, default shell is
-# /bin/false, default homedir is /dev/null, and there are no default groups.
-enewuser() {
-       if [[ ${EUID} != 0 ]] ; then
-               einfo "Insufficient privileges to execute ${FUNCNAME[0]}"
-               return 0
-       fi
-       _assert_pkg_ebuild_phase ${FUNCNAME}
-
-       # get the username
-       local euser=$1; shift
-       if [[ -z ${euser} ]] ; then
-               eerror "No username specified !"
-               die "Cannot call enewuser without a username"
-       fi
-
-       # lets see if the username already exists
-       if [[ -n $(egetent passwd "${euser}") ]] ; then
-               return 0
-       fi
-       einfo "Adding user '${euser}' to your system ..."
-
-       # options to pass to useradd
-       local opts=()
-
-       # handle uid
-       local euid=$1; shift
-       if [[ -n ${euid} && ${euid} != -1 ]] ; then
-               if [[ ${euid} -gt 0 ]] ; then
-                       if [[ -n $(egetent passwd ${euid}) ]] ; then
-                               euid="next"
-                       fi
-               else
-                       eerror "Userid given but is not greater than 0 !"
-                       die "${euid} is not a valid UID"
-               fi
-       else
-               euid="next"
-       fi
-       if [[ ${euid} == "next" ]] ; then
-               for ((euid = 101; euid <= 999; euid++)); do
-                       [[ -z $(egetent passwd ${euid}) ]] && break
-               done
-       fi
-       opts+=( -u ${euid} )
-       einfo " - Userid: ${euid}"
-
-       # handle shell
-       local eshell=$1; shift
-       if [[ ! -z ${eshell} ]] && [[ ${eshell} != "-1" ]] ; then
-               if [[ ! -e ${EROOT}${eshell} ]] ; then
-                       eerror "A shell was specified but it does not exist !"
-                       die "${eshell} does not exist in ${EROOT}"
-               fi
-               if [[ ${eshell} == */false || ${eshell} == */nologin ]] ; then
-                       eerror "Do not specify ${eshell} yourself, use -1"
-                       die "Pass '-1' as the shell parameter"
-               fi
-       else
-               for eshell in /sbin/nologin /usr/sbin/nologin /bin/false 
/usr/bin/false /dev/null ; do
-                       [[ -x ${ROOT}${eshell} ]] && break
-               done
-
-               if [[ ${eshell} == "/dev/null" ]] ; then
-                       eerror "Unable to identify the shell to use, proceeding 
with userland default."
-                       case ${USERLAND} in
-                               GNU)    eshell="/bin/false" ;;
-                               BSD)    eshell="/sbin/nologin" ;;
-                               Darwin) eshell="/usr/sbin/nologin" ;;
-                               *) die "Unable to identify the default shell 
for userland ${USERLAND}"
-                       esac
-               fi
-       fi
-       einfo " - Shell: ${eshell}"
-       opts+=( -s "${eshell}" )
-
-       # handle homedir
-       local ehome=$1; shift
-       if [[ -z ${ehome} ]] || [[ ${ehome} == "-1" ]] ; then
-               ehome="/dev/null"
-       fi
-       einfo " - Home: ${ehome}"
-       opts+=( -d "${ehome}" )
-
-       # handle groups
-       local egroups=$1; shift
-       local g egroups_arr
-       IFS="," read -r -a egroups_arr <<<"${egroups}"
-       if [[ ${#egroups_arr[@]} -gt 0 ]] ; then
-               local defgroup exgroups
-               for g in "${egroups_arr[@]}" ; do
-                       if [[ -z $(egetent group "${g}") ]] ; then
-                               eerror "You must add group ${g} to the system 
first"
-                               die "${g} is not a valid GID"
-                       fi
-                       if [[ -z ${defgroup} ]] ; then
-                               defgroup=${g}
-                       else
-                               exgroups+=",${g}"
-                       fi
-               done
-               opts+=( -g "${defgroup}" )
-               if [[ ! -z ${exgroups} ]] ; then
-                       opts+=( -G "${exgroups:1}" )
-               fi
-       fi
-       einfo " - Groups: ${egroups:-(none)}"
-
-       # handle extra args
-       if [[ $# -gt 0 ]] ; then
-               die "extra arguments no longer supported; please file a bug"
-       else
-               local comment="added by portage for ${PN}"
-               opts+=( -c "${comment}" )
-               einfo " - GECOS: ${comment}"
-       fi
-
-       # add the user
-       case ${CHOST} in
-       *-darwin*)
-               ### Make the user
-               dscl . create "/users/${euser}" uid ${euid}
-               dscl . create "/users/${euser}" shell "${eshell}"
-               dscl . create "/users/${euser}" home "${ehome}"
-               dscl . create "/users/${euser}" realname "added by portage for 
${PN}"
-               ### Add the user to the groups specified
-               for g in "${egroups_arr[@]}" ; do
-                       dscl . merge "/groups/${g}" users "${euser}"
-               done
-               ;;
-
-       *-freebsd*|*-dragonfly*)
-               pw useradd "${euser}" "${opts[@]}" || die
-               ;;
-
-       *-netbsd*)
-               useradd "${opts[@]}" "${euser}" || die
-               ;;
-
-       *-openbsd*)
-               # all ops the same, except the -g vs -g/-G ...
-               useradd -u ${euid} -s "${eshell}" \
-                       -d "${ehome}" -g "${egroups}" "${euser}" || die
-               ;;
-
-       *)
-               useradd -r "${opts[@]}" "${euser}" || die
-               ;;
-       esac
-
-       if [[ ! -e ${EROOT}/${ehome} ]] ; then
-               einfo " - Creating ${ehome} in ${EROOT}"
-               mkdir -p "${EROOT}/${ehome}"
-               chown "${euser}" "${EROOT}/${ehome}"
-               chmod 755 "${EROOT}/${ehome}"
-       fi
-}
-
-# @FUNCTION: enewgroup
-# @USAGE: <group> [gid]
-# @DESCRIPTION:
-# This function does not require you to understand how to properly add a
-# group to the system.  Just give it a group name to add and enewgroup will
-# do the rest.  You may specify the gid for the group or allow the group to
-# allocate the next available one.
-enewgroup() {
-       if [[ ${EUID} != 0 ]] ; then
-               einfo "Insufficient privileges to execute ${FUNCNAME[0]}"
-               return 0
-       fi
-       _assert_pkg_ebuild_phase ${FUNCNAME}
-
-       # get the group
-       local egroup=$1; shift
-       if [[ -z ${egroup} ]] ; then
-               eerror "No group specified !"
-               die "Cannot call enewgroup without a group"
-       fi
-
-       # see if group already exists
-       if [[ -n $(egetent group "${egroup}") ]] ; then
-               return 0
-       fi
-       einfo "Adding group '${egroup}' to your system ..."
-
-       # handle gid
-       local egid=$1; shift
-       if [[ ! -z ${egid} ]] ; then
-               if [[ ${egid} -gt 0 ]] ; then
-                       if [[ -n $(egetent group ${egid}) ]] ; then
-                               egid="next available; requested gid taken"
-                       fi
-               else
-                       eerror "Groupid given but is not greater than 0 !"
-                       die "${egid} is not a valid GID"
-               fi
-       else
-               egid="next available"
-       fi
-       einfo " - Groupid: ${egid}"
-
-       # handle extra
-       if [[ $# -gt 0 ]] ; then
-               die "extra arguments no longer supported; please file a bug"
-       fi
-
-       # Some targets need to find the next available GID manually
-       _enewgroup_next_gid() {
-               if [[ ${egid} == *[!0-9]* ]] ; then
-                       # Non numeric
-                       for ((egid = 101; egid <= 999; egid++)) ; do
-                               [[ -z $(egetent group ${egid}) ]] && break
-                       done
-               fi
-       }
-
-       # add the group
-       case ${CHOST} in
-       *-darwin*)
-               _enewgroup_next_gid
-               dscl . create "/groups/${egroup}" gid ${egid}
-               dscl . create "/groups/${egroup}" passwd '*'
-               ;;
-
-       *-freebsd*|*-dragonfly*)
-               _enewgroup_next_gid
-               pw groupadd "${egroup}" -g ${egid} || die
-               ;;
-
-       *-netbsd*)
-               _enewgroup_next_gid
-               groupadd -g ${egid} "${egroup}" || die
-               ;;
-
-       *)
-               local opts
-               if [[ ${egid} == *[!0-9]* ]] ; then
-                       # Non numeric; let groupadd figure out a GID for us
-                       opts=""
-               else
-                       opts="-g ${egid}"
-               fi
-               # We specify -r so that we get a GID in the system range from 
login.defs
-               groupadd -r ${opts} "${egroup}" || die
-               ;;
-       esac
-}
-
-# @FUNCTION: egethome
-# @USAGE: <user>
-# @DESCRIPTION:
-# Gets the home directory for the specified user.
-egethome() {
-       local pos
-
-       [[ $# -eq 1 ]] || die "usage: egethome <user>"
-
-       case ${CHOST} in
-       *-darwin*|*-freebsd*|*-dragonfly*)
-               pos=9
-               ;;
-       *)      # Linux, NetBSD, OpenBSD, etc...
-               pos=6
-               ;;
-       esac
-
-       egetent passwd "$1" | cut -d: -f${pos}
-}
-
-# @FUNCTION: egetshell
-# @USAGE: <user>
-# @DESCRIPTION:
-# Gets the shell for the specified user.
-egetshell() {
-       local pos
-
-       [[ $# -eq 1 ]] || die "usage: egetshell <user>"
-
-       case ${CHOST} in
-       *-darwin*|*-freebsd*|*-dragonfly*)
-               pos=10
-               ;;
-       *)      # Linux, NetBSD, OpenBSD, etc...
-               pos=7
-               ;;
-       esac
-
-       egetent passwd "$1" | cut -d: -f${pos}
-}
-
-# @FUNCTION: esethome
-# @USAGE: <user> <homedir>
-# @DESCRIPTION:
-# Update the home directory in a platform-agnostic way.
-# Required parameters is the username and the new home directory.
-# Specify -1 if you want to set home to the enewuser default
-# of /dev/null.
-# If the new home directory does not exist, it is created.
-# Any previously existing home directory is NOT moved.
-esethome() {
-       _assert_pkg_ebuild_phase ${FUNCNAME}
-
-       # get the username
-       local euser=$1; shift
-       if [[ -z ${euser} ]] ; then
-               eerror "No username specified !"
-               die "Cannot call esethome without a username"
-       fi
-
-       # lets see if the username already exists
-       if [[ -z $(egetent passwd "${euser}") ]] ; then
-               ewarn "User does not exist, cannot set home dir -- skipping."
-               return 1
-       fi
-
-       # handle homedir
-       local ehome=$1; shift
-       if [[ -z ${ehome} ]] ; then
-               eerror "No home directory specified !"
-               die "Cannot call esethome without a home directory or '-1'"
-       fi
-
-       if [[ ${ehome} == "-1" ]] ; then
-               ehome="/dev/null"
-       fi
-
-       # exit with no message if home dir is up to date
-       if [[ $(egethome "${euser}") == ${ehome} ]]; then
-               return 0
-       fi
-
-       einfo "Updating home for user '${euser}' ..."
-       einfo " - Home: ${ehome}"
-
-       # ensure home directory exists, otherwise update will fail
-       if [[ ! -e ${EROOT}/${ehome} ]] ; then
-               einfo " - Creating ${ehome} in ${EROOT}"
-               mkdir -p "${EROOT}/${ehome}"
-               chown "${euser}" "${EROOT}/${ehome}"
-               chmod 755 "${EROOT}/${ehome}"
-       fi
-
-       # update the home directory
-       case ${CHOST} in
-       *-darwin*)
-               dscl . change "/users/${euser}" home "${ehome}"
-               ;;
-
-       *-freebsd*|*-dragonfly*)
-               pw usermod "${euser}" -d "${ehome}" && return 0
-               [[ $? == 8 ]] && eerror "${euser} is in use, cannot update home"
-               eerror "There was an error when attempting to update the home 
directory for ${euser}"
-               eerror "Please update it manually on your system:"
-               eerror "\t pw usermod \"${euser}\" -d \"${ehome}\""
-               ;;
-
-       *)
-               usermod -d "${ehome}" "${euser}" && return 0
-               [[ $? == 8 ]] && eerror "${euser} is in use, cannot update home"
-               eerror "There was an error when attempting to update the home 
directory for ${euser}"
-               eerror "Please update it manually on your system (as root):"
-               eerror "\t usermod -d \"${ehome}\" \"${euser}\""
-               ;;
-       esac
-}
-
-fi

Reply via email to