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 ANT_HOME="/usr/share/ant" declare -x APACHE2_MODULES="" declare -x APACHE2_MPMS="" declare -x ARCH="amd64" declare -- ARCHIVE_URI="https://github.com/kumina/openvpn_exporter/archive/0.2.1.tar.gz -> openvpn_exporter-0.2.1.tar.gz" declare BDEPEND="" declare -x BOOTSTRAP_USE="unicode internal-glib pkg-config split-usr python_targets_python3_6 python_targets_python2_7 multilib systemd udev" 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 DEBUGBUILD="1" declare -x DEFAULT_ABI="amd64" declare -x DEFINED_PHASES=" compile install setup test unpack" declare DEPEND=">=dev-lang/go-1.10" declare DESCRIPTION="Prometheus Exporter for OpenVPN" declare -x DESTTREE="/usr" declare -x DIROPTIONS="-m0755" declare -x EAPI="6" declare -x EGO_BUILD_FLAGS="-p 1" declare -- EGO_PN="github.com/kumina/openvpn_exporter" declare -a EGO_VENDOR=([0]="github.com/prometheus/client_golang f504d69affe11ec1ccb2e5948127f86878c9fd57" [1]="github.com/beorn7/perks 3a771d992973f24aa725d07868b467d1ddfceafb" [2]="github.com/golang/protobuf e09c5db296004fbe3f74490e84dcd62c3c5ddb1b" [3]="github.com/prometheus/client_model 99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c" [4]="github.com/prometheus/common 38c53a9f4bfcd932d1b00bfc65e256a7fba6b37a" [5]="github.com/matttproud/golang_protobuf_extensions c12348ce28de40eed0136aa2b644d0ee0650e56c" [6]="github.com/prometheus/procfs 780932d4fbbe0e69b84c34c20f5c8d0981e109ea") declare -- EGO_VENDOR_URI=" https://github.com/prometheus/client_golang/archive/f504d69affe11ec1ccb2e5948127f86878c9fd57.tar.gz -> github.com-prometheus-client_golang-f504d69affe11ec1ccb2e5948127f86878c9fd57.tar.gz https://github.com/beorn7/perks/archive/3a771d992973f24aa725d07868b467d1ddfceafb.tar.gz -> github.com-beorn7-perks-3a771d992973f24aa725d07868b467d1ddfceafb.tar.gz https://github.com/golang/protobuf/archive/e09c5db296004fbe3f74490e84dcd62c3c5ddb1b.tar.gz -> github.com-golang-protobuf-e09c5db296004fbe3f74490e84dcd62c3c5ddb1b.tar.gz https://github.com/prometheus/client_model/archive/99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c.tar.gz -> github.com-prometheus-client_model-99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c.tar.gz https://github.com/prometheus/common/archive/38c53a9f4bfcd932d1b00bfc65e256a7fba6b37a.tar.gz -> github.com-prometheus-common-38c53a9f4bfcd932d1b00bfc65e256a7fba6b37a.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/procfs/archive/780932d4fbbe0e69b84c34c20f5c8d0981e109ea.tar.gz -> github.com-prometheus-procfs-780932d4fbbe0e69b84c34c20f5c8d0981e109ea.tar.gz" declare -x ELIBC="glibc" declare -x ENLIGHTENMENT_MODULES="" declare -x ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN 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 -- EPOCHREALTIME="1555351397.077621" declare -- EPOCHSECONDS="1555351397" declare -x EXEOPTIONS="-m0755" 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 FLTK_DOCDIR="/usr/share/doc/fltk-1.3.5/html" declare -x GCC_COLORS="" declare -x GCC_SPECS="" declare -x GO19CONCURRENTCOMPILATION="0" declare -x GOMAXPROCS="1" declare -- GO_DEPEND=">=dev-lang/go-1.10" declare -x GPSD_PROTOCOLS="" declare -x GREP_COLORS="never" declare -x GRUB_PLATFORMS="" declare -x GSETTINGS_BACKEND="dconf" declare HDEPEND="" declare HOMEPAGE="https://github.com/kumina/openvpn_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 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-guest prefix-stack 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-guest prefix-stack" declare -x JAVAC="/etc/java-config-2/current-system-vm/bin/javac" declare -x JAVA_HOME="/etc/java-config-2/current-system-vm" declare -x JDK_HOME="/etc/java-config-2/current-system-vm" 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 LE_CONFIG_HOME="/etc/acme-sh/" declare -x LE_WORKING_DIR="/etc/acme-sh/" declare -x LIBDIR_amd64="lib64" declare -x LIBDIR_x32="libx32" declare -x LIBDIR_x86="lib" 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_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/lib/llvm/8/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/openvpn_exporter-0.2.1/html") declare -a PORTAGE_DOSTRIP=() declare -a PORTAGE_DOSTRIP_SKIP=() declare -x PORT_LOGDIR="/var/log/portage" 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="strip" 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/openvpn_exporter-0.2.1/work/openvpn_exporter-0.2.1" declare -x SANDBOX_DEBUG="0" declare -x SANDBOX_DENY="" declare -x SANDBOX_PREDICT="/var/tmp/portage/app-metrics/openvpn_exporter-0.2.1/homedir:/dev/crypto:/var/cache/man:/proc/self/coredump_filter:/var/cache/fontconfig" declare -x SANDBOX_READ="/:/var/tmp/portage" 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/portage:/var/tmp/portage/app-metrics/openvpn_exporter-0.2.1/homedir/.bash_history" declare -x SANE_BACKENDS="" declare -x SGML_CATALOG_FILES="/etc/sgml/openjade-1.3.2.cat:/etc/sgml/sgml-ent.cat:/etc/sgml/xml-docbook-4.1.2.cat:/etc/sgml/xml-docbook-4.2.cat:/etc/sgml/xml-docbook-4.5.cat:/etc/sgml/xml-docbook-4.4.cat:/etc/sgml/sgml-docbook.cat:/etc/sgml/xml-docbook-4.3.cat:/etc/sgml/sgml-docbook-3.0.cat:/etc/sgml/dsssl-docbook-stylesheets.cat:/etc/sgml/sgml-docbook-3.1.cat:/etc/sgml/sgml-lite.cat:/etc/sgml/sgml-docbook-4.0.cat:/etc/sgml/sgml-docbook-4.2.cat:/etc/sgml/sgml-docbook-4.4.cat:/etc/sgml/sgml-docbook-4.1.cat:/etc/sgml/xml-simple-docbook-4.1.2.4.cat:/etc/sgml/xml-simple-docbook-1.0.cat" declare -x SHELL="/bin/bash" declare -x SLOT="0" declare SRC_URI="https://github.com/kumina/openvpn_exporter/archive/0.2.1.tar.gz -> openvpn_exporter-0.2.1.tar.gz https://github.com/prometheus/client_golang/archive/f504d69affe11ec1ccb2e5948127f86878c9fd57.tar.gz -> github.com-prometheus-client_golang-f504d69affe11ec1ccb2e5948127f86878c9fd57.tar.gz https://github.com/beorn7/perks/archive/3a771d992973f24aa725d07868b467d1ddfceafb.tar.gz -> github.com-beorn7-perks-3a771d992973f24aa725d07868b467d1ddfceafb.tar.gz https://github.com/golang/protobuf/archive/e09c5db296004fbe3f74490e84dcd62c3c5ddb1b.tar.gz -> github.com-golang-protobuf-e09c5db296004fbe3f74490e84dcd62c3c5ddb1b.tar.gz https://github.com/prometheus/client_model/archive/99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c.tar.gz -> github.com-prometheus-client_model-99fa1f4be8e564e8a6b613da7fa6f46c9edafc6c.tar.gz https://github.com/prometheus/common/archive/38c53a9f4bfcd932d1b00bfc65e256a7fba6b37a.tar.gz -> github.com-prometheus-common-38c53a9f4bfcd932d1b00bfc65e256a7fba6b37a.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/procfs/archive/780932d4fbbe0e69b84c34c20f5c8d0981e109ea.tar.gz -> github.com-prometheus-procfs-780932d4fbbe0e69b84c34c20f5c8d0981e109ea.tar.gz" declare -x SYMLINK_LIB="no" 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 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_DIRS="/etc/xdg" declare -x XDG_CONFIG_HOME="/root/config" declare -x XDG_DATA_DIRS="/usr/local/share:/usr/share" 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 XERCESC_NLS_HOME="/usr/share/xerces-c/msg" 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 "; 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} ;; *) type -p nscd > /dev/null && nscd -i "${db}" 2> /dev/null; getent "${db}" "${key}" ;; esac } egethome () { local pos; [[ $# -eq 1 ]] || die "usage: egethome "; 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 "; 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)" GOCACHE="${T}/go-cache" 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 " 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} } rc_compile () { pushd src/${EGO_PN} || die; GOPATH="${S}" go build -v -o ${PN} || die; popd || die } src_compile () { golang-build_src_compile "$@" } src_configure () { default } src_install () { dobin ${PN}; dodoc src/${EGO_PN}/{CHANGELOG,README}.md; local dir; for dir in /var/{lib,log}/${PN}; do keepdir "${dir}"; fowners ${PN}:${PN} "${dir}"; done; newinitd "${FILESDIR}"/${PN}.initd ${PN}; newconfd "${FILESDIR}"/${PN}.confd ${PN}; insinto /etc/logrotate.d; newins "${FILESDIR}/${PN}.logrotated" "${PN}" } src_prepare () { default } src_test () { golang-build_src_test "$@" } src_unpack () { golang-vcs-snapshot_src_unpack "$@" }