Advertisement
Guest User

/mnt/extended/Portage/build64Pure/portage/sys-apps/net-tools

a guest
Jun 23rd, 2014
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 85.86 KB | None | 0 0
  1. declare -x ABI="amd64"
  2. declare -x ABI_X86="64"
  3. declare -x ALSA_CARDS=""
  4. declare -x APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias"
  5. declare -x AR="x86_64-pc-linux-gnu-ar"
  6. declare -x ARCH="amd64"
  7. declare -x BASEDIR="/mnt/extended/Portage"
  8. declare -x BOOTSTRAP_USE="cxx unicode internal-glib python_targets_python3_3 python_targets_python2_7 multilib multilib"
  9. declare -x CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author"
  10. declare -x CAMERAS="ptp2"
  11. declare -x CBUILD="x86_64-pc-linux-gnu"
  12. declare -x CC="x86_64-pc-linux-gnu-gcc"
  13. declare -x CFLAGS="-march=athlon64-sse3 -mtune=k8 -mcx16 -msahf -mmmx -msse -msse2 -msse3 -m3dnow -O2 -pipe -fomit-frame-pointer"
  14. declare -x CFLAGS_amd64="-m64"
  15. declare -x CFLAGS_default
  16. declare -x CFLAGS_x32="-mx32"
  17. declare -x CFLAGS_x86="-m32"
  18. declare -x CHOST="x86_64-pc-linux-gnu"
  19. declare -x CHOST_amd64="x86_64-pc-linux-gnu"
  20. declare -x CHOST_default="x86_64-pc-linux-gnu"
  21. declare -x CHOST_x32="x86_64-pc-linux-gnux32"
  22. declare -x CHOST_x86="i686-pc-linux-gnu"
  23. declare -x COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog"
  24. declare -x CTARGET_default="x86_64-pc-linux-gnu"
  25. declare -x CXXFLAGS="-march=athlon64-sse3 -mtune=k8 -mcx16 -msahf -mmmx -msse -msse2 -msse3 -m3dnow -O2 -pipe -fomit-frame-pointer"
  26. declare -x DEFAULT_ABI="amd64"
  27. declare -x DEFINED_PHASES=" configure install postinst prepare setup"
  28. declare DEPEND="!<sys-apps/openrc-0.9.9.3
  29.     selinux? ( sys-libs/libselinux )
  30.     selinux? ( virtual/pkgconfig )
  31.     app-arch/xz-utils "
  32. declare DESCRIPTION="Standard Linux networking tools"
  33. declare -x DESTTREE="/usr"
  34. declare -x DIROPTIONS="-m0755"
  35. declare -x EAPI="3"
  36. declare -x ELIBC="glibc"
  37. declare -- EPATCH_COMMON_OPTS="-g0 -E --no-backup-if-mismatch"
  38. declare -- EPATCH_EXCLUDE="0001-revert-621a2f376334f8097604b9fee5783e0f1141e66d-for-.patch"
  39. declare -- EPATCH_FORCE="no"
  40. declare -- EPATCH_MULTI_MSG="Applying various patches (bugfixes/updates) ..."
  41. declare -- EPATCH_OPTS=""
  42. declare -- EPATCH_SINGLE_MSG=""
  43. declare -- EPATCH_SOURCE="/mnt/extended/Portage/build64Pure/portage/sys-apps/net-tools-1.60_p20130513023548/work/patch"
  44. declare -- EPATCH_SUFFIX="patch.bz2"
  45. declare -x EXEOPTIONS="-m0755"
  46. declare -x FCFLAGS="-O2 -pipe"
  47. declare -x FETCHCOMMAND_SSH="bash -c \"x=\\\${2#ssh://} ; host=\\\${x%%/*} ; port=\\\${host##*:} ; host=\\\${host%:*} ; [[ \\\${host} = \\\${port} ]] && port=22 ; exec rsync --rsh=\\\"ssh -p\\\${port} \\\${3}\\\" -avP \\\"\\\${host}:/\\\${x#*/}\\\" \\\"\\\$1\\\"\" rsync \"\${DISTDIR}/\${FILE}\" \"\${URI}\" \"\${PORTAGE_SSH_OPTS}\""
  48. declare -x FFLAGS="-O2 -pipe"
  49. declare -x GCC_SPECS=""
  50. declare -x GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx"
  51. declare -x GRUB_PLATFORMS=""
  52. declare -x GSETTINGS_BACKEND="dconf"
  53. declare HDEPEND=""
  54. declare -x HG="/usr/bin/hg"
  55. declare HOMEPAGE="http://net-tools.sourceforge.net/"
  56. declare -x HW="smp sse sse2 sse3 3dnow mmx -bluetooth -dvd"
  57. declare -x INHERITED=" multilib toolchain-funcs eutils flag-o-matic"
  58. declare -x INPUT_DEVICES="evdev"
  59. declare -x INSDESTTREE=""
  60. declare -x INSOPTIONS="-m0644"
  61. declare IUSE="nls old-output selinux static "
  62. declare -x IUSE_IMPLICIT="prefix"
  63. declare -x JAVAC="/etc/java-config-2/current-system-vm/bin/javac"
  64. declare -x JAVA_HOME="/etc/java-config-2/current-system-vm"
  65. declare -x JDK_HOME="/etc/java-config-2/current-system-vm"
  66. declare -x KERNEL="linux"
  67. declare -x KERNEL_ABI="amd64"
  68. declare -x KEYWORDS="~alpha amd64 arm arm64 hppa ia64 m68k ~mips ~ppc ~ppc64 s390 sh ~sparc x86 ~amd64-linux ~x86-linux"
  69. declare -x KV="3.14.4-ck"
  70. declare -x LCD_DEVICES=""
  71. declare -x LC_MESSAGES="C"
  72. declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed"
  73. declare -x LDFLAGS_amd64="-m elf_x86_64"
  74. declare -x LDFLAGS_default
  75. declare -x LDFLAGS_x32="-m elf32_x86_64"
  76. declare -x LDFLAGS_x86="-m elf_i386"
  77. declare -x LIBDIR_amd64="lib64"
  78. declare -x LIBDIR_amd64_fbsd="lib64"
  79. declare -x LIBDIR_arm="lib"
  80. declare -x LIBDIR_arm64="lib64"
  81. declare -x LIBDIR_default="lib"
  82. declare -x LIBDIR_n32="lib32"
  83. declare -x LIBDIR_n64="lib64"
  84. declare -x LIBDIR_o32="lib"
  85. declare -x LIBDIR_ppc="lib32"
  86. declare -x LIBDIR_ppc64="lib64"
  87. declare -x LIBDIR_s390="lib32"
  88. declare -x LIBDIR_s390x="lib64"
  89. declare -x LIBDIR_sparc32="lib32"
  90. declare -x LIBDIR_sparc64="lib64"
  91. declare -x LIBDIR_x32="libx32"
  92. declare -x LIBDIR_x86="lib32"
  93. declare -x LIBDIR_x86_fbsd="lib32"
  94. declare -x LIBOPTIONS="-m0644"
  95. declare -x LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer"
  96. declare -x LICENSE="GPL-2"
  97. declare -x MAKEOPTS="-j3"
  98. declare -x MULTILIB_ABIS="amd64"
  99. declare -x MULTILIB_STRICT_DENY="64-bit.*shared object"
  100. 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"
  101. declare -x MULTILIB_STRICT_EXEMPT="(perl5|gcc|gcc-lib|binutils|eclipse-3|debug|portage|udev|systemd|clang|python-exec)"
  102. declare -x MULTIOSDIRS="../lib64"
  103. declare -x NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
  104. declare -x OFFICE_IMPLEMENTATION="libreoffice"
  105. declare -x OPENCL_PROFILE="nvidia"
  106. declare -x OPENGL_PROFILE="nvidia"
  107. declare -x OPTIMIZATION="custom-cflags custom-optimization lightweight"
  108. declare -- PATCH_VER="1"
  109. declare -x PATH="/usr/lib64/portage/bin/ebuild-helpers:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.7.3:/bin/custom:/sbin/custom:."
  110. declare PDEPEND=""
  111. declare -x PHP_TARGETS=""
  112. declare -x PKG_CONFIG_PATH="/usr/lib64/pkgconfig"
  113. declare -a PORTAGE_DOCOMPRESS='([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")'
  114. declare -x PORTAGE_DOCOMPRESS_SIZE_LIMIT="128"
  115. declare -a PORTAGE_DOCOMPRESS_SKIP='([0]="/usr/share/doc/net-tools-1.60_p20130513023548/html")'
  116. declare -x PRELINK_PATH_MASK="/usr/lib64/klibc:/usr/lib64/libfreebl3.so:/usr/lib64/libnssdbm3.so:/usr/lib64/libsoftokn3.so"
  117. 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"
  118. declare -x PROPERTIES=""
  119. declare -x PROVIDE=""
  120. declare -x PYTHONDONTWRITEBYTECODE="1"
  121. declare -x PYTHON_SINGLE_TARGET=""
  122. declare -x PYTHON_TARGETS=""
  123. declare -x QEMU_SOFTMMU_TARGETS="arm i386 x86_64"
  124. declare -x QEMU_USER_TARGETS="arm armeb i386 x86_64"
  125. declare -x QT_GRAPHICSSYSTEM="raster"
  126. declare -x RDEPEND="!<sys-apps/openrc-0.9.9.3
  127.     selinux? ( sys-libs/libselinux ) "
  128. declare REPOSITORY
  129. declare REQUIRED_USE=""
  130. declare -x RESTRICT=""
  131. declare -x RESUMECOMMAND_SSH="bash -c \"x=\\\${2#ssh://} ; host=\\\${x%%/*} ; port=\\\${host##*:} ; host=\\\${host%:*} ; [[ \\\${host} = \\\${port} ]] && port=22 ; exec rsync --rsh=\\\"ssh -p\\\${port} \\\${3}\\\" -avP \\\"\\\${host}:/\\\${x#*/}\\\" \\\"\\\$1\\\"\" rsync \"\${DISTDIR}/\${FILE}\" \"\${URI}\" \"\${PORTAGE_SSH_OPTS}\""
  132. declare -x RUBYOPT="-rauto_gem"
  133. declare -x RUBY_TARGETS=""
  134. declare -x S="/mnt/extended/Portage/build64Pure/portage/sys-apps/net-tools-1.60_p20130513023548/work/net-tools-1.60_p20130513023548"
  135. declare -x SANDBOX_DEBUG="0"
  136. declare -x SANDBOX_DENY=""
  137. declare -x SANDBOX_PID="11062"
  138. declare -x SANDBOX_PREDICT="/mnt/extended/Portage/build64Pure/portage/sys-apps/net-tools-1.60_p20130513023548/homedir:/dev/crypto:/proc/self/coredump_filter:/dev/random:/proc/self/coredump_filter:/var/cache/fontconfig"
  139. declare -x SANDBOX_READ="/:/mnt/extended/Portage/build64Pure"
  140. declare -x SANDBOX_VERBOSE="1"
  141. declare -x SANDBOX_WRITE=":/dev/console:/dev/fd:/dev/full:/dev/null:/dev/pts/:/dev/pty:/dev/shm:/dev/tts:/dev/tty:/dev/vc/:/dev/zero:/mnt/extended/Portage/build64Pure:/mnt/extended/Portage/build64Pure/portage/sys-apps/net-tools-1.60_p20130513023548/homedir/.bash_history:/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/"
  142. declare -x SHELL="/bin/bash"
  143. declare -x SLOT="0"
  144. declare SRC_URI="mirror://gentoo/net-tools-1.60_p20130513023548.tar.xz
  145.         mirror://gentoo/net-tools-1.60_p20130513023548-patches-1.tar.xz"
  146. declare -x SYMLINK_LIB="yes"
  147. declare -x USE="abi_x86_64 amd64 elibc_glibc kernel_linux nls userland_GNU"
  148. declare -x USERLAND="GNU"
  149. declare -x USE_EXPAND_IMPLICIT="ARCH ELIBC KERNEL USERLAND"
  150. declare -x USE_EXPAND_UNPREFIXED="ARCH"
  151. declare -x USE_EXPAND_VALUES_ARCH="alpha amd64 amd64-fbsd amd64-linux arm arm-linux arm64 hppa hppa-hpux ia64 ia64-hpux ia64-linux m68k m68k-mint mips ppc ppc64 ppc64-linux ppc-aix ppc-macos ppc-openbsd s390 sh sparc sparc64-freebsd sparc64-solaris sparc-fbsd sparc-solaris x64-freebsd x64-macos x64-openbsd x64-solaris x86 x86-cygwin x86-fbsd x86-freebsd x86-interix x86-linux x86-macos x86-netbsd x86-openbsd x86-solaris x86-winnt"
  152. declare -x USE_EXPAND_VALUES_ELIBC="AIX Cygwin Darwin DragonFly FreeBSD glibc HPUX Interix mintlib musl NetBSD OpenBSD SunOS uclibc Winnt"
  153. declare -x USE_EXPAND_VALUES_KERNEL="AIX Cygwin Darwin FreeBSD freemint HPUX Interix linux NetBSD OpenBSD SunOS Winnt"
  154. declare -x USE_EXPAND_VALUES_USERLAND="BSD GNU"
  155. declare -x VBOX_APP_HOME="/opt/VirtualBox"
  156. declare -x VIDEO_CARDS=""
  157. declare -x XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
  158. declare -x _E_DOCDESTTREE_=""
  159. declare -x _E_EXEDESTTREE_=""
  160. declare -a __ESTACK_eshopts__='()'
  161. declare -a __ESTACK_evar__='()'
  162. declare -- ___ECLASS_ONCE_EUTILS="recur -_+^+_- spank"
  163. declare -- ___ECLASS_ONCE_FLAG_O_MATIC="recur -_+^+_- spank"
  164. declare -- ___ECLASS_ONCE_MULTILIB="recur -_+^+_- spank"
  165. declare -- ___ECLASS_ONCE_TOOLCHAIN_FUNCS="recur -_+^+_- spank"
  166. declare -- phase_func
  167. __bashpid ()
  168. {
  169.     sh -c 'echo ${PPID}'
  170. }
  171. _epatch_draw_line ()
  172. {
  173.     [[ -z $1 ]] && set "$(printf "%65s" '')";
  174.     echo "${1//?/=}"
  175. }
  176. _eutils_eprefix_init ()
  177. {
  178.     has "${EAPI:-0}" 0 1 2 && : ${ED:=${D}} ${EPREFIX:=} ${EROOT:=${ROOT}}
  179. }
  180. _filter-hardened ()
  181. {
  182.     local f;
  183.     for f in "$@";
  184.     do
  185.         case "${f}" in
  186.             -fPIC | -fpic | -fPIE | -fpie | -Wl,pie | -pie)
  187.                 gcc-specs-pie || continue;
  188.                 is-flagq -nopie || append-flags -nopie
  189.             ;;
  190.             -fstack-protector)
  191.                 gcc-specs-ssp || continue;
  192.                 is-flagq -fno-stack-protector || append-flags $(test-flags -fno-stack-protector)
  193.             ;;
  194.             -fstack-protector-all)
  195.                 gcc-specs-ssp-to-all || continue;
  196.                 is-flagq -fno-stack-protector-all || append-flags $(test-flags -fno-stack-protector-all)
  197.             ;;
  198.             -fno-strict-overflow)
  199.                 gcc-specs-nostrict || continue;
  200.                 is-flagq -fstrict-overflow || append-flags $(test-flags -fstrict-overflow)
  201.             ;;
  202.         esac;
  203.     done
  204. }
  205. _filter-var ()
  206. {
  207.     local f x var=$1 new=();
  208.     shift;
  209.     for f in ${!var};
  210.     do
  211.         for x in "$@";
  212.         do
  213.             [[ ${f} == ${x} ]] && continue 2;
  214.         done;
  215.         new+=("${f}");
  216.     done;
  217.     eval export ${var}=\""${new[*]}"\"
  218. }
  219. _gcc-install-dir ()
  220. {
  221.     echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null |      awk '$1=="install:" {print $2}')"
  222. }
  223. _gcc-specs-directive_raw ()
  224. {
  225.     local cc=$(tc-getCC);
  226.     local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  227.     ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  228. $1=="*"directive":"  { pspec=spec; spec=""; outside=0; next }
  229.     outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  230.     spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  231.     { spec=spec $0 }
  232. END { print spec }';
  233.     return 0
  234. }
  235. _gcc-specs-exists ()
  236. {
  237.     [[ -f $(_gcc-install-dir)/$1 ]]
  238. }
  239. _gcc_fullversion ()
  240. {
  241.     local ver="$1";
  242.     shift;
  243.     set -- `$(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__"`;
  244.     eval echo "$ver"
  245. }
  246. _iconins ()
  247. {
  248.     ( local funcname=$1;
  249.     shift;
  250.     local size dir;
  251.     local context=apps;
  252.     local theme=hicolor;
  253.     while [[ $# -gt 0 ]]; do
  254.         case $1 in
  255.             -s | --size)
  256.                 if [[ ${2%%x*}x${2%%x*} == "$2" ]]; then
  257.                     size=${2%%x*};
  258.                 else
  259.                     size=${2};
  260.                 fi;
  261.                 case ${size} in
  262.                     16 | 22 | 24 | 32 | 36 | 48 | 64 | 72 | 96 | 128 | 192 | 256)
  263.                         size=${size}x${size}
  264.                     ;;
  265.                     scalable)
  266.  
  267.                     ;;
  268.                     *)
  269.                         eerror "${size} is an unsupported icon size!";
  270.                         exit 1
  271.                     ;;
  272.                 esac;
  273.                 shift 2
  274.             ;;
  275.             -t | --theme)
  276.                 theme=${2};
  277.                 shift 2
  278.             ;;
  279.             -c | --context)
  280.                 context=${2};
  281.                 shift 2
  282.             ;;
  283.             *)
  284.                 if [[ -z ${size} ]]; then
  285.                     insinto /usr/share/pixmaps;
  286.                 else
  287.                     insinto /usr/share/icons/${theme}/${size}/${context};
  288.                 fi;
  289.                 if [[ ${funcname} == doicon ]]; then
  290.                     if [[ -f $1 ]]; then
  291.                         doins "${1}";
  292.                     else
  293.                         if [[ -d $1 ]]; then
  294.                             shopt -s nullglob;
  295.                             doins "${1}"/*.{png,svg};
  296.                             shopt -u nullglob;
  297.                         else
  298.                             eerror "${1} is not a valid file/directory!";
  299.                             exit 1;
  300.                         fi;
  301.                     fi;
  302.                 else
  303.                     break;
  304.                 fi;
  305.                 shift 1
  306.             ;;
  307.         esac;
  308.     done;
  309.     if [[ ${funcname} == newicon ]]; then
  310.         newins "$@";
  311.     fi ) || die
  312. }
  313. _is_flagq ()
  314. {
  315.     local x var;
  316.     eval var=\""\${$1[*]}"\";
  317.     for x in ${var};
  318.     do
  319.         [[ ${x} == $2 ]] && return 0;
  320.     done;
  321.     return 1
  322. }
  323. _tc-getPROG ()
  324. {
  325.     local tuple=$1;
  326.     local v var vars=$2;
  327.     local prog=$3;
  328.     var=${vars%% *};
  329.     for v in ${vars};
  330.     do
  331.         if [[ -n ${!v} ]]; then
  332.             export ${var}="${!v}";
  333.             echo "${!v}";
  334.             return 0;
  335.         fi;
  336.     done;
  337.     local search=;
  338.     [[ -n $4 ]] && search=$(type -p "$4-${prog}");
  339.     [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p "${!tuple}-${prog}");
  340.     [[ -n ${search} ]] && prog=${search##*/};
  341.     export ${var}=${prog};
  342.     echo "${!var}"
  343. }
  344. all-flag-vars ()
  345. {
  346.     echo {C,CPP,CXX,CCAS,F,FC,LD}FLAGS
  347. }
  348. append-cflags ()
  349. {
  350.     [[ $# -eq 0 ]] && return 0;
  351.     export CFLAGS+=" $*";
  352.     return 0
  353. }
  354. append-cppflags ()
  355. {
  356.     [[ $# -eq 0 ]] && return 0;
  357.     export CPPFLAGS+=" $*";
  358.     return 0
  359. }
  360. append-cxxflags ()
  361. {
  362.     [[ $# -eq 0 ]] && return 0;
  363.     export CXXFLAGS+=" $*";
  364.     return 0
  365. }
  366. append-fflags ()
  367. {
  368.     [[ $# -eq 0 ]] && return 0;
  369.     export FFLAGS+=" $*";
  370.     export FCFLAGS+=" $*";
  371.     return 0
  372. }
  373. append-flags ()
  374. {
  375.     [[ $# -eq 0 ]] && return 0;
  376.     case " $* " in
  377.         *' '-[DIU]*)
  378.             eqawarn 'please use append-cppflags for preprocessor flags'
  379.         ;;
  380.         *' '-L* | *' '-Wl,*)
  381.             eqawarn 'please use append-ldflags for linker flags'
  382.         ;;
  383.     esac;
  384.     append-cflags "$@";
  385.     append-cxxflags "$@";
  386.     append-fflags "$@";
  387.     return 0
  388. }
  389. append-ldflags ()
  390. {
  391.     [[ $# -eq 0 ]] && return 0;
  392.     local flag;
  393.     for flag in "$@";
  394.     do
  395.         [[ ${flag} == -l* ]] && eqawarn "Appending a library link instruction (${flag}); libraries to link to should not be passed through LDFLAGS";
  396.     done;
  397.     export LDFLAGS="${LDFLAGS} $*";
  398.     return 0
  399. }
  400. append-lfs-flags ()
  401. {
  402.     [[ $# -ne 0 ]] && die "append-lfs-flags takes no arguments";
  403.     append-cppflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  404. }
  405. append-libs ()
  406. {
  407.     [[ $# -eq 0 ]] && return 0;
  408.     local flag;
  409.     for flag in "$@";
  410.     do
  411.         if [[ -z "${flag// }" ]]; then
  412.             eqawarn "Appending an empty argument to LIBS is invalid! Skipping.";
  413.             continue;
  414.         fi;
  415.         case $flag in
  416.             -[lL]*)
  417.                 export LIBS="${LIBS} ${flag}"
  418.             ;;
  419.             -*)
  420.                 eqawarn "Appending non-library to LIBS (${flag}); Other linker flags should be passed via LDFLAGS";
  421.                 export LIBS="${LIBS} ${flag}"
  422.             ;;
  423.             *)
  424.                 export LIBS="${LIBS} -l${flag}"
  425.             ;;
  426.         esac;
  427.     done;
  428.     return 0
  429. }
  430. built_with_use ()
  431. {
  432.     _eutils_eprefix_init;
  433.     local hidden="no";
  434.     if [[ $1 == "--hidden" ]]; then
  435.         hidden="yes";
  436.         shift;
  437.     fi;
  438.     local missing_action="die";
  439.     if [[ $1 == "--missing" ]]; then
  440.         missing_action=$2;
  441.         shift;
  442.         shift;
  443.         case ${missing_action} in
  444.             true | false | die)
  445.  
  446.             ;;
  447.             *)
  448.                 die "unknown action '${missing_action}'"
  449.             ;;
  450.         esac;
  451.     fi;
  452.     local opt=$1;
  453.     [[ ${opt:0:1} = "-" ]] && shift || opt="-a";
  454.     local PKG=$(best_version $1);
  455.     [[ -z ${PKG} ]] && die "Unable to resolve $1 to an installed package";
  456.     shift;
  457.     local USEFILE=${EROOT}/var/db/pkg/${PKG}/USE;
  458.     local IUSEFILE=${EROOT}/var/db/pkg/${PKG}/IUSE;
  459.     if [[ ! -e ${USEFILE} ]] || [[ ! -e ${IUSEFILE} && ${hidden} == "no" ]]; then
  460.         case ${missing_action} in
  461.             true)
  462.                 return 0
  463.             ;;
  464.             false)
  465.                 return 1
  466.             ;;
  467.             die)
  468.                 die "Unable to determine what USE flags $PKG was built with"
  469.             ;;
  470.         esac;
  471.     fi;
  472.     if [[ ${hidden} == "no" ]]; then
  473.         local IUSE_BUILT=($(<"${IUSEFILE}"));
  474.         local expand;
  475.         for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]');
  476.         do
  477.             if [[ $1 == ${expand}_* ]]; then
  478.                 expand="";
  479.                 break;
  480.             fi;
  481.         done;
  482.         if [[ -n ${expand} ]]; then
  483.             if ! has $1 ${IUSE_BUILT[@]#[-+]}; then
  484.                 case ${missing_action} in
  485.                     true)
  486.                         return 0
  487.                     ;;
  488.                     false)
  489.                         return 1
  490.                     ;;
  491.                     die)
  492.                         die "$PKG does not actually support the $1 USE flag!"
  493.                     ;;
  494.                 esac;
  495.             fi;
  496.         fi;
  497.     fi;
  498.     local USE_BUILT=$(<${USEFILE});
  499.     while [[ $# -gt 0 ]]; do
  500.         if [[ ${opt} = "-o" ]]; then
  501.             has $1 ${USE_BUILT} && return 0;
  502.         else
  503.             has $1 ${USE_BUILT} || return 1;
  504.         fi;
  505.         shift;
  506.     done;
  507.     [[ ${opt} = "-a" ]]
  508. }
  509. check_license ()
  510. {
  511.     die "you no longer need this as portage supports ACCEPT_LICENSE itself"
  512. }
  513. doicon ()
  514. {
  515.     _iconins ${FUNCNAME} "$@"
  516. }
  517. domenu ()
  518. {
  519.     ( local i j ret=0;
  520.     insinto /usr/share/applications;
  521.     for i in "$@";
  522.     do
  523.         if [[ -f ${i} ]]; then
  524.             doins "${i}";
  525.             ((ret+=$?));
  526.         else
  527.             if [[ -d ${i} ]]; then
  528.                 for j in "${i}"/*.desktop;
  529.                 do
  530.                     doins "${j}";
  531.                     ((ret+=$?));
  532.                 done;
  533.             else
  534.                 ((++ret));
  535.             fi;
  536.         fi;
  537.     done;
  538.     exit ${ret} )
  539. }
  540. ebeep ()
  541. {
  542.     ewarn "QA Notice: ebeep is not defined in EAPI=${EAPI}, please file a bug at http://bugs.gentoo.org"
  543. }
  544. econf_build ()
  545. {
  546.     tc-env_build econf --build=${CBUILD:-${CHOST}} "$@"
  547. }
  548. ecvs_clean ()
  549. {
  550.     [[ -z $* ]] && set -- .;
  551.     find "$@" -type d -name 'CVS' -prune -print0 | xargs -0 rm -rf;
  552.     find "$@" -type f -name '.cvs*' -print0 | xargs -0 rm -rf
  553. }
  554. edos2unix ()
  555. {
  556.     [[ $# -eq 0 ]] && return 0;
  557.     sed -i 's/\r$//' -- "$@" || die
  558. }
  559. einstalldocs ()
  560. {
  561.     debug-print-function ${FUNCNAME} "${@}";
  562.     local dodoc_opts=-r;
  563.     has ${EAPI} 0 1 2 3 && dodoc_opts=;
  564.     if ! declare -p DOCS &>/dev/null; then
  565.         local d;
  566.         for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS FAQ CREDITS CHANGELOG;
  567.         do
  568.             if [[ -s ${d} ]]; then
  569.                 dodoc "${d}" || die;
  570.             fi;
  571.         done;
  572.     else
  573.         if [[ $(declare -p DOCS) == "declare -a"* ]]; then
  574.             if [[ -n ${DOCS[@]} ]]; then
  575.                 dodoc ${dodoc_opts} "${DOCS[@]}" || die;
  576.             fi;
  577.         else
  578.             if [[ -n ${DOCS} ]]; then
  579.                 dodoc ${dodoc_opts} ${DOCS} || die;
  580.             fi;
  581.         fi;
  582.     fi;
  583.     if [[ $(declare -p HTML_DOCS 2>/dev/null) == "declare -a"* ]]; then
  584.         if [[ -n ${HTML_DOCS[@]} ]]; then
  585.             dohtml -r "${HTML_DOCS[@]}" || die;
  586.         fi;
  587.     else
  588.         if [[ -n ${HTML_DOCS} ]]; then
  589.             dohtml -r ${HTML_DOCS} || die;
  590.         fi;
  591.     fi;
  592.     return 0
  593. }
  594. emktemp ()
  595. {
  596.     local exe="touch";
  597.     [[ $1 == -d ]] && exe="mkdir" && shift;
  598.     local topdir=$1;
  599.     if [[ -z ${topdir} ]]; then
  600.         [[ -z ${T} ]] && topdir="/tmp" || topdir=${T};
  601.     fi;
  602.     if ! type -P mktemp > /dev/null; then
  603.         local tmp=/;
  604.         while [[ -e ${tmp} ]]; do
  605.             tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM};
  606.         done;
  607.         ${exe} "${tmp}" || ${exe} -p "${tmp}";
  608.         echo "${tmp}";
  609.     else
  610.         if [[ ${exe} == "touch" ]]; then
  611.             TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX;
  612.         else
  613.             TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX;
  614.         fi;
  615.     fi
  616. }
  617. epatch ()
  618. {
  619.     function _epatch_draw_line ()
  620.     {
  621.         [[ -z $1 ]] && set "$(printf "%65s" '')";
  622.         echo "${1//?/=}"
  623.     };
  624.     unset P4CONFIG P4PORT P4USER;
  625.     local EPATCH_OPTS=(${EPATCH_OPTS[*]});
  626.     while [[ $# -gt 0 ]]; do
  627.         case $1 in
  628.             -*)
  629.                 EPATCH_OPTS+=("$1")
  630.             ;;
  631.             *)
  632.                 break
  633.             ;;
  634.         esac;
  635.         shift;
  636.     done;
  637.     if [[ $# -gt 1 ]]; then
  638.         local m;
  639.         for m in "$@";
  640.         do
  641.             epatch "${m}";
  642.         done;
  643.         return 0;
  644.     fi;
  645.     local SINGLE_PATCH="no";
  646.     [[ $# -eq 0 ]] && set -- "${EPATCH_SOURCE}";
  647.     if [[ -f $1 ]]; then
  648.         SINGLE_PATCH="yes";
  649.         set -- "$1";
  650.         local EPATCH_SUFFIX=$1;
  651.     else
  652.         if [[ -d $1 ]]; then
  653.             evar_push_set LC_COLLATE C;
  654.             set -- "$1"/*${EPATCH_SUFFIX:+."${EPATCH_SUFFIX}"};
  655.            evar_pop;
  656.        else
  657.            if [[ -f ${EPATCH_SOURCE}/$1 ]]; then
  658.                epatch "${EPATCH_SOURCE}/$1";
  659.                return $?;
  660.            else
  661.                [[ $# -ne 0 ]] && EPATCH_SOURCE=$1;
  662.                echo;
  663.                eerror "Cannot find \$EPATCH_SOURCE!  Value for \$EPATCH_SOURCE is:";
  664.                eerror;
  665.                eerror "  ${EPATCH_SOURCE}";
  666.                eerror "  ( ${EPATCH_SOURCE##*/} )";
  667.                echo;
  668.                die "Cannot find \$EPATCH_SOURCE!";
  669.            fi;
  670.        fi;
  671.    fi;
  672.    EPATCH_OPTS="${EPATCH_COMMON_OPTS} ${EPATCH_OPTS[*]}";
  673.    local PIPE_CMD;
  674.    case ${EPATCH_SUFFIX##*\.} in
  675.        xz)
  676.            PIPE_CMD="xz -dc"
  677.        ;;
  678.        lzma)
  679.            PIPE_CMD="lzma -dc"
  680.        ;;
  681.        bz2)
  682.            PIPE_CMD="bzip2 -dc"
  683.        ;;
  684.        gz | Z | z)
  685.            PIPE_CMD="gzip -dc"
  686.        ;;
  687.        ZIP | zip)
  688.            PIPE_CMD="unzip -p"
  689.        ;;
  690.        *)
  691.  
  692.        ;;
  693.    esac;
  694.    [[ ${SINGLE_PATCH} == "no" ]] && einfo "${EPATCH_MULTI_MSG}";
  695.    local x;
  696.    for x in "$@";
  697.    do
  698.        [[ ! -f ${x} ]] && continue;
  699.        local patchname=${x##*/};
  700.        local a=${patchname#*_};
  701.        a=${a%%_*};
  702.        if ! [[ ${SINGLE_PATCH} == "yes" || ${EPATCH_FORCE} == "yes" || ${a} == all || ${a} == ${ARCH} ]]; then
  703.            continue;
  704.        fi;
  705.        if [[ -n ${EPATCH_EXCLUDE} ]]; then
  706.            eshopts_push -o noglob;
  707.            local ex;
  708.            for ex in ${EPATCH_EXCLUDE};
  709.            do
  710.                if [[ ${patchname} == ${ex} ]]; then
  711.                    einfo "  Skipping ${patchname} due to EPATCH_EXCLUDE ...";
  712.                    eshopts_pop;
  713.                    continue 2;
  714.                fi;
  715.            done;
  716.            for ex in ${EPATCH_USER_EXCLUDE};
  717.            do
  718.                if [[ ${patchname} == ${ex} ]]; then
  719.                    einfo "  Skipping ${patchname} due to EPATCH_USER_EXCLUDE ...";
  720.                    eshopts_pop;
  721.                    continue 2;
  722.                fi;
  723.            done;
  724.            eshopts_pop;
  725.        fi;
  726.        if [[ ${SINGLE_PATCH} == "yes" ]]; then
  727.            if [[ -n ${EPATCH_SINGLE_MSG} ]]; then
  728.                einfo "${EPATCH_SINGLE_MSG}";
  729.            else
  730.                einfo "Applying ${patchname} ...";
  731.            fi;
  732.        else
  733.            einfo "  ${patchname} ...";
  734.        fi;
  735.        local STDERR_TARGET="${T}/${patchname}.out";
  736.        if [[ -e ${STDERR_TARGET} ]]; then
  737.            STDERR_TARGET="${T}/${patchname}-$$.out";
  738.        fi;
  739.        printf "***** %s *****\nPWD: %s\n\n" "${patchname}" "${PWD}" > "${STDERR_TARGET}";
  740.        local count=0;
  741.        local PATCH_TARGET;
  742.        if [[ -n ${PIPE_CMD} ]]; then
  743.            PATCH_TARGET="${T}/$$.patch";
  744.            echo "PIPE_COMMAND:  ${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> "${STDERR_TARGET}";
  745.            if ! ( ${PIPE_CMD} "${x}" > "${PATCH_TARGET}" ) >> "${STDERR_TARGET}" 2>&1; then
  746.                echo;
  747.                eerror "Could not extract patch!";
  748.                count=5;
  749.                break;
  750.            fi;
  751.        else
  752.            PATCH_TARGET=${x};
  753.        fi;
  754.        local abs_paths=$(egrep -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }');
  755.        if [[ -n ${abs_paths} ]]; then
  756.            count=1;
  757.            printf "NOTE: skipping -p0 due to absolute paths in patch:\n%s\n" "${abs_paths}" >> "${STDERR_TARGET}";
  758.        fi;
  759.         local rel_paths=$(egrep -n '^[-+]{3} [^ ]*[.][.]/' "${PATCH_TARGET}");
  760.        if [[ -n ${rel_paths} ]]; then
  761.            echo;
  762.            eerror "Rejected Patch: ${patchname} !";
  763.            eerror " ( ${PATCH_TARGET} )";
  764.            eerror;
  765.            eerror "Your patch uses relative paths '../':";
  766.            eerror "${rel_paths}";
  767.            echo;
  768.            die "you need to fix the relative paths in patch";
  769.        fi;
  770.        local patch_cmd;
  771.        local patch="patch";
  772.        eval $(alias patch 2>/dev/null | sed 's:^alias ::');
  773.        while [[ ${count} -lt 5 ]]; do
  774.            patch_cmd="${patch} -p${count} ${EPATCH_OPTS}";
  775.            ( _epatch_draw_line "***** ${patchname} *****";
  776.            echo;
  777.            echo "PATCH COMMAND:  ${patch_cmd} < '${PATCH_TARGET}'";
  778.            echo;
  779.            _epatch_draw_line "***** ${patchname} *****";
  780.            ${patch_cmd} --dry-run -f < "${PATCH_TARGET}" 2>&1;
  781.            ret=$?;
  782.            echo;
  783.            echo "patch program exited with status ${ret}";
  784.            exit ${ret} ) >> "${STDERR_TARGET}";
  785.            if [ $? -eq 0 ]; then
  786.                ( _epatch_draw_line "***** ${patchname} *****";
  787.                echo;
  788.                echo "ACTUALLY APPLYING ${patchname} ...";
  789.                echo;
  790.                _epatch_draw_line "***** ${patchname} *****";
  791.                ${patch_cmd} < "${PATCH_TARGET}" 2>&1;
  792.                ret=$?;
  793.                echo;
  794.                echo "patch program exited with status ${ret}";
  795.                exit ${ret} ) >> "${STDERR_TARGET}";
  796.                if [ $? -ne 0 ]; then
  797.                    echo;
  798.                    eerror "A dry-run of patch command succeeded, but actually";
  799.                    eerror "applying the patch failed!";
  800.                    count=5;
  801.                fi;
  802.                break;
  803.            fi;
  804.            : $(( count++ ));
  805.        done;
  806.        if [[ -n ${PIPE_CMD} ]]; then
  807.            rm -f "${PATCH_TARGET}";
  808.        fi;
  809.        if [[ ${count} -ge 5 ]]; then
  810.            echo;
  811.            eerror "Failed Patch: ${patchname} !";
  812.            eerror " ( ${PATCH_TARGET} )";
  813.            eerror;
  814.            eerror "Include in your bugreport the contents of:";
  815.            eerror;
  816.            eerror "  ${STDERR_TARGET}";
  817.            echo;
  818.            die "Failed Patch: ${patchname}!";
  819.        fi;
  820.        rm -f "${STDERR_TARGET}";
  821.        cat >> "${T}/epatch.log"  <<-EOF
  822. PATCH: ${x}
  823. CMD: ${patch_cmd}
  824. PWD: ${PWD}
  825.  
  826. EOF
  827.  
  828.        eend 0;
  829.    done;
  830.    [[ ${SINGLE_PATCH} == "no" ]] && einfo "Done with patching";
  831.    :
  832. }
  833. epatch_user ()
  834. {
  835.    [[ $# -ne 0 ]] && die "epatch_user takes no options";
  836.    local applied="${T}/epatch_user.log";
  837.    [[ -e ${applied} ]] && return 2;
  838.    local EPATCH_SOURCE check base=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
  839.    for check in ${CATEGORY}/{${P}-${PR},${P},${PN}}{,:${SLOT}};
  840.    do
  841.        EPATCH_SOURCE=${base}/${CTARGET}/${check};
  842.        [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${CHOST}/${check};
  843.        [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${check};
  844.        if [[ -d ${EPATCH_SOURCE} ]]; then
  845.            EPATCH_SOURCE=${EPATCH_SOURCE} EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" EPATCH_MULTI_MSG="Applying user patches from ${EPATCH_SOURCE} ..." epatch;
  846.            echo "${EPATCH_SOURCE}" > "${applied}";
  847.            return 0;
  848.        fi;
  849.    done;
  850.    echo "none" > "${applied}";
  851.    return 1
  852. }
  853. epause ()
  854. {
  855.    ewarn "QA Notice: epause is not defined in EAPI=${EAPI}, please file a bug at http://bugs.gentoo.org"
  856. }
  857. epunt_cxx ()
  858. {
  859.    local dir=$1;
  860.    [[ -z ${dir} ]] && dir=${S};
  861.    ebegin "Removing useless C++ checks";
  862.    local f p any_found;
  863.    while IFS= read -r -d '' f; do
  864.        for p in "${PORTDIR}"/eclass/ELT-patches/nocxx/*.patch;
  865.        do
  866.            if patch --no-backup-if-mismatch -p1 "${f}" "${p}" > /dev/null; then
  867.                any_found=1;
  868.                break;
  869.            fi;
  870.        done;
  871.    done < <(find "${dir}" -name configure -print0);
  872.    if [[ -z ${any_found} ]]; then
  873.        eqawarn "epunt_cxx called unnecessarily (no C++ checks to punt).";
  874.    fi;
  875.    eend 0
  876. }
  877. eshopts_pop ()
  878. {
  879.    local s;
  880.    estack_pop eshopts s || die "${FUNCNAME}: unbalanced push";
  881.    if [[ ${s} == "shopt -"* ]]; then
  882.        eval "${s}" || die "${FUNCNAME}: sanity: invalid shopt options: ${s}";
  883.    else
  884.        set +$- || die "${FUNCNAME}: sanity: invalid shell settings: $-";
  885.        set -${s} || die "${FUNCNAME}: sanity: unable to restore saved shell settings: ${s}";
  886.    fi
  887. }
  888. eshopts_push ()
  889. {
  890.    if [[ $1 == -[su] ]]; then
  891.        estack_push eshopts "$(shopt -p)";
  892.        [[ $# -eq 0 ]] && return 0;
  893.        shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*";
  894.    else
  895.        estack_push eshopts $-;
  896.        [[ $# -eq 0 ]] && return 0;
  897.        set "$@" || die "${FUNCNAME}: bad options to set: $*";
  898.    fi
  899. }
  900. estack_pop ()
  901. {
  902.    [[ $# -eq 0 || $# -gt 2 ]] && die "estack_pop: incorrect # of arguments";
  903.     local __estack_name="__ESTACK_$1__";
  904.     shift;
  905.     local __estack_retvar=$1;
  906.     shift;
  907.     eval local __estack_i=\${#${__estack_name}\[@\]};
  908.     [[ $(( --__estack_i )) -eq -1 ]] && return 1;
  909.     if [[ -n ${__estack_retvar} ]]; then
  910.         eval ${__estack_retvar}=\"\${${__estack_name}\[${__estack_i}\]}\";
  911.     fi;
  912.     eval unset ${__estack_name}\[${__estack_i}\]
  913. }
  914. estack_push ()
  915. {
  916.     [[ $# -eq 0 ]] && die "estack_push: incorrect # of arguments";
  917.     local stack_name="__ESTACK_$1__";
  918.     shift;
  919.     eval ${stack_name}+=\( \"\$@\" \)
  920. }
  921. esvn_clean ()
  922. {
  923.     [[ -z $* ]] && set -- .;
  924.     find "$@" -type d -name '.svn' -prune -print0 | xargs -0 rm -rf
  925. }
  926. eumask_pop ()
  927. {
  928.     [[ $# -eq 0 ]] || die "${FUNCNAME}: we take no options";
  929.     local s;
  930.     estack_pop eumask s || die "${FUNCNAME}: unbalanced push";
  931.     umask ${s} || die "${FUNCNAME}: sanity: could not restore umask: ${s}"
  932. }
  933. eumask_push ()
  934. {
  935.     estack_push eumask "$(umask)";
  936.     umask "$@" || die "${FUNCNAME}: bad options to umask: $*"
  937. }
  938. evar_pop ()
  939. {
  940.     local cnt=${1:-bad};
  941.     case $# in
  942.         0)
  943.             cnt=1
  944.         ;;
  945.         1)
  946.             isdigit "${cnt}" || die "${FUNCNAME}: first arg must be a number: $*"
  947.         ;;
  948.         *)
  949.             die "${FUNCNAME}: only accepts one arg: $*"
  950.         ;;
  951.     esac;
  952.     local var val;
  953.     while (( cnt-- )); do
  954.         estack_pop evar val || die "${FUNCNAME}: unbalanced push";
  955.         estack_pop evar var || die "${FUNCNAME}: unbalanced push";
  956.         [[ ${val} == "${___ECLASS_ONCE_EUTILS}" ]] && unset ${var} || printf -v "${var}" '%s' "${val}";
  957.     done
  958. }
  959. evar_push ()
  960. {
  961.     local var val;
  962.     for var in "$@";
  963.     do
  964.         [[ ${!var+set} == "set" ]] && val=${!var} || val="${___ECLASS_ONCE_EUTILS}";
  965.         estack_push evar "${var}" "${val}";
  966.     done
  967. }
  968. evar_push_set ()
  969. {
  970.     local var=$1;
  971.     evar_push ${var};
  972.     case $# in
  973.         1)
  974.             unset ${var}
  975.         ;;
  976.         2)
  977.             printf -v "${var}" '%s' "$2"
  978.         ;;
  979.         *)
  980.             die "${FUNCNAME}: incorrect # of args: $*"
  981.         ;;
  982.     esac
  983. }
  984. filter-flags ()
  985. {
  986.     _filter-hardened "$@";
  987.     local v;
  988.     for v in $(all-flag-vars);
  989.     do
  990.         _filter-var ${v} "$@";
  991.     done;
  992.     return 0
  993. }
  994. filter-ldflags ()
  995. {
  996.     _filter-var LDFLAGS "$@";
  997.     return 0
  998. }
  999. filter-lfs-flags ()
  1000. {
  1001.     [[ $# -ne 0 ]] && die "filter-lfs-flags takes no arguments";
  1002.     filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  1003. }
  1004. filter-mfpmath ()
  1005. {
  1006.     local orig_mfpmath new_math prune_math;
  1007.     orig_mfpmath=$(get-flag -mfpmath);
  1008.     new_math=$(get-flag mfpmath);
  1009.     new_math=${new_math/both/387,sse};
  1010.     new_math=" ${new_math//[,+]/ } ";
  1011.     prune_math="";
  1012.     for prune_math in "$@";
  1013.     do
  1014.         new_math=${new_math/ ${prune_math} / };
  1015.     done;
  1016.     new_math=$(echo ${new_math});
  1017.     new_math=${new_math// /,};
  1018.     if [[ -z ${new_math} ]]; then
  1019.         filter-flags ${orig_mfpmath};
  1020.     else
  1021.         replace-flags ${orig_mfpmath} -mfpmath=${new_math};
  1022.     fi;
  1023.     return 0
  1024. }
  1025. gcc-fullversion ()
  1026. {
  1027.     _gcc_fullversion '$1.$2.$3' "$@"
  1028. }
  1029. gcc-major-version ()
  1030. {
  1031.     _gcc_fullversion '$1' "$@"
  1032. }
  1033. gcc-micro-version ()
  1034. {
  1035.     _gcc_fullversion '$3' "$@"
  1036. }
  1037. gcc-minor-version ()
  1038. {
  1039.     _gcc_fullversion '$2' "$@"
  1040. }
  1041. gcc-specs-directive ()
  1042. {
  1043.     local directive subdname subdirective;
  1044.     directive="$(_gcc-specs-directive_raw $1)";
  1045.     while [[ ${directive} == *%\(*\)* ]]; do
  1046.         subdname=${directive/*%\(};
  1047.         subdname=${subdname/\)*};
  1048.         subdirective="$(_gcc-specs-directive_raw ${subdname})";
  1049.         directive="${directive//\%(${subdname})/${subdirective}}";
  1050.     done;
  1051.     echo "${directive}";
  1052.     return 0
  1053. }
  1054. gcc-specs-nostrict ()
  1055. {
  1056.     local directive;
  1057.     directive=$(gcc-specs-directive cc1);
  1058.     return $([[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]])
  1059. }
  1060. gcc-specs-now ()
  1061. {
  1062.     local directive;
  1063.     directive=$(gcc-specs-directive link_command);
  1064.     return $([[ "${directive/\{!nonow:}" != "${directive}" ]])
  1065. }
  1066. gcc-specs-pie ()
  1067. {
  1068.     local directive;
  1069.     directive=$(gcc-specs-directive cc1);
  1070.     return $([[ "${directive/\{!nopie:}" != "${directive}" ]])
  1071. }
  1072. gcc-specs-relro ()
  1073. {
  1074.     local directive;
  1075.     directive=$(gcc-specs-directive link_command);
  1076.     return $([[ "${directive/\{!norelro:}" != "${directive}" ]])
  1077. }
  1078. gcc-specs-ssp ()
  1079. {
  1080.     local directive;
  1081.     directive=$(gcc-specs-directive cc1);
  1082.     return $([[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]])
  1083. }
  1084. gcc-specs-ssp-to-all ()
  1085. {
  1086.     local directive;
  1087.     directive=$(gcc-specs-directive cc1);
  1088.     return $([[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]])
  1089. }
  1090. gcc-version ()
  1091. {
  1092.     _gcc_fullversion '$1.$2' "$@"
  1093. }
  1094. gen_usr_ldscript ()
  1095. {
  1096.     local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  1097.     [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  1098.     tc-is-static-only && return;
  1099.     case ${CTARGET:-${CHOST}} in
  1100.         *-darwin*)
  1101.  
  1102.         ;;
  1103.         *linux* | *-freebsd* | *-openbsd* | *-netbsd*)
  1104.             use prefix && return 0
  1105.         ;;
  1106.         *)
  1107.             return 0
  1108.         ;;
  1109.     esac;
  1110.     dodir /usr/${libdir};
  1111.     if [[ $1 == "-a" ]]; then
  1112.         auto=true;
  1113.         shift;
  1114.         dodir /${libdir};
  1115.     fi;
  1116.     local flags=(${CFLAGS} ${LDFLAGS} -Wl,--verbose);
  1117.     if $(tc-getLD) --version | grep -q 'GNU gold'; then
  1118.         local d="${T}/bfd-linker";
  1119.         mkdir -p "${d}";
  1120.         ln -sf $(which ${CHOST}-ld.bfd) "${d}"/ld;
  1121.         flags+=(-B"${d}");
  1122.     fi;
  1123.     output_format=$($(tc-getCC) "${flags[@]}" 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  1124.     [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  1125.     for lib in "$@";
  1126.     do
  1127.         local tlib;
  1128.         if ${auto}; then
  1129.             lib="lib${lib}${suffix}";
  1130.         else
  1131.             [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  1132.         fi;
  1133.         case ${CTARGET:-${CHOST}} in
  1134.             *-darwin*)
  1135.                 if ${auto}; then
  1136.                     tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1137.                 else
  1138.                     tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  1139.                 fi;
  1140.                 [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  1141.                 tlib=${tlib##*/};
  1142.                 if ${auto}; then
  1143.                     mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1144.                     if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  1145.                         mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1146.                     fi;
  1147.                     rm -f "${ED}"/${libdir}/${lib};
  1148.                 fi;
  1149.                 if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  1150.                     chmod u+w "${ED}${libdir}/${tlib}";
  1151.                     local nowrite=yes;
  1152.                 fi;
  1153.                 install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  1154.                 [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  1155.                 pushd "${ED}/usr/${libdir}" > /dev/null;
  1156.                 ln -snf "../../${libdir}/${tlib}" "${lib}";
  1157.                 popd > /dev/null
  1158.             ;;
  1159.             *)
  1160.                 if ${auto}; then
  1161.                     tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1162.                     [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  1163.                     mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  1164.                     if [[ ${tlib} != ${lib}* ]]; then
  1165.                         mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  1166.                     fi;
  1167.                     rm -f "${ED}"/${libdir}/${lib};
  1168.                 else
  1169.                     tlib=${lib};
  1170.                 fi;
  1171.                 cat > "${ED}/usr/${libdir}/${lib}"  <<-END_LDSCRIPT
  1172. /* GNU ld script
  1173.    Since Gentoo has critical dynamic libraries in /lib, and the static versions
  1174.    in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  1175.    run into linking problems.  This "fake" dynamic lib is a linker script that
  1176.    redirects the linker to the real lib.  And yes, this works in the cross-
  1177.    compiling scenario as the sysroot-ed linker will prepend the real path.
  1178.  
  1179.    See bug http://bugs.gentoo.org/4411 for more info.
  1180.  */
  1181. ${output_format}
  1182. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  1183. END_LDSCRIPT
  1184.  
  1185.             ;;
  1186.         esac
  1187.         fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  1188.     done
  1189. }
  1190. get-flag ()
  1191. {
  1192.     local f var findflag="$1";
  1193.     for var in $(all-flag-vars);
  1194.     do
  1195.         for f in ${!var};
  1196.         do
  1197.             if [ "${f/${findflag}}" != "${f}" ]; then
  1198.                 printf "%s\n" "${f/-${findflag}=}";
  1199.                 return 0;
  1200.             fi;
  1201.         done;
  1202.     done;
  1203.     return 1
  1204. }
  1205. get_abi_CFLAGS ()
  1206. {
  1207.     get_abi_var CFLAGS "$@"
  1208. }
  1209. get_abi_CHOST ()
  1210. {
  1211.     get_abi_var CHOST "$@"
  1212. }
  1213. get_abi_CTARGET ()
  1214. {
  1215.     get_abi_var CTARGET "$@"
  1216. }
  1217. get_abi_FAKE_TARGETS ()
  1218. {
  1219.     get_abi_var FAKE_TARGETS "$@"
  1220. }
  1221. get_abi_LDFLAGS ()
  1222. {
  1223.     get_abi_var LDFLAGS "$@"
  1224. }
  1225. get_abi_LIBDIR ()
  1226. {
  1227.     get_abi_var LIBDIR "$@"
  1228. }
  1229. get_abi_var ()
  1230. {
  1231.     local flag=$1;
  1232.     local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  1233.     local var="${flag}_${abi}";
  1234.     echo ${!var}
  1235. }
  1236. get_all_abis ()
  1237. {
  1238.     local x order="" mvar dvar;
  1239.     mvar="MULTILIB_ABIS";
  1240.     dvar="DEFAULT_ABI";
  1241.     if [[ -n $1 ]]; then
  1242.         mvar="$1_${mvar}";
  1243.         dvar="$1_${dvar}";
  1244.     fi;
  1245.     if [[ -z ${!mvar} ]]; then
  1246.         echo "default";
  1247.         return 0;
  1248.     fi;
  1249.     for x in ${!mvar};
  1250.     do
  1251.         if [[ ${x} != ${!dvar} ]]; then
  1252.             order="${order:+${order} }${x}";
  1253.         fi;
  1254.     done;
  1255.     order="${order:+${order} }${!dvar}";
  1256.     echo ${order};
  1257.     return 0
  1258. }
  1259. get_all_libdirs ()
  1260. {
  1261.     local libdirs abi;
  1262.     for abi in ${MULTILIB_ABIS};
  1263.     do
  1264.         libdirs+=" $(get_abi_LIBDIR ${abi})";
  1265.     done;
  1266.     [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  1267.     echo "${libdirs}"
  1268. }
  1269. get_install_abis ()
  1270. {
  1271.     local x order="";
  1272.     if [[ -z ${MULTILIB_ABIS} ]]; then
  1273.         echo "default";
  1274.         return 0;
  1275.     fi;
  1276.     if [[ ${EMULTILIB_PKG} == "true" ]]; then
  1277.         for x in ${MULTILIB_ABIS};
  1278.         do
  1279.             if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  1280.                 has ${x} ${ABI_DENY} || order="${order} ${x}";
  1281.             fi;
  1282.         done;
  1283.         has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  1284.         if [[ -n ${ABI_ALLOW} ]]; then
  1285.             local ordera="";
  1286.             for x in ${order};
  1287.             do
  1288.                 if has ${x} ${ABI_ALLOW}; then
  1289.                     ordera="${ordera} ${x}";
  1290.                 fi;
  1291.             done;
  1292.             order=${ordera};
  1293.         fi;
  1294.     else
  1295.         order=${DEFAULT_ABI};
  1296.     fi;
  1297.     if [[ -z ${order} ]]; then
  1298.         die "The ABI list is empty.  Are you using a proper multilib profile?  Perhaps your USE flags or MULTILIB_ABIS are too restrictive for this package.";
  1299.     fi;
  1300.     echo ${order};
  1301.     return 0
  1302. }
  1303. get_libdir ()
  1304. {
  1305.     local CONF_LIBDIR;
  1306.     if [ -n "${CONF_LIBDIR_OVERRIDE}" ]; then
  1307.         echo ${CONF_LIBDIR_OVERRIDE};
  1308.     else
  1309.         get_abi_LIBDIR;
  1310.     fi
  1311. }
  1312. get_libname ()
  1313. {
  1314.     local libname;
  1315.     local ver=$1;
  1316.     case ${CHOST} in
  1317.         *-cygwin | mingw* | *-mingw*)
  1318.             libname="dll"
  1319.         ;;
  1320.         *-darwin*)
  1321.             libname="dylib"
  1322.         ;;
  1323.         *-mint*)
  1324.             libname="irrelevant"
  1325.         ;;
  1326.         hppa*-hpux*)
  1327.             libname="sl"
  1328.         ;;
  1329.         *)
  1330.             libname="so"
  1331.         ;;
  1332.     esac;
  1333.     if [[ -z $* ]]; then
  1334.         echo ".${libname}";
  1335.     else
  1336.         for ver in "$@";
  1337.         do
  1338.             case ${CHOST} in
  1339.                 *-darwin*)
  1340.                     echo ".${ver}.${libname}"
  1341.                 ;;
  1342.                 *-mint*)
  1343.                     echo ".${libname}"
  1344.                 ;;
  1345.                 *)
  1346.                     echo ".${libname}.${ver}"
  1347.                 ;;
  1348.             esac;
  1349.         done;
  1350.     fi
  1351. }
  1352. get_modname ()
  1353. {
  1354.     local modname;
  1355.     local ver=$1;
  1356.     case ${CHOST} in
  1357.         *-darwin*)
  1358.             modname="bundle"
  1359.         ;;
  1360.         *)
  1361.             modname="so"
  1362.         ;;
  1363.     esac;
  1364.     echo ".${modname}"
  1365. }
  1366. has_m32 ()
  1367. {
  1368.     die "${FUNCNAME}: don't use this anymore"
  1369. }
  1370. has_m64 ()
  1371. {
  1372.     eqawarn "${FUNCNAME}: don't use this anymore";
  1373.     local temp="$(emktemp)";
  1374.     echo "int main() { return(0); }" > "${temp}".c;
  1375.     MY_CC=$(tc-getCC);
  1376.     ${MY_CC/ .*/} -m64 -o "$(emktemp)" "${temp}".c > /dev/null 2>&1;
  1377.     local ret=$?;
  1378.     rm -f "${temp}".c;
  1379.     [[ ${ret} != 1 ]] && return 0;
  1380.     return 1
  1381. }
  1382. has_multilib_profile ()
  1383. {
  1384.     [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  1385. }
  1386. in_iuse ()
  1387. {
  1388.     debug-print-function ${FUNCNAME} "${@}";
  1389.     [[ ${#} -eq 1 ]] || die "Invalid args to ${FUNCNAME}()";
  1390.     local flag=${1};
  1391.     local liuse=(${IUSE});
  1392.     has "${flag}" "${liuse[@]#[+-]}"
  1393. }
  1394. is-flag ()
  1395. {
  1396.     is-flagq "$@" && echo true
  1397. }
  1398. is-flagq ()
  1399. {
  1400.     [[ -n $2 ]] && die "Usage: is-flag <flag>";
  1401.     local var;
  1402.     for var in $(all-flag-vars);
  1403.     do
  1404.         _is_flagq ${var} "$1" && return 0;
  1405.     done;
  1406.     return 1
  1407. }
  1408. is-ldflag ()
  1409. {
  1410.     is-ldflagq "$@" && echo true
  1411. }
  1412. is-ldflagq ()
  1413. {
  1414.     [[ -n $2 ]] && die "Usage: is-ldflag <flag>";
  1415.     _is_flagq LDFLAGS $1
  1416. }
  1417. is_final_abi ()
  1418. {
  1419.     has_multilib_profile || return 0;
  1420.     set -- $(get_install_abis);
  1421.     local LAST_ABI=$#;
  1422.     [[ ${!LAST_ABI} == ${ABI} ]]
  1423. }
  1424. isdigit ()
  1425. {
  1426.     local d;
  1427.     for d in "$@";
  1428.     do
  1429.         [[ ${d:-bad} == *[!0-9]* ]] && return 1;
  1430.     done;
  1431.     return 0
  1432. }
  1433. maint_pkg_create ()
  1434. {
  1435.     cd /usr/local/src/net-tools;
  1436.     local stamp=$(date --date="$(git log -n1 --pretty=format:%ci master)" -u +%Y%m%d%H%M%S);
  1437.     local pv="${PV/_p*}_p${stamp}";
  1438.     pv=${pv/9999/1.60};
  1439.     local p="${PN}-${pv}";
  1440.     git archive --prefix="${p}/" master | tar xf - -C "${T}";
  1441.     pushd "${T}" > /dev/null;
  1442.     sed -i "/^RELEASE/s:=.*:=${pv}:" */Makefile || die;
  1443.     tar cf - ${p}/ | xz > ${p}.tar.xz;
  1444.     popd > /dev/null;
  1445.     local patches="${p}-patches-${PATCH_VER:-1}";
  1446.     local d="${T}/${patches}";
  1447.     mkdir "${d}";
  1448.     git format-patch -o "${d}" master..gentoo > /dev/null;
  1449.     echo "From http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git" > "${d}"/README;
  1450.     tar cf - -C "${T}" ${d##*/} | xz > "${T}"/${patches}.tar.xz;
  1451.     rm -rf "${d}";
  1452.     du -b "${T}"/*.tar.xz
  1453. }
  1454. make_desktop_entry ()
  1455. {
  1456.     [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable";
  1457.     local exec=${1};
  1458.     local name=${2:-${PN}};
  1459.     local icon=${3:-${PN}};
  1460.     local type=${4};
  1461.     local fields=${5};
  1462.     if [[ -z ${type} ]]; then
  1463.         local catmaj=${CATEGORY%%-*};
  1464.         local catmin=${CATEGORY##*-};
  1465.         case ${catmaj} in
  1466.             app)
  1467.                 case ${catmin} in
  1468.                     accessibility)
  1469.                         type="Utility;Accessibility"
  1470.                     ;;
  1471.                     admin)
  1472.                         type=System
  1473.                     ;;
  1474.                     antivirus)
  1475.                         type=System
  1476.                     ;;
  1477.                     arch)
  1478.                         type="Utility;Archiving"
  1479.                     ;;
  1480.                     backup)
  1481.                         type="Utility;Archiving"
  1482.                     ;;
  1483.                     cdr)
  1484.                         type="AudioVideo;DiscBurning"
  1485.                     ;;
  1486.                     dicts)
  1487.                         type="Office;Dictionary"
  1488.                     ;;
  1489.                     doc)
  1490.                         type=Documentation
  1491.                     ;;
  1492.                     editors)
  1493.                         type="Utility;TextEditor"
  1494.                     ;;
  1495.                     emacs)
  1496.                         type="Development;TextEditor"
  1497.                     ;;
  1498.                     emulation)
  1499.                         type="System;Emulator"
  1500.                     ;;
  1501.                     laptop)
  1502.                         type="Settings;HardwareSettings"
  1503.                     ;;
  1504.                     office)
  1505.                         type=Office
  1506.                     ;;
  1507.                     pda)
  1508.                         type="Office;PDA"
  1509.                     ;;
  1510.                     vim)
  1511.                         type="Development;TextEditor"
  1512.                     ;;
  1513.                     xemacs)
  1514.                         type="Development;TextEditor"
  1515.                     ;;
  1516.                 esac
  1517.             ;;
  1518.             dev)
  1519.                 type="Development"
  1520.             ;;
  1521.             games)
  1522.                 case ${catmin} in
  1523.                     action | fps)
  1524.                         type=ActionGame
  1525.                     ;;
  1526.                     arcade)
  1527.                         type=ArcadeGame
  1528.                     ;;
  1529.                     board)
  1530.                         type=BoardGame
  1531.                     ;;
  1532.                     emulation)
  1533.                         type=Emulator
  1534.                     ;;
  1535.                     kids)
  1536.                         type=KidsGame
  1537.                     ;;
  1538.                     puzzle)
  1539.                         type=LogicGame
  1540.                     ;;
  1541.                     roguelike)
  1542.                         type=RolePlaying
  1543.                     ;;
  1544.                     rpg)
  1545.                         type=RolePlaying
  1546.                     ;;
  1547.                     simulation)
  1548.                         type=Simulation
  1549.                     ;;
  1550.                     sports)
  1551.                         type=SportsGame
  1552.                     ;;
  1553.                     strategy)
  1554.                         type=StrategyGame
  1555.                     ;;
  1556.                 esac;
  1557.                 type="Game;${type}"
  1558.             ;;
  1559.             gnome)
  1560.                 type="Gnome;GTK"
  1561.             ;;
  1562.             kde)
  1563.                 type="KDE;Qt"
  1564.             ;;
  1565.             mail)
  1566.                 type="Network;Email"
  1567.             ;;
  1568.             media)
  1569.                 case ${catmin} in
  1570.                     gfx)
  1571.                         type=Graphics
  1572.                     ;;
  1573.                     *)
  1574.                         case ${catmin} in
  1575.                             radio)
  1576.                                 type=Tuner
  1577.                             ;;
  1578.                             sound)
  1579.                                 type=Audio
  1580.                             ;;
  1581.                             tv)
  1582.                                 type=TV
  1583.                             ;;
  1584.                             video)
  1585.                                 type=Video
  1586.                             ;;
  1587.                         esac;
  1588.                         type="AudioVideo;${type}"
  1589.                     ;;
  1590.                 esac
  1591.             ;;
  1592.             net)
  1593.                 case ${catmin} in
  1594.                     dialup)
  1595.                         type=Dialup
  1596.                     ;;
  1597.                     ftp)
  1598.                         type=FileTransfer
  1599.                     ;;
  1600.                     im)
  1601.                         type=InstantMessaging
  1602.                     ;;
  1603.                     irc)
  1604.                         type=IRCClient
  1605.                     ;;
  1606.                     mail)
  1607.                         type=Email
  1608.                     ;;
  1609.                     news)
  1610.                         type=News
  1611.                     ;;
  1612.                     nntp)
  1613.                         type=News
  1614.                     ;;
  1615.                     p2p)
  1616.                         type=FileTransfer
  1617.                     ;;
  1618.                     voip)
  1619.                         type=Telephony
  1620.                     ;;
  1621.                 esac;
  1622.                 type="Network;${type}"
  1623.             ;;
  1624.             sci)
  1625.                 case ${catmin} in
  1626.                     astro*)
  1627.                         type=Astronomy
  1628.                     ;;
  1629.                     bio*)
  1630.                         type=Biology
  1631.                     ;;
  1632.                     calc*)
  1633.                         type=Calculator
  1634.                     ;;
  1635.                     chem*)
  1636.                         type=Chemistry
  1637.                     ;;
  1638.                     elec*)
  1639.                         type=Electronics
  1640.                     ;;
  1641.                     geo*)
  1642.                         type=Geology
  1643.                     ;;
  1644.                     math*)
  1645.                         type=Math
  1646.                     ;;
  1647.                     physics)
  1648.                         type=Physics
  1649.                     ;;
  1650.                     visual*)
  1651.                         type=DataVisualization
  1652.                     ;;
  1653.                 esac;
  1654.                 type="Education;Science;${type}"
  1655.             ;;
  1656.             sys)
  1657.                 type="System"
  1658.             ;;
  1659.             www)
  1660.                 case ${catmin} in
  1661.                     client)
  1662.                         type=WebBrowser
  1663.                     ;;
  1664.                 esac;
  1665.                 type="Network;${type}"
  1666.             ;;
  1667.             *)
  1668.                 type=
  1669.             ;;
  1670.         esac;
  1671.     fi;
  1672.     if [ "${SLOT}" == "0" ]; then
  1673.         local desktop_name="${PN}";
  1674.     else
  1675.         local desktop_name="${PN}-${SLOT}";
  1676.     fi;
  1677.     local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop";
  1678.     type=${type%;}${type:+;};
  1679.     eshopts_push -s extglob;
  1680.     if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then
  1681.         ewarn "As described in the Icon Theme Specification, icon file extensions are not";
  1682.         ewarn "allowed in .desktop files if the value is not an absolute path.";
  1683.         icon=${icon%.@(xpm|png|svg)};
  1684.     fi;
  1685.     eshopts_pop;
  1686.     cat > "${desktop}"  <<-EOF
  1687. [Desktop Entry]
  1688. Name=${name}
  1689. Type=Application
  1690. Comment=${DESCRIPTION}
  1691. Exec=${exec}
  1692. TryExec=${exec%% *}
  1693. Icon=${icon}
  1694. Categories=${type}
  1695. EOF
  1696.  
  1697.     if [[ ${fields:-=} != *=* ]]; then
  1698.         ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}";
  1699.         fields="Path=${fields}";
  1700.     fi;
  1701.     [[ -n ${fields} ]] && printf '%b\n' "${fields}" >> "${desktop}";
  1702.     ( insinto /usr/share/applications;
  1703.     doins "${desktop}" ) || die "installing desktop file failed"
  1704. }
  1705. make_session_desktop ()
  1706. {
  1707.     [[ -z $1 ]] && eerror "$0: You must specify the title" && return 1;
  1708.     [[ -z $2 ]] && eerror "$0: You must specify the command" && return 1;
  1709.     local title=$1;
  1710.     local command=$2;
  1711.     local desktop=${T}/${wm:-${PN}}.desktop;
  1712.     shift 2;
  1713.     cat > "${desktop}"  <<-EOF
  1714. [Desktop Entry]
  1715. Name=${title}
  1716. Comment=This session logs you into ${title}
  1717. Exec=${command} $*
  1718. TryExec=${command}
  1719. Type=XSession
  1720. EOF
  1721.  
  1722.     ( insinto /usr/share/xsessions;
  1723.     doins "${desktop}" )
  1724. }
  1725. make_wrapper ()
  1726. {
  1727.     _eutils_eprefix_init;
  1728.     local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5;
  1729.     local tmpwrapper=$(emktemp);
  1730.     ( echo '#!/bin/sh';
  1731.     [[ -n ${chdir} ]] && printf 'cd "%s"\n' "${EPREFIX}${chdir}";
  1732.     if [[ -n ${libdir} ]]; then
  1733.         local var;
  1734.         if [[ ${CHOST} == *-darwin* ]]; then
  1735.             var=DYLD_LIBRARY_PATH;
  1736.         else
  1737.             var=LD_LIBRARY_PATH;
  1738.         fi;
  1739.         cat  <<-EOF
  1740. if [ "\${${var}+set}" = "set" ] ; then
  1741. export ${var}="\${${var}}:${EPREFIX}${libdir}"
  1742. else
  1743. export ${var}="${EPREFIX}${libdir}"
  1744. fi
  1745. EOF
  1746.  
  1747.     fi
  1748.     printf 'exec %s "$@"\n' "${bin/#\//${EPREFIX}\/}" ) > "${tmpwrapper}";
  1749.     chmod go+rx "${tmpwrapper}";
  1750.     if [[ -n ${path} ]]; then
  1751.         ( exeinto "${path}";
  1752.         newexe "${tmpwrapper}" "${wrapper}" ) || die;
  1753.     else
  1754.         newbin "${tmpwrapper}" "${wrapper}" || die;
  1755.     fi
  1756. }
  1757. multilib_env ()
  1758. {
  1759.     local CTARGET=${1:-${CTARGET}};
  1760.     local cpu=${CTARGET%%*-};
  1761.     case ${cpu} in
  1762.         aarch64*)
  1763.             export CFLAGS_arm=${CFLAGS_arm-};
  1764.             case ${cpu} in
  1765.                 aarch64*be)
  1766.                     export CHOST_arm="armv8b-${CTARGET#*-}"
  1767.                 ;;
  1768.                 *)
  1769.                     export CHOST_arm="armv8l-${CTARGET#*-}"
  1770.                 ;;
  1771.             esac;
  1772.             CHOST_arm=${CHOST_arm/%-gnu/-gnueabi};
  1773.             export CTARGET_arm=${CHOST_arm};
  1774.             export LIBDIR_arm="lib";
  1775.             export CFLAGS_arm64=${CFLAGS_arm64-};
  1776.             export CHOST_arm64=${CTARGET};
  1777.             export CTARGET_arm64=${CHOST_arm64};
  1778.             export LIBDIR_arm64="lib64";
  1779.             : ${MULTILIB_ABIS=arm64};
  1780.             : ${DEFAULT_ABI=arm64}
  1781.         ;;
  1782.         x86_64*)
  1783.             export CFLAGS_x86=${CFLAGS_x86--m32};
  1784.             export CHOST_x86=${CTARGET/x86_64/i686};
  1785.             CHOST_x86=${CHOST_x86/%-gnux32/-gnu};
  1786.             export CTARGET_x86=${CHOST_x86};
  1787.             if [[ ${SYMLINK_LIB} == "yes" ]]; then
  1788.                 export LIBDIR_x86="lib32";
  1789.             else
  1790.                 export LIBDIR_x86="lib";
  1791.             fi;
  1792.             export CFLAGS_amd64=${CFLAGS_amd64--m64};
  1793.             export CHOST_amd64=${CTARGET/%-gnux32/-gnu};
  1794.             export CTARGET_amd64=${CHOST_amd64};
  1795.             export LIBDIR_amd64="lib64";
  1796.             export CFLAGS_x32=${CFLAGS_x32--mx32};
  1797.             export CHOST_x32=${CTARGET/%-gnu/-gnux32};
  1798.             export CTARGET_x32=${CHOST_x32};
  1799.             export LIBDIR_x32="libx32";
  1800.             case ${CTARGET} in
  1801.                 *-gnux32)
  1802.                     : ${MULTILIB_ABIS=x32 amd64 x86};
  1803.                     : ${DEFAULT_ABI=x32}
  1804.                 ;;
  1805.                 *)
  1806.                     : ${MULTILIB_ABIS=amd64 x86};
  1807.                     : ${DEFAULT_ABI=amd64}
  1808.                 ;;
  1809.             esac
  1810.         ;;
  1811.         mips64*)
  1812.             export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  1813.             export CHOST_o32=${CTARGET/mips64/mips};
  1814.             export CTARGET_o32=${CHOST_o32};
  1815.             export LIBDIR_o32="lib";
  1816.             export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  1817.             export CHOST_n32=${CTARGET};
  1818.             export CTARGET_n32=${CHOST_n32};
  1819.             export LIBDIR_n32="lib32";
  1820.             export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  1821.             export CHOST_n64=${CTARGET};
  1822.             export CTARGET_n64=${CHOST_n64};
  1823.             export LIBDIR_n64="lib64";
  1824.             : ${MULTILIB_ABIS=n64 n32 o32};
  1825.             : ${DEFAULT_ABI=n32}
  1826.         ;;
  1827.         powerpc64*)
  1828.             export CFLAGS_ppc=${CFLAGS_ppc--m32};
  1829.             export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  1830.             export CTARGET_ppc=${CHOST_ppc};
  1831.             export LIBDIR_ppc="lib";
  1832.             export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  1833.             export CHOST_ppc64=${CTARGET};
  1834.             export CTARGET_ppc64=${CHOST_ppc64};
  1835.             export LIBDIR_ppc64="lib64";
  1836.             : ${MULTILIB_ABIS=ppc64 ppc};
  1837.             : ${DEFAULT_ABI=ppc64}
  1838.         ;;
  1839.         s390x*)
  1840.             export CFLAGS_s390=${CFLAGS_s390--m31};
  1841.             export CHOST_s390=${CTARGET/s390x/s390};
  1842.             export CTARGET_s390=${CHOST_s390};
  1843.             export LIBDIR_s390="lib";
  1844.             export CFLAGS_s390x=${CFLAGS_s390x--m64};
  1845.             export CHOST_s390x=${CTARGET};
  1846.             export CTARGET_s390x=${CHOST_s390x};
  1847.             export LIBDIR_s390x="lib64";
  1848.             : ${MULTILIB_ABIS=s390x s390};
  1849.             : ${DEFAULT_ABI=s390x}
  1850.         ;;
  1851.         sparc64*)
  1852.             export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
  1853.             export CHOST_sparc32=${CTARGET/sparc64/sparc};
  1854.             export CTARGET_sparc32=${CHOST_sparc32};
  1855.             export LIBDIR_sparc32="lib";
  1856.             export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  1857.             export CHOST_sparc64=${CTARGET};
  1858.             export CTARGET_sparc64=${CHOST_sparc64};
  1859.             export LIBDIR_sparc64="lib64";
  1860.             : ${MULTILIB_ABIS=sparc64 sparc32};
  1861.             : ${DEFAULT_ABI=sparc64}
  1862.         ;;
  1863.         *)
  1864.             : ${MULTILIB_ABIS=default};
  1865.             : ${DEFAULT_ABI=default}
  1866.         ;;
  1867.     esac;
  1868.     export MULTILIB_ABIS DEFAULT_ABI
  1869. }
  1870. multilib_toolchain_setup ()
  1871. {
  1872.     local v vv;
  1873.     export ABI=$1;
  1874.     if [[ ${__DEFAULT_ABI_SAVED} == "true" ]]; then
  1875.         for v in CHOST CBUILD AS CC CXX LD PKG_CONFIG_{LIBDIR,PATH};
  1876.         do
  1877.             vv="__abi_saved_${v}";
  1878.             [[ ${!vv+set} == "set" ]] && export ${v}="${!vv}" || unset ${v};
  1879.             unset ${vv};
  1880.         done;
  1881.         unset __DEFAULT_ABI_SAVED;
  1882.     fi;
  1883.     if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  1884.         for v in CHOST CBUILD AS CC CXX LD PKG_CONFIG_{LIBDIR,PATH};
  1885.         do
  1886.             vv="__abi_saved_${v}";
  1887.             [[ ${!v+set} == "set" ]] && export ${vv}="${!v}" || unset ${vv};
  1888.         done;
  1889.         export __DEFAULT_ABI_SAVED="true";
  1890.         export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  1891.         export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  1892.         export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  1893.         export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  1894.         export CHOST=$(get_abi_CHOST $1);
  1895.         export CBUILD=$(get_abi_CHOST $1);
  1896.         export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig;
  1897.         export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig;
  1898.     fi
  1899. }
  1900. newicon ()
  1901. {
  1902.     _iconins ${FUNCNAME} "$@"
  1903. }
  1904. newmenu ()
  1905. {
  1906.     ( insinto /usr/share/applications;
  1907.     newins "$@" )
  1908. }
  1909. no-as-needed ()
  1910. {
  1911.     case $($(tc-getLD) -v 2>&1 </dev/null) in
  1912.         *GNU*)
  1913.             echo "-Wl,--no-as-needed"
  1914.         ;;
  1915.     esac
  1916. }
  1917. number_abis ()
  1918. {
  1919.     set -- `get_install_abis`;
  1920.     echo $#
  1921. }
  1922. optfeature ()
  1923. {
  1924.     debug-print-function ${FUNCNAME} "$@";
  1925.     local i j msg;
  1926.     local desc=$1;
  1927.     local flag=0;
  1928.     shift;
  1929.     for i in "$@";
  1930.     do
  1931.         for j in ${i};
  1932.         do
  1933.             if has_version "${j}"; then
  1934.                 flag=1;
  1935.             else
  1936.                 flag=0;
  1937.                 break;
  1938.             fi;
  1939.         done;
  1940.         if [[ ${flag} -eq 1 ]]; then
  1941.             break;
  1942.         fi;
  1943.     done;
  1944.     if [[ ${flag} -eq 0 ]]; then
  1945.         for i in "$@";
  1946.         do
  1947.             msg=" ";
  1948.             for j in ${i};
  1949.             do
  1950.                 msg+=" ${j} and";
  1951.             done;
  1952.             msg="${msg:0: -4} for ${desc}";
  1953.             elog "${msg}";
  1954.         done;
  1955.     fi
  1956. }
  1957. path_exists ()
  1958. {
  1959.     local opt=$1;
  1960.     [[ ${opt} == -[ao] ]] && shift || opt="-a";
  1961.     [[ $# -eq 0 ]] && return 1;
  1962.     local p r=0;
  1963.     for p in "$@";
  1964.     do
  1965.         [[ -e ${p} ]];
  1966.         : $(( r += $? ));
  1967.     done;
  1968.     case ${opt} in
  1969.         -a)
  1970.             return $(( r != 0 ))
  1971.         ;;
  1972.         -o)
  1973.             return $(( r == $# ))
  1974.         ;;
  1975.     esac
  1976. }
  1977. pkg_nofetch ()
  1978. {
  1979.     __eapi0_pkg_nofetch "$@"
  1980. }
  1981. pkg_postinst ()
  1982. {
  1983.     einfo "etherwake and such have been split into net-misc/ethercard-diag"
  1984. }
  1985. pkg_setup ()
  1986. {
  1987.     [[ -n ${VAPIER_LOVES_YOU} ]] && maint_pkg_create
  1988. }
  1989. preserve_old_lib ()
  1990. {
  1991.     _eutils_eprefix_init;
  1992.     if [[ ${EBUILD_PHASE} != "preinst" ]]; then
  1993.         eerror "preserve_old_lib() must be called from pkg_preinst() only";
  1994.         die "Invalid preserve_old_lib() usage";
  1995.     fi;
  1996.     [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]";
  1997.     has preserve-libs ${FEATURES} && return 0;
  1998.     local lib dir;
  1999.     for lib in "$@";
  2000.     do
  2001.         [[ -e ${EROOT}/${lib} ]] || continue;
  2002.         dir=${lib%/*};
  2003.         dodir ${dir} || die "dodir ${dir} failed";
  2004.         cp "${EROOT}"/${lib} "${ED}"/${lib} || die "cp ${lib} failed";
  2005.         touch "${ED}"/${lib};
  2006.     done
  2007. }
  2008. preserve_old_lib_notify ()
  2009. {
  2010.     if [[ ${EBUILD_PHASE} != "postinst" ]]; then
  2011.         eerror "preserve_old_lib_notify() must be called from pkg_postinst() only";
  2012.         die "Invalid preserve_old_lib_notify() usage";
  2013.     fi;
  2014.     has preserve-libs ${FEATURES} && return 0;
  2015.     _eutils_eprefix_init;
  2016.     local lib notice=0;
  2017.     for lib in "$@";
  2018.     do
  2019.         [[ -e ${EROOT}/${lib} ]] || continue;
  2020.         if [[ ${notice} -eq 0 ]]; then
  2021.             notice=1;
  2022.             ewarn "Old versions of installed libraries were detected on your system.";
  2023.             ewarn "In order to avoid breaking packages that depend on these old libs,";
  2024.             ewarn "the libraries are not being removed.  You need to run revdep-rebuild";
  2025.             ewarn "in order to remove these old dependencies.  If you do not have this";
  2026.             ewarn "helper program, simply emerge the 'gentoolkit' package.";
  2027.             ewarn;
  2028.         fi;
  2029.         ewarn "  # revdep-rebuild --library '${lib}' && rm '${lib}'";
  2030.     done
  2031. }
  2032. prune_libtool_files ()
  2033. {
  2034.     debug-print-function ${FUNCNAME} "$@";
  2035.     local removing_all removing_modules opt;
  2036.     _eutils_eprefix_init;
  2037.     for opt in "$@";
  2038.     do
  2039.         case "${opt}" in
  2040.             --all)
  2041.                 removing_all=1;
  2042.                 removing_modules=1
  2043.             ;;
  2044.             --modules)
  2045.                 removing_modules=1
  2046.             ;;
  2047.             *)
  2048.                 die "Invalid argument to ${FUNCNAME}(): ${opt}"
  2049.             ;;
  2050.         esac;
  2051.     done;
  2052.     local f;
  2053.     local queue=();
  2054.     while IFS= read -r -d '' f; do
  2055.         local archivefile=${f/%.la/.a};
  2056.         if ! sed -n -e '/^# Generated by .*libtool/q0;4q1' "${f}"; then
  2057.             continue;
  2058.         fi;
  2059.         [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed';
  2060.         local reason pkgconfig_scanned;
  2061.         local snotlink=$(sed -n -e 's:^shouldnotlink=::p' "${f}");
  2062.         if [[ ${snotlink} == yes ]]; then
  2063.             if [[ -f ${archivefile} ]]; then
  2064.                 einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)";
  2065.                 queue+=("${archivefile}");
  2066.             fi;
  2067.             if [[ -n ${removing_modules} ]]; then
  2068.                 reason='module';
  2069.             fi;
  2070.         else
  2071.             if [[ -n ${removing_all} ]]; then
  2072.                 reason='requested';
  2073.             else
  2074.                 if [[ ! -f ${archivefile} ]]; then
  2075.                     reason='no static archive';
  2076.                 else
  2077.                     if [[ ! -n $(sed -nre                   "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p"                  "${f}") ]]; then
  2078.                         reason='no libs & flags';
  2079.                     else
  2080.                         if [[ ! -n ${pkgconfig_scanned} ]]; then
  2081.                             local pc_libs=();
  2082.                             if [[ ! -n ${removing_all} ]]; then
  2083.                                 local pc;
  2084.                                 local tf=${T}/prune-lt-files.pc;
  2085.                                 local pkgconf=$(tc-getPKG_CONFIG);
  2086.                                 while IFS= read -r -d '' pc; do
  2087.                                     local arg libs;
  2088.                                     if ${pkgconf} --exists "${pc}" &>/dev/null; then
  2089.                                         sed -e '/^Requires:/d' "${pc}" > "${tf}";
  2090.                                         libs=$(${pkgconf} --libs "${tf}");
  2091.                                     else
  2092.                                         libs=$(sed -ne 's/^Libs://p' "${pc}");
  2093.                                     fi;
  2094.                                     for arg in ${libs};
  2095.                                     do
  2096.                                         if [[ ${arg} == -l* ]]; then
  2097.                                             if [[ ${arg} == '*$*' ]]; then
  2098.                                                 eqawarn "${FUNCNAME}: variable substitution likely failed in ${pc}";
  2099.                                                 eqawarn "(arg: ${arg})";
  2100.                                                 eqawarn "Most likely, you need to add virtual/pkgconfig to DEPEND.";
  2101.                                             fi;
  2102.                                             pc_libs+=(lib${arg#-l}.la);
  2103.                                         fi;
  2104.                                     done;
  2105.                                 done < <(find "${D}" -type f -name '*.pc' -print0);
  2106.                                 rm -f "${tf}";
  2107.                             fi;
  2108.                             pkgconfig_scanned=1;
  2109.                         fi;
  2110.                         has "${f##*/}" "${pc_libs[@]}" && reason='covered by .pc';
  2111.                     fi;
  2112.                 fi;
  2113.             fi;
  2114.         fi;
  2115.         if [[ -n ${reason} ]]; then
  2116.             einfo "Removing unnecessary ${f#${D%/}} (${reason})";
  2117.             queue+=("${f}");
  2118.         fi;
  2119.     done < <(find "${ED}" -xtype f -name '*.la' -print0);
  2120.     if [[ -n ${queue[@]} ]]; then
  2121.         rm -f "${queue[@]}";
  2122.     fi
  2123. }
  2124. raw-ldflags ()
  2125. {
  2126.     local x input="$@";
  2127.     [[ -z ${input} ]] && input=${LDFLAGS};
  2128.     set --;
  2129.     for x in ${input};
  2130.     do
  2131.         case ${x} in
  2132.             -Wl,*)
  2133.                 x=${x#-Wl,};
  2134.                 set -- "$@" ${x//,/ }
  2135.             ;;
  2136.             *)
  2137.  
  2138.             ;;
  2139.         esac;
  2140.     done;
  2141.     echo "$@"
  2142. }
  2143. replace-cpu-flags ()
  2144. {
  2145.     local newcpu="$#";
  2146.     newcpu="${!newcpu}";
  2147.     while [ $# -gt 1 ]; do
  2148.         replace-flags "-march=${1}" "-march=${newcpu}";
  2149.         replace-flags "-mcpu=${1}" "-mcpu=${newcpu}";
  2150.         replace-flags "-mtune=${1}" "-mtune=${newcpu}";
  2151.         shift;
  2152.     done;
  2153.     return 0
  2154. }
  2155. replace-flags ()
  2156. {
  2157.     [[ $# != 2 ]] && die "Usage: replace-flags <old flag> <new flag>";
  2158.     local f var new;
  2159.     for var in $(all-flag-vars);
  2160.     do
  2161.         new=();
  2162.         for f in ${!var};
  2163.         do
  2164.             [[ ${f} == ${1} ]] && f=${2};
  2165.             new+=("${f}");
  2166.         done;
  2167.         eval export ${var}=\""${new[*]}"\";
  2168.     done;
  2169.     return 0
  2170. }
  2171. replace-sparc64-flags ()
  2172. {
  2173.     local SPARC64_CPUS="ultrasparc3 ultrasparc v9";
  2174.     if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then
  2175.         for x in ${SPARC64_CPUS};
  2176.         do
  2177.             CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}";
  2178.         done;
  2179.     else
  2180.         for x in ${SPARC64_CPUS};
  2181.         do
  2182.             CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  2183.         done;
  2184.     fi;
  2185.     if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]; then
  2186.         for x in ${SPARC64_CPUS};
  2187.         do
  2188.             CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}";
  2189.         done;
  2190.     else
  2191.         for x in ${SPARC64_CPUS};
  2192.         do
  2193.             CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  2194.         done;
  2195.     fi;
  2196.     export CFLAGS CXXFLAGS
  2197. }
  2198. set_opt ()
  2199. {
  2200.     local opt=$1 ans;
  2201.     shift;
  2202.     ans=$("$@" && echo y || echo n);
  2203.     einfo "Setting option ${opt} to ${ans}";
  2204.     sed -i -e "/^bool.* ${opt} /s:[yn]$:${ans}:" config.in || die
  2205. }
  2206. setup-allowed-flags ()
  2207. {
  2208.     ALLOWED_FLAGS="-pipe";
  2209.     ALLOWED_FLAGS+=" -O -O1 -O2 -Os -Og -mcpu -march -mtune";
  2210.     ALLOWED_FLAGS+=" -fstack-protector*";
  2211.     ALLOWED_FLAGS+=" -fbounds-checking -fno-strict-overflow";
  2212.     ALLOWED_FLAGS+=" -fno-PIE -fno-pie -fno-unit-at-a-time";
  2213.     ALLOWED_FLAGS+=" -g -g[0-9] -ggdb -ggdb[0-9] -gdwarf-* gstabs -gstabs+";
  2214.     ALLOWED_FLAGS+=" -fno-ident -fpermissive -frecord-gcc-switches";
  2215.     ALLOWED_FLAGS+=" -fdiagnostics*";
  2216.     ALLOWED_FLAGS+=" -W* -w";
  2217.     ALLOWED_FLAGS+=" -fno-stack-protector* -fabi-version=*      -fno-strict-aliasing -fno-bounds-checking -fstrict-overflow         -fno-omit-frame-pointer -fno-builtin*";
  2218.     ALLOWED_FLAGS+=" -mregparm -mno-app-regs -mapp-regs -mno-mmx -mno-sse       -mno-sse2 -mno-sse3 -mno-ssse3 -mno-sse4 -mno-sse4.1 -mno-sse4.2        -mno-avx -mno-aes -mno-pclmul -mno-sse4a -mno-3dnow -mno-popcnt         -mno-abm -mips1 -mips2 -mips3 -mips4 -mips32 -mips64 -mips16 -mplt      -msoft-float -mno-soft-float -mhard-float -mno-hard-float -mfpu         -mieee -mieee-with-inexact -mschedule -mfloat-gprs -mspe -mno-spe       -mtls-direct-seg-refs -mno-tls-direct-seg-refs -mflat -mno-flat         -mno-faster-structs -mfaster-structs -m32 -m64 -mx32 -mabi      -mlittle-endian -mbig-endian -EL -EB -fPIC -mlive-g0 -mcmodel       -mstack-bias -mno-stack-bias -msecure-plt -m*-toc -mfloat-abi       -D* -U*";
  2219.     ALLOWED_FLAGS+=" -mno-fma4 -mno-movbe -mno-xop -mno-lwp";
  2220.     ALLOWED_FLAGS+=" -mno-fsgsbase -mno-rdrnd -mno-f16c -mno-bmi -mno-tbm";
  2221.     ALLOWED_FLAGS+=" -mno-avx2 -mno-bmi2 -mno-fma -mno-lzcnt";
  2222.     ALLOWED_FLAGS+=" -mno-fxsr -mno-rtm -mno-xsave -mno-xsaveopt";
  2223.     ALLOWED_FLAGS+=" -mno-avx512cd -mno-avx512er -mno-avx512f -mno-avx512pf -mno-sha";
  2224.     ALLOWED_FLAGS+=" -I* -L* -R* -Wl,*";
  2225.     export ALLOWED_FLAGS;
  2226.     return 0
  2227. }
  2228. src_compile ()
  2229. {
  2230.     __eapi2_src_compile "$@"
  2231. }
  2232. src_configure ()
  2233. {
  2234.     set_opt I18N use nls;
  2235.     set_opt HAVE_HWIB has_version '>=sys-kernel/linux-headers-2.6';
  2236.     set_opt HAVE_HWTR has_version '<sys-kernel/linux-headers-3.5';
  2237.     set_opt HAVE_HWSTRIP has_version '<sys-kernel/linux-headers-3.6';
  2238.     set_opt SELINUX use selinux;
  2239.     if use static; then
  2240.         append-flags -static;
  2241.         append-ldflags -static;
  2242.     fi;
  2243.     tc-export AR CC;
  2244.     yes "" | ./configure.sh config.in || die
  2245. }
  2246. src_install ()
  2247. {
  2248.     emake DESTDIR="${ED}" install || die;
  2249.     dodoc README README.ipv6 TODO
  2250. }
  2251. src_prepare ()
  2252. {
  2253.     if [[ -n ${PATCH_VER} ]]; then
  2254.         use old-output || EPATCH_EXCLUDE="0001-revert-621a2f376334f8097604b9fee5783e0f1141e66d-for-.patch";
  2255.         EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" epatch "${WORKDIR}"/${P}-patches-${PATCH_VER};
  2256.     fi
  2257. }
  2258. src_test ()
  2259. {
  2260.     __eapi0_src_test "$@"
  2261. }
  2262. src_unpack ()
  2263. {
  2264.     __eapi0_src_unpack "$@"
  2265. }
  2266. strip-flags ()
  2267. {
  2268.     local x y var;
  2269.     setup-allowed-flags;
  2270.     set -f;
  2271.     for var in $(all-flag-vars);
  2272.     do
  2273.         local new=();
  2274.         for x in ${!var};
  2275.         do
  2276.             local flag=${x%%=*};
  2277.             for y in ${ALLOWED_FLAGS};
  2278.             do
  2279.                 if [[ -z ${flag%%${y}} ]]; then
  2280.                     new+=("${x}");
  2281.                     break;
  2282.                 fi;
  2283.             done;
  2284.         done;
  2285.         if _is_flagq ${var} "-O*" && ! _is_flagq new "-O*"; then
  2286.             new+=(-O2);
  2287.         fi;
  2288.         if [[ ${!var} != "${new[*]}" ]]; then
  2289.             einfo "strip-flags: ${var}: changed '${!var}' to '${new[*]}'";
  2290.         fi;
  2291.         eval export ${var}=\""${new[*]}"\";
  2292.     done;
  2293.     set +f;
  2294.     return 0
  2295. }
  2296. strip-linguas ()
  2297. {
  2298.     local ls newls nols;
  2299.     if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
  2300.         local op=$1;
  2301.         shift;
  2302.         ls=$(find "$1" -name '*.po' -exec basename {} .po ';');
  2303.         shift;
  2304.         local d f;
  2305.         for d in "$@";
  2306.         do
  2307.             if [[ ${op} == "-u" ]]; then
  2308.                 newls=${ls};
  2309.             else
  2310.                 newls="";
  2311.             fi;
  2312.             for f in $(find "$d" -name '*.po' -exec basename {} .po ';');
  2313.             do
  2314.                 if [[ ${op} == "-i" ]]; then
  2315.                     has ${f} ${ls} && newls="${newls} ${f}";
  2316.                 else
  2317.                     has ${f} ${ls} || newls="${newls} ${f}";
  2318.                 fi;
  2319.             done;
  2320.             ls=${newls};
  2321.         done;
  2322.     else
  2323.         ls="$@";
  2324.     fi;
  2325.     nols="";
  2326.     newls="";
  2327.     for f in ${LINGUAS};
  2328.     do
  2329.         if has ${f} ${ls}; then
  2330.             newls="${newls} ${f}";
  2331.         else
  2332.             nols="${nols} ${f}";
  2333.         fi;
  2334.     done;
  2335.     [[ -n ${nols} ]] && einfo "Sorry, but ${PN} does not support the LINGUAS:" ${nols};
  2336.     export LINGUAS=${newls:1}
  2337. }
  2338. strip-unsupported-flags ()
  2339. {
  2340.     export CFLAGS=$(test-flags-CC ${CFLAGS});
  2341.     export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS});
  2342.     export FFLAGS=$(test-flags-F77 ${FFLAGS});
  2343.     export FCFLAGS=$(test-flags-FC ${FCFLAGS})
  2344. }
  2345. tc-arch ()
  2346. {
  2347.     tc-ninja_magic_to_arch portage "$@"
  2348. }
  2349. tc-arch-kernel ()
  2350. {
  2351.     tc-ninja_magic_to_arch kern "$@"
  2352. }
  2353. tc-endian ()
  2354. {
  2355.     local host=$1;
  2356.     [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  2357.     host=${host%%-*};
  2358.     case ${host} in
  2359.         aarch64*be)
  2360.             echo big
  2361.         ;;
  2362.         aarch64)
  2363.             echo little
  2364.         ;;
  2365.         alpha*)
  2366.             echo big
  2367.         ;;
  2368.         arm*b*)
  2369.             echo big
  2370.         ;;
  2371.         arm*)
  2372.             echo little
  2373.         ;;
  2374.         cris*)
  2375.             echo little
  2376.         ;;
  2377.         hppa*)
  2378.             echo big
  2379.         ;;
  2380.         i?86*)
  2381.             echo little
  2382.         ;;
  2383.         ia64*)
  2384.             echo little
  2385.         ;;
  2386.         m68*)
  2387.             echo big
  2388.         ;;
  2389.         mips*l*)
  2390.             echo little
  2391.         ;;
  2392.         mips*)
  2393.             echo big
  2394.         ;;
  2395.         powerpc*le)
  2396.             echo little
  2397.         ;;
  2398.         powerpc*)
  2399.             echo big
  2400.         ;;
  2401.         s390*)
  2402.             echo big
  2403.         ;;
  2404.         sh*b*)
  2405.             echo big
  2406.         ;;
  2407.         sh*)
  2408.             echo little
  2409.         ;;
  2410.         sparc*)
  2411.             echo big
  2412.         ;;
  2413.         x86_64*)
  2414.             echo little
  2415.         ;;
  2416.         *)
  2417.             echo wtf
  2418.         ;;
  2419.     esac
  2420. }
  2421. tc-env_build ()
  2422. {
  2423.     tc-export_build_env;
  2424.     CFLAGS=${BUILD_CFLAGS} CXXFLAGS=${BUILD_CXXFLAGS} CPPFLAGS=${BUILD_CPPFLAGS} LDFLAGS=${BUILD_LDFLAGS} AR=$(tc-getBUILD_AR) AS=$(tc-getBUILD_AS) CC=$(tc-getBUILD_CC) CPP=$(tc-getBUILD_CPP) CXX=$(tc-getBUILD_CXX) LD=$(tc-getBUILD_LD) NM=$(tc-getBUILD_NM) PKG_CONFIG=$(tc-getBUILD_PKG_CONFIG) RANLIB=$(tc-getBUILD_RANLIB) "$@"
  2425. }
  2426. tc-export ()
  2427. {
  2428.     local var;
  2429.     for var in "$@";
  2430.     do
  2431.         [[ $(type -t tc-get${var}) != "function" ]] && die "tc-export: invalid export variable '${var}'";
  2432.         eval tc-get${var} > /dev/null;
  2433.     done
  2434. }
  2435. tc-export_build_env ()
  2436. {
  2437.     tc-export "$@";
  2438.     : ${BUILD_CFLAGS:=-O1 -pipe};
  2439.     : ${BUILD_CXXFLAGS:=-O1 -pipe};
  2440.     : ${BUILD_CPPFLAGS:=};
  2441.     : ${BUILD_LDFLAGS:=};
  2442.     export BUILD_{C,CXX,CPP,LD}FLAGS;
  2443.     local v;
  2444.     for v in BUILD_{C,CXX,CPP,LD}FLAGS;
  2445.     do
  2446.         export ${v#BUILD_}_FOR_BUILD="${!v}";
  2447.     done
  2448. }
  2449. tc-getAR ()
  2450. {
  2451.     tc-getPROG AR ar "$@"
  2452. }
  2453. tc-getAS ()
  2454. {
  2455.     tc-getPROG AS as "$@"
  2456. }
  2457. tc-getBUILD_AR ()
  2458. {
  2459.     tc-getBUILD_PROG AR ar "$@"
  2460. }
  2461. tc-getBUILD_AS ()
  2462. {
  2463.     tc-getBUILD_PROG AS as "$@"
  2464. }
  2465. tc-getBUILD_CC ()
  2466. {
  2467.     tc-getBUILD_PROG CC gcc "$@"
  2468. }
  2469. tc-getBUILD_CPP ()
  2470. {
  2471.     tc-getBUILD_PROG CPP cpp "$@"
  2472. }
  2473. tc-getBUILD_CXX ()
  2474. {
  2475.     tc-getBUILD_PROG CXX g++ "$@"
  2476. }
  2477. tc-getBUILD_LD ()
  2478. {
  2479.     tc-getBUILD_PROG LD ld "$@"
  2480. }
  2481. tc-getBUILD_NM ()
  2482. {
  2483.     tc-getBUILD_PROG NM nm "$@"
  2484. }
  2485. tc-getBUILD_OBJCOPY ()
  2486. {
  2487.     tc-getBUILD_PROG OBJCOPY objcopy "$@"
  2488. }
  2489. tc-getBUILD_PKG_CONFIG ()
  2490. {
  2491.     tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  2492. }
  2493. tc-getBUILD_PROG ()
  2494. {
  2495.     _tc-getPROG CBUILD "BUILD_$1 $1_FOR_BUILD HOST$1" "${@:2}"
  2496. }
  2497. tc-getBUILD_RANLIB ()
  2498. {
  2499.     tc-getBUILD_PROG RANLIB ranlib "$@"
  2500. }
  2501. tc-getBUILD_STRIP ()
  2502. {
  2503.     tc-getBUILD_PROG STRIP strip "$@"
  2504. }
  2505. tc-getCC ()
  2506. {
  2507.     tc-getPROG CC gcc "$@"
  2508. }
  2509. tc-getCPP ()
  2510. {
  2511.     tc-getPROG CPP cpp "$@"
  2512. }
  2513. tc-getCXX ()
  2514. {
  2515.     tc-getPROG CXX g++ "$@"
  2516. }
  2517. tc-getDLLWRAP ()
  2518. {
  2519.     tc-getPROG DLLWRAP dllwrap "$@"
  2520. }
  2521. tc-getF77 ()
  2522. {
  2523.     tc-getPROG F77 gfortran "$@"
  2524. }
  2525. tc-getFC ()
  2526. {
  2527.     tc-getPROG FC gfortran "$@"
  2528. }
  2529. tc-getGCJ ()
  2530. {
  2531.     tc-getPROG GCJ gcj "$@"
  2532. }
  2533. tc-getLD ()
  2534. {
  2535.     tc-getPROG LD ld "$@"
  2536. }
  2537. tc-getNM ()
  2538. {
  2539.     tc-getPROG NM nm "$@"
  2540. }
  2541. tc-getOBJCOPY ()
  2542. {
  2543.     tc-getPROG OBJCOPY objcopy "$@"
  2544. }
  2545. tc-getPKG_CONFIG ()
  2546. {
  2547.     tc-getPROG PKG_CONFIG pkg-config "$@"
  2548. }
  2549. tc-getPROG ()
  2550. {
  2551.     _tc-getPROG CHOST "$@"
  2552. }
  2553. tc-getRANLIB ()
  2554. {
  2555.     tc-getPROG RANLIB ranlib "$@"
  2556. }
  2557. tc-getRC ()
  2558. {
  2559.     tc-getPROG RC windres "$@"
  2560. }
  2561. tc-getSTRIP ()
  2562. {
  2563.     tc-getPROG STRIP strip "$@"
  2564. }
  2565. tc-has-openmp ()
  2566. {
  2567.     local base="${T}/test-tc-openmp";
  2568.     cat > "${base}.c"  <<-EOF
  2569. #include <omp.h>
  2570. int main() {
  2571. int nthreads, tid, ret = 0;
  2572. #pragma omp parallel private(nthreads, tid)
  2573. {
  2574. tid = omp_get_thread_num();
  2575. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  2576. }
  2577. return ret;
  2578. }
  2579. EOF
  2580.  
  2581.     $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &>/dev/null;
  2582.     local ret=$?;
  2583.     rm -f "${base}"*;
  2584.     return ${ret}
  2585. }
  2586. tc-has-tls ()
  2587. {
  2588.     local base="${T}/test-tc-tls";
  2589.     cat > "${base}.c"  <<-EOF
  2590. int foo(int *i) {
  2591. static __thread int j = 0;
  2592. return *i ? j : *i;
  2593. }
  2594. EOF
  2595.  
  2596.     local flags;
  2597.     case $1 in
  2598.         -s)
  2599.             flags="-S"
  2600.         ;;
  2601.         -c)
  2602.             flags="-c"
  2603.         ;;
  2604.         -l)
  2605.  
  2606.         ;;
  2607.         -*)
  2608.             die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  2609.         ;;
  2610.     esac;
  2611.     : ${flags:=-fPIC -shared -Wl,-z,defs};
  2612.     [[ $1 == -* ]] && shift;
  2613.     $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &>/dev/null;
  2614.     local ret=$?;
  2615.     rm -f "${base}"*;
  2616.     return ${ret}
  2617. }
  2618. tc-is-cross-compiler ()
  2619. {
  2620.     return $([[ ${CBUILD:-${CHOST}} != ${CHOST} ]])
  2621. }
  2622. tc-is-softfloat ()
  2623. {
  2624.     local CTARGET=${CTARGET:-${CHOST}};
  2625.     case ${CTARGET} in
  2626.         bfin* | h8300*)
  2627.             echo "only"
  2628.         ;;
  2629.         *)
  2630.             if [[ ${CTARGET//_/-} == *-softfloat-* ]]; then
  2631.                 echo "yes";
  2632.             else
  2633.                 if [[ ${CTARGET//_/-} == *-softfp-* ]]; then
  2634.                     echo "softfp";
  2635.                 else
  2636.                     echo "no";
  2637.                 fi;
  2638.             fi
  2639.         ;;
  2640.     esac
  2641. }
  2642. tc-is-static-only ()
  2643. {
  2644.     local host=${CTARGET:-${CHOST}};
  2645.     return $([[ ${host} == *-mint* ]])
  2646. }
  2647. tc-ninja_magic_to_arch ()
  2648. {
  2649.     function ninj ()
  2650.     {
  2651.         [[ ${type} == "kern" ]] && echo $1 || echo $2
  2652.     };
  2653.     local type=$1;
  2654.     local host=$2;
  2655.     [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  2656.     local KV=${KV:-${KV_FULL}};
  2657.     [[ ${type} == "kern" ]] && [[ -z ${KV} ]] && ewarn "QA: Kernel version could not be determined, please inherit kernel-2 or linux-info";
  2658.     case ${host} in
  2659.         aarch64*)
  2660.             echo arm64
  2661.         ;;
  2662.         alpha*)
  2663.             echo alpha
  2664.         ;;
  2665.         arm*)
  2666.             echo arm
  2667.         ;;
  2668.         avr*)
  2669.             ninj avr32 avr
  2670.         ;;
  2671.         bfin*)
  2672.             ninj blackfin bfin
  2673.         ;;
  2674.         c6x)
  2675.             echo c6x
  2676.         ;;
  2677.         cris*)
  2678.             echo cris
  2679.         ;;
  2680.         frv)
  2681.             echo frv
  2682.         ;;
  2683.         hexagon)
  2684.             echo hexagon
  2685.         ;;
  2686.         hppa*)
  2687.             ninj parisc hppa
  2688.         ;;
  2689.         i?86*)
  2690.             if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -lt $(KV_to_int 2.6.24) || ${host} == *freebsd* ]]; then
  2691.                 echo i386;
  2692.             else
  2693.                 echo x86;
  2694.             fi
  2695.         ;;
  2696.         ia64*)
  2697.             echo ia64
  2698.         ;;
  2699.         m68*)
  2700.             echo m68k
  2701.         ;;
  2702.         metag)
  2703.             echo metag
  2704.         ;;
  2705.         mips*)
  2706.             echo mips
  2707.         ;;
  2708.         nios2*)
  2709.             echo nios2
  2710.         ;;
  2711.         nios*)
  2712.             echo nios
  2713.         ;;
  2714.         or32)
  2715.             echo openrisc
  2716.         ;;
  2717.         powerpc*)
  2718.             if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]]; then
  2719.                 echo powerpc;
  2720.             else
  2721.                 if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -eq $(KV_to_int 2.6.15) ]]; then
  2722.                     if [[ ${host} == powerpc64* ]] || [[ ${PROFILE_ARCH} == "ppc64" ]]; then
  2723.                         echo powerpc;
  2724.                     else
  2725.                         echo ppc;
  2726.                     fi;
  2727.                 else
  2728.                     if [[ ${host} == powerpc64* ]]; then
  2729.                         echo ppc64;
  2730.                     else
  2731.                         if [[ ${PROFILE_ARCH} == "ppc64" ]]; then
  2732.                             ninj ppc64 ppc;
  2733.                         else
  2734.                             echo ppc;
  2735.                         fi;
  2736.                     fi;
  2737.                 fi;
  2738.             fi
  2739.         ;;
  2740.         s390*)
  2741.             echo s390
  2742.         ;;
  2743.         score)
  2744.             echo score
  2745.         ;;
  2746.         sh64*)
  2747.             ninj sh64 sh
  2748.         ;;
  2749.         sh*)
  2750.             echo sh
  2751.         ;;
  2752.         sparc64*)
  2753.             ninj sparc64 sparc
  2754.         ;;
  2755.         sparc*)
  2756.             [[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
  2757.         ;;
  2758.         tile*)
  2759.             echo tile
  2760.         ;;
  2761.         vax*)
  2762.             echo vax
  2763.         ;;
  2764.         x86_64*freebsd*)
  2765.             echo amd64
  2766.         ;;
  2767.         x86_64*)
  2768.             if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.24) ]]; then
  2769.                 echo x86;
  2770.             else
  2771.                 ninj x86_64 amd64;
  2772.             fi
  2773.         ;;
  2774.         xtensa*)
  2775.             echo xtensa
  2776.         ;;
  2777.         *)
  2778.             echo unknown
  2779.         ;;
  2780.     esac
  2781. }
  2782. test-flag-CC ()
  2783. {
  2784.     test-flag-PROG "CC" c "$1"
  2785. }
  2786. test-flag-CXX ()
  2787. {
  2788.     test-flag-PROG "CXX" c++ "$1"
  2789. }
  2790. test-flag-F77 ()
  2791. {
  2792.     test-flag-PROG "F77" f77 "$1"
  2793. }
  2794. test-flag-FC ()
  2795. {
  2796.     test-flag-PROG "FC" f95 "$1"
  2797. }
  2798. test-flag-PROG ()
  2799. {
  2800.     local comp=$1;
  2801.     local lang=$2;
  2802.     local flag=$3;
  2803.     [[ -z ${comp} || -z ${flag} ]] && return 1;
  2804.     local PROG=$(tc-get${comp});
  2805.     if ${PROG} -c -o /dev/null -x${lang} - < /dev/null > /dev/null 2>&1; then
  2806.         ${PROG} "${flag}" -c -o /dev/null -x${lang} - < /dev/null > /dev/null 2>&1;
  2807.     else
  2808.         ${PROG} "${flag}" -c -o /dev/null /dev/null > /dev/null 2>&1;
  2809.     fi
  2810. }
  2811. test-flags ()
  2812. {
  2813.     test-flags-CC "$@"
  2814. }
  2815. test-flags-CC ()
  2816. {
  2817.     test-flags-PROG "CC" "$@"
  2818. }
  2819. test-flags-CXX ()
  2820. {
  2821.     test-flags-PROG "CXX" "$@"
  2822. }
  2823. test-flags-F77 ()
  2824. {
  2825.     test-flags-PROG "F77" "$@"
  2826. }
  2827. test-flags-FC ()
  2828. {
  2829.     test-flags-PROG "FC" "$@"
  2830. }
  2831. test-flags-PROG ()
  2832. {
  2833.     local comp=$1;
  2834.     local flags=();
  2835.     local x;
  2836.     shift;
  2837.     [[ -z ${comp} ]] && return 1;
  2838.     for x in "$@";
  2839.     do
  2840.         test-flag-${comp} "${x}" && flags+=("${x}");
  2841.     done;
  2842.     echo "${flags[*]}";
  2843.     [[ ${#flags[@]} -gt 0 ]]
  2844. }
  2845. test_version_info ()
  2846. {
  2847.     if [[ $($(tc-getCC) --version 2>&1) == *$1* ]]; then
  2848.         return 0;
  2849.     else
  2850.         return 1;
  2851.     fi
  2852. }
  2853. use_if_iuse ()
  2854. {
  2855.     in_iuse $1 || return 1;
  2856.     use $1
  2857. }
  2858. usex ()
  2859. {
  2860.     use "$1" && echo "${2-yes}$4" || echo "${3-no}$5"
  2861. }
  2862. validate_desktop_entries ()
  2863. {
  2864.     _eutils_eprefix_init;
  2865.     if [[ -x "${EPREFIX}"/usr/bin/desktop-file-validate ]]; then
  2866.         einfo "Checking desktop entry validity";
  2867.         local directories="";
  2868.         for d in /usr/share/applications $@;
  2869.         do
  2870.             [[ -d ${ED}${d} ]] && directories="${directories} ${ED}${d}";
  2871.         done;
  2872.         if [[ -n ${directories} ]]; then
  2873.             for FILE in $(find ${directories} -name "*\.desktop"                            -not -path '*.hidden*' | sort -u 2>/dev/null);
  2874.             do
  2875.                 local temp=$(desktop-file-validate ${FILE} | grep -v "warning:" |                               sed -e "s|error: ||" -e "s|${FILE}:|--|g" );
  2876.                 [[ -n $temp ]] && elog ${temp/--/${FILE/${ED}/}:};
  2877.             done;
  2878.         fi;
  2879.         echo "";
  2880.     else
  2881.         einfo "Passing desktop entry validity check. Install dev-util/desktop-file-utils, if you want to help to improve Gentoo.";
  2882.     fi
  2883. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement