declare -x ABI="amd64"
declare -x ABI_MIPS=""
declare -x ABI_PPC=""
declare -x ABI_S390=""
declare -x ABI_X86="64"
declare -x ALSA_CARDS=""
declare -x APACHE2_MODULES=""
declare -x APACHE2_MPMS=""
declare -x ARCH="amd64"
declare -- ARCHIVE_URI="https://github.com/jirwin/burrow_exporter/archive/v0.0.6.tar.gz -> burrow_exporter-0.0.6.tar.gz"
declare BDEPEND=""
declare -x BOOTSTRAP_USE="cxx unicode internal-glib split-usr python_targets_python3_6 python_targets_python2_7 multilib"
declare -x CALLIGRA_EXPERIMENTAL_FEATURES=""
declare -x CALLIGRA_FEATURES=""
declare -x CAMERAS=""
declare -x CATKIN_PREFIX_PATH="/usr"
declare -x CBUILD="x86_64-pc-linux-gnu"
declare -x CFLAGS="-O2 -pipe -march=native"
declare -x CFLAGS_amd64="-m64"
declare -x CFLAGS_x32="-mx32"
declare -x CFLAGS_x86="-m32"
declare -x CHOST="x86_64-pc-linux-gnu"
declare -x CHOST_amd64="x86_64-pc-linux-gnu"
declare -x CHOST_x32="x86_64-pc-linux-gnux32"
declare -x CHOST_x86="i686-pc-linux-gnu"
declare -x COLLECTD_PLUGINS=""
declare -x CPU_FLAGS_ARM=""
declare -x CPU_FLAGS_X86=""
declare -x CURL_SSL=""
declare -x CXXFLAGS="-O2 -pipe -march=native"
declare -x DEFAULT_ABI="amd64"
declare -x DEFINED_PHASES=" compile install prepare setup test unpack"
declare DEPEND=">=dev-lang/go-1.9"
declare DESCRIPTION="Prometheus exporter for Burrow"
declare -x DESTTREE="/usr"
declare -x DIROPTIONS="-m0755"
declare -x EAPI="6"
declare -x EGO_BUILD_FLAGS="-p 1"
declare -- EGO_PN="github.com/jirwin/burrow_exporter"
declare -a EGO_VENDOR=([0]="github.com/beorn7/perks 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9" [1]="github.com/golang/protobuf 2bba0603135d7d7f5cb73b2125beeda19c09f4ef" [2]="github.com/matttproud/golang_protobuf_extensions c12348ce28de40eed0136aa2b644d0ee0650e56c" [3]="github.com/prometheus/client_golang 42552c195dd3f3089fbf9cf26e139da150af35aa" [4]="github.com/prometheus/client_model 6f3806018612930941127f2a7c6c453ba2c527d2" [5]="github.com/prometheus/common 13ba4ddd0caa9c28ca7b7bffe1dfa9ed8d5ef207" [6]="github.com/prometheus/procfs 65c1f6f8f0fc1e2185eb9863a3bc751496404259" [7]="github.com/Sirupsen/logrus ba1b36c82c5e05c4f912a88eab0dcd91a171688f" [8]="github.com/urfave/cli ab403a54a148f2d857920810291539e1f817ee7b")
declare -- EGO_VENDOR_URI=" https://github.com/beorn7/perks/archive/4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9.tar.gz -> github.com-beorn7-perks-4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9.tar.gz https://github.com/golang/protobuf/archive/2bba0603135d7d7f5cb73b2125beeda19c09f4ef.tar.gz -> github.com-golang-protobuf-2bba0603135d7d7f5cb73b2125beeda19c09f4ef.tar.gz https://github.com/matttproud/golang_protobuf_extensions/archive/c12348ce28de40eed0136aa2b644d0ee0650e56c.tar.gz -> github.com-matttproud-golang_protobuf_extensions-c12348ce28de40eed0136aa2b644d0ee0650e56c.tar.gz https://github.com/prometheus/client_golang/archive/42552c195dd3f3089fbf9cf26e139da150af35aa.tar.gz -> github.com-prometheus-client_golang-42552c195dd3f3089fbf9cf26e139da150af35aa.tar.gz https://github.com/prometheus/client_model/archive/6f3806018612930941127f2a7c6c453ba2c527d2.tar.gz -> github.com-prometheus-client_model-6f3806018612930941127f2a7c6c453ba2c527d2.tar.gz https://github.com/prometheus/common/archive/13ba4ddd0caa9c28ca7b7bffe1dfa9ed8d5ef207.tar.gz -> github.com-prometheus-common-13ba4ddd0caa9c28ca7b7bffe1dfa9ed8d5ef207.tar.gz https://github.com/prometheus/procfs/archive/65c1f6f8f0fc1e2185eb9863a3bc751496404259.tar.gz -> github.com-prometheus-procfs-65c1f6f8f0fc1e2185eb9863a3bc751496404259.tar.gz https://github.com/Sirupsen/logrus/archive/ba1b36c82c5e05c4f912a88eab0dcd91a171688f.tar.gz -> github.com-Sirupsen-logrus-ba1b36c82c5e05c4f912a88eab0dcd91a171688f.tar.gz https://github.com/urfave/cli/archive/ab403a54a148f2d857920810291539e1f817ee7b.tar.gz -> github.com-urfave-cli-ab403a54a148f2d857920810291539e1f817ee7b.tar.gz"
declare -x ELIBC="glibc"
declare -x ENLIGHTENMENT_MODULES=""
declare -x ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
declare -x EXEOPTIONS="-m0755"
declare -- EXPORTER_COMMIT="01f0ef9"
declare -x FCFLAGS="-O2 -pipe"
declare -x FETCHCOMMAND_SSH="bash -c \"x=\\\${2#ssh://} ; host=\\\${x%%/*} ; port=\\\${host##*:} ; host=\\\${host%:*} ; [[ \\\${host} = \\\${port} ]] && port= ; exec rsync --rsh=\\\"ssh \\\${port:+-p\\\${port}} \\\${3}\\\" -avP \\\"\\\${host}:/\\\${x#*/}\\\" \\\"\\\$1\\\"\" rsync \"\${DISTDIR}/\${FILE}\" \"\${URI}\" \"\${PORTAGE_SSH_OPTS}\""
declare -x FFLAGS="-O2 -pipe"
declare -x FFTOOLS=""
declare -x GCC_COLORS=""
declare -x GCC_SPECS=""
declare -x GO19CONCURRENTCOMPILATION="0"
declare -x GOMAXPROCS="1"
declare -x GPSD_PROTOCOLS=""
declare -x GREP_COLORS="never"
declare -x GRUB_PLATFORMS=""
declare HDEPEND=""
declare HOMEPAGE="https://github.com/jirwin/burrow_exporter"
declare -x INHERITED=" user golang-base golang-build golang-vcs-snapshot"
declare -x INPUT_DEVICES=""
declare -x INSDESTTREE=""
declare -x INSOPTIONS="-m0644"
declare IUSE=""
declare -x IUSE_EFFECTIVE="abi_x86_64 alpha amd64 amd64-fbsd amd64-linux arm arm-linux arm64 elibc_AIX elibc_Cygwin elibc_Darwin elibc_DragonFly elibc_FreeBSD elibc_HPUX elibc_Interix elibc_NetBSD elibc_OpenBSD elibc_SunOS elibc_Winnt elibc_bionic elibc_glibc elibc_mingw elibc_mintlib elibc_musl elibc_uclibc hppa ia64 kernel_AIX kernel_Darwin kernel_FreeBSD kernel_HPUX kernel_NetBSD kernel_OpenBSD kernel_SunOS kernel_Winnt kernel_freemint kernel_linux m68k m68k-mint mips ppc ppc-aix ppc-macos ppc64 ppc64-linux prefix prefix-chain prefix-guest s390 sh sparc sparc-solaris sparc64-solaris userland_BSD userland_GNU x64-cygwin x64-macos x64-solaris x86 x86-cygwin x86-fbsd x86-linux x86-macos x86-solaris x86-winnt"
declare -x IUSE_IMPLICIT="abi_x86_64 prefix prefix-chain prefix-guest"
declare -x KERNEL="linux"
declare -x KEYWORDS="~amd64"
declare -x L10N=""
declare -x LANG="en_US.UTF-8"
declare -x LCD_DEVICES=""
declare -x LC_COLLATE="C"
declare -x LC_MESSAGES="C"
declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed"
declare -x LDFLAGS_amd64="-m elf_x86_64"
declare -x LDFLAGS_x32="-m elf32_x86_64"
declare -x LDFLAGS_x86="-m elf_i386"
declare -x LIBDIR_amd64="lib64"
declare -x LIBDIR_x32="libx32"
declare -x LIBDIR_x86="lib32"
declare -x LIBOPTIONS="-m0644"
declare -x LIBREOFFICE_EXTENSIONS=""
declare -x LICENSE="Apache-2.0"
declare -x LIRC_DEVICES=""
declare -x LLVM_TARGETS=""
declare -x MAKEOPTS="-j1"
declare -x MANPAGER="manpager"
declare -x MONKEYD_PLUGINS=""
declare -x MULTILIB_ABIS="amd64 x86"
declare -x MULTILIB_STRICT_DENY="64-bit.*shared object"
declare -x MULTILIB_STRICT_DIRS="/lib32 /lib /usr/lib32 /usr/lib /usr/kde/*/lib32 /usr/kde/*/lib /usr/qt/*/lib32 /usr/qt/*/lib /usr/X11R6/lib32 /usr/X11R6/lib"
declare -x MULTILIB_STRICT_EXEMPT="(perl5|gcc|gcc-lib|binutils|eclipse-3|debug|portage|udev|systemd|clang|python-exec|llvm)"
declare -x NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
declare -x NETBEANS_MODULES=""
declare -x NGINX_MODULES_HTTP=""
declare -x NGINX_MODULES_MAIL=""
declare -x NGINX_MODULES_STREAM=""
declare -x NINJAFLAGS="-j1"
declare -x OFED_DRIVERS=""
declare -x OFFICE_IMPLEMENTATION=""
declare -x OPENGL_PROFILE="xorg-x11"
declare -x OPENMPI_FABRICS=""
declare -x OPENMPI_OFED_FEATURES=""
declare -x OPENMPI_RM=""
declare -x PATH="/usr/lib/portage/python3.6/ebuild-helpers/xattr:/usr/lib/portage/python3.6/ebuild-helpers:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/7.3.0:/usr/lib/llvm/6/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin"
declare -x PAX_MARKINGS="none"
declare PDEPEND=""
declare -x PHP_TARGETS=""
declare -x PKG_CONFIG_PATH="/usr/lib64/pkgconfig"
declare -x PORTAGE_COMPRESSION_COMMAND="bzip2"
declare -a PORTAGE_DOCOMPRESS=([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")
declare -x PORTAGE_DOCOMPRESS_SIZE_LIMIT="128"
declare -a PORTAGE_DOCOMPRESS_SKIP=([0]="/usr/share/doc/burrow_exporter-0.0.6/html")
declare -a PORTAGE_DOSTRIP=([0]="/")
declare -a PORTAGE_DOSTRIP_SKIP=()
declare -x POSTGRES_TARGETS=""
declare -x PROFILE_ONLY_VARIABLES="ARCH ELIBC IUSE_IMPLICIT KERNEL USERLAND USE_EXPAND_IMPLICIT USE_EXPAND_UNPREFIXED USE_EXPAND_VALUES_ARCH USE_EXPAND_VALUES_ELIBC USE_EXPAND_VALUES_KERNEL USE_EXPAND_VALUES_USERLAND"
declare -x PROPERTIES=""
declare -x PYTHONDONTWRITEBYTECODE="1"
declare -x PYTHON_SINGLE_TARGET=""
declare -x PYTHON_TARGETS=""
declare -- QA_FLAGS_IGNORED=".*"
declare -x QEMU_SOFTMMU_TARGETS=""
declare -x QEMU_USER_TARGETS=""
declare RDEPEND=""
declare REPOSITORY
declare REQUIRED_USE=""
declare -x RESTRICT=""
declare -x RESUMECOMMAND_SSH="bash -c \"x=\\\${2#ssh://} ; host=\\\${x%%/*} ; port=\\\${host##*:} ; host=\\\${host%:*} ; [[ \\\${host} = \\\${port} ]] && port= ; exec rsync --rsh=\\\"ssh \\\${port:+-p\\\${port}} \\\${3}\\\" -avP \\\"\\\${host}:/\\\${x#*/}\\\" \\\"\\\$1\\\"\" rsync \"\${DISTDIR}/\${FILE}\" \"\${URI}\" \"\${PORTAGE_SSH_OPTS}\""
declare -x ROS_MESSAGES=""
declare -x ROS_PACKAGE_PATH="/usr/share/ros_packages"
declare -x ROS_ROOT="/usr/share/ros"
declare -x RUBY_TARGETS=""
declare -x RUSTFLAGS="-C codegen-units=1"
declare -x RUST_TEST_TASKS="1"
declare -x RUST_TEST_THREADS="1"
declare -x S="/var/tmp/portage/app-metrics/burrow_exporter-0.0.6/work/burrow_exporter-0.0.6"
declare -x SANDBOX_DEBUG="0"
declare -x SANDBOX_DENY=""
declare -x SANDBOX_PREDICT="/var/tmp/portage/app-metrics/burrow_exporter-0.0.6/homedir:/var/cache/fontconfig"
declare -x SANDBOX_READ="/:/var/tmp"
declare -x SANDBOX_VERBOSE="1"
declare -x SANDBOX_WRITE=":/dev/console:/dev/fd:/dev/full:/dev/null:/dev/ptmx:/dev/pts/:/dev/pty:/dev/shm:/dev/tts:/dev/tty:/dev/vc/:/dev/zero:/proc/self/fd:/tmp/:/usr/lib/cf:/usr/lib/conftest:/usr/lib32/cf:/usr/lib32/conftest:/usr/lib64/cf:/usr/lib64/conftest:/usr/tmp/cf:/usr/tmp/conftest:/var/tmp:/var/tmp/:/var/tmp/portage/app-metrics/burrow_exporter-0.0.6/homedir/.bash_history"
declare -x SANE_BACKENDS=""
declare -x SHELL="/bin/bash"
declare -x SLOT="0"
declare SRC_URI="https://github.com/jirwin/burrow_exporter/archive/v0.0.6.tar.gz -> burrow_exporter-0.0.6.tar.gz
	 https://github.com/beorn7/perks/archive/4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9.tar.gz -> github.com-beorn7-perks-4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9.tar.gz https://github.com/golang/protobuf/archive/2bba0603135d7d7f5cb73b2125beeda19c09f4ef.tar.gz -> github.com-golang-protobuf-2bba0603135d7d7f5cb73b2125beeda19c09f4ef.tar.gz https://github.com/matttproud/golang_protobuf_extensions/archive/c12348ce28de40eed0136aa2b644d0ee0650e56c.tar.gz -> github.com-matttproud-golang_protobuf_extensions-c12348ce28de40eed0136aa2b644d0ee0650e56c.tar.gz https://github.com/prometheus/client_golang/archive/42552c195dd3f3089fbf9cf26e139da150af35aa.tar.gz -> github.com-prometheus-client_golang-42552c195dd3f3089fbf9cf26e139da150af35aa.tar.gz https://github.com/prometheus/client_model/archive/6f3806018612930941127f2a7c6c453ba2c527d2.tar.gz -> github.com-prometheus-client_model-6f3806018612930941127f2a7c6c453ba2c527d2.tar.gz https://github.com/prometheus/common/archive/13ba4ddd0caa9c28ca7b7bffe1dfa9ed8d5ef207.tar.gz -> github.com-prometheus-common-13ba4ddd0caa9c28ca7b7bffe1dfa9ed8d5ef207.tar.gz https://github.com/prometheus/procfs/archive/65c1f6f8f0fc1e2185eb9863a3bc751496404259.tar.gz -> github.com-prometheus-procfs-65c1f6f8f0fc1e2185eb9863a3bc751496404259.tar.gz https://github.com/Sirupsen/logrus/archive/ba1b36c82c5e05c4f912a88eab0dcd91a171688f.tar.gz -> github.com-Sirupsen-logrus-ba1b36c82c5e05c4f912a88eab0dcd91a171688f.tar.gz https://github.com/urfave/cli/archive/ab403a54a148f2d857920810291539e1f817ee7b.tar.gz -> github.com-urfave-cli-ab403a54a148f2d857920810291539e1f817ee7b.tar.gz"
declare -- STRIP_MASK="*.a"
declare -x SYMLINK_LIB="yes"
declare -x SYSROOT=""
declare -x TWISTED_DISABLE_WRITING_OF_PLUGIN_CACHE="1"
declare -x USE="abi_x86_64 amd64 elibc_glibc kernel_linux userland_GNU"
declare -x USERLAND="GNU"
declare -x USE_EXPAND_IMPLICIT="ARCH ELIBC KERNEL USERLAND"
declare -x USE_EXPAND_UNPREFIXED="ARCH"
declare -x USE_EXPAND_VALUES_ARCH="alpha amd64 amd64-fbsd amd64-linux arm arm-linux arm64 hppa ia64 m68k m68k-mint mips ppc ppc64 ppc64-linux ppc-aix ppc-macos s390 sh sparc sparc64-solaris sparc-solaris x64-cygwin x64-macos x64-solaris x86 x86-cygwin x86-fbsd x86-linux x86-macos x86-solaris x86-winnt"
declare -x USE_EXPAND_VALUES_ELIBC="AIX bionic Cygwin Darwin DragonFly FreeBSD glibc HPUX Interix mingw mintlib musl NetBSD OpenBSD SunOS uclibc Winnt"
declare -x USE_EXPAND_VALUES_KERNEL="AIX Darwin FreeBSD freemint HPUX linux NetBSD OpenBSD SunOS Winnt"
declare -x USE_EXPAND_VALUES_USERLAND="BSD GNU"
declare -x UWSGI_PLUGINS=""
declare -x VIDEO_CARDS=""
declare -x VOICEMAIL_STORAGE=""
declare -x XDG_CACHE_HOME="/root/cache"
declare -x XDG_CONFIG_HOME="/root/config"
declare -x XDG_DATA_HOME="/root/share"
declare -x XDG_DESKTOP_DIR="/root/Desktop"
declare -x XDG_DOCUMENTS_DIR="/root/Documents"
declare -x XDG_DOWNLOAD_DIR="/root/Downloads"
declare -x XDG_MUSIC_DIR="/root/Music"
declare -x XDG_PICTURES_DIR="/root/Pictures"
declare -x XDG_PUBLICSHARE_DIR="/root/Public"
declare -x XDG_RUNTIME_DIR="/root/run"
declare -x XDG_TEMPLATES_DIR="/root/Templates"
declare -x XDG_VIDEOS_DIR="/root/Videos"
declare -x XFCE_PLUGINS=""
declare -x XTABLES_ADDONS=""
declare -x _E_DOCDESTTREE_=""
declare -x _E_EXEDESTTREE_=""
declare -- _GOLANG_BASE="1"
declare -- _GOLANG_BUILD="1"
declare -- _USER_ECLASS="1"
declare -- phase_func
__eapi6_src_install () 
{ 
    if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
        emake DESTDIR="${D}" install;
    fi;
    einstalldocs
}
__eapi6_src_prepare () 
{ 
    if [[ $(declare -p PATCHES 2>/dev/null) == "declare -a"* ]]; then
        [[ ${#PATCHES[@]} -gt 0 ]] && eapply "${PATCHES[@]}";
    else
        if [[ -n ${PATCHES} ]]; then
            eapply ${PATCHES};
        fi;
    fi;
    eapply_user
}
_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
}
_enewgroup_next_gid () 
{ 
    if [[ ${egid} == *[!0-9]* ]]; then
        for ((egid = 101; egid <= 999; egid++))
        do
            [[ -z $(egetent group ${egid}) ]] && break;
        done;
    fi
}
_golang-vcs-snapshot_dovendor () 
{ 
    local VENDOR_PATH=$1 VENDORPN=$2 TARBALL=$3;
    rm -fr "${VENDOR_PATH}/${VENDORPN}" || die;
    mkdir -p "${VENDOR_PATH}/${VENDORPN}" || die;
    tar -C "${VENDOR_PATH}/${VENDORPN}" -x --strip-components 1 -f "${DISTDIR}"/${TARBALL} || die
}
eapply () 
{ 
    local failed patch_cmd=patch;
    local -x LC_COLLATE=POSIX;
    type -P gpatch > /dev/null && patch_cmd=gpatch;
    function _eapply_patch () 
    { 
        local f=${1};
        local prefix=${2};
        started_applying=1;
        ebegin "${prefix:-Applying }${f##*/}";
        ${patch_cmd} -p1 -f -s -g0 --no-backup-if-mismatch "${patch_options[@]}" < "${f}";
        failed=${?};
        if ! eend "${failed}"; then
            __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
        fi
    };
    local patch_options=() files=();
    local i found_doublehyphen;
    for ((i = 1; i <= ${#@}; ++i ))
    do
        if [[ ${@:i:1} == -- ]]; then
            patch_options=("${@:1:i-1}");
            files=("${@:i+1}");
            found_doublehyphen=1;
            break;
        fi;
    done;
    if [[ -z ${found_doublehyphen} ]]; then
        for ((i = 1; i <= ${#@}; ++i ))
        do
            if [[ ${@:i:1} != -* ]]; then
                patch_options=("${@:1:i-1}");
                files=("${@:i}");
                break;
            fi;
        done;
        for i in "${files[@]}";
        do
            if [[ ${i} == -* ]]; then
                die "eapply: all options must be passed before non-options";
            fi;
        done;
    fi;
    if [[ ${#files[@]} -eq 0 ]]; then
        die "eapply: no files specified";
    fi;
    local f;
    for f in "${files[@]}";
    do
        if [[ -d ${f} ]]; then
            function _eapply_get_files () 
            { 
                local LC_ALL=POSIX;
                local prev_shopt=$(shopt -p nullglob);
                shopt -s nullglob;
                local f;
                for f in "${1}"/*;
                do
                    if [[ ${f} == *.diff || ${f} == *.patch ]]; then
                        files+=("${f}");
                    fi;
                done;
                ${prev_shopt}
            };
            local files=();
            _eapply_get_files "${f}";
            [[ ${#files[@]} -eq 0 ]] && die "No *.{patch,diff} files in directory ${f}";
            einfo "Applying patches from ${f} ...";
            local f2;
            for f2 in "${files[@]}";
            do
                _eapply_patch "${f2}" '  ';
                [[ ${failed} -ne 0 ]] && return "${failed}";
            done;
        else
            _eapply_patch "${f}";
            [[ ${failed} -ne 0 ]] && return "${failed}";
        fi;
    done;
    return 0
}
eapply_user () 
{ 
    [[ ${EBUILD_PHASE} == prepare ]] || die "eapply_user() called during invalid phase: ${EBUILD_PHASE}";
    local tagfile=${T}/.portage_user_patches_applied;
    [[ -f ${tagfile} ]] && return;
     >> "${tagfile}";
    local basedir=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
    local applied d f;
    local -A _eapply_user_patches;
    local prev_shopt=$(shopt -p nullglob);
    shopt -s nullglob;
    for d in "${basedir}"/${CATEGORY}/{${P}-${PR},${P},${PN}}{:${SLOT%/*},};
    do
        for f in "${d}"/*;
        do
            if [[ ( ${f} == *.diff || ${f} == *.patch ) && -z ${_eapply_user_patches[${f##*/}]} ]]; then
                _eapply_user_patches[${f##*/}]=${f};
            fi;
        done;
    done;
    if [[ ${#_eapply_user_patches[@]} -gt 0 ]]; then
        while read -r -d '' f; do
            f=${_eapply_user_patches[${f}]};
            if [[ -s ${f} ]]; then
                eapply "${f}";
                applied=1;
            fi;
        done < <(printf -- '%s\0' "${!_eapply_user_patches[@]}" |
				LC_ALL=C sort -z);
    fi;
    ${prev_shopt};
    [[ -n ${applied} ]] && ewarn "User patches applied."
}
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]*)
                    nidump ${db} . | awk -F: "(\$1 ~ /^${key}\$/) {print;exit;}"
                ;;
                *)
                    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]*)
                    dscl . -read /${db}/${key} 2> /dev/null | grep RecordName
                ;;
                *)
                    dscl . -search /${db} ${mykey} ${key} 2> /dev/null
                ;;
            esac
        ;;
        *-freebsd* | *-dragonfly*)
            case ${db} in 
                passwd)
                    db="user"
                ;;
                *)

                ;;
            esac;
            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}
        ;;
        *)
            nscd -i "${db}" 2> /dev/null;
            getent "${db}" "${key}"
        ;;
    esac
}
egethome () 
{ 
    local pos;
    [[ $# -eq 1 ]] || die "usage: egethome <user>";
    case ${CHOST} in 
        *-darwin* | *-freebsd* | *-dragonfly*)
            pos=9
        ;;
        *)
            pos=6
        ;;
    esac;
    egetent passwd "$1" | cut -d: -f${pos}
}
egetshell () 
{ 
    local pos;
    [[ $# -eq 1 ]] || die "usage: egetshell <user>";
    case ${CHOST} in 
        *-darwin* | *-freebsd* | *-dragonfly*)
            pos=10
        ;;
        *)
            pos=7
        ;;
    esac;
    egetent passwd "$1" | cut -d: -f${pos}
}
ego_pn_check () 
{ 
    [[ -z "${EGO_PN}" ]] && die "${ECLASS}.eclass: EGO_PN is not set";
    return 0
}
einstalldocs () 
{ 
    ( if ! declare -p DOCS &> /dev/null; then
        local d;
        for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS FAQ CREDITS CHANGELOG;
        do
            [[ -f ${d} && -s ${d} ]] && docinto / && dodoc "${d}";
        done;
    else
        if [[ $(declare -p DOCS) == "declare -a"* ]]; then
            [[ ${#DOCS[@]} -gt 0 ]] && docinto / && dodoc -r "${DOCS[@]}";
        else
            [[ -n ${DOCS} ]] && docinto / && dodoc -r ${DOCS};
        fi;
    fi );
    ( if [[ $(declare -p HTML_DOCS 2>/dev/null) == "declare -a"* ]]; then
        [[ ${#HTML_DOCS[@]} -gt 0 ]] && docinto html && dodoc -r "${HTML_DOCS[@]}";
    else
        [[ -n ${HTML_DOCS} ]] && docinto html && dodoc -r ${HTML_DOCS};
    fi )
}
enewgroup () 
{ 
    if [[ ${EUID} != 0 ]]; then
        einfo "Insufficient privileges to execute ${FUNCNAME[0]}";
        return 0;
    fi;
    _assert_pkg_ebuild_phase ${FUNCNAME};
    local egroup=$1;
    shift;
    if [[ -z ${egroup} ]]; then
        eerror "No group specified !";
        die "Cannot call enewgroup without a group";
    fi;
    if [[ -n $(egetent group "${egroup}") ]]; then
        return 0;
    fi;
    einfo "Adding group '${egroup}' to your system ...";
    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}";
    if [[ $# -gt 0 ]]; then
        die "extra arguments no longer supported; please file a bug";
    fi;
    function _enewgroup_next_gid () 
    { 
        if [[ ${egid} == *[!0-9]* ]]; then
            for ((egid = 101; egid <= 999; egid++))
            do
                [[ -z $(egetent group ${egid}) ]] && break;
            done;
        fi
    };
    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
                opts="";
            else
                opts="-g ${egid}";
            fi;
            groupadd -r ${opts} "${egroup}" || die
        ;;
    esac
}
enewuser () 
{ 
    if [[ ${EUID} != 0 ]]; then
        einfo "Insufficient privileges to execute ${FUNCNAME[0]}";
        return 0;
    fi;
    _assert_pkg_ebuild_phase ${FUNCNAME};
    local euser=$1;
    shift;
    if [[ -z ${euser} ]]; then
        eerror "No username specified !";
        die "Cannot call enewuser without a username";
    fi;
    if [[ -n $(egetent passwd "${euser}") ]]; then
        return 0;
    fi;
    einfo "Adding user '${euser}' to your system ...";
    local opts=();
    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}";
    local eshell=$1;
    shift;
    if [[ ! -z ${eshell} ]] && [[ ${eshell} != "-1" ]]; then
        if [[ ! -e ${ROOT}${eshell} ]]; then
            eerror "A shell was specified but it does not exist !";
            die "${eshell} does not exist in ${ROOT}";
        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}");
    local ehome=$1;
    shift;
    if [[ -z ${ehome} ]] || [[ ${ehome} == "-1" ]]; then
        ehome="/dev/null";
    fi;
    einfo " - Home: ${ehome}";
    opts+=(-d "${ehome}");
    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)}";
    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;
    case ${CHOST} in 
        *-darwin*)
            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}";
            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*)
            useradd -u ${euid} -s "${eshell}" -d "${ehome}" -g "${egroups}" "${euser}" || die
        ;;
        *)
            useradd -r "${opts[@]}" "${euser}" || die
        ;;
    esac;
    if [[ ! -e ${ROOT}/${ehome} ]]; then
        einfo " - Creating ${ehome} in ${ROOT}";
        mkdir -p "${ROOT}/${ehome}";
        chown "${euser}" "${ROOT}/${ehome}";
        chmod 755 "${ROOT}/${ehome}";
    fi
}
esethome () 
{ 
    _assert_pkg_ebuild_phase ${FUNCNAME};
    local euser=$1;
    shift;
    if [[ -z ${euser} ]]; then
        eerror "No username specified !";
        die "Cannot call esethome without a username";
    fi;
    if [[ -z $(egetent passwd "${euser}") ]]; then
        ewarn "User does not exist, cannot set home dir -- skipping.";
        return 1;
    fi;
    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;
    if [[ $(egethome "${euser}") == ${ehome} ]]; then
        return 0;
    fi;
    einfo "Updating home for user '${euser}' ...";
    einfo " - Home: ${ehome}";
    if [[ ! -e ${ROOT}/${ehome} ]]; then
        einfo " - Creating ${ehome} in ${ROOT}";
        mkdir -p "${ROOT}/${ehome}";
        chown "${euser}" "${ROOT}/${ehome}";
        chmod 755 "${ROOT}/${ehome}";
    fi;
    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
}
get_golibdir () 
{ 
    echo /usr/lib/go-gentoo
}
get_golibdir_gopath () 
{ 
    echo "${EPREFIX}$(get_golibdir)"
}
get_libdir () 
{ 
    local libdir_var="LIBDIR_${ABI}";
    local libdir="lib";
    [[ -n ${ABI} && -n ${!libdir_var} ]] && libdir=${!libdir_var};
    echo "${libdir}"
}
golang-build_src_compile () 
{ 
    debug-print-function ${FUNCNAME} "$@";
    ego_pn_check;
    set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" go build -v -work -x ${EGO_BUILD_FLAGS} "${EGO_PN}";
    echo "$@";
    "$@" || die
}
golang-build_src_install () 
{ 
    debug-print-function ${FUNCNAME} "$@";
    ego_pn_check;
    set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" go install -v -work -x ${EGO_BUILD_FLAGS} "${EGO_PN}";
    echo "$@";
    "$@" || die;
    golang_install_pkgs
}
golang-build_src_test () 
{ 
    debug-print-function ${FUNCNAME} "$@";
    ego_pn_check;
    set -- env GOPATH="${WORKDIR}/${P}:$(get_golibdir_gopath)" go test -v -work -x "${EGO_PN}";
    echo "$@";
    "$@" || die
}
golang-vcs-snapshot_src_unpack () 
{ 
    local lib vendor_path x;
    ego_pn_check;
    set -- ${A};
    x="$1";
    mkdir -p "${WORKDIR}/${P}/src/${EGO_PN%/...}" || die;
    tar -C "${WORKDIR}/${P}/src/${EGO_PN%/...}" -x --strip-components 1 -f "${DISTDIR}/${x}" || die;
    if [[ -n "${EGO_VENDOR}" ]]; then
        vendor_path="${WORKDIR}/${P}/src/${EGO_PN%/...}/vendor";
        mkdir -p "${vendor_path}" || die;
        for lib in "${EGO_VENDOR[@]}";
        do
            lib=(${lib});
            if [[ -n ${lib[2]} ]]; then
                einfo "Vendoring ${lib[0]} ${lib[2]//\//-}-${lib[1]}.tar.gz";
                _golang-vcs-snapshot_dovendor "${vendor_path}" ${lib[0]} ${lib[2]//\//-}-${lib[1]}.tar.gz;
            else
                einfo "Vendoring ${lib[0]} ${lib[0]//\//-}-${lib[1]}.tar.gz";
                _golang-vcs-snapshot_dovendor "${vendor_path}" ${lib[0]} ${lib[0]//\//-}-${lib[1]}.tar.gz;
            fi;
        done;
    fi
}
golang_install_pkgs () 
{ 
    debug-print-function ${FUNCNAME} "$@";
    ego_pn_check;
    insinto "$(get_golibdir)";
    insopts -m0644 -p;
    doins -r pkg src
}
in_iuse () 
{ 
    local use=${1};
    if [[ -z "${use}" ]]; then
        echo "!!! in_iuse() called without a parameter." 1>&2;
        echo "!!! in_iuse <USEFLAG>" 1>&2;
        die "in_iuse() called without a parameter";
    fi;
    local liuse=(${IUSE_EFFECTIVE});
    has "${use}" "${liuse[@]#[+-]}"
}
pkg_nofetch () 
{ 
    default
}
pkg_setup () 
{ 
    enewgroup ${PN};
    enewuser ${PN} -1 -1 -1 ${PN}
}
src_compile () 
{ 
    pushd src/${EGO_PN} || die;
    GOPATH="${S}" go build -v -o bin/burrow_exporter || die;
    popd || die
}
src_configure () 
{ 
    default
}
src_install () 
{ 
    pushd src/${EGO_PN} || die;
    dobin bin/burrow_exporter;
    dodoc {README,CHANGELOG}.md;
    popd || die;
    keepdir /var/log/mongodb_exporter;
    fowners ${PN}:${PN} /var/log/mongodb_exporter;
    newinitd "${FILESDIR}"/${PN}.initd ${PN};
    newconfd "${FILESDIR}"/${PN}.confd ${PN}
}
src_prepare () 
{ 
    default;
    sed -i -e "s/0.0.4/${PV}/" src/${EGO_PN}/burrow-exporter.go || die
}
src_test () 
{ 
    golang-build_src_test "$@"
}
src_unpack () 
{ 
    golang-vcs-snapshot_src_unpack "$@"
}