Advertisement
Guest User

Untitled

a guest
Jun 16th, 2012
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 120.43 KB | None | 0 0
  1. declare -x ABI="amd64"
  2. declare -a ALL_AUTOTOOLS_MACROS='([0]="AC_PROG_LIBTOOL" [1]="AM_PROG_LIBTOOL" [2]="LT_INIT" [3]="AC_CONFIG_HEADERS" [4]="AC_CONFIG_SUBDIRS" [5]="AC_CONFIG_AUX_DIR" [6]="AC_CONFIG_MACRO_DIR" [7]="AM_INIT_AUTOMAKE" [8]="AM_GLIB_GNU_GETTEXT" [9]="AM_GNU_GETTEXT_VERSION" [10]="AC_PROG_INTLTOOL" [11]="IT_PROG_INTLTOOL" [12]="GTK_DOC_CHECK" [13]="GNOME_DOC_INIT")'
  3. declare -x ALSA_CARDS=""
  4. declare -x ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol"
  5. declare -x ANT_HOME="/usr/share/ant"
  6. declare -x APACHE2_MODULES="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"
  7. declare -x ARCH="amd64"
  8. declare -- AT_M4DIR=""
  9. declare -- AT_SYS_M4DIR=""
  10. declare -- AUTOTOOLS_AUTO_DEPEND="yes"
  11. declare -- AUTOTOOLS_DEPEND="|| ( >=sys-devel/automake-1.11.1:1.11 >=sys-devel/automake-1.12:1.12 ) >=sys-devel/autoconf-2.68 sys-devel/libtool"
  12. declare -- BASE_EXPF="src_unpack src_compile src_install src_prepare src_configure"
  13. declare -x BOOTSTRAP_USE="cxx unicode multilib"
  14. declare -x CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump"
  15. declare -x CAMERAS="ptp2"
  16. declare -x CBUILD="x86_64-pc-linux-gnu"
  17. declare -x CC="x86_64-pc-linux-gnu-gcc"
  18. declare -x CFLAGS="-O2 -pipe"
  19. declare -x CFLAGS_amd64="-m64"
  20. declare -x CFLAGS_default
  21. declare -x CFLAGS_x32="-mx32"
  22. declare -x CFLAGS_x86="-m32"
  23. declare -x CG_COMPILER_EXE="/usr/bin/cgc"
  24. declare -x CHOST="x86_64-pc-linux-gnu"
  25. declare -x CHOST_amd64="x86_64-pc-linux-gnu"
  26. declare -x CHOST_default="x86_64-pc-linux-gnu"
  27. declare -x CHOST_x32="x86_64-pc-linux-gnu"
  28. declare -x CHOST_x86="i686-pc-linux-gnu"
  29. declare -x COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog"
  30. declare -x CROSSCOMPILE_OPTS=""
  31. declare -x CTARGET_default="x86_64-pc-linux-gnu"
  32. declare -x CXX="x86_64-pc-linux-gnu-g++"
  33. declare -x CXXFLAGS="-O2 -pipe"
  34. declare -x DEFAULT_ABI="amd64"
  35. declare -x DEFINED_PHASES=" compile configure install postinst preinst prepare setup unpack"
  36. declare DEPEND="dev-db/sqlite:3
  37. >=dev-games/physfs-2[zip]
  38. dev-libs/popt
  39. media-libs/libogg
  40. media-libs/libpng
  41. media-libs/libsdl[opengl,video]
  42. media-libs/libtheora
  43. media-libs/libvorbis
  44. media-libs/openal
  45. media-libs/sdl-net
  46. media-libs/quesoglc
  47. virtual/glu
  48. virtual/opengl
  49. nls? ( virtual/libintl )
  50. sys-devel/bison
  51. app-arch/zip
  52. virtual/pkgconfig
  53. nls? ( sys-devel/gettext ) || ( >=sys-devel/automake-1.11.1:1.11 >=sys-devel/automake-1.12:1.12 ) >=sys-devel/autoconf-2.68 sys-devel/libtool"
  54. declare DESCRIPTION="3D real-time strategy game"
  55. declare -x DESTTREE="/usr"
  56. declare -x DIROPTIONS="-m0755"
  57. declare -x EAPI="2"
  58. declare -- EBUILD_DEATH_HOOKS=" wait"
  59. declare -- ECLASSDIR_LOCAL="/usr/portage/eclass"
  60. declare -- ECONF_SOURCE="."
  61. declare -x ELIBC="glibc"
  62. declare -- EPATCH_COMMON_OPTS="-g0 -E --no-backup-if-mismatch"
  63. declare -- EPATCH_EXCLUDE=""
  64. declare -- EPATCH_FORCE="no"
  65. declare -- EPATCH_MULTI_MSG="Applying various patches (bugfixes/updates) ..."
  66. declare -- EPATCH_OPTS=""
  67. declare -- EPATCH_SINGLE_MSG=""
  68. declare -- EPATCH_SOURCE="/var/tmp/portage/games-strategy/warzone2100-2.3.9/work/patch"
  69. declare -- EPATCH_SUFFIX="patch.bz2"
  70. declare -x EXEOPTIONS="-m0755"
  71. declare -x FCFLAGS=""
  72. 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}\\\" -avP \\\"\\\${host}:/\\\${x#*/}\\\" \\\"\\\$1\\\"\" rsync \"\${DISTDIR}/\${FILE}\" \"\${URI}\""
  73. declare -x FFLAGS=""
  74. declare -x GAMES_BINDIR="/usr/games/bin"
  75. declare -x GAMES_DATADIR="/usr/share/games"
  76. declare -x GAMES_DATADIR_BASE="/usr/share"
  77. declare -x GAMES_ENVD="90games"
  78. declare -x GAMES_GROUP="games"
  79. declare -x GAMES_LOGDIR="/var/log/games"
  80. declare -x GAMES_PREFIX="/usr/games"
  81. declare -x GAMES_PREFIX_OPT="/opt"
  82. declare -x GAMES_STATEDIR="/var/games"
  83. declare -x GAMES_SYSCONFDIR="/etc/games"
  84. declare -x GAMES_USER="root"
  85. declare -x GAMES_USER_DED="games"
  86. declare -x GCC_SPECS=""
  87. declare -x GDK_USE_XFT="1"
  88. 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 ubx"
  89. declare -x GRUB_PLATFORMS=""
  90. declare -x GSETTINGS_BACKEND="gconf"
  91. declare HOMEPAGE="http://wz2100.net/"
  92. declare -x INHERITED=" multilib toolchain-funcs libtool multiprocessing autotools user eutils versionator base games"
  93. declare -x INPUT_DEVICES="evdev synaptics"
  94. declare -x INSDESTTREE=""
  95. declare -x INSOPTIONS="-m0644"
  96. declare IUSE="debug nls videos "
  97. declare -x JAVAC="/etc/java-config-2/current-system-vm/bin/javac"
  98. declare -x JAVA_HOME="/etc/java-config-2/current-system-vm"
  99. declare -x JDK_HOME="/etc/java-config-2/current-system-vm"
  100. declare -x KERNEL="linux"
  101. declare -x KERNEL_ABI="amd64"
  102. declare -x KEYWORDS="amd64 ~ppc x86"
  103. declare -x KV="3.2.12-gentoo"
  104. declare -x LCD_DEVICES=""
  105. declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed"
  106. declare -x LDFLAGS_amd64="-m elf_x86_64"
  107. declare -x LDFLAGS_default
  108. declare -x LDFLAGS_x32="-m elf32_x86_64"
  109. declare -x LDFLAGS_x86="-m elf_i386"
  110. declare -x LIBDIR_amd64="lib64"
  111. declare -x LIBDIR_amd64_fbsd="lib64"
  112. declare -x LIBDIR_default="lib"
  113. declare -x LIBDIR_n32="lib32"
  114. declare -x LIBDIR_n64="lib64"
  115. declare -x LIBDIR_o32="lib"
  116. declare -x LIBDIR_ppc="lib32"
  117. declare -x LIBDIR_ppc64="lib64"
  118. declare -x LIBDIR_s390="lib32"
  119. declare -x LIBDIR_s390x="lib64"
  120. declare -x LIBDIR_sparc32="lib32"
  121. declare -x LIBDIR_sparc64="lib64"
  122. declare -x LIBDIR_x32="libx32"
  123. declare -x LIBDIR_x86="lib32"
  124. declare -x LIBDIR_x86_fbsd="lib32"
  125. declare -x LIBGL_DRIVERS_PATH="/usr/lib64/dri:/usr/lib32/dri"
  126. declare -x LIBOPTIONS="-m0644"
  127. declare -x LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer"
  128. declare -x LICENSE="GPL-2 CCPL-Attribution-ShareAlike-3.0 public-domain"
  129. declare -x MULTILIB_ABIS="amd64 x86"
  130. declare -x MULTILIB_STRICT_DENY="64-bit.*shared object"
  131. 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"
  132. declare -x MULTILIB_STRICT_EXEMPT="(perl5|gcc|gcc-lib|binutils|eclipse-3|debug|portage|udev)"
  133. declare -- MY_PV="2.3"
  134. declare -x NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
  135. declare -x OPENCL_PROFILE="amd"
  136. declare -x OPENGL_PROFILE="ati"
  137. 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.5.3"
  138. declare PDEPEND=""
  139. declare -x PHP_TARGETS=""
  140. declare -x PKG_CONFIG_PATH="/usr/lib64/pkgconfig"
  141. declare -a PORTAGE_DOCOMPRESS='([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")'
  142. declare -a PORTAGE_DOCOMPRESS_SKIP='([0]="/usr/share/doc/warzone2100-2.3.9/html")'
  143. declare -x PRELINK_PATH_MASK="/usr/lib64/klibc:/usr/lib64/libfreebl3.so:/usr/lib64/libnssdbm3.so:/usr/lib64/libsoftokn3.so"
  144. declare -x PROFILE_ONLY_VARIABLES="ARCH ELIBC KERNEL USERLAND"
  145. declare -x PROPERTIES=""
  146. declare -x PROVIDE=""
  147. declare -x PYTHONDONTWRITEBYTECODE="1"
  148. declare -x PYTHON_TARGETS="python3_2"
  149. declare -x QT_GRAPHICSSYSTEM="raster"
  150. declare -x QT_PLUGIN_PATH="/usr/lib64/kde4/plugins"
  151. declare -x RDEPEND="dev-db/sqlite:3
  152. >=dev-games/physfs-2[zip]
  153. dev-libs/popt
  154. media-libs/libogg
  155. media-libs/libpng
  156. media-libs/libsdl[opengl,video]
  157. media-libs/libtheora
  158. media-libs/libvorbis
  159. media-libs/openal
  160. media-libs/sdl-net
  161. media-libs/quesoglc
  162. virtual/glu
  163. virtual/opengl
  164. nls? ( virtual/libintl )
  165. media-fonts/dejavu "
  166. declare REPOSITORY
  167. declare REQUIRED_USE=""
  168. declare -x RESTRICT=""
  169. 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}\\\" -avP \\\"\\\${host}:/\\\${x#*/}\\\" \\\"\\\$1\\\"\" rsync \"\${DISTDIR}/\${FILE}\" \"\${URI}\""
  170. declare -x RUBY_TARGETS="ruby18 ruby19"
  171. declare -x S="/var/tmp/portage/games-strategy/warzone2100-2.3.9/work/warzone2100-2.3.9"
  172. declare -x SANDBOX_DEBUG="0"
  173. declare -x SANDBOX_DENY=""
  174. declare -x SANDBOX_PID="12413"
  175. declare -x SANDBOX_PREDICT="/var/tmp/portage/games-strategy/warzone2100-2.3.9/homedir:/dev/crypto:/dev/random:/proc/self/coredump_filter:/var/cache/fontconfig"
  176. declare -x SANDBOX_READ="/:/var/tmp"
  177. declare -x SANDBOX_VERBOSE="1"
  178. 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:/proc/self/fd:/tmp/:/usr/lib/cf:/usr/lib/conftest:/usr/lib32/cf:/usr/lib32/conftest:/usr/lib64/cf:/usr/lib64/conftest:/usr/tmp/cf:/usr/tmp/conftest:/var/tmp:/var/tmp/:/var/tmp/portage/games-strategy/warzone2100-2.3.9/homedir/.bash_history"
  179. declare -x SANE_CONFIG_DIR="/etc/sane.d"
  180. declare -x SLOT="0"
  181. declare SRC_URI="mirror://sourceforge/warzone2100/warzone2100-2.3.9.tar.gz
  182. videos? ( mirror://sourceforge/warzone2100/warzone2100/Videos/2.2/high-quality-en/sequences.wz -> warzone2100-videos-2.2.wz )"
  183. declare -x SYMLINK_LIB="yes"
  184. declare -x USB_DEVFS_PATH="/dev/bus/usb"
  185. declare -x USE="amd64 consolekit elibc_glibc kernel_linux multilib nls policykit userland_GNU"
  186. declare -x USERLAND="GNU"
  187. declare -- VIDEOS_P="warzone2100-videos-2.2.wz"
  188. declare -- VIDEOS_PV="2.2"
  189. declare -x VIDEO_CARDS=""
  190. declare -x WANT_AUTOCONF="2.5"
  191. declare -x WANT_AUTOMAKE="1.11"
  192. declare -x WANT_LIBTOOL="latest"
  193. declare -x XDG_CONFIG_DIRS="/etc/xdg"
  194. declare -x XDG_DATA_DIRS="/usr/local/share:/usr/share"
  195. 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"
  196. declare -x _E_DOCDESTTREE_=""
  197. declare -x _E_EXEDESTTREE_=""
  198. declare -a _LATEST_AUTOMAKE='([0]="1.11.1:1.11" [1]="1.12:1.12")'
  199. declare -- ___ECLASS_ONCE_AUTOTOOLS="recur -_+^+_- spank"
  200. declare -- ___ECLASS_ONCE_BASE="recur -_+^+_- spank"
  201. declare -- ___ECLASS_ONCE_EUTILS="recur -_+^+_- spank"
  202. declare -- ___ECLASS_ONCE_GAMES="recur -_+^+_- spank"
  203. declare -- ___ECLASS_ONCE_LIBTOOL="recur -_+^+_- spank"
  204. declare -- ___ECLASS_ONCE_MULTILIB="recur -_+^+_- spank"
  205. declare -- ___ECLASS_ONCE_MULTIPROCESSING="recur -_+^+_- spank"
  206. declare -- ___ECLASS_ONCE_TOOLCHAIN_FUNCS="recur -_+^+_- spank"
  207. declare -- ___ECLASS_ONCE_USER="recur -_+^+_- spank"
  208. declare -- ___ECLASS_ONCE_VERSIONATOR="recur -_+^+_- spank"
  209. declare -- _libtool_atom="sys-devel/libtool"
  210. declare -- mj_control_fd="10"
  211. declare -- mj_max_jobs="1"
  212. declare -- mj_num_jobs="0"
  213. declare -- phase_func
  214. ELT_libtool_version ()
  215. {
  216. ( unset VERSION;
  217. eval $(grep -e '^[[:space:]]*VERSION=' "$1");
  218. echo "${VERSION:-0}" )
  219. }
  220. ELT_try_and_apply_patch ()
  221. {
  222. local ret=0;
  223. local file=$1;
  224. local patch=$2;
  225. local src=$3;
  226. local disp="${src} patch";
  227. local log="${T}/elibtool.log";
  228. if [[ -z ${__ELT_NOTED_TMP} ]]; then
  229. __ELT_NOTED_TMP=true;
  230. printf 'temp patch: %s\n' "${patch}" > "${log}";
  231. fi;
  232. printf '\nTrying %s\n' "${disp}" >> "${log}";
  233. if patch -p0 --dry-run "${file}" "${patch}" >> "${log}" 2>&1; then
  234. einfo " Applying ${disp} ...";
  235. patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" >> "${log}" 2>&1;
  236. ret=$?;
  237. export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${src}";
  238. else
  239. ret=1;
  240. fi;
  241. return "${ret}"
  242. }
  243. ELT_walk_patches ()
  244. {
  245. local patch tmp;
  246. local ret=1;
  247. local file=$1;
  248. local patch_set=$2;
  249. local patch_dir="$(elt_patch_dir)/${patch_set}";
  250. local rem_int_dep=$3;
  251. [[ -z ${patch_set} ]] && return 1;
  252. [[ ! -d ${patch_dir} ]] && return 1;
  253. local sed_args=(-e "s:@GENTOO_LIBDIR@:$(get_libdir):g");
  254. if [[ -n ${rem_int_dep} ]]; then
  255. sed_args+=(-e "s|@REM_INT_DEP@|${rem_int_dep}|g");
  256. fi;
  257. pushd "$(elt_patch_dir)" > /dev/null || die;
  258. for patch in $(find "${patch_set}" -maxdepth 1 -type f | LC_ALL=C sort -r);
  259. do
  260. tmp="${T}/libtool-elt.patch";
  261. sed "${sed_args[@]}" "${patch}" > "${tmp}" || die;
  262. if ELT_try_and_apply_patch "${file}" "${tmp}" "${patch}"; then
  263. ret=0;
  264. break;
  265. fi;
  266. done;
  267. popd > /dev/null;
  268. return ${ret}
  269. }
  270. VER_major ()
  271. {
  272. [[ -z $1 ]] && return 1;
  273. local VER=$@;
  274. echo "${VER%%[^[:digit:]]*}"
  275. }
  276. VER_micro ()
  277. {
  278. [[ -z $1 ]] && return 1;
  279. local VER=$@;
  280. VER=${VER#*.*.};
  281. echo "${VER%%[^[:digit:]]*}"
  282. }
  283. VER_minor ()
  284. {
  285. [[ -z $1 ]] && return 1;
  286. local VER=$@;
  287. VER=${VER#*.};
  288. echo "${VER%%[^[:digit:]]*}"
  289. }
  290. VER_to_int ()
  291. {
  292. [[ -z $1 ]] && return 1;
  293. local VER_MAJOR=$(VER_major "$1");
  294. local VER_MINOR=$(VER_minor "$1");
  295. local VER_MICRO=$(VER_micro "$1");
  296. local VER_int=$(( VER_MAJOR * 65536 + VER_MINOR * 256 + VER_MICRO ));
  297. if [[ ${VER_int} -ge 65536 ]]; then
  298. echo "${VER_int}";
  299. return 0;
  300. fi;
  301. echo 1;
  302. return 1
  303. }
  304. _assert_pkg_ebuild_phase ()
  305. {
  306. case ${EBUILD_PHASE} in
  307. setup | preinst | postinst)
  308.  
  309. ;;
  310. *)
  311. eerror "'$1()' called from '${EBUILD_PHASE}' phase which is not OK:";
  312. eerror "You may only call from pkg_{setup,preinst,postinst} functions.";
  313. eerror "Package fails at QA and at life. Please file a bug.";
  314. die "Bad package! $1 is only for use in some pkg_* functions!"
  315. ;;
  316. esac
  317. }
  318. _at_uses_autoheader ()
  319. {
  320. _at_uses_pkg AC_CONFIG_HEADERS
  321. }
  322. _at_uses_automake ()
  323. {
  324. _at_uses_pkg AM_INIT_AUTOMAKE
  325. }
  326. _at_uses_gettext ()
  327. {
  328. _at_uses_pkg AM_GNU_GETTEXT_VERSION
  329. }
  330. _at_uses_glibgettext ()
  331. {
  332. _at_uses_pkg AM_GLIB_GNU_GETTEXT
  333. }
  334. _at_uses_gnomedoc ()
  335. {
  336. _at_uses_pkg GNOME_DOC_INIT
  337. }
  338. _at_uses_gtkdoc ()
  339. {
  340. _at_uses_pkg GTK_DOC_CHECK
  341. }
  342. _at_uses_intltool ()
  343. {
  344. _at_uses_pkg {AC,IT}_PROG_INTLTOOL
  345. }
  346. _at_uses_libtool ()
  347. {
  348. _at_uses_pkg A{C,M}_PROG_LIBTOOL LT_INIT
  349. }
  350. _at_uses_pkg ()
  351. {
  352. if [[ -n $(autotools_check_macro "$@") ]]; then
  353. return 0;
  354. else
  355. local macro args=();
  356. for macro in "$@";
  357. do
  358. args+=(-e "^[[:space:]]*${macro}\>");
  359. done;
  360. egrep -q "${args[@]}" configure.??;
  361. fi
  362. }
  363. _autotools_m4dir_include ()
  364. {
  365. local x include_opts;
  366. for x in "$@";
  367. do
  368. case ${x} in
  369. -I)
  370.  
  371. ;;
  372. *)
  373. [[ ! -d ${x} ]] && ewarn "autotools.eclass: '${x}' does not exist";
  374. include_opts+=" -I ${x}"
  375. ;;
  376. esac;
  377. done;
  378. echo ${include_opts}
  379. }
  380. _elibtoolize ()
  381. {
  382. local LIBTOOLIZE=${LIBTOOLIZE:-libtoolize};
  383. type -P glibtoolize > /dev/null && LIBTOOLIZE=glibtoolize;
  384. [[ -f GNUmakefile.am || -f Makefile.am ]] && set -- "$@" --automake;
  385. if [[ $1 == "--install" ]]; then
  386. ${LIBTOOLIZE} -n --install &>/dev/null || shift;
  387. fi;
  388. autotools_run_tool ${LIBTOOLIZE} "$@" ${opts}
  389. }
  390. _gcc-install-dir ()
  391. {
  392. echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null | awk '$1=="install:" {print $2}')"
  393. }
  394. _gcc-specs-directive_raw ()
  395. {
  396. local cc=$(tc-getCC);
  397. local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  398. ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  399. $1=="*"directive":" { pspec=spec; spec=""; outside=0; next }
  400. outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  401. spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  402. { spec=spec $0 }
  403. END { print spec }';
  404. return 0
  405. }
  406. _gcc-specs-exists ()
  407. {
  408. [[ -f $(_gcc-install-dir)/$1 ]]
  409. }
  410. _gcc_fullversion ()
  411. {
  412. local ver="$1";
  413. shift;
  414. set -- `$(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__"`;
  415. eval echo "$ver"
  416. }
  417. _iconins ()
  418. {
  419. ( local funcname=$1;
  420. shift;
  421. local size dir;
  422. local context=apps;
  423. local theme=hicolor;
  424. while [[ $# -gt 0 ]]; do
  425. case $1 in
  426. -s | --size)
  427. if [[ ${2%%x*}x${2%%x*} == "$2" ]]; then
  428. size=${2%%x*};
  429. else
  430. size=${2};
  431. fi;
  432. case ${size} in
  433. 16 | 22 | 24 | 32 | 36 | 48 | 64 | 72 | 96 | 128 | 192 | 256)
  434. size=${size}x${size}
  435. ;;
  436. scalable)
  437.  
  438. ;;
  439. *)
  440. eerror "${size} is an unsupported icon size!";
  441. exit 1
  442. ;;
  443. esac;
  444. shift 2
  445. ;;
  446. -t | --theme)
  447. theme=${2};
  448. shift 2
  449. ;;
  450. -c | --context)
  451. context=${2};
  452. shift 2
  453. ;;
  454. *)
  455. if [[ -z ${size} ]]; then
  456. insinto /usr/share/pixmaps;
  457. else
  458. insinto /usr/share/icons/${theme}/${size}/${context};
  459. fi;
  460. if [[ ${funcname} == doicon ]]; then
  461. if [[ -f $1 ]]; then
  462. doins "${1}";
  463. else
  464. if [[ -d $1 ]]; then
  465. shopt -s nullglob;
  466. doins "${1}"/*.{png,svg};
  467. shopt -u nullglob;
  468. else
  469. eerror "${1} is not a valid file/directory!";
  470. exit 1;
  471. fi;
  472. fi;
  473. else
  474. break;
  475. fi;
  476. shift 1
  477. ;;
  478. esac;
  479. done;
  480. if [[ ${funcname} == newicon ]]; then
  481. newins "$@";
  482. fi ) || die
  483. }
  484. _multijob_fork ()
  485. {
  486. [[ $# -eq 1 ]] || die "incorrect number of arguments";
  487. local ret=0;
  488. [[ $1 == "post" ]] && : $(( ++mj_num_jobs ));
  489. if [[ ${mj_num_jobs} -ge ${mj_max_jobs} ]]; then
  490. multijob_finish_one;
  491. ret=$?;
  492. fi;
  493. [[ $1 == "pre" ]] && : $(( ++mj_num_jobs ));
  494. return ${ret}
  495. }
  496. _tc-getPROG ()
  497. {
  498. local tuple=$1;
  499. local v var vars=$2;
  500. local prog=$3;
  501. var=${vars%% *};
  502. for v in ${vars};
  503. do
  504. if [[ -n ${!v} ]]; then
  505. export ${var}="${!v}";
  506. echo "${!v}";
  507. return 0;
  508. fi;
  509. done;
  510. local search=;
  511. [[ -n $4 ]] && search=$(type -p "$4-${prog}");
  512. [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p "${!tuple}-${prog}");
  513. [[ -n ${search} ]] && prog=${search##*/};
  514. export ${var}=${prog};
  515. echo "${!var}"
  516. }
  517. autotools_check_macro ()
  518. {
  519. [[ -f configure.ac || -f configure.in ]] || return 0;
  520. local trace_file=".__autoconf_trace_data";
  521. if [[ ! -e ${trace_file} ]] || [[ aclocal.m4 -nt ${trace_file} ]]; then
  522. WANT_AUTOCONF="2.5" autoconf $(autotools_m4dir_include) ${ALL_AUTOTOOLS_MACROS[@]/#/--trace=} > ${trace_file} 2> /dev/null;
  523. fi;
  524. local macro args=();
  525. for macro in "$@";
  526. do
  527. has ${macro} ${ALL_AUTOTOOLS_MACROS[@]} || die "internal error: add ${macro} to ALL_AUTOTOOLS_MACROS";
  528. args+=(-e ":${macro}:");
  529. done;
  530. grep "${args[@]}" ${trace_file}
  531. }
  532. autotools_check_macro_val ()
  533. {
  534. local macro scan_out;
  535. for macro in "$@";
  536. do
  537. autotools_check_macro "${macro}" | gawk -v macro="${macro}" '($0 !~ /^[[:space:]]*(#|dnl)/) {
  538. if (match($0, macro ":(.*)$", res))
  539. print res[1]
  540. }' | uniq;
  541. done;
  542. return 0
  543. }
  544. autotools_env_setup ()
  545. {
  546. if [[ ${WANT_AUTOMAKE} == "latest" ]]; then
  547. local pv;
  548. for pv in ${_LATEST_AUTOMAKE[@]/#*:};
  549. do
  550. ROOT=/ has_version "=sys-devel/automake-${pv}*" && export WANT_AUTOMAKE="${pv}";
  551. done;
  552. [[ ${WANT_AUTOMAKE} == "latest" ]] && die "Cannot find the latest automake! Tried ${_LATEST_AUTOMAKE}";
  553. fi;
  554. [[ ${WANT_AUTOCONF} == "latest" ]] && export WANT_AUTOCONF=2.5
  555. }
  556. autotools_m4dir_include ()
  557. {
  558. _autotools_m4dir_include ${AT_M4DIR}
  559. }
  560. autotools_m4sysdir_include ()
  561. {
  562. _autotools_m4dir_include $(eval echo ${AT_SYS_M4DIR})
  563. }
  564. autotools_run_tool ()
  565. {
  566. local autofail=true m4flags=false missing_ok=false;
  567. while [[ -n $1 ]]; do
  568. case $1 in
  569. --at-no-fail)
  570. autofail=false
  571. ;;
  572. --at-m4flags)
  573. m4flags=true
  574. ;;
  575. --at-missing)
  576. missing_ok=true
  577. ;;
  578. *)
  579. break
  580. ;;
  581. esac;
  582. shift;
  583. done;
  584. if [[ ${EBUILD_PHASE} != "unpack" && ${EBUILD_PHASE} != "prepare" ]]; then
  585. ewarn "QA Warning: running $1 in ${EBUILD_PHASE} phase";
  586. fi;
  587. if ${missing_ok} && ! type -P ${1} > /dev/null; then
  588. einfo "Skipping '$*' due $1 not installed";
  589. return 0;
  590. fi;
  591. autotools_env_setup;
  592. local STDERR_TARGET="${T}/$1.out";
  593. if [[ -e ${STDERR_TARGET} ]]; then
  594. local i=1;
  595. while :; do
  596. STDERR_TARGET="${T}/$1-${i}.out";
  597. [[ -e ${STDERR_TARGET} ]] || break;
  598. : $(( i++ ));
  599. done;
  600. fi;
  601. if ${m4flags}; then
  602. set -- "${1}" $(autotools_m4dir_include) "${@:2}" $(autotools_m4sysdir_include);
  603. fi;
  604. printf "***** $1 *****\n***** PWD: ${PWD}\n***** $*\n\n" > "${STDERR_TARGET}";
  605. ebegin "Running $@";
  606. "$@" >> "${STDERR_TARGET}" 2>&1;
  607. if ! eend $? && ${autofail}; then
  608. echo;
  609. eerror "Failed Running $1 !";
  610. eerror;
  611. eerror "Include in your bugreport the contents of:";
  612. eerror;
  613. eerror " ${STDERR_TARGET}";
  614. echo;
  615. die "Failed Running $1 !";
  616. fi
  617. }
  618. base_src_compile ()
  619. {
  620. debug-print-function $FUNCNAME "$@";
  621. has src_configure ${BASE_EXPF} || base_src_configure;
  622. base_src_make "$@"
  623. }
  624. base_src_configure ()
  625. {
  626. debug-print-function $FUNCNAME "$@";
  627. [[ -x ${ECONF_SOURCE:-.}/configure ]] && econf "$@"
  628. }
  629. base_src_install ()
  630. {
  631. debug-print-function $FUNCNAME "$@";
  632. emake DESTDIR="${D}" "$@" install || die "died running make install, $FUNCNAME";
  633. base_src_install_docs
  634. }
  635. base_src_install_docs ()
  636. {
  637. debug-print-function $FUNCNAME "$@";
  638. local x;
  639. pushd "${S}" > /dev/null;
  640. if [[ "$(declare -p DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
  641. for x in "${DOCS[@]}";
  642. do
  643. debug-print "$FUNCNAME: docs: creating document from ${x}";
  644. dodoc "${x}" || die "dodoc failed";
  645. done;
  646. fi;
  647. if [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then
  648. for x in "${HTML_DOCS[@]}";
  649. do
  650. debug-print "$FUNCNAME: docs: creating html document from ${x}";
  651. dohtml -r "${x}" || die "dohtml failed";
  652. done;
  653. fi;
  654. popd > /dev/null
  655. }
  656. base_src_make ()
  657. {
  658. debug-print-function $FUNCNAME "$@";
  659. if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  660. emake "$@" || die "died running emake, $FUNCNAME";
  661. fi
  662. }
  663. base_src_prepare ()
  664. {
  665. debug-print-function $FUNCNAME "$@";
  666. debug-print "$FUNCNAME: PATCHES=$PATCHES";
  667. local patches_failed=0;
  668. pushd "${S}" > /dev/null;
  669. if [[ "$(declare -p PATCHES 2>/dev/null 2>&1)" == "declare -a"* ]]; then
  670. for x in "${PATCHES[@]}";
  671. do
  672. debug-print "$FUNCNAME: applying patch from ${x}";
  673. if [[ -d "${x}" ]]; then
  674. EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch};
  675. oldval=${EPATCH_SOURCE};
  676. EPATCH_SOURCE=${x};
  677. EPATCH_FORCE=yes;
  678. epatch;
  679. EPATCH_SOURCE=${oldval};
  680. else
  681. if [[ -f "${x}" ]]; then
  682. epatch "${x}";
  683. else
  684. ewarn "QA: File or directory \"${x}\" does not exist.";
  685. ewarn "QA: Check your PATCHES array or add missing file/directory.";
  686. patches_failed=1;
  687. fi;
  688. fi;
  689. done;
  690. [[ ${patches_failed} -eq 1 ]] && die "Some patches failed. See above messages.";
  691. else
  692. for x in ${PATCHES};
  693. do
  694. debug-print "$FUNCNAME: patching from ${x}";
  695. epatch "${x}";
  696. done;
  697. fi;
  698. debug-print "$FUNCNAME: applying user patches";
  699. epatch_user;
  700. popd > /dev/null
  701. }
  702. base_src_unpack ()
  703. {
  704. debug-print-function $FUNCNAME "$@";
  705. pushd "${WORKDIR}" > /dev/null;
  706. if [[ $(type -t unpacker_src_unpack) == "function" ]]; then
  707. unpacker_src_unpack;
  708. else
  709. if [[ -n ${A} ]]; then
  710. unpack ${A};
  711. fi;
  712. fi;
  713. has src_prepare ${BASE_EXPF} || base_src_prepare;
  714. popd > /dev/null
  715. }
  716. built_with_use ()
  717. {
  718. local hidden="no";
  719. if [[ $1 == "--hidden" ]]; then
  720. hidden="yes";
  721. shift;
  722. fi;
  723. local missing_action="die";
  724. if [[ $1 == "--missing" ]]; then
  725. missing_action=$2;
  726. shift;
  727. shift;
  728. case ${missing_action} in
  729. true | false | die)
  730.  
  731. ;;
  732. *)
  733. die "unknown action '${missing_action}'"
  734. ;;
  735. esac;
  736. fi;
  737. local opt=$1;
  738. [[ ${opt:0:1} = "-" ]] && shift || opt="-a";
  739. local PKG=$(best_version $1);
  740. [[ -z ${PKG} ]] && die "Unable to resolve $1 to an installed package";
  741. shift;
  742. local USEFILE=${ROOT}/var/db/pkg/${PKG}/USE;
  743. local IUSEFILE=${ROOT}/var/db/pkg/${PKG}/IUSE;
  744. if [[ ! -e ${USEFILE} ]] || [[ ! -e ${IUSEFILE} && ${hidden} == "no" ]]; then
  745. case ${missing_action} in
  746. true)
  747. return 0
  748. ;;
  749. false)
  750. return 1
  751. ;;
  752. die)
  753. die "Unable to determine what USE flags $PKG was built with"
  754. ;;
  755. esac;
  756. fi;
  757. if [[ ${hidden} == "no" ]]; then
  758. local IUSE_BUILT=($(<"${IUSEFILE}"));
  759. local expand;
  760. for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]');
  761. do
  762. if [[ $1 == ${expand}_* ]]; then
  763. expand="";
  764. break;
  765. fi;
  766. done;
  767. if [[ -n ${expand} ]]; then
  768. if ! has $1 ${IUSE_BUILT[@]#[-+]}; then
  769. case ${missing_action} in
  770. true)
  771. return 0
  772. ;;
  773. false)
  774. return 1
  775. ;;
  776. die)
  777. die "$PKG does not actually support the $1 USE flag!"
  778. ;;
  779. esac;
  780. fi;
  781. fi;
  782. fi;
  783. local USE_BUILT=$(<${USEFILE});
  784. while [[ $# -gt 0 ]]; do
  785. if [[ ${opt} = "-o" ]]; then
  786. has $1 ${USE_BUILT} && return 0;
  787. else
  788. has $1 ${USE_BUILT} || return 1;
  789. fi;
  790. shift;
  791. done;
  792. [[ ${opt} = "-a" ]]
  793. }
  794. check_license ()
  795. {
  796. die "you no longer need this as portage supports ACCEPT_LICENSE itself"
  797. }
  798. config_rpath_update ()
  799. {
  800. local dst src=$(type -P gettext | sed 's:bin/gettext:share/gettext/config.rpath:');
  801. [[ $# -eq 0 ]] && set -- $(find -name config.rpath);
  802. [[ $# -eq 0 ]] && return 0;
  803. einfo "Updating all config.rpath files";
  804. for dst in "$@";
  805. do
  806. einfo " ${dst}";
  807. cp "${src}" "${dst}" || die;
  808. done
  809. }
  810. darwintoolize ()
  811. {
  812. die "Use elibtoolize"
  813. }
  814. delete_all_version_separators ()
  815. {
  816. replace_all_version_separators "" "${1}"
  817. }
  818. delete_version_separator ()
  819. {
  820. replace_version_separator "${1}" "" "${2}"
  821. }
  822. dogamesbin ()
  823. {
  824. gameswrapper ${FUNCNAME/games} "$@"
  825. }
  826. dogameslib ()
  827. {
  828. gameswrapper ${FUNCNAME/games} "$@"
  829. }
  830. dogameslib.a ()
  831. {
  832. gameswrapper ${FUNCNAME/games} "$@"
  833. }
  834. dogameslib.so ()
  835. {
  836. gameswrapper ${FUNCNAME/games} "$@"
  837. }
  838. dogamessbin ()
  839. {
  840. gameswrapper ${FUNCNAME/games} "$@"
  841. }
  842. doicon ()
  843. {
  844. _iconins ${FUNCNAME} "$@"
  845. }
  846. domenu ()
  847. {
  848. ( local i j ret=0;
  849. insinto /usr/share/applications;
  850. for i in "$@";
  851. do
  852. if [[ -f ${i} ]]; then
  853. doins "${i}";
  854. ((ret+=$?));
  855. else
  856. if [[ -d ${i} ]]; then
  857. for j in "${i}"/*.desktop;
  858. do
  859. doins "${j}";
  860. ((ret+=$?));
  861. done;
  862. else
  863. ((++ret));
  864. fi;
  865. fi;
  866. done;
  867. exit ${ret} )
  868. }
  869. eaclocal ()
  870. {
  871. [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && autotools_run_tool --at-m4flags aclocal "$@" $(eaclocal_amflags)
  872. }
  873. eaclocal_amflags ()
  874. {
  875. local aclocal_opts amflags_file;
  876. for amflags_file in GNUmakefile.am Makefile.am GNUmakefile.in Makefile.in;
  877. do
  878. [[ -e ${amflags_file} ]] || continue;
  879. autotools_env_setup;
  880. aclocal_opts=$(sed -n "/^ACLOCAL_AMFLAGS[[:space:]]*=/{ # match the first line
  881. s:[^=]*=::p; # then gobble up all escaped lines
  882. : nextline /\\\\$/{ n; p; b nextline; } }" ${amflags_file});
  883. eval aclocal_opts=\""${aclocal_opts}"\";
  884. break;
  885. done;
  886. echo ${aclocal_opts}
  887. }
  888. eautoconf ()
  889. {
  890. if [[ ! -f configure.ac && ! -f configure.in ]]; then
  891. echo;
  892. eerror "No configure.{ac,in} present in '${PWD}'!";
  893. echo;
  894. die "No configure.{ac,in} present!";
  895. fi;
  896. autotools_run_tool --at-m4flags autoconf "$@"
  897. }
  898. eautoheader ()
  899. {
  900. _at_uses_autoheader || return 0;
  901. autotools_run_tool --at-no-fail --at-m4flags autoheader "$@"
  902. }
  903. eautomake ()
  904. {
  905. local extra_opts;
  906. local makefile_name;
  907. for makefile_name in {GNUmakefile,{M,m}akefile}.am "";
  908. do
  909. [[ -f ${makefile_name} ]] && break;
  910. done;
  911. if [[ -z ${makefile_name} ]]; then
  912. _at_uses_automake || return 0;
  913. else
  914. if [[ -z ${FROM_EAUTORECONF} && -f ${makefile_name%.am}.in ]]; then
  915. local used_automake;
  916. local installed_automake;
  917. installed_automake=$(WANT_AUTOMAKE= automake --version | head -n 1 | sed -e 's:.*(GNU automake) ::');
  918. used_automake=$(head -n 1 < ${makefile_name%.am}.in | sed -e 's:.*by automake \(.*\) from .*:\1:');
  919. if [[ ${installed_automake} != ${used_automake} ]]; then
  920. einfo "Automake used for the package (${used_automake}) differs from";
  921. einfo "the installed version (${installed_automake}).";
  922. eautoreconf;
  923. return 0;
  924. fi;
  925. fi;
  926. fi;
  927. [[ -f INSTALL && -f AUTHORS && -f ChangeLog && -f NEWS && -f README ]] || extra_opts="${extra_opts} --foreign";
  928. autotools_run_tool automake --add-missing --copy ${extra_opts} "$@"
  929. }
  930. eautopoint ()
  931. {
  932. autotools_run_tool autopoint "$@"
  933. }
  934. eautoreconf ()
  935. {
  936. local x g multitop;
  937. if [[ -z ${AT_TOPLEVEL_EAUTORECONF} ]]; then
  938. AT_TOPLEVEL_EAUTORECONF="yes";
  939. multitop="yes";
  940. multijob_init;
  941. fi;
  942. if [[ -z ${AT_NO_RECURSIVE} ]]; then
  943. for x in $(autotools_check_macro_val AC_CONFIG_SUBDIRS);
  944. do
  945. if [[ -d ${x} ]]; then
  946. pushd "${x}" > /dev/null;
  947. AT_NOELIBTOOLIZE="yes" multijob_child_init eautoreconf || die;
  948. popd > /dev/null;
  949. fi;
  950. done;
  951. fi;
  952. einfo "Running eautoreconf in '${PWD}' ...";
  953. local m4dirs=$(autotools_check_macro_val AC_CONFIG_{AUX,MACRO}_DIR);
  954. [[ -n ${m4dirs} ]] && mkdir -p ${m4dirs};
  955. local i tools=(glibgettext false "autotools_run_tool glib-gettextize --copy --force" gettext false "autotools_run_tool --at-missing autopoint --force" intltool false "autotools_run_tool intltoolize --automake --copy --force" gtkdoc false "autotools_run_tool --at-missing gtkdocize --copy" gnomedoc false "autotools_run_tool --at-missing gnome-doc-prepare --copy --force" libtool false "_elibtoolize --install --copy --force");
  956. for ((i = 0; i < ${#tools[@]}; i += 3 ))
  957. do
  958. if _at_uses_${tools[i]}; then
  959. tools[i+1]=true;
  960. ${tools[i+2]};
  961. fi;
  962. done;
  963. local rerun_aclocal=false;
  964. eaclocal;
  965. for ((i = 0; i < ${#tools[@]}; i += 3 ))
  966. do
  967. if ! ${tools[i+1]} && _at_uses_${tools[i]}; then
  968. ${tools[i+2]};
  969. rerun_aclocal=true;
  970. fi;
  971. done;
  972. ${rerun_aclocal} && eaclocal;
  973. eautoconf;
  974. eautoheader;
  975. [[ ${AT_NOEAUTOMAKE} != "yes" ]] && FROM_EAUTORECONF="yes" eautomake ${AM_OPTS};
  976. if [[ ${AT_NOELIBTOOLIZE} != "yes" ]]; then
  977. S=${PWD} elibtoolize --force;
  978. fi;
  979. if [[ -n ${multitop} ]]; then
  980. unset AT_TOPLEVEL_EAUTORECONF;
  981. multijob_finish || die;
  982. fi;
  983. return 0
  984. }
  985. ebeep ()
  986. {
  987. local n;
  988. if [[ -z ${EBEEP_IGNORE} ]]; then
  989. for ((n=1 ; n <= ${1:-5} ; n++))
  990. do
  991. echo -ne "\a";
  992. sleep 0.1 &>/dev/null;
  993. sleep 0,1 &>/dev/null;
  994. echo -ne "\a";
  995. sleep 1;
  996. done;
  997. fi
  998. }
  999. econf_build ()
  1000. {
  1001. tc-env_build econf --build=${CBUILD:-${CHOST}} "$@"
  1002. }
  1003. ecvs_clean ()
  1004. {
  1005. [[ -z $* ]] && set -- .;
  1006. find "$@" -type d -name 'CVS' -prune -print0 | xargs -0 rm -rf;
  1007. find "$@" -type f -name '.cvs*' -print0 | xargs -0 rm -rf
  1008. }
  1009. edos2unix ()
  1010. {
  1011. [[ $# -eq 0 ]] && return 0;
  1012. sed -i 's/\r$//' -- "$@" || die
  1013. }
  1014. egamesconf ()
  1015. {
  1016. econf --prefix="${GAMES_PREFIX}" --libdir="$(games_get_libdir)" --datadir="${GAMES_DATADIR}" --sysconfdir="${GAMES_SYSCONFDIR}" --localstatedir="${GAMES_STATEDIR}" "$@"
  1017. }
  1018. egetent ()
  1019. {
  1020. local db=$1 key=$2;
  1021. [[ $# -ge 3 ]] && die "usage: egetent <database> <key>";
  1022. case ${db} in
  1023. passwd | group)
  1024.  
  1025. ;;
  1026. *)
  1027. die "sorry, database '${db}' not yet supported; file a bug"
  1028. ;;
  1029. esac;
  1030. case ${CHOST} in
  1031. *-darwin[678])
  1032. case ${key} in
  1033. *[!0-9]*)
  1034. nidump ${db} . | awk -F: "(\$1 ~ /^${key}\$/) {print;exit;}"
  1035. ;;
  1036. *)
  1037. nidump ${db} . | awk -F: "(\$3 == ${key}) {print;exit;}"
  1038. ;;
  1039. esac
  1040. ;;
  1041. *-darwin*)
  1042. local mykey;
  1043. case ${db} in
  1044. passwd)
  1045. db="Users" mykey="UniqueID"
  1046. ;;
  1047. group)
  1048. db="Groups" mykey="PrimaryGroupID"
  1049. ;;
  1050. esac;
  1051. case ${key} in
  1052. *[!0-9]*)
  1053. dscl . -read /${db}/${key} 2> /dev/null | grep RecordName
  1054. ;;
  1055. *)
  1056. dscl . -search /${db} ${mykey} ${key} 2> /dev/null
  1057. ;;
  1058. esac
  1059. ;;
  1060. *-freebsd* | *-dragonfly*)
  1061. case ${db} in
  1062. passwd)
  1063. db="user"
  1064. ;;
  1065. *)
  1066.  
  1067. ;;
  1068. esac;
  1069. local opts;
  1070. if [[ ${key} == [[:digit:]]* ]]; then
  1071. [[ ${db} == "user" ]] && opts="-u" || opts="-g";
  1072. fi;
  1073. pw show ${db} ${opts} "${key}" -q
  1074. ;;
  1075. *-netbsd* | *-openbsd*)
  1076. grep "${key}:\*:" /etc/${db}
  1077. ;;
  1078. *)
  1079. nscd -i "${db}" 2> /dev/null;
  1080. getent "${db}" "${key}"
  1081. ;;
  1082. esac
  1083. }
  1084. egethome ()
  1085. {
  1086. local pos;
  1087. [[ $# -eq 1 ]] || die "usage: egethome <user>";
  1088. case ${CHOST} in
  1089. *-darwin* | *-freebsd* | *-dragonfly*)
  1090. pos=9
  1091. ;;
  1092. *)
  1093. pos=6
  1094. ;;
  1095. esac;
  1096. egetent passwd "$1" | cut -d: -f${pos}
  1097. }
  1098. egetshell ()
  1099. {
  1100. local pos;
  1101. [[ $# -eq 1 ]] || die "usage: egetshell <user>";
  1102. case ${CHOST} in
  1103. *-darwin* | *-freebsd* | *-dragonfly*)
  1104. pos=10
  1105. ;;
  1106. *)
  1107. pos=7
  1108. ;;
  1109. esac;
  1110. egetent passwd "$1" | cut -d: -f${pos}
  1111. }
  1112. elibtoolize ()
  1113. {
  1114. local x;
  1115. local do_portage="no";
  1116. local do_reversedeps="no";
  1117. local do_only_patches="no";
  1118. local do_uclibc="yes";
  1119. local deptoremove=;
  1120. local do_shallow="no";
  1121. local force="false";
  1122. local elt_patches="install-sh ltmain portage relink max_cmd_len sed test tmp cross as-needed";
  1123. for x in "$@";
  1124. do
  1125. case ${x} in
  1126. --portage)
  1127. do_portage="yes"
  1128. ;;
  1129. --reverse-deps)
  1130. do_reversedeps="yes";
  1131. elt_patches+=" fix-relink"
  1132. ;;
  1133. --patch-only)
  1134. do_only_patches="yes"
  1135. ;;
  1136. --remove-internal-dep=*)
  1137. deptoremove=${x#--remove-internal-dep=};
  1138. [[ -n ${deptoremove} ]] && elt_patches+=" rem-int-dep"
  1139. ;;
  1140. --shallow)
  1141. do_shallow="yes"
  1142. ;;
  1143. --no-uclibc)
  1144. do_uclibc="no"
  1145. ;;
  1146. --force)
  1147. force="true"
  1148. ;;
  1149. *)
  1150. eerror "Invalid elibtoolize option: ${x}";
  1151. die "elibtoolize called with ${x} ??"
  1152. ;;
  1153. esac;
  1154. done;
  1155. [[ ${do_uclibc} == "yes" ]] && elt_patches+=" uclibc-conf uclibc-ltconf";
  1156. case ${CHOST} in
  1157. *-aix*)
  1158. elt_patches+=" hardcode aixrtl aix-noundef"
  1159. ;;
  1160. *-darwin*)
  1161. elt_patches+=" darwin-ltconf darwin-ltmain darwin-conf"
  1162. ;;
  1163. *-solaris*)
  1164. elt_patches+=" sol2-conf"
  1165. ;;
  1166. *-freebsd*)
  1167. elt_patches+=" fbsd-conf fbsd-ltconf"
  1168. ;;
  1169. *-hpux*)
  1170. elt_patches+=" hpux-conf deplibs hc-flag-ld hardcode hardcode-relink relink-prog no-lc"
  1171. ;;
  1172. *-irix*)
  1173. elt_patches+=" irix-ltmain"
  1174. ;;
  1175. *-mint*)
  1176. elt_patches+=" mint-conf"
  1177. ;;
  1178. esac;
  1179. if $(tc-getLD) --version 2>&1 | grep -qs 'GNU gold'; then
  1180. elt_patches+=" gold-conf";
  1181. fi;
  1182. set --;
  1183. if [[ ${do_shallow} == "yes" ]]; then
  1184. [[ -f ${S}/ltmain.sh ]] && set -- "${S}";
  1185. else
  1186. set -- $(find "${S}" -name ltmain.sh -printf '%h ');
  1187. fi;
  1188. local d p;
  1189. for d in "$@";
  1190. do
  1191. export ELT_APPLIED_PATCHES=;
  1192. if [[ -f ${d}/.elibtoolized ]]; then
  1193. ${force} || continue;
  1194. fi;
  1195. local outfunc="einfo";
  1196. [[ -f ${d}/.elibtoolized ]] && outfunc="ewarn";
  1197. ${outfunc} "Running elibtoolize in: ${d#${WORKDIR}/}/";
  1198. if [[ ${outfunc} == "ewarn" ]]; then
  1199. ewarn " We've already been run in this tree; you should";
  1200. ewarn " avoid this if possible (perhaps by filing a bug)";
  1201. fi;
  1202. for p in ${elt_patches};
  1203. do
  1204. local ret=0;
  1205. case ${p} in
  1206. portage)
  1207. if ! grep -qs 'We do not want portage' "${d}/ltmain.sh"; then
  1208. ELT_walk_patches "${d}/ltmain.sh" "${p}";
  1209. ret=$?;
  1210. fi
  1211. ;;
  1212. rem-int-dep)
  1213. ELT_walk_patches "${d}/ltmain.sh" "${p}" "${deptoremove}";
  1214. ret=$?
  1215. ;;
  1216. fix-relink)
  1217. if grep -qs 'inst_prefix_dir' "${d}/ltmain.sh"; then
  1218. ELT_walk_patches "${d}/ltmain.sh" "${p}";
  1219. ret=$?;
  1220. fi
  1221. ;;
  1222. max_cmd_len)
  1223. if grep -qs 'max_cmd_len' "${d}/ltmain.sh"; then
  1224. ELT_walk_patches "${d}/ltmain.sh" "${p}";
  1225. ret=$?;
  1226. fi
  1227. ;;
  1228. as-needed)
  1229. ELT_walk_patches "${d}/ltmain.sh" "${p}";
  1230. ret=$?
  1231. ;;
  1232. uclibc-conf)
  1233. if grep -qs 'Transform linux' "${d}/configure"; then
  1234. ELT_walk_patches "${d}/configure" "${p}";
  1235. ret=$?;
  1236. else
  1237. if [[ ! -e ${d}/configure ]] && grep -qs 'Transform linux' "${d}/../configure"; then
  1238. ELT_walk_patches "${d}/../configure" "${p}";
  1239. ret=$?;
  1240. fi;
  1241. fi
  1242. ;;
  1243. uclibc-ltconf)
  1244. if [[ -s ${d}/ltconfig ]]; then
  1245. ELT_walk_patches "${d}/ltconfig" "${p}";
  1246. ret=$?;
  1247. fi
  1248. ;;
  1249. fbsd-conf)
  1250. if grep -qs 'version_type=freebsd-' "${d}/configure"; then
  1251. ELT_walk_patches "${d}/configure" "${p}";
  1252. ret=$?;
  1253. else
  1254. if [[ ! -e ${d}/configure ]] && grep -qs 'version_type=freebsd-' "${d}/../configure"; then
  1255. ELT_walk_patches "${d}/../configure" "${p}";
  1256. ret=$?;
  1257. fi;
  1258. fi
  1259. ;;
  1260. fbsd-ltconf)
  1261. if [[ -s ${d}/ltconfig ]]; then
  1262. ELT_walk_patches "${d}/ltconfig" "${p}";
  1263. ret=$?;
  1264. fi
  1265. ;;
  1266. darwin-conf)
  1267. if grep -qs '&& echo \.so ||' "${d}/configure"; then
  1268. ELT_walk_patches "${d}/configure" "${p}";
  1269. ret=$?;
  1270. else
  1271. if [[ ! -e ${d}/configure ]] && grep -qs '&& echo \.so ||' "${d}/../configure"; then
  1272. ELT_walk_patches "${d}/../configure" "${p}";
  1273. ret=$?;
  1274. fi;
  1275. fi
  1276. ;;
  1277. darwin-ltconf)
  1278. if [[ -s ${d}/ltconfig ]]; then
  1279. ELT_walk_patches "${d}/ltconfig" "${p}";
  1280. ret=$?;
  1281. fi
  1282. ;;
  1283. darwin-ltmain)
  1284. if [[ -e ${d}/ltmain.sh ]] && ! grep -qs 'verstring="-compatibility_version' "${d}/ltmain.sh"; then
  1285. ELT_walk_patches "${d}/ltmain.sh" "${p}";
  1286. ret=$?;
  1287. fi
  1288. ;;
  1289. aixrtl | hpux-conf)
  1290. ret=1;
  1291. local subret=0;
  1292. while [[ $subret -eq 0 ]]; do
  1293. subret=1;
  1294. if [[ -e ${d}/configure ]]; then
  1295. ELT_walk_patches "${d}/configure" "${p}";
  1296. subret=$?;
  1297. else
  1298. if [[ ! -e ${d}/configure && -e ${d}/../configure ]]; then
  1299. ELT_walk_patches "${d}/../configure" "${p}";
  1300. subret=$?;
  1301. fi;
  1302. fi;
  1303. if [[ $subret -eq 0 ]]; then
  1304. ret=0;
  1305. fi;
  1306. done
  1307. ;;
  1308. mint-conf | gold-conf | sol2-conf)
  1309. ret=1;
  1310. local subret=1;
  1311. if [[ -e ${d}/configure ]]; then
  1312. ELT_walk_patches "${d}/configure" "${p}";
  1313. subret=$?;
  1314. else
  1315. if [[ -e ${d}/../configure ]]; then
  1316. ELT_walk_patches "${d}/../configure" "${p}";
  1317. subret=$?;
  1318. else
  1319. if [[ -e ${d}/../../configure ]]; then
  1320. ELT_walk_patches "${d}/../../configure" "${p}";
  1321. subret=$?;
  1322. fi;
  1323. fi;
  1324. fi;
  1325. if [[ $subret -eq 0 ]]; then
  1326. ret=0;
  1327. fi
  1328. ;;
  1329. install-sh)
  1330. ELT_walk_patches "${d}/install-sh" "${p}";
  1331. ret=$?
  1332. ;;
  1333. cross)
  1334. if tc-is-cross-compiler; then
  1335. ELT_walk_patches "${d}/ltmain.sh" "${p}";
  1336. ret=$?;
  1337. fi
  1338. ;;
  1339. *)
  1340. ELT_walk_patches "${d}/ltmain.sh" "${p}";
  1341. ret=$?
  1342. ;;
  1343. esac;
  1344. if [[ ${ret} -ne 0 ]]; then
  1345. case ${p} in
  1346. relink)
  1347. local version=$(ELT_libtool_version "${d}/ltmain.sh");
  1348. if ! grep -qs 'inst_prefix_dir' "${d}/ltmain.sh" && [[ $(VER_to_int "${version}") -ge $(VER_to_int "1.4.0") ]]; then
  1349. ewarn " Could not apply relink.patch!";
  1350. fi
  1351. ;;
  1352. portage)
  1353. if [[ ${do_portage} == "yes" ]]; then
  1354. if ! grep -qs 'We do not want portage' "${d}/ltmain.sh"; then
  1355. echo;
  1356. eerror "Portage patch requested, but failed to apply!";
  1357. eerror "Please file a bug report to add a proper patch.";
  1358. die "Portage patch requested, but failed to apply!";
  1359. fi;
  1360. else
  1361. if grep -qs 'We do not want portage' "${d}/ltmain.sh"; then
  1362. :;
  1363. else
  1364. local version=$(ELT_libtool_version "${d}"/ltmain.sh);
  1365. echo;
  1366. eerror "Portage patch failed to apply (ltmain.sh version ${version})!";
  1367. eerror "Please file a bug report to add a proper patch.";
  1368. die "Portage patch failed to apply!";
  1369. fi;
  1370. ELT_APPLIED_PATCHES="portage";
  1371. fi
  1372. ;;
  1373. uclibc-*)
  1374. [[ ${CHOST} == *-uclibc ]] && ewarn " uClibc patch set '${p}' failed to apply!"
  1375. ;;
  1376. fbsd-*)
  1377. if [[ ${CHOST} == *-freebsd* ]]; then
  1378. if [[ -z $(grep 'Handle Gentoo/FreeBSD as it was Linux' "${d}/configure" "${d}/../configure" 2>/dev/null) ]]; then
  1379. eerror " FreeBSD patch set '${p}' failed to apply!";
  1380. die "FreeBSD patch set '${p}' failed to apply!";
  1381. fi;
  1382. fi
  1383. ;;
  1384. darwin-*)
  1385. [[ ${CHOST} == *"-darwin"* ]] && ewarn " Darwin patch set '${p}' failed to apply!"
  1386. ;;
  1387. esac;
  1388. fi;
  1389. done;
  1390. if [[ -z ${ELT_APPLIED_PATCHES} ]]; then
  1391. if [[ ${do_portage} == "no" && ${do_reversedeps} == "no" && ${do_only_patches} == "no" && ${deptoremove} == "" ]]; then
  1392. ewarn "Cannot apply any patches, please file a bug about this";
  1393. die;
  1394. fi;
  1395. fi;
  1396. rm -f "${d}/libtool";
  1397. > "${d}/.elibtoolized";
  1398. done
  1399. }
  1400. elt_patch_dir ()
  1401. {
  1402. local d="${ECLASSDIR}/ELT-patches";
  1403. if [[ ! -d ${d} ]]; then
  1404. d="${ECLASSDIR_LOCAL}/ELT-patches";
  1405. fi;
  1406. echo "${d}"
  1407. }
  1408. emktemp ()
  1409. {
  1410. local exe="touch";
  1411. [[ $1 == -d ]] && exe="mkdir" && shift;
  1412. local topdir=$1;
  1413. if [[ -z ${topdir} ]]; then
  1414. [[ -z ${T} ]] && topdir="/tmp" || topdir=${T};
  1415. fi;
  1416. if ! type -P mktemp > /dev/null; then
  1417. local tmp=/;
  1418. while [[ -e ${tmp} ]]; do
  1419. tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM};
  1420. done;
  1421. ${exe} "${tmp}" || ${exe} -p "${tmp}";
  1422. echo "${tmp}";
  1423. else
  1424. if [[ ${exe} == "touch" ]]; then
  1425. TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX;
  1426. else
  1427. TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX;
  1428. fi;
  1429. fi
  1430. }
  1431. enewgroup ()
  1432. {
  1433. _assert_pkg_ebuild_phase ${FUNCNAME};
  1434. local egroup=$1;
  1435. shift;
  1436. if [[ -z ${egroup} ]]; then
  1437. eerror "No group specified !";
  1438. die "Cannot call enewgroup without a group";
  1439. fi;
  1440. if [[ -n $(egetent group "${egroup}") ]]; then
  1441. return 0;
  1442. fi;
  1443. einfo "Adding group '${egroup}' to your system ...";
  1444. local egid=$1;
  1445. shift;
  1446. if [[ ! -z ${egid} ]]; then
  1447. if [[ ${egid} -gt 0 ]]; then
  1448. if [[ -n $(egetent group ${egid}) ]]; then
  1449. egid="next available; requested gid taken";
  1450. fi;
  1451. else
  1452. eerror "Groupid given but is not greater than 0 !";
  1453. die "${egid} is not a valid GID";
  1454. fi;
  1455. else
  1456. egid="next available";
  1457. fi;
  1458. einfo " - Groupid: ${egid}";
  1459. if [[ $# -gt 0 ]]; then
  1460. die "extra arguments no longer supported; please file a bug";
  1461. fi;
  1462. function _enewgroup_next_gid ()
  1463. {
  1464. if [[ ${egid} == *[!0-9]* ]]; then
  1465. for ((egid = 101; egid <= 999; egid++))
  1466. do
  1467. [[ -z $(egetent group ${egid}) ]] && break;
  1468. done;
  1469. fi
  1470. };
  1471. case ${CHOST} in
  1472. *-darwin*)
  1473. _enewgroup_next_gid;
  1474. dscl . create "/groups/${egroup}" gid ${egid};
  1475. dscl . create "/groups/${egroup}" passwd '*'
  1476. ;;
  1477. *-freebsd* | *-dragonfly*)
  1478. _enewgroup_next_gid;
  1479. pw groupadd "${egroup}" -g ${egid} || die
  1480. ;;
  1481. *-netbsd*)
  1482. _enewgroup_next_gid;
  1483. groupadd -g ${egid} "${egroup}" || die
  1484. ;;
  1485. *)
  1486. local opts;
  1487. if [[ ${egid} == *[!0-9]* ]]; then
  1488. opts="";
  1489. else
  1490. opts="-g ${egid}";
  1491. fi;
  1492. groupadd -r ${opts} "${egroup}" || die
  1493. ;;
  1494. esac
  1495. }
  1496. enewuser ()
  1497. {
  1498. _assert_pkg_ebuild_phase ${FUNCNAME};
  1499. local euser=$1;
  1500. shift;
  1501. if [[ -z ${euser} ]]; then
  1502. eerror "No username specified !";
  1503. die "Cannot call enewuser without a username";
  1504. fi;
  1505. if [[ -n $(egetent passwd "${euser}") ]]; then
  1506. return 0;
  1507. fi;
  1508. einfo "Adding user '${euser}' to your system ...";
  1509. local opts=();
  1510. local euid=$1;
  1511. shift;
  1512. if [[ -n ${euid} && ${euid} != -1 ]]; then
  1513. if [[ ${euid} -gt 0 ]]; then
  1514. if [[ -n $(egetent passwd ${euid}) ]]; then
  1515. euid="next";
  1516. fi;
  1517. else
  1518. eerror "Userid given but is not greater than 0 !";
  1519. die "${euid} is not a valid UID";
  1520. fi;
  1521. else
  1522. euid="next";
  1523. fi;
  1524. if [[ ${euid} == "next" ]]; then
  1525. for ((euid = 101; euid <= 999; euid++))
  1526. do
  1527. [[ -z $(egetent passwd ${euid}) ]] && break;
  1528. done;
  1529. fi;
  1530. opts+=(-u ${euid});
  1531. einfo " - Userid: ${euid}";
  1532. local eshell=$1;
  1533. shift;
  1534. if [[ ! -z ${eshell} ]] && [[ ${eshell} != "-1" ]]; then
  1535. if [[ ! -e ${ROOT}${eshell} ]]; then
  1536. eerror "A shell was specified but it does not exist !";
  1537. die "${eshell} does not exist in ${ROOT}";
  1538. fi;
  1539. if [[ ${eshell} == */false || ${eshell} == */nologin ]]; then
  1540. eerror "Do not specify ${eshell} yourself, use -1";
  1541. die "Pass '-1' as the shell parameter";
  1542. fi;
  1543. else
  1544. for eshell in /sbin/nologin /usr/sbin/nologin /bin/false /usr/bin/false /dev/null;
  1545. do
  1546. [[ -x ${ROOT}${eshell} ]] && break;
  1547. done;
  1548. if [[ ${eshell} == "/dev/null" ]]; then
  1549. eerror "Unable to identify the shell to use, proceeding with userland default.";
  1550. case ${USERLAND} in
  1551. GNU)
  1552. eshell="/bin/false"
  1553. ;;
  1554. BSD)
  1555. eshell="/sbin/nologin"
  1556. ;;
  1557. Darwin)
  1558. eshell="/usr/sbin/nologin"
  1559. ;;
  1560. *)
  1561. die "Unable to identify the default shell for userland ${USERLAND}"
  1562. ;;
  1563. esac;
  1564. fi;
  1565. fi;
  1566. einfo " - Shell: ${eshell}";
  1567. opts+=(-s "${eshell}");
  1568. local ehome=$1;
  1569. shift;
  1570. if [[ -z ${ehome} ]] || [[ ${ehome} == "-1" ]]; then
  1571. ehome="/dev/null";
  1572. fi;
  1573. einfo " - Home: ${ehome}";
  1574. opts+=(-d "${ehome}");
  1575. local egroups=$1;
  1576. shift;
  1577. local g egroups_arr;
  1578. IFS="," read -r -a egroups_arr <<< "${egroups}";
  1579. shift;
  1580. if [[ ${#egroups_arr[@]} -gt 0 ]]; then
  1581. local defgroup exgroups;
  1582. for g in "${egroups_arr[@]}";
  1583. do
  1584. if [[ -z $(egetent group "${g}") ]]; then
  1585. eerror "You must add group ${g} to the system first";
  1586. die "${g} is not a valid GID";
  1587. fi;
  1588. if [[ -z ${defgroup} ]]; then
  1589. defgroup=${g};
  1590. else
  1591. exgroups+=",${g}";
  1592. fi;
  1593. done;
  1594. opts+=(-g "${defgroup}");
  1595. if [[ ! -z ${exgroups} ]]; then
  1596. opts+=(-G "${exgroups:1}");
  1597. fi;
  1598. fi;
  1599. einfo " - Groups: ${egroups:-(none)}";
  1600. if [[ $# -gt 0 ]]; then
  1601. die "extra arguments no longer supported; please file a bug";
  1602. else
  1603. local comment="added by portage for ${PN}";
  1604. opts+=(-c "${comment}");
  1605. einfo " - GECOS: ${comment}";
  1606. fi;
  1607. case ${CHOST} in
  1608. *-darwin*)
  1609. dscl . create "/users/${euser}" uid ${euid};
  1610. dscl . create "/users/${euser}" shell "${eshell}";
  1611. dscl . create "/users/${euser}" home "${ehome}";
  1612. dscl . create "/users/${euser}" realname "added by portage for ${PN}";
  1613. for g in "${egroups_arr[@]}";
  1614. do
  1615. dscl . merge "/groups/${g}" users "${euser}";
  1616. done
  1617. ;;
  1618. *-freebsd* | *-dragonfly*)
  1619. pw useradd "${euser}" "${opts[@]}" || die
  1620. ;;
  1621. *-netbsd*)
  1622. useradd "${opts[@]}" "${euser}" || die
  1623. ;;
  1624. *-openbsd*)
  1625. useradd -u ${euid} -s "${eshell}" -d "${ehome}" -g "${egroups}" "${euser}" || die
  1626. ;;
  1627. *)
  1628. useradd -r "${opts[@]}" "${euser}" || die
  1629. ;;
  1630. esac;
  1631. if [[ ! -e ${ROOT}/${ehome} ]]; then
  1632. einfo " - Creating ${ehome} in ${ROOT}";
  1633. mkdir -p "${ROOT}/${ehome}";
  1634. chown "${euser}" "${ROOT}/${ehome}";
  1635. chmod 755 "${ROOT}/${ehome}";
  1636. fi
  1637. }
  1638. epatch ()
  1639. {
  1640. function _epatch_draw_line ()
  1641. {
  1642. [[ -z $1 ]] && set "$(printf "%65s" '')";
  1643. echo "${1//?/=}"
  1644. };
  1645. unset P4CONFIG P4PORT P4USER;
  1646. local EPATCH_OPTS=(${EPATCH_OPTS[*]});
  1647. while [[ $# -gt 0 ]]; do
  1648. case $1 in
  1649. -*)
  1650. EPATCH_OPTS+=("$1")
  1651. ;;
  1652. *)
  1653. break
  1654. ;;
  1655. esac;
  1656. shift;
  1657. done;
  1658. if [[ $# -gt 1 ]]; then
  1659. local m;
  1660. for m in "$@";
  1661. do
  1662. epatch "${m}";
  1663. done;
  1664. return 0;
  1665. fi;
  1666. local SINGLE_PATCH="no";
  1667. [[ $# -eq 0 ]] && set -- "${EPATCH_SOURCE}";
  1668. if [[ -f $1 ]]; then
  1669. SINGLE_PATCH="yes";
  1670. set -- "$1";
  1671. local EPATCH_SUFFIX=$1;
  1672. else
  1673. if [[ -d $1 ]]; then
  1674. set -- "$1"/*${EPATCH_SUFFIX:+."${EPATCH_SUFFIX}"};
  1675. else
  1676. if [[ -f ${EPATCH_SOURCE}/$1 ]]; then
  1677. epatch "${EPATCH_SOURCE}/$1";
  1678. return $?;
  1679. else
  1680. [[ $# -ne 0 ]] && EPATCH_SOURCE=$1;
  1681. echo;
  1682. eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:";
  1683. eerror;
  1684. eerror " ${EPATCH_SOURCE}";
  1685. eerror " ( ${EPATCH_SOURCE##*/} )";
  1686. echo;
  1687. die "Cannot find \$EPATCH_SOURCE!";
  1688. fi;
  1689. fi;
  1690. fi;
  1691. EPATCH_OPTS="${EPATCH_COMMON_OPTS} ${EPATCH_OPTS[*]}";
  1692. local PIPE_CMD;
  1693. case ${EPATCH_SUFFIX##*\.} in
  1694. xz)
  1695. PIPE_CMD="xz -dc"
  1696. ;;
  1697. lzma)
  1698. PIPE_CMD="lzma -dc"
  1699. ;;
  1700. bz2)
  1701. PIPE_CMD="bzip2 -dc"
  1702. ;;
  1703. gz | Z | z)
  1704. PIPE_CMD="gzip -dc"
  1705. ;;
  1706. ZIP | zip)
  1707. PIPE_CMD="unzip -p"
  1708. ;;
  1709. *)
  1710.  
  1711. ;;
  1712. esac;
  1713. [[ ${SINGLE_PATCH} == "no" ]] && einfo "${EPATCH_MULTI_MSG}";
  1714. local x;
  1715. for x in "$@";
  1716. do
  1717. [[ ! -f ${x} ]] && continue;
  1718. local patchname=${x##*/};
  1719. local a=${patchname#*_};
  1720. a=${a%%_*};
  1721. if ! [[ ${SINGLE_PATCH} == "yes" || ${EPATCH_FORCE} == "yes" || ${a} == all || ${a} == ${ARCH} ]]; then
  1722. continue;
  1723. fi;
  1724. if [[ -n ${EPATCH_EXCLUDE} ]]; then
  1725. eshopts_push -o noglob;
  1726. local ex;
  1727. for ex in ${EPATCH_EXCLUDE};
  1728. do
  1729. if [[ ${patchname} == ${ex} ]]; then
  1730. eshopts_pop;
  1731. continue 2;
  1732. fi;
  1733. done;
  1734. eshopts_pop;
  1735. fi;
  1736. if [[ ${SINGLE_PATCH} == "yes" ]]; then
  1737. if [[ -n ${EPATCH_SINGLE_MSG} ]]; then
  1738. einfo "${EPATCH_SINGLE_MSG}";
  1739. else
  1740. einfo "Applying ${patchname} ...";
  1741. fi;
  1742. else
  1743. einfo " ${patchname} ...";
  1744. fi;
  1745. local STDERR_TARGET="${T}/${patchname}.out";
  1746. if [[ -e ${STDERR_TARGET} ]]; then
  1747. STDERR_TARGET="${T}/${patchname}-$$.out";
  1748. fi;
  1749. printf "***** %s *****\nPWD: %s\n\n" "${patchname}" "${PWD}" > "${STDERR_TARGET}";
  1750. local count=0;
  1751. local PATCH_TARGET;
  1752. if [[ -n ${PIPE_CMD} ]]; then
  1753. PATCH_TARGET="${T}/$$.patch";
  1754. echo "PIPE_COMMAND: ${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> "${STDERR_TARGET}";
  1755. if ! ( ${PIPE_CMD} "${x}" > "${PATCH_TARGET}" ) >> "${STDERR_TARGET}" 2>&1; then
  1756. echo;
  1757. eerror "Could not extract patch!";
  1758. count=5;
  1759. break;
  1760. fi;
  1761. else
  1762. PATCH_TARGET=${x};
  1763. fi;
  1764. local abs_paths=$(egrep -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }');
  1765. if [[ -n ${abs_paths} ]]; then
  1766. count=1;
  1767. printf "NOTE: skipping -p0 due to absolute paths in patch:\n%s\n" "${abs_paths}" >> "${STDERR_TARGET}";
  1768. fi;
  1769. local rel_paths=$(egrep -n '^[-+]{3} [^ ]*[.][.]/' "${PATCH_TARGET}");
  1770. if [[ -n ${rel_paths} ]]; then
  1771. eqawarn "QA Notice: Your patch uses relative paths '../'.";
  1772. eqawarn " In the future this will cause a failure.";
  1773. eqawarn "${rel_paths}";
  1774. fi;
  1775. local patch_cmd;
  1776. while [[ ${count} -lt 5 ]]; do
  1777. patch_cmd="${BASH_ALIASES[patch]:-patch} -p${count} ${EPATCH_OPTS}";
  1778. ( _epatch_draw_line "***** ${patchname} *****";
  1779. echo;
  1780. echo "PATCH COMMAND: ${patch_cmd} < '${PATCH_TARGET}'";
  1781. echo;
  1782. _epatch_draw_line "***** ${patchname} *****";
  1783. ${patch_cmd} --dry-run -f < "${PATCH_TARGET}" 2>&1;
  1784. ret=$?;
  1785. echo;
  1786. echo "patch program exited with status ${ret}";
  1787. exit ${ret} ) >> "${STDERR_TARGET}";
  1788. if [ $? -eq 0 ]; then
  1789. ( _epatch_draw_line "***** ${patchname} *****";
  1790. echo;
  1791. echo "ACTUALLY APPLYING ${patchname} ...";
  1792. echo;
  1793. _epatch_draw_line "***** ${patchname} *****";
  1794. ${patch_cmd} < "${PATCH_TARGET}" 2>&1;
  1795. ret=$?;
  1796. echo;
  1797. echo "patch program exited with status ${ret}";
  1798. exit ${ret} ) >> "${STDERR_TARGET}";
  1799. if [ $? -ne 0 ]; then
  1800. echo;
  1801. eerror "A dry-run of patch command succeeded, but actually";
  1802. eerror "applying the patch failed!";
  1803. count=5;
  1804. fi;
  1805. break;
  1806. fi;
  1807. : $(( count++ ));
  1808. done;
  1809. if [[ -n ${PIPE_CMD} ]]; then
  1810. rm -f "${PATCH_TARGET}";
  1811. fi;
  1812. if [[ ${count} -ge 5 ]]; then
  1813. echo;
  1814. eerror "Failed Patch: ${patchname} !";
  1815. eerror " ( ${PATCH_TARGET} )";
  1816. eerror;
  1817. eerror "Include in your bugreport the contents of:";
  1818. eerror;
  1819. eerror " ${STDERR_TARGET}";
  1820. echo;
  1821. die "Failed Patch: ${patchname}!";
  1822. fi;
  1823. rm -f "${STDERR_TARGET}";
  1824. cat >> "${T}/epatch.log" <<-EOF
  1825. PATCH: ${x}
  1826. CMD: ${patch_cmd}
  1827. PWD: ${PWD}
  1828.  
  1829. EOF
  1830.  
  1831. eend 0;
  1832. done;
  1833. [[ ${SINGLE_PATCH} == "no" ]] && einfo "Done with patching";
  1834. :
  1835. }
  1836. epatch_user ()
  1837. {
  1838. [[ $# -ne 0 ]] && die "epatch_user takes no options";
  1839. local applied="${T}/epatch_user.log";
  1840. [[ -e ${applied} ]] && return 2;
  1841. local EPATCH_SOURCE check base=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
  1842. for check in ${CATEGORY}/{${P}-${PR},${P},${PN}};
  1843. do
  1844. EPATCH_SOURCE=${base}/${CTARGET}/${check};
  1845. [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${CHOST}/${check};
  1846. [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${check};
  1847. if [[ -d ${EPATCH_SOURCE} ]]; then
  1848. EPATCH_SOURCE=${EPATCH_SOURCE} EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" EPATCH_MULTI_MSG="Applying user patches from ${EPATCH_SOURCE} ..." epatch;
  1849. echo "${EPATCH_SOURCE}" > "${applied}";
  1850. return 0;
  1851. fi;
  1852. done;
  1853. echo "none" > "${applied}";
  1854. return 1
  1855. }
  1856. epause ()
  1857. {
  1858. [[ -z ${EPAUSE_IGNORE} ]] && sleep ${1:-5}
  1859. }
  1860. epunt_cxx ()
  1861. {
  1862. local dir=$1;
  1863. [[ -z ${dir} ]] && dir=${S};
  1864. ebegin "Removing useless C++ checks";
  1865. local f;
  1866. find "${dir}" -name configure | while read f; do
  1867. patch --no-backup-if-mismatch -p0 "${f}" "${PORTDIR}/eclass/ELT-patches/nocxx/nocxx.patch" > /dev/null;
  1868. done;
  1869. eend 0
  1870. }
  1871. eshopts_pop ()
  1872. {
  1873. local s;
  1874. estack_pop eshopts s || die "${FUNCNAME}: unbalanced push";
  1875. if [[ ${s} == "shopt -"* ]]; then
  1876. eval "${s}" || die "${FUNCNAME}: sanity: invalid shopt options: ${s}";
  1877. else
  1878. set +$- || die "${FUNCNAME}: sanity: invalid shell settings: $-";
  1879. set -${s} || die "${FUNCNAME}: sanity: unable to restore saved shell settings: ${s}";
  1880. fi
  1881. }
  1882. eshopts_push ()
  1883. {
  1884. if [[ $1 == -[su] ]]; then
  1885. estack_push eshopts "$(shopt -p)";
  1886. [[ $# -eq 0 ]] && return 0;
  1887. shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*";
  1888. else
  1889. estack_push eshopts $-;
  1890. [[ $# -eq 0 ]] && return 0;
  1891. set "$@" || die "${FUNCNAME}: bad options to set: $*";
  1892. fi
  1893. }
  1894. estack_pop ()
  1895. {
  1896. [[ $# -eq 0 || $# -gt 2 ]] && die "estack_pop: incorrect # of arguments";
  1897. local __estack_name="__ESTACK_$1__";
  1898. shift;
  1899. local __estack_retvar=$1;
  1900. shift;
  1901. eval local __estack_i=\${#${__estack_name}\[@\]};
  1902. [[ $(( --__estack_i )) -eq -1 ]] && return 1;
  1903. if [[ -n ${__estack_retvar} ]]; then
  1904. eval ${__estack_retvar}=\"\${${__estack_name}\[${__estack_i}\]}\";
  1905. fi;
  1906. eval unset ${__estack_name}\[${__estack_i}\]
  1907. }
  1908. estack_push ()
  1909. {
  1910. [[ $# -eq 0 ]] && die "estack_push: incorrect # of arguments";
  1911. local stack_name="__ESTACK_$1__";
  1912. shift;
  1913. eval ${stack_name}+=\( \"\$@\" \)
  1914. }
  1915. esvn_clean ()
  1916. {
  1917. [[ -z $* ]] && set -- .;
  1918. find "$@" -type d -name '.svn' -prune -print0 | xargs -0 rm -rf
  1919. }
  1920. eumask_pop ()
  1921. {
  1922. [[ $# -eq 0 ]] || die "${FUNCNAME}: we take no options";
  1923. local s;
  1924. estack_pop eumask s || die "${FUNCNAME}: unbalanced push";
  1925. umask ${s} || die "${FUNCNAME}: sanity: could not restore umask: ${s}"
  1926. }
  1927. eumask_push ()
  1928. {
  1929. estack_push eumask "$(umask)";
  1930. umask "$@" || die "${FUNCNAME}: bad options to umask: $*"
  1931. }
  1932. games_get_libdir ()
  1933. {
  1934. echo ${GAMES_PREFIX}/$(get_libdir)
  1935. }
  1936. games_make_wrapper ()
  1937. {
  1938. gameswrapper ${FUNCNAME/games_} "$@"
  1939. }
  1940. games_pkg_postinst ()
  1941. {
  1942. gamesenv;
  1943. if [[ -z "${GAMES_SHOW_WARNING}" ]]; then
  1944. ewarn "Remember, in order to play games, you have to";
  1945. ewarn "be in the '${GAMES_GROUP}' group.";
  1946. echo;
  1947. case ${CHOST} in
  1948. *-darwin*)
  1949. ewarn "Just run 'niutil -appendprop / /groups/games users <USER>'"
  1950. ;;
  1951. *-freebsd* | *-dragonfly*)
  1952. ewarn "Just run 'pw groupmod ${GAMES_GROUP} -m <USER>'"
  1953. ;;
  1954. *)
  1955. ewarn "Just run 'gpasswd -a <USER> ${GAMES_GROUP}', then have <USER> re-login."
  1956. ;;
  1957. esac;
  1958. echo;
  1959. einfo "For more info about Gentoo gaming in general, see our website:";
  1960. einfo " http://games.gentoo.org/";
  1961. echo;
  1962. fi
  1963. }
  1964. games_pkg_preinst ()
  1965. {
  1966. local f;
  1967. while read f; do
  1968. if [[ -e ${ROOT}/${GAMES_STATEDIR}/${f} ]]; then
  1969. cp -p "${ROOT}/${GAMES_STATEDIR}/${f}" "${D}/${GAMES_STATEDIR}/${f}" || die "cp failed";
  1970. touch "${D}/${GAMES_STATEDIR}/${f}";
  1971. fi;
  1972. done < <(find "${D}/${GAMES_STATEDIR}" -type f -printf '%P\n' 2>/dev/null)
  1973. }
  1974. games_pkg_setup ()
  1975. {
  1976. tc-export CC CXX;
  1977. enewgroup "${GAMES_GROUP}" 35;
  1978. [[ ${GAMES_USER} != "root" ]] && enewuser "${GAMES_USER}" 35 -1 "${GAMES_PREFIX}" "${GAMES_GROUP}";
  1979. [[ ${GAMES_USER_DED} != "root" ]] && enewuser "${GAMES_USER_DED}" 36 /bin/bash "${GAMES_PREFIX}" "${GAMES_GROUP}";
  1980. [[ ${USERLAND} != "GNU" ]] && return 0;
  1981. [[ $(egetshell "${GAMES_USER_DED}") == "/bin/false" ]] && usermod -s /bin/bash "${GAMES_USER_DED}"
  1982. }
  1983. games_src_compile ()
  1984. {
  1985. case ${EAPI:-0} in
  1986. 0 | 1)
  1987. games_src_configure
  1988. ;;
  1989. esac;
  1990. base_src_make
  1991. }
  1992. games_src_configure ()
  1993. {
  1994. [[ -x ./configure ]] && egamesconf
  1995. }
  1996. games_umod_unpack ()
  1997. {
  1998. local umod=$1;
  1999. mkdir -p "${Ddir}"/System;
  2000. cp "${dir}"/System/{ucc-bin,{Manifest,Def{ault,User}}.ini,{Engine,Core,zlib,ogg,vorbis}.so,{Engine,Core}.int} "${Ddir}"/System;
  2001. cd "${Ddir}"/System;
  2002. UT_DATA_PATH=${Ddir}/System ./ucc-bin umodunpack -x "${S}/${umod}" -nohomedir &>/dev/null || die "uncompressing file ${umod}";
  2003. rm -f "${Ddir}"/System/{ucc-bin,{Manifest,Def{ault,User},User,UT200{3,4}}.ini,{Engine,Core,zlib,ogg,vorbis}.so,{Engine,Core}.int,ucc.log} &>/dev/null || die "Removing temporary files"
  2004. }
  2005. games_ut_unpack ()
  2006. {
  2007. local ut_unpack="$1";
  2008. local f=;
  2009. if [[ -z ${ut_unpack} ]]; then
  2010. die "You must provide an argument to games_ut_unpack";
  2011. fi;
  2012. if [[ -f ${ut_unpack} ]]; then
  2013. uz2unpack "${ut_unpack}" "${ut_unpack%.uz2}" || die "uncompressing file ${ut_unpack}";
  2014. fi;
  2015. if [[ -d ${ut_unpack} ]]; then
  2016. while read f; do
  2017. uz2unpack "${ut_unpack}/${f}" "${ut_unpack}/${f%.uz2}" || die "uncompressing file ${f}";
  2018. rm -f "${ut_unpack}/${f}" || die "deleting compressed file ${f}";
  2019. done < <(find "${ut_unpack}" -maxdepth 1 -name '*.uz2' -printf '%f\n' 2>/dev/null);
  2020. fi
  2021. }
  2022. gamesenv ()
  2023. {
  2024. local d libdirs;
  2025. for d in $(get_all_libdirs);
  2026. do
  2027. libdirs="${libdirs}:${GAMES_PREFIX}/${d}";
  2028. done;
  2029. cat > "${ROOT}"/etc/env.d/${GAMES_ENVD} <<-EOF
  2030. LDPATH="${libdirs:1}"
  2031. PATH="${GAMES_BINDIR}"
  2032. EOF
  2033.  
  2034. }
  2035. gamesowners ()
  2036. {
  2037. chown ${GAMES_USER}:${GAMES_GROUP} "$@"
  2038. }
  2039. gamesperms ()
  2040. {
  2041. chmod u+rw,g+r-w,o-rwx "$@"
  2042. }
  2043. gameswrapper ()
  2044. {
  2045. ( into "${GAMES_PREFIX}";
  2046. cmd=$1;
  2047. shift;
  2048. ${cmd} "$@" )
  2049. }
  2050. gcc-fullversion ()
  2051. {
  2052. _gcc_fullversion '$1.$2.$3' "$@"
  2053. }
  2054. gcc-major-version ()
  2055. {
  2056. _gcc_fullversion '$1' "$@"
  2057. }
  2058. gcc-micro-version ()
  2059. {
  2060. _gcc_fullversion '$3' "$@"
  2061. }
  2062. gcc-minor-version ()
  2063. {
  2064. _gcc_fullversion '$2' "$@"
  2065. }
  2066. gcc-specs-directive ()
  2067. {
  2068. local directive subdname subdirective;
  2069. directive="$(_gcc-specs-directive_raw $1)";
  2070. while [[ ${directive} == *%\(*\)* ]]; do
  2071. subdname=${directive/*%\(};
  2072. subdname=${subdname/\)*};
  2073. subdirective="$(_gcc-specs-directive_raw ${subdname})";
  2074. directive="${directive//\%(${subdname})/${subdirective}}";
  2075. done;
  2076. echo "${directive}";
  2077. return 0
  2078. }
  2079. gcc-specs-nostrict ()
  2080. {
  2081. local directive;
  2082. directive=$(gcc-specs-directive cc1);
  2083. return $([[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]])
  2084. }
  2085. gcc-specs-now ()
  2086. {
  2087. local directive;
  2088. directive=$(gcc-specs-directive link_command);
  2089. return $([[ "${directive/\{!nonow:}" != "${directive}" ]])
  2090. }
  2091. gcc-specs-pie ()
  2092. {
  2093. local directive;
  2094. directive=$(gcc-specs-directive cc1);
  2095. return $([[ "${directive/\{!nopie:}" != "${directive}" ]])
  2096. }
  2097. gcc-specs-relro ()
  2098. {
  2099. local directive;
  2100. directive=$(gcc-specs-directive link_command);
  2101. return $([[ "${directive/\{!norelro:}" != "${directive}" ]])
  2102. }
  2103. gcc-specs-ssp ()
  2104. {
  2105. local directive;
  2106. directive=$(gcc-specs-directive cc1);
  2107. return $([[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]])
  2108. }
  2109. gcc-specs-ssp-to-all ()
  2110. {
  2111. local directive;
  2112. directive=$(gcc-specs-directive cc1);
  2113. return $([[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]])
  2114. }
  2115. gcc-version ()
  2116. {
  2117. _gcc_fullversion '$1.$2' "$@"
  2118. }
  2119. gen_usr_ldscript ()
  2120. {
  2121. local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  2122. [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  2123. tc-is-static-only && return;
  2124. dodir /usr/${libdir};
  2125. if [[ $1 == "-a" ]]; then
  2126. auto=true;
  2127. shift;
  2128. dodir /${libdir};
  2129. fi;
  2130. output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  2131. [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  2132. for lib in "$@";
  2133. do
  2134. local tlib;
  2135. if ${auto}; then
  2136. lib="lib${lib}${suffix}";
  2137. else
  2138. [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  2139. fi;
  2140. case ${CTARGET:-${CHOST}} in
  2141. *-darwin*)
  2142. if ${auto}; then
  2143. tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  2144. else
  2145. tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  2146. fi;
  2147. [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  2148. tlib=${tlib##*/};
  2149. if ${auto}; then
  2150. mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  2151. if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  2152. mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  2153. fi;
  2154. rm -f "${ED}"/${libdir}/${lib};
  2155. fi;
  2156. if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  2157. chmod u+w "${ED}${libdir}/${tlib}";
  2158. local nowrite=yes;
  2159. fi;
  2160. install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  2161. [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  2162. pushd "${ED}/usr/${libdir}" > /dev/null;
  2163. ln -snf "../../${libdir}/${tlib}" "${lib}";
  2164. popd > /dev/null
  2165. ;;
  2166. *-aix* | *-irix* | *64*-hpux* | *-interix* | *-winnt*)
  2167. if ${auto}; then
  2168. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  2169. tlib=$(readlink "${ED}"/${libdir}/${lib});
  2170. tlib=${tlib##*/};
  2171. if [[ -z ${tlib} ]]; then
  2172. tlib=${lib};
  2173. else
  2174. rm -f "${ED}"/${libdir}/${lib};
  2175. fi;
  2176. else
  2177. tlib=${lib};
  2178. fi;
  2179. pushd "${ED}/usr/${libdir}" > /dev/null;
  2180. ln -snf "../../${libdir}/${tlib}" "${lib}";
  2181. popd > /dev/null
  2182. ;;
  2183. hppa*-hpux*)
  2184. if ${auto}; then
  2185. tlib=$(chatr "${ED}"/usr/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}');
  2186. [[ -z ${tlib} ]] && tlib=${lib};
  2187. tlib=${tlib##*/};
  2188. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  2189. if [[ ${tlib} != ${lib}* ]]; then
  2190. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  2191. fi;
  2192. [[ ${tlib} != ${lib} ]] && rm -f "${ED}"/${libdir}/${lib};
  2193. else
  2194. tlib=$(chatr "${ED}"/${libdir}/${lib} | sed -n '/internal name:/{n;s/^ *//;p;q}');
  2195. [[ -z ${tlib} ]] && tlib=${lib};
  2196. tlib=${tlib##*/};
  2197. fi;
  2198. pushd "${ED}"/usr/${libdir} > /dev/null;
  2199. ln -snf "../../${libdir}/${tlib}" "${lib}";
  2200. [[ ${tlib} != ${lib} ]] && ln -snf "../../${libdir}/${tlib}" "${tlib}";
  2201. popd > /dev/null
  2202. ;;
  2203. *)
  2204. if ${auto}; then
  2205. tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  2206. [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  2207. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  2208. if [[ ${tlib} != ${lib}* ]]; then
  2209. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  2210. fi;
  2211. rm -f "${ED}"/${libdir}/${lib};
  2212. else
  2213. tlib=${lib};
  2214. fi;
  2215. cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
  2216. /* GNU ld script
  2217. Since Gentoo has critical dynamic libraries in /lib, and the static versions
  2218. in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  2219. run into linking problems. This "fake" dynamic lib is a linker script that
  2220. redirects the linker to the real lib. And yes, this works in the cross-
  2221. compiling scenario as the sysroot-ed linker will prepend the real path.
  2222.  
  2223. See bug http://bugs.gentoo.org/4411 for more info.
  2224. */
  2225. ${output_format}
  2226. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  2227. END_LDSCRIPT
  2228.  
  2229. ;;
  2230. esac
  2231. fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  2232. done
  2233. }
  2234. get_abi_CFLAGS ()
  2235. {
  2236. get_abi_var CFLAGS "$@"
  2237. }
  2238. get_abi_CHOST ()
  2239. {
  2240. get_abi_var CHOST "$@"
  2241. }
  2242. get_abi_CTARGET ()
  2243. {
  2244. get_abi_var CTARGET "$@"
  2245. }
  2246. get_abi_FAKE_TARGETS ()
  2247. {
  2248. get_abi_var FAKE_TARGETS "$@"
  2249. }
  2250. get_abi_LDFLAGS ()
  2251. {
  2252. get_abi_var LDFLAGS "$@"
  2253. }
  2254. get_abi_LIBDIR ()
  2255. {
  2256. get_abi_var LIBDIR "$@"
  2257. }
  2258. get_abi_var ()
  2259. {
  2260. local flag=$1;
  2261. local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  2262. local var="${flag}_${abi}";
  2263. echo ${!var}
  2264. }
  2265. get_after_major_version ()
  2266. {
  2267. echo $(get_version_component_range 2- "${1:-${PV}}")
  2268. }
  2269. get_all_abis ()
  2270. {
  2271. local order="" mvar dvar;
  2272. mvar="MULTILIB_ABIS";
  2273. dvar="DEFAULT_ABI";
  2274. if [[ -n $1 ]]; then
  2275. mvar="$1_${mvar}";
  2276. dvar="$1_${dvar}";
  2277. fi;
  2278. if [[ -z ${!mvar} ]]; then
  2279. echo "default";
  2280. return 0;
  2281. fi;
  2282. for x in ${!mvar};
  2283. do
  2284. if [[ ${x} != ${!dvar} ]]; then
  2285. order="${order:+${order} }${x}";
  2286. fi;
  2287. done;
  2288. order="${order:+${order} }${!dvar}";
  2289. echo ${order};
  2290. return 0
  2291. }
  2292. get_all_libdirs ()
  2293. {
  2294. local libdirs;
  2295. local abi;
  2296. local dir;
  2297. for abi in ${MULTILIB_ABIS};
  2298. do
  2299. libdirs+=" $(get_abi_LIBDIR ${abi})";
  2300. done;
  2301. [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  2302. echo "${libdirs}"
  2303. }
  2304. get_all_version_components ()
  2305. {
  2306. eshopts_push -s extglob;
  2307. local ver_str=${1:-${PV}} result;
  2308. result=();
  2309. if [[ ${VERSIONATOR_CACHE_VER_STR} == ${ver_str} ]]; then
  2310. echo ${VERSIONATOR_CACHE_RESULT};
  2311. eshopts_pop;
  2312. return;
  2313. fi;
  2314. export VERSIONATOR_CACHE_VER_STR=${ver_str};
  2315. while [[ -n $ver_str ]]; do
  2316. case "${ver_str::1}" in
  2317. [[:digit:]])
  2318. result+=("${ver_str%%[^[:digit:]]*}");
  2319. ver_str=${ver_str##+([[:digit:]])}
  2320. ;;
  2321. [-_.])
  2322. result+=("${ver_str::1}");
  2323. ver_str=${ver_str:1}
  2324. ;;
  2325. [[:alpha:]])
  2326. local not_match=${ver_str##+([[:alpha:]])*([[:digit:]])};
  2327. result+=("${ver_str::${#ver_str} - ${#not_match}}");
  2328. ver_str=${not_match}
  2329. ;;
  2330. *)
  2331. result+=("${ver_str::1}");
  2332. ver_str=${ver_str:1}
  2333. ;;
  2334. esac;
  2335. done;
  2336. export VERSIONATOR_CACHE_RESULT=${result[*]};
  2337. echo ${result[@]};
  2338. eshopts_pop
  2339. }
  2340. get_install_abis ()
  2341. {
  2342. local order="";
  2343. if [[ -z ${MULTILIB_ABIS} ]]; then
  2344. echo "default";
  2345. return 0;
  2346. fi;
  2347. if [[ ${EMULTILIB_PKG} == "true" ]]; then
  2348. for x in ${MULTILIB_ABIS};
  2349. do
  2350. if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  2351. has ${x} ${ABI_DENY} || order="${order} ${x}";
  2352. fi;
  2353. done;
  2354. has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  2355. if [[ -n ${ABI_ALLOW} ]]; then
  2356. local ordera="";
  2357. for x in ${order};
  2358. do
  2359. if has ${x} ${ABI_ALLOW}; then
  2360. ordera="${ordera} ${x}";
  2361. fi;
  2362. done;
  2363. order=${ordera};
  2364. fi;
  2365. else
  2366. order=${DEFAULT_ABI};
  2367. fi;
  2368. if [[ -z ${order} ]]; then
  2369. 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.";
  2370. fi;
  2371. echo ${order};
  2372. return 0
  2373. }
  2374. get_last_version_component_index ()
  2375. {
  2376. echo $(($(get_version_component_count "${1:-${PV}}" ) - 1))
  2377. }
  2378. get_libdir ()
  2379. {
  2380. local CONF_LIBDIR;
  2381. if [ -n "${CONF_LIBDIR_OVERRIDE}" ]; then
  2382. echo ${CONF_LIBDIR_OVERRIDE};
  2383. else
  2384. get_abi_LIBDIR;
  2385. fi
  2386. }
  2387. get_libname ()
  2388. {
  2389. local libname;
  2390. local ver=$1;
  2391. case ${CHOST} in
  2392. *-cygwin | mingw* | *-mingw*)
  2393. libname="dll"
  2394. ;;
  2395. *-darwin*)
  2396. libname="dylib"
  2397. ;;
  2398. *-mint*)
  2399. libname="irrelevant"
  2400. ;;
  2401. hppa*-hpux*)
  2402. libname="sl"
  2403. ;;
  2404. *)
  2405. libname="so"
  2406. ;;
  2407. esac;
  2408. if [[ -z $* ]]; then
  2409. echo ".${libname}";
  2410. else
  2411. for ver in "$@";
  2412. do
  2413. case ${CHOST} in
  2414. *-darwin*)
  2415. echo ".${ver}.${libname}"
  2416. ;;
  2417. *-mint*)
  2418. echo ".${libname}"
  2419. ;;
  2420. *)
  2421. echo ".${libname}.${ver}"
  2422. ;;
  2423. esac;
  2424. done;
  2425. fi
  2426. }
  2427. get_major_version ()
  2428. {
  2429. local c=($(get_all_version_components "${1:-${PV}}"));
  2430. echo ${c[0]}
  2431. }
  2432. get_modname ()
  2433. {
  2434. local modname;
  2435. local ver=$1;
  2436. case ${CHOST} in
  2437. *-darwin*)
  2438. modname="bundle"
  2439. ;;
  2440. *)
  2441. modname="so"
  2442. ;;
  2443. esac;
  2444. echo ".${modname}"
  2445. }
  2446. get_version_component_count ()
  2447. {
  2448. local a=($(get_version_components "${1:-${PV}}"));
  2449. echo ${#a[@]}
  2450. }
  2451. get_version_component_range ()
  2452. {
  2453. eshopts_push -s extglob;
  2454. local c v="${2:-${PV}}" range="${1}" range_start range_end;
  2455. local -i i=-1 j=0;
  2456. c=($(get_all_version_components "${v}"));
  2457. range_start=${range%-*};
  2458. range_start=${range_start:-1};
  2459. range_end=${range#*-};
  2460. range_end=${range_end:-${#c[@]}};
  2461. while ((j < range_start)); do
  2462. i+=1;
  2463. ((i > ${#c[@]})) && eshopts_pop && return;
  2464. [[ -n "${c[i]//[-._]}" ]] && j+=1;
  2465. done;
  2466. while ((j <= range_end)); do
  2467. echo -n ${c[i]};
  2468. ((i > ${#c[@]})) && eshopts_pop && return;
  2469. [[ -n "${c[i]//[-._]}" ]] && j+=1;
  2470. i+=1;
  2471. done;
  2472. eshopts_pop
  2473. }
  2474. get_version_components ()
  2475. {
  2476. local c=$(get_all_version_components "${1:-${PV}}");
  2477. echo ${c//[-._]/ }
  2478. }
  2479. has_multilib_profile ()
  2480. {
  2481. [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  2482. }
  2483. in_iuse ()
  2484. {
  2485. debug-print-function ${FUNCNAME} "${@}";
  2486. [[ ${#} -eq 1 ]] || die "Invalid args to ${FUNCNAME}()";
  2487. local flag=${1};
  2488. local liuse=(${IUSE});
  2489. has "${flag}" "${liuse[@]#[+-]}"
  2490. }
  2491. is_final_abi ()
  2492. {
  2493. has_multilib_profile || return 0;
  2494. set -- $(get_install_abis);
  2495. local LAST_ABI=$#;
  2496. [[ ${!LAST_ABI} == ${ABI} ]]
  2497. }
  2498. make_desktop_entry ()
  2499. {
  2500. [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable";
  2501. local exec=${1};
  2502. local name=${2:-${PN}};
  2503. local icon=${3:-${PN}};
  2504. local type=${4};
  2505. local fields=${5};
  2506. if [[ -z ${type} ]]; then
  2507. local catmaj=${CATEGORY%%-*};
  2508. local catmin=${CATEGORY##*-};
  2509. case ${catmaj} in
  2510. app)
  2511. case ${catmin} in
  2512. accessibility)
  2513. type="Utility;Accessibility"
  2514. ;;
  2515. admin)
  2516. type=System
  2517. ;;
  2518. antivirus)
  2519. type=System
  2520. ;;
  2521. arch)
  2522. type="Utility;Archiving"
  2523. ;;
  2524. backup)
  2525. type="Utility;Archiving"
  2526. ;;
  2527. cdr)
  2528. type="AudioVideo;DiscBurning"
  2529. ;;
  2530. dicts)
  2531. type="Office;Dictionary"
  2532. ;;
  2533. doc)
  2534. type=Documentation
  2535. ;;
  2536. editors)
  2537. type="Utility;TextEditor"
  2538. ;;
  2539. emacs)
  2540. type="Development;TextEditor"
  2541. ;;
  2542. emulation)
  2543. type="System;Emulator"
  2544. ;;
  2545. laptop)
  2546. type="Settings;HardwareSettings"
  2547. ;;
  2548. office)
  2549. type=Office
  2550. ;;
  2551. pda)
  2552. type="Office;PDA"
  2553. ;;
  2554. vim)
  2555. type="Development;TextEditor"
  2556. ;;
  2557. xemacs)
  2558. type="Development;TextEditor"
  2559. ;;
  2560. esac
  2561. ;;
  2562. dev)
  2563. type="Development"
  2564. ;;
  2565. games)
  2566. case ${catmin} in
  2567. action | fps)
  2568. type=ActionGame
  2569. ;;
  2570. arcade)
  2571. type=ArcadeGame
  2572. ;;
  2573. board)
  2574. type=BoardGame
  2575. ;;
  2576. emulation)
  2577. type=Emulator
  2578. ;;
  2579. kids)
  2580. type=KidsGame
  2581. ;;
  2582. puzzle)
  2583. type=LogicGame
  2584. ;;
  2585. roguelike)
  2586. type=RolePlaying
  2587. ;;
  2588. rpg)
  2589. type=RolePlaying
  2590. ;;
  2591. simulation)
  2592. type=Simulation
  2593. ;;
  2594. sports)
  2595. type=SportsGame
  2596. ;;
  2597. strategy)
  2598. type=StrategyGame
  2599. ;;
  2600. esac;
  2601. type="Game;${type}"
  2602. ;;
  2603. gnome)
  2604. type="Gnome;GTK"
  2605. ;;
  2606. kde)
  2607. type="KDE;Qt"
  2608. ;;
  2609. mail)
  2610. type="Network;Email"
  2611. ;;
  2612. media)
  2613. case ${catmin} in
  2614. gfx)
  2615. type=Graphics
  2616. ;;
  2617. *)
  2618. case ${catmin} in
  2619. radio)
  2620. type=Tuner
  2621. ;;
  2622. sound)
  2623. type=Audio
  2624. ;;
  2625. tv)
  2626. type=TV
  2627. ;;
  2628. video)
  2629. type=Video
  2630. ;;
  2631. esac;
  2632. type="AudioVideo;${type}"
  2633. ;;
  2634. esac
  2635. ;;
  2636. net)
  2637. case ${catmin} in
  2638. dialup)
  2639. type=Dialup
  2640. ;;
  2641. ftp)
  2642. type=FileTransfer
  2643. ;;
  2644. im)
  2645. type=InstantMessaging
  2646. ;;
  2647. irc)
  2648. type=IRCClient
  2649. ;;
  2650. mail)
  2651. type=Email
  2652. ;;
  2653. news)
  2654. type=News
  2655. ;;
  2656. nntp)
  2657. type=News
  2658. ;;
  2659. p2p)
  2660. type=FileTransfer
  2661. ;;
  2662. voip)
  2663. type=Telephony
  2664. ;;
  2665. esac;
  2666. type="Network;${type}"
  2667. ;;
  2668. sci)
  2669. case ${catmin} in
  2670. astro*)
  2671. type=Astronomy
  2672. ;;
  2673. bio*)
  2674. type=Biology
  2675. ;;
  2676. calc*)
  2677. type=Calculator
  2678. ;;
  2679. chem*)
  2680. type=Chemistry
  2681. ;;
  2682. elec*)
  2683. type=Electronics
  2684. ;;
  2685. geo*)
  2686. type=Geology
  2687. ;;
  2688. math*)
  2689. type=Math
  2690. ;;
  2691. physics)
  2692. type=Physics
  2693. ;;
  2694. visual*)
  2695. type=DataVisualization
  2696. ;;
  2697. esac;
  2698. type="Education;Science;${type}"
  2699. ;;
  2700. sys)
  2701. type="System"
  2702. ;;
  2703. www)
  2704. case ${catmin} in
  2705. client)
  2706. type=WebBrowser
  2707. ;;
  2708. esac;
  2709. type="Network;${type}"
  2710. ;;
  2711. *)
  2712. type=
  2713. ;;
  2714. esac;
  2715. fi;
  2716. if [ "${SLOT}" == "0" ]; then
  2717. local desktop_name="${PN}";
  2718. else
  2719. local desktop_name="${PN}-${SLOT}";
  2720. fi;
  2721. local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop";
  2722. type=${type%;}${type:+;};
  2723. eshopts_push -s extglob;
  2724. if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then
  2725. ewarn "As described in the Icon Theme Specification, icon file extensions are not";
  2726. ewarn "allowed in .desktop files if the value is not an absolute path.";
  2727. icon=${icon%.@(xpm|png|svg)};
  2728. fi;
  2729. eshopts_pop;
  2730. cat > "${desktop}" <<-EOF
  2731. [Desktop Entry]
  2732. Name=${name}
  2733. Type=Application
  2734. Comment=${DESCRIPTION}
  2735. Exec=${exec}
  2736. TryExec=${exec%% *}
  2737. Icon=${icon}
  2738. Categories=${type}
  2739. EOF
  2740.  
  2741. if [[ ${fields:-=} != *=* ]]; then
  2742. ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}";
  2743. fields="Path=${fields}";
  2744. fi;
  2745. [[ -n ${fields} ]] && printf '%b\n' "${fields}" >> "${desktop}";
  2746. ( insinto /usr/share/applications;
  2747. doins "${desktop}" ) || die "installing desktop file failed"
  2748. }
  2749. make_session_desktop ()
  2750. {
  2751. [[ -z $1 ]] && eerror "$0: You must specify the title" && return 1;
  2752. [[ -z $2 ]] && eerror "$0: You must specify the command" && return 1;
  2753. local title=$1;
  2754. local command=$2;
  2755. local desktop=${T}/${wm:-${PN}}.desktop;
  2756. shift 2;
  2757. cat > "${desktop}" <<-EOF
  2758. [Desktop Entry]
  2759. Name=${title}
  2760. Comment=This session logs you into ${title}
  2761. Exec=${command} $*
  2762. TryExec=${command}
  2763. Type=XSession
  2764. EOF
  2765.  
  2766. ( insinto /usr/share/xsessions;
  2767. doins "${desktop}" )
  2768. }
  2769. make_wrapper ()
  2770. {
  2771. local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5;
  2772. local tmpwrapper=$(emktemp);
  2773. cat > "${tmpwrapper}" <<EOF
  2774. #!/bin/sh
  2775. cd "${chdir:-.}"
  2776. if [ -n "${libdir}" ] ; then
  2777. if [ "\${LD_LIBRARY_PATH+set}" = "set" ] ; then
  2778. export LD_LIBRARY_PATH="\${LD_LIBRARY_PATH}:${libdir}"
  2779. else
  2780. export LD_LIBRARY_PATH="${libdir}"
  2781. fi
  2782. fi
  2783. exec ${bin} "\$@"
  2784. EOF
  2785.  
  2786. chmod go+rx "${tmpwrapper}";
  2787. if [[ -n ${path} ]]; then
  2788. ( exeinto "${path}";
  2789. newexe "${tmpwrapper}" "${wrapper}" ) || die;
  2790. else
  2791. newbin "${tmpwrapper}" "${wrapper}" || die;
  2792. fi
  2793. }
  2794. makeopts_jobs ()
  2795. {
  2796. [[ $# -eq 0 ]] && set -- ${MAKEOPTS};
  2797. local jobs=$(echo " $* " | sed -r -n -e 's:.*[[:space:]](-j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p' -e 's:.*[[:space:]](-j|--jobs)[[:space:]].*:999:p');
  2798. echo ${jobs:-1}
  2799. }
  2800. multijob_child_init ()
  2801. {
  2802. local mode="pre";
  2803. case $1 in
  2804. --pre)
  2805. mode="pre";
  2806. shift
  2807. ;;
  2808. --post)
  2809. mode="post";
  2810. shift
  2811. ;;
  2812. esac;
  2813. if [[ $# -eq 0 ]]; then
  2814. trap 'echo ${BASHPID} $? >&'${mj_control_fd} EXIT;
  2815. trap 'exit 1' INT TERM;
  2816. else
  2817. local ret;
  2818. [[ ${mode} == "pre" ]] && {
  2819. multijob_pre_fork;
  2820. ret=$?
  2821. };
  2822. ( multijob_child_init;
  2823. "$@" ) & [[ ${mode} == "post" ]] && {
  2824. multijob_post_fork;
  2825. ret=$?
  2826. };
  2827. return ${ret};
  2828. fi
  2829. }
  2830. multijob_finish ()
  2831. {
  2832. local ret=0;
  2833. while [[ ${mj_num_jobs} -gt 0 ]]; do
  2834. multijob_finish_one;
  2835. : $(( ret |= $? ));
  2836. done;
  2837. wait;
  2838. [[ $# -eq 0 ]] || die "${FUNCNAME} takes no arguments";
  2839. return ${ret}
  2840. }
  2841. multijob_finish_one ()
  2842. {
  2843. [[ $# -eq 0 ]] || die "${FUNCNAME} takes no arguments";
  2844. local pid ret;
  2845. read -r -u ${mj_control_fd} pid ret || die;
  2846. : $(( --mj_num_jobs ));
  2847. return ${ret}
  2848. }
  2849. multijob_init ()
  2850. {
  2851. has wait ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" wait";
  2852. local pipe="${T}/multijob.pipe";
  2853. mkfifo "${pipe}";
  2854. redirect_alloc_fd mj_control_fd "${pipe}";
  2855. rm -f "${pipe}";
  2856. mj_max_jobs=$(makeopts_jobs "$@");
  2857. mj_num_jobs=0
  2858. }
  2859. multijob_post_fork ()
  2860. {
  2861. _multijob_fork post "$@"
  2862. }
  2863. multijob_pre_fork ()
  2864. {
  2865. _multijob_fork pre "$@"
  2866. }
  2867. multilib_env ()
  2868. {
  2869. local CTARGET=${1:-${CTARGET}};
  2870. case ${CTARGET} in
  2871. x86_64*)
  2872. export CFLAGS_x86=${CFLAGS_x86--m32};
  2873. export CHOST_x86=${CTARGET/x86_64/i686};
  2874. export CTARGET_x86=${CHOST_x86};
  2875. if [[ ${SYMLINK_LIB} == "yes" ]]; then
  2876. export LIBDIR_x86="lib32";
  2877. else
  2878. export LIBDIR_x86="lib";
  2879. fi;
  2880. export CFLAGS_amd64=${CFLAGS_amd64--m64};
  2881. export CHOST_amd64=${CTARGET};
  2882. export CTARGET_amd64=${CHOST_amd64};
  2883. export LIBDIR_amd64="lib64";
  2884. export CFLAGS_x32=${CFLAGS_x32--mx32};
  2885. export CHOST_x32=${CTARGET};
  2886. export CTARGET_x32=${CHOST_x32};
  2887. export LIBDIR_x32="libx32";
  2888. : ${MULTILIB_ABIS=amd64 x86};
  2889. : ${DEFAULT_ABI=amd64}
  2890. ;;
  2891. mips64*)
  2892. export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  2893. export CHOST_o32=${CTARGET/mips64/mips};
  2894. export CTARGET_o32=${CHOST_o32};
  2895. export LIBDIR_o32="lib";
  2896. export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  2897. export CHOST_n32=${CTARGET};
  2898. export CTARGET_n32=${CHOST_n32};
  2899. export LIBDIR_n32="lib32";
  2900. export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  2901. export CHOST_n64=${CTARGET};
  2902. export CTARGET_n64=${CHOST_n64};
  2903. export LIBDIR_n64="lib64";
  2904. : ${MULTILIB_ABIS=n64 n32 o32};
  2905. : ${DEFAULT_ABI=n32}
  2906. ;;
  2907. powerpc64*)
  2908. export CFLAGS_ppc=${CFLAGS_ppc--m32};
  2909. export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  2910. export CTARGET_ppc=${CHOST_ppc};
  2911. export LIBDIR_ppc="lib";
  2912. export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  2913. export CHOST_ppc64=${CTARGET};
  2914. export CTARGET_ppc64=${CHOST_ppc64};
  2915. export LIBDIR_ppc64="lib64";
  2916. : ${MULTILIB_ABIS=ppc64 ppc};
  2917. : ${DEFAULT_ABI=ppc64}
  2918. ;;
  2919. s390x*)
  2920. export CFLAGS_s390=${CFLAGS_s390--m31};
  2921. export CHOST_s390=${CTARGET/s390x/s390};
  2922. export CTARGET_s390=${CHOST_s390};
  2923. export LIBDIR_s390="lib";
  2924. export CFLAGS_s390x=${CFLAGS_s390x--m64};
  2925. export CHOST_s390x=${CTARGET};
  2926. export CTARGET_s390x=${CHOST_s390x};
  2927. export LIBDIR_s390x="lib64";
  2928. : ${MULTILIB_ABIS=s390x s390};
  2929. : ${DEFAULT_ABI=s390x}
  2930. ;;
  2931. sparc*)
  2932. export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
  2933. export CHOST_sparc32=${CTARGET/sparc64/sparc};
  2934. export CTARGET_sparc32=${CHOST_sparc32};
  2935. export LIBDIR_sparc32="lib";
  2936. export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  2937. export CHOST_sparc64=${CTARGET};
  2938. export CTARGET_sparc64=${CHOST_sparc64};
  2939. export LIBDIR_sparc64="lib64";
  2940. : ${MULTILIB_ABIS=sparc64 sparc32};
  2941. : ${DEFAULT_ABI=sparc64}
  2942. ;;
  2943. *)
  2944. : ${MULTILIB_ABIS=default};
  2945. : ${DEFAULT_ABI=default}
  2946. ;;
  2947. esac;
  2948. export MULTILIB_ABIS DEFAULT_ABI
  2949. }
  2950. multilib_toolchain_setup ()
  2951. {
  2952. local v vv;
  2953. export ABI=$1;
  2954. if [[ ${__DEFAULT_ABI_SAVED} == "true" ]]; then
  2955. for v in CHOST CBUILD AS CC CXX LD;
  2956. do
  2957. vv="__abi_saved_${v}";
  2958. export ${v}="${!vv}";
  2959. unset ${vv};
  2960. done;
  2961. unset __DEFAULT_ABI_SAVED;
  2962. fi;
  2963. if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  2964. for v in CHOST CBUILD AS CC CXX LD;
  2965. do
  2966. export __abi_saved_${v}="${!v}";
  2967. done;
  2968. export __DEFAULT_ABI_SAVED="true";
  2969. export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  2970. export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  2971. export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  2972. export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  2973. export CHOST=$(get_abi_CHOST $1);
  2974. export CBUILD=$(get_abi_CHOST $1);
  2975. fi
  2976. }
  2977. newgamesbin ()
  2978. {
  2979. gameswrapper ${FUNCNAME/games} "$@"
  2980. }
  2981. newgamessbin ()
  2982. {
  2983. gameswrapper ${FUNCNAME/games} "$@"
  2984. }
  2985. newicon ()
  2986. {
  2987. _iconins ${FUNCNAME} "$@"
  2988. }
  2989. newmenu ()
  2990. {
  2991. ( insinto /usr/share/applications;
  2992. newins "$@" )
  2993. }
  2994. number_abis ()
  2995. {
  2996. set -- `get_install_abis`;
  2997. echo $#
  2998. }
  2999. path_exists ()
  3000. {
  3001. local opt=$1;
  3002. [[ ${opt} == -[ao] ]] && shift || opt="-a";
  3003. [[ $# -eq 0 ]] && return 1;
  3004. local p r=0;
  3005. for p in "$@";
  3006. do
  3007. [[ -e ${p} ]];
  3008. : $(( r += $? ));
  3009. done;
  3010. case ${opt} in
  3011. -a)
  3012. return $(( r != 0 ))
  3013. ;;
  3014. -o)
  3015. return $(( r == $# ))
  3016. ;;
  3017. esac
  3018. }
  3019. pkg_nofetch ()
  3020. {
  3021. _eapi0_pkg_nofetch "$@"
  3022. }
  3023. pkg_postinst ()
  3024. {
  3025. games_pkg_postinst "$@"
  3026. }
  3027. pkg_preinst ()
  3028. {
  3029. games_pkg_preinst "$@"
  3030. }
  3031. pkg_setup ()
  3032. {
  3033. games_pkg_setup "$@"
  3034. }
  3035. pre_pkg_setup ()
  3036. {
  3037. [[ $ROOT = / ]] && cfg-update --index
  3038. }
  3039. prepgamesdirs ()
  3040. {
  3041. local dir f mode;
  3042. for dir in "${GAMES_PREFIX}" "${GAMES_PREFIX_OPT}" "${GAMES_DATADIR}" "${GAMES_SYSCONFDIR}" "${GAMES_STATEDIR}" "$(games_get_libdir)" "${GAMES_BINDIR}" "$@";
  3043. do
  3044. [[ ! -d ${D}/${dir} ]] && continue;
  3045. ( gamesowners -R "${D}/${dir}";
  3046. find "${D}/${dir}" -type d -print0 | xargs -0 chmod 750;
  3047. mode=o-rwx,g+r,g-w;
  3048. [[ ${dir} = ${GAMES_STATEDIR} ]] && mode=o-rwx,g+r;
  3049. find "${D}/${dir}" -type f -print0 | xargs -0 chmod $mode;
  3050. if [[ ${dir} == "${GAMES_PREFIX_OPT}" ]]; then
  3051. fowners root:root "${dir}";
  3052. fperms 755 "${dir}";
  3053. for d in $(get_libdir) bin;
  3054. do
  3055. if [[ -e ${d} ]]; then
  3056. fowners root:root "${dir}/${d}";
  3057. fperms 755 "${dir}/${d}";
  3058. fi;
  3059. done;
  3060. fi ) &>/dev/null;
  3061. f=$(find "${D}/${dir}" -perm +4000 -a -uid 0 2>/dev/null);
  3062. if [[ -n ${f} ]]; then
  3063. eerror "A game was detected that is setuid root!";
  3064. eerror "${f}";
  3065. die "refusing to merge a setuid root game";
  3066. fi;
  3067. done;
  3068. [[ -d ${D}/${GAMES_BINDIR} ]] || return 0;
  3069. find "${D}/${GAMES_BINDIR}" -maxdepth 1 -type f -exec chmod 750 '{}' \;
  3070. }
  3071. preserve_old_lib ()
  3072. {
  3073. if [[ ${EBUILD_PHASE} != "preinst" ]]; then
  3074. eerror "preserve_old_lib() must be called from pkg_preinst() only";
  3075. die "Invalid preserve_old_lib() usage";
  3076. fi;
  3077. [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]";
  3078. has preserve-libs ${FEATURES} && return 0;
  3079. local lib dir;
  3080. for lib in "$@";
  3081. do
  3082. [[ -e ${ROOT}/${lib} ]] || continue;
  3083. dir=${lib%/*};
  3084. dodir ${dir} || die "dodir ${dir} failed";
  3085. cp "${ROOT}"/${lib} "${D}"/${lib} || die "cp ${lib} failed";
  3086. touch "${D}"/${lib};
  3087. done
  3088. }
  3089. preserve_old_lib_notify ()
  3090. {
  3091. if [[ ${EBUILD_PHASE} != "postinst" ]]; then
  3092. eerror "preserve_old_lib_notify() must be called from pkg_postinst() only";
  3093. die "Invalid preserve_old_lib_notify() usage";
  3094. fi;
  3095. has preserve-libs ${FEATURES} && return 0;
  3096. local lib notice=0;
  3097. for lib in "$@";
  3098. do
  3099. [[ -e ${ROOT}/${lib} ]] || continue;
  3100. if [[ ${notice} -eq 0 ]]; then
  3101. notice=1;
  3102. ewarn "Old versions of installed libraries were detected on your system.";
  3103. ewarn "In order to avoid breaking packages that depend on these old libs,";
  3104. ewarn "the libraries are not being removed. You need to run revdep-rebuild";
  3105. ewarn "in order to remove these old dependencies. If you do not have this";
  3106. ewarn "helper program, simply emerge the 'gentoolkit' package.";
  3107. ewarn;
  3108. fi;
  3109. ewarn " # revdep-rebuild --library '${lib}' && rm '${lib}'";
  3110. done
  3111. }
  3112. prune_libtool_files ()
  3113. {
  3114. debug-print-function ${FUNCNAME} "$@";
  3115. local removing_all opt;
  3116. for opt in "$@";
  3117. do
  3118. case "${opt}" in
  3119. --all)
  3120. removing_all=1
  3121. ;;
  3122. *)
  3123. die "Invalid argument to ${FUNCNAME}(): ${opt}"
  3124. ;;
  3125. esac;
  3126. done;
  3127. local pc_libs=();
  3128. if [[ ! -n ${removing_all} ]]; then
  3129. local f;
  3130. local tf=${T}/prune-lt-files.pc;
  3131. local pkgconf=$(tc-getPKG_CONFIG);
  3132. while IFS= read -r -d '' f; do
  3133. local arg;
  3134. sed -e '/^Requires:/d' "${f}" > "${tf}";
  3135. for arg in $("${pkgconf}" --libs "${tf}");
  3136. do
  3137. [[ ${arg} == -l* ]] && pc_libs+=(lib${arg#-l}.la);
  3138. done;
  3139. done < <(find "${D}" -type f -name '*.pc' -print0);
  3140. rm -f "${tf}";
  3141. fi;
  3142. local f;
  3143. while IFS= read -r -d '' f; do
  3144. local archivefile=${f/%.la/.a};
  3145. [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed';
  3146. if grep -q '^shouldnotlink=yes$' "${f}"; then
  3147. einfo "Removing unnecessary ${archivefile#${D%/}}";
  3148. rm -f "${archivefile}";
  3149. [[ -n ${removing_all} ]] || continue;
  3150. fi;
  3151. local reason;
  3152. if [[ -n ${removing_all} ]]; then
  3153. reason='requested';
  3154. else
  3155. if [[ ! -f ${archivefile} ]]; then
  3156. reason='no static archive';
  3157. else
  3158. if has "${f##*/}" "${pc_libs[@]}"; then
  3159. reason='covered by .pc';
  3160. else
  3161. if [[ ! -n $(sed -nre "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" "${f}") ]]; then
  3162. reason='no libs & flags';
  3163. fi;
  3164. fi;
  3165. fi;
  3166. fi;
  3167. if [[ -n ${reason} ]]; then
  3168. einfo "Removing unnecessary ${f#${D%/}} (${reason})";
  3169. rm -f "${f}";
  3170. fi;
  3171. done < <(find "${D}" -type f -name '*.la' -print0)
  3172. }
  3173. redirect_alloc_fd ()
  3174. {
  3175. local var=$1 file=$2 redir=${3:-"<>"};
  3176. if [[ $(( (BASH_VERSINFO[0] << 8) + BASH_VERSINFO[1] )) -ge $(( (4 << 8) + 1 )) ]]; then
  3177. eval "exec {${var}}${redir}'${file}'";
  3178. else
  3179. local fd=10;
  3180. while :; do
  3181. if [[ ! -e /dev/fd/${fd} ]] && [[ ! -L /dev/fd/${fd} ]]; then
  3182. eval "exec ${fd}${redir}'${file}'" && break;
  3183. fi;
  3184. [[ ${fd} -gt 1024 ]] && die 'could not locate a free temp fd !?';
  3185. : $(( ++fd ));
  3186. done;
  3187. : $(( ${var} = fd ));
  3188. fi
  3189. }
  3190. replace_all_version_separators ()
  3191. {
  3192. local c=($(get_all_version_components "${2:-${PV}}"));
  3193. c=${c[@]//[-._]/$1};
  3194. echo ${c// }
  3195. }
  3196. replace_version_separator ()
  3197. {
  3198. eshopts_push -s extglob;
  3199. local w c v="${3:-${PV}}";
  3200. declare -i i found=0;
  3201. w=${1:-1};
  3202. c=($(get_all_version_components ${v}));
  3203. if [[ ${w} != *[[:digit:]]* ]]; then
  3204. for ((i = 0; i < ${#c[@]}; i++))
  3205. do
  3206. if [[ ${c[i]} == ${w} ]]; then
  3207. c[i]=${2};
  3208. break;
  3209. fi;
  3210. done;
  3211. else
  3212. for ((i = 0; i < ${#c[@]}; i++))
  3213. do
  3214. if [[ -n "${c[i]//[^-._]}" ]]; then
  3215. found+=1;
  3216. if ((found == w)); then
  3217. c[i]=${2};
  3218. break;
  3219. fi;
  3220. fi;
  3221. done;
  3222. fi;
  3223. c=${c[*]};
  3224. echo ${c// };
  3225. eshopts_pop
  3226. }
  3227. src_compile ()
  3228. {
  3229. games_src_compile "$@"
  3230. }
  3231. src_configure ()
  3232. {
  3233. egamesconf --disable-motif --disable-dependency-tracking --docdir=/usr/share/doc/${PF} --localedir=/usr/share/locale --with-distributor="Gentoo ${PF}" --with-icondir=/usr/share/pixmaps --with-applicationdir=/usr/share/applications $(use_enable debug debug relaxed) $(use_enable nls)
  3234. }
  3235. src_install ()
  3236. {
  3237. emake DESTDIR="${D}" install || die;
  3238. rm -f "${D}"/usr/share/doc/${PF}/COPYING*;
  3239. if use videos; then
  3240. insinto "${GAMES_DATADIR}"/${PN};
  3241. newins "${DISTDIR}"/${VIDEOS_P} sequences.wz || die;
  3242. fi;
  3243. doman doc/warzone2100.6;
  3244. prepgamesdirs
  3245. }
  3246. src_prepare ()
  3247. {
  3248. eautoreconf
  3249. }
  3250. src_test ()
  3251. {
  3252. _eapi0_src_test "$@"
  3253. }
  3254. src_unpack ()
  3255. {
  3256. base_src_unpack "$@"
  3257. }
  3258. strip-linguas ()
  3259. {
  3260. local ls newls nols;
  3261. if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
  3262. local op=$1;
  3263. shift;
  3264. ls=$(find "$1" -name '*.po' -exec basename {} .po ';');
  3265. shift;
  3266. local d f;
  3267. for d in "$@";
  3268. do
  3269. if [[ ${op} == "-u" ]]; then
  3270. newls=${ls};
  3271. else
  3272. newls="";
  3273. fi;
  3274. for f in $(find "$d" -name '*.po' -exec basename {} .po ';');
  3275. do
  3276. if [[ ${op} == "-i" ]]; then
  3277. has ${f} ${ls} && newls="${newls} ${f}";
  3278. else
  3279. has ${f} ${ls} || newls="${newls} ${f}";
  3280. fi;
  3281. done;
  3282. ls=${newls};
  3283. done;
  3284. else
  3285. ls="$@";
  3286. fi;
  3287. nols="";
  3288. newls="";
  3289. for f in ${LINGUAS};
  3290. do
  3291. if has ${f} ${ls}; then
  3292. newls="${newls} ${f}";
  3293. else
  3294. nols="${nols} ${f}";
  3295. fi;
  3296. done;
  3297. [[ -n ${nols} ]] && einfo "Sorry, but ${PN} does not support the LINGUAS:" ${nols};
  3298. export LINGUAS=${newls:1}
  3299. }
  3300. tc-arch ()
  3301. {
  3302. tc-ninja_magic_to_arch portage "$@"
  3303. }
  3304. tc-arch-kernel ()
  3305. {
  3306. tc-ninja_magic_to_arch kern "$@"
  3307. }
  3308. tc-endian ()
  3309. {
  3310. local host=$1;
  3311. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  3312. host=${host%%-*};
  3313. case ${host} in
  3314. alpha*)
  3315. echo big
  3316. ;;
  3317. arm*b*)
  3318. echo big
  3319. ;;
  3320. arm*)
  3321. echo little
  3322. ;;
  3323. cris*)
  3324. echo little
  3325. ;;
  3326. hppa*)
  3327. echo big
  3328. ;;
  3329. i?86*)
  3330. echo little
  3331. ;;
  3332. ia64*)
  3333. echo little
  3334. ;;
  3335. m68*)
  3336. echo big
  3337. ;;
  3338. mips*l*)
  3339. echo little
  3340. ;;
  3341. mips*)
  3342. echo big
  3343. ;;
  3344. powerpc*)
  3345. echo big
  3346. ;;
  3347. s390*)
  3348. echo big
  3349. ;;
  3350. sh*b*)
  3351. echo big
  3352. ;;
  3353. sh*)
  3354. echo little
  3355. ;;
  3356. sparc*)
  3357. echo big
  3358. ;;
  3359. x86_64*)
  3360. echo little
  3361. ;;
  3362. *)
  3363. echo wtf
  3364. ;;
  3365. esac
  3366. }
  3367. tc-env_build ()
  3368. {
  3369. tc-export_build_env;
  3370. 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) "$@"
  3371. }
  3372. tc-export ()
  3373. {
  3374. local var;
  3375. for var in "$@";
  3376. do
  3377. [[ $(type -t tc-get${var}) != "function" ]] && die "tc-export: invalid export variable '${var}'";
  3378. eval tc-get${var} > /dev/null;
  3379. done
  3380. }
  3381. tc-export_build_env ()
  3382. {
  3383. tc-export "$@";
  3384. : ${BUILD_CFLAGS:=-O1 -pipe};
  3385. : ${BUILD_CXXFLAGS:=-O1 -pipe};
  3386. : ${BUILD_CPPFLAGS:=};
  3387. : ${BUILD_LDFLAGS:=};
  3388. export BUILD_{C,CXX,CPP,LD}FLAGS
  3389. }
  3390. tc-getAR ()
  3391. {
  3392. tc-getPROG AR ar "$@"
  3393. }
  3394. tc-getAS ()
  3395. {
  3396. tc-getPROG AS as "$@"
  3397. }
  3398. tc-getBUILD_AR ()
  3399. {
  3400. tc-getBUILD_PROG AR ar "$@"
  3401. }
  3402. tc-getBUILD_AS ()
  3403. {
  3404. tc-getBUILD_PROG AS as "$@"
  3405. }
  3406. tc-getBUILD_CC ()
  3407. {
  3408. tc-getBUILD_PROG CC gcc "$@"
  3409. }
  3410. tc-getBUILD_CPP ()
  3411. {
  3412. tc-getBUILD_PROG CPP cpp "$@"
  3413. }
  3414. tc-getBUILD_CXX ()
  3415. {
  3416. tc-getBUILD_PROG CXX g++ "$@"
  3417. }
  3418. tc-getBUILD_LD ()
  3419. {
  3420. tc-getBUILD_PROG LD ld "$@"
  3421. }
  3422. tc-getBUILD_NM ()
  3423. {
  3424. tc-getBUILD_PROG NM nm "$@"
  3425. }
  3426. tc-getBUILD_OBJCOPY ()
  3427. {
  3428. tc-getBUILD_PROG OBJCOPY objcopy "$@"
  3429. }
  3430. tc-getBUILD_PKG_CONFIG ()
  3431. {
  3432. tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  3433. }
  3434. tc-getBUILD_PROG ()
  3435. {
  3436. _tc-getPROG CBUILD "BUILD_$1 $1_FOR_BUILD HOST$1" "${@:2}"
  3437. }
  3438. tc-getBUILD_RANLIB ()
  3439. {
  3440. tc-getBUILD_PROG RANLIB ranlib "$@"
  3441. }
  3442. tc-getBUILD_STRIP ()
  3443. {
  3444. tc-getBUILD_PROG STRIP strip "$@"
  3445. }
  3446. tc-getCC ()
  3447. {
  3448. tc-getPROG CC gcc "$@"
  3449. }
  3450. tc-getCPP ()
  3451. {
  3452. tc-getPROG CPP cpp "$@"
  3453. }
  3454. tc-getCXX ()
  3455. {
  3456. tc-getPROG CXX g++ "$@"
  3457. }
  3458. tc-getDLLWRAP ()
  3459. {
  3460. tc-getPROG DLLWRAP dllwrap "$@"
  3461. }
  3462. tc-getF77 ()
  3463. {
  3464. tc-getPROG F77 gfortran "$@"
  3465. }
  3466. tc-getFC ()
  3467. {
  3468. tc-getPROG FC gfortran "$@"
  3469. }
  3470. tc-getGCJ ()
  3471. {
  3472. tc-getPROG GCJ gcj "$@"
  3473. }
  3474. tc-getLD ()
  3475. {
  3476. tc-getPROG LD ld "$@"
  3477. }
  3478. tc-getNM ()
  3479. {
  3480. tc-getPROG NM nm "$@"
  3481. }
  3482. tc-getOBJCOPY ()
  3483. {
  3484. tc-getPROG OBJCOPY objcopy "$@"
  3485. }
  3486. tc-getPKG_CONFIG ()
  3487. {
  3488. tc-getPROG PKG_CONFIG pkg-config "$@"
  3489. }
  3490. tc-getPROG ()
  3491. {
  3492. _tc-getPROG CHOST "$@"
  3493. }
  3494. tc-getRANLIB ()
  3495. {
  3496. tc-getPROG RANLIB ranlib "$@"
  3497. }
  3498. tc-getRC ()
  3499. {
  3500. tc-getPROG RC windres "$@"
  3501. }
  3502. tc-getSTRIP ()
  3503. {
  3504. tc-getPROG STRIP strip "$@"
  3505. }
  3506. tc-has-openmp ()
  3507. {
  3508. local base="${T}/test-tc-openmp";
  3509. cat > "${base}.c" <<-EOF
  3510. #include <omp.h>
  3511. int main() {
  3512. int nthreads, tid, ret = 0;
  3513. #pragma omp parallel private(nthreads, tid)
  3514. {
  3515. tid = omp_get_thread_num();
  3516. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  3517. }
  3518. return ret;
  3519. }
  3520. EOF
  3521.  
  3522. $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &>/dev/null;
  3523. local ret=$?;
  3524. rm -f "${base}"*;
  3525. return ${ret}
  3526. }
  3527. tc-has-tls ()
  3528. {
  3529. local base="${T}/test-tc-tls";
  3530. cat > "${base}.c" <<-EOF
  3531. int foo(int *i) {
  3532. static __thread int j = 0;
  3533. return *i ? j : *i;
  3534. }
  3535. EOF
  3536.  
  3537. local flags;
  3538. case $1 in
  3539. -s)
  3540. flags="-S"
  3541. ;;
  3542. -c)
  3543. flags="-c"
  3544. ;;
  3545. -l)
  3546.  
  3547. ;;
  3548. -*)
  3549. die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  3550. ;;
  3551. esac;
  3552. : ${flags:=-fPIC -shared -Wl,-z,defs};
  3553. [[ $1 == -* ]] && shift;
  3554. $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &>/dev/null;
  3555. local ret=$?;
  3556. rm -f "${base}"*;
  3557. return ${ret}
  3558. }
  3559. tc-is-cross-compiler ()
  3560. {
  3561. return $([[ ${CBUILD:-${CHOST}} != ${CHOST} ]])
  3562. }
  3563. tc-is-softfloat ()
  3564. {
  3565. local CTARGET=${CTARGET:-${CHOST}};
  3566. case ${CTARGET} in
  3567. bfin* | h8300*)
  3568. echo "only"
  3569. ;;
  3570. *)
  3571. if [[ ${CTARGET//_/-} == *-softfloat-* ]]; then
  3572. echo "yes";
  3573. else
  3574. if [[ ${CTARGET//_/-} == *-softfp-* ]]; then
  3575. echo "softfp";
  3576. else
  3577. echo "no";
  3578. fi;
  3579. fi
  3580. ;;
  3581. esac
  3582. }
  3583. tc-is-static-only ()
  3584. {
  3585. local host=${CTARGET:-${CHOST}};
  3586. return $([[ ${host} == *-mint* ]])
  3587. }
  3588. tc-ninja_magic_to_arch ()
  3589. {
  3590. function ninj ()
  3591. {
  3592. [[ ${type} == "kern" ]] && echo $1 || echo $2
  3593. };
  3594. local type=$1;
  3595. local host=$2;
  3596. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  3597. case ${host} in
  3598. alpha*)
  3599. echo alpha
  3600. ;;
  3601. arm*)
  3602. echo arm
  3603. ;;
  3604. avr*)
  3605. ninj avr32 avr
  3606. ;;
  3607. bfin*)
  3608. ninj blackfin bfin
  3609. ;;
  3610. cris*)
  3611. echo cris
  3612. ;;
  3613. hppa*)
  3614. ninj parisc hppa
  3615. ;;
  3616. i?86*)
  3617. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -lt $(KV_to_int 2.6.24) || ${host} == *freebsd* ]]; then
  3618. echo i386;
  3619. else
  3620. echo x86;
  3621. fi
  3622. ;;
  3623. ia64*)
  3624. echo ia64
  3625. ;;
  3626. m68*)
  3627. echo m68k
  3628. ;;
  3629. mips*)
  3630. echo mips
  3631. ;;
  3632. nios2*)
  3633. echo nios2
  3634. ;;
  3635. nios*)
  3636. echo nios
  3637. ;;
  3638. powerpc*)
  3639. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]]; then
  3640. echo powerpc;
  3641. else
  3642. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -eq $(KV_to_int 2.6.15) ]]; then
  3643. if [[ ${host} == powerpc64* ]] || [[ ${PROFILE_ARCH} == "ppc64" ]]; then
  3644. echo powerpc;
  3645. else
  3646. echo ppc;
  3647. fi;
  3648. else
  3649. if [[ ${host} == powerpc64* ]]; then
  3650. echo ppc64;
  3651. else
  3652. if [[ ${PROFILE_ARCH} == "ppc64" ]]; then
  3653. ninj ppc64 ppc;
  3654. else
  3655. echo ppc;
  3656. fi;
  3657. fi;
  3658. fi;
  3659. fi
  3660. ;;
  3661. s390*)
  3662. echo s390
  3663. ;;
  3664. sh64*)
  3665. ninj sh64 sh
  3666. ;;
  3667. sh*)
  3668. echo sh
  3669. ;;
  3670. sparc64*)
  3671. ninj sparc64 sparc
  3672. ;;
  3673. sparc*)
  3674. [[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
  3675. ;;
  3676. vax*)
  3677. echo vax
  3678. ;;
  3679. x86_64*freebsd*)
  3680. echo amd64
  3681. ;;
  3682. x86_64*)
  3683. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.24) ]]; then
  3684. echo x86;
  3685. else
  3686. ninj x86_64 amd64;
  3687. fi
  3688. ;;
  3689. *)
  3690. echo unknown
  3691. ;;
  3692. esac
  3693. }
  3694. uclibctoolize ()
  3695. {
  3696. die "Use elibtoolize"
  3697. }
  3698. use_if_iuse ()
  3699. {
  3700. in_iuse $1 || return 1;
  3701. use $1
  3702. }
  3703. usex ()
  3704. {
  3705. use "$1" && echo "${2-yes}$4" || echo "${3-no}$5"
  3706. }
  3707. validate_desktop_entries ()
  3708. {
  3709. if [[ -x /usr/bin/desktop-file-validate ]]; then
  3710. einfo "Checking desktop entry validity";
  3711. local directories="";
  3712. for d in /usr/share/applications $@;
  3713. do
  3714. [[ -d ${D}${d} ]] && directories="${directories} ${D}${d}";
  3715. done;
  3716. if [[ -n ${directories} ]]; then
  3717. for FILE in $(find ${directories} -name "*\.desktop" -not -path '*.hidden*' | sort -u 2>/dev/null);
  3718. do
  3719. local temp=$(desktop-file-validate ${FILE} | grep -v "warning:" | sed -e "s|error: ||" -e "s|${FILE}:|--|g" );
  3720. [[ -n $temp ]] && elog ${temp/--/${FILE/${D}/}:};
  3721. done;
  3722. fi;
  3723. echo "";
  3724. else
  3725. einfo "Passing desktop entry validity check. Install dev-util/desktop-file-utils, if you want to help to improve Gentoo.";
  3726. fi
  3727. }
  3728. version_compare ()
  3729. {
  3730. eshopts_push -s extglob;
  3731. local ver_a=${1} ver_b=${2} parts_a parts_b;
  3732. local cur_tok_a cur_tok_b num_part_a num_part_b;
  3733. local -i cur_idx_a=0 cur_idx_b=0 prev_idx_a prev_idx_b;
  3734. parts_a=($(get_all_version_components "${ver_a}" ));
  3735. parts_b=($(get_all_version_components "${ver_b}" ));
  3736. local -i inf_loop=0;
  3737. while true; do
  3738. inf_loop+=1;
  3739. ((inf_loop > 20)) && die "versionator compare bug [numbers, ${ver_a}, ${ver_b}]";
  3740. prev_idx_a=cur_idx_a;
  3741. prev_idx_b=cur_idx_b;
  3742. cur_tok_a=${parts_a[cur_idx_a]};
  3743. cur_tok_b=${parts_b[cur_idx_b]};
  3744. if [[ -n ${cur_tok_a} ]] && [[ -z ${cur_tok_a//[[:digit:]]} ]]; then
  3745. cur_idx_a+=1;
  3746. [[ ${parts_a[cur_idx_a]} == . ]] && cur_idx_a+=1;
  3747. else
  3748. cur_tok_a=;
  3749. fi;
  3750. if [[ -n ${cur_tok_b} ]] && [[ -z ${cur_tok_b//[[:digit:]]} ]]; then
  3751. cur_idx_b+=1;
  3752. [[ ${parts_b[cur_idx_b]} == . ]] && cur_idx_b+=1;
  3753. else
  3754. cur_tok_b=;
  3755. fi;
  3756. [[ -z ${cur_tok_a} && -z ${cur_tok_b} ]] && break;
  3757. [[ -z ${cur_tok_a} ]] && eshopts_pop && return 1;
  3758. [[ -z ${cur_tok_b} ]] && eshopts_pop && return 3;
  3759. if (( prev_idx_a != 0 && prev_idx_b != 0 )) && [[ ${cur_tok_a} == 0* || ${cur_tok_b} == 0* ]]; then
  3760. cur_tok_a=${cur_tok_a%%+(0)};
  3761. cur_tok_b=${cur_tok_b%%+(0)};
  3762. [[ ${cur_tok_a} < ${cur_tok_b} ]] && eshopts_pop && return 1;
  3763. [[ ${cur_tok_a} > ${cur_tok_b} ]] && eshopts_pop && return 3;
  3764. else
  3765. cur_tok_a=${cur_tok_a##+(0)};
  3766. cur_tok_b=${cur_tok_b##+(0)};
  3767. : ${cur_tok_a:=0};
  3768. : ${cur_tok_b:=0};
  3769. ((cur_tok_a < cur_tok_b)) && eshopts_pop && return 1;
  3770. ((cur_tok_a > cur_tok_b)) && eshopts_pop && return 3;
  3771. fi;
  3772. done;
  3773. local letter_a=;
  3774. letter_a=${parts_a[cur_idx_a]};
  3775. if [[ ${#letter_a} -eq 1 && -z ${letter_a/[a-z]} ]]; then
  3776. cur_idx_a+=1;
  3777. else
  3778. letter_a=@;
  3779. fi;
  3780. local letter_b=;
  3781. letter_b=${parts_b[cur_idx_b]};
  3782. if [[ ${#letter_b} -eq 1 && -z ${letter_b/[a-z]} ]]; then
  3783. cur_idx_b+=1;
  3784. else
  3785. letter_b=@;
  3786. fi;
  3787. [[ ${letter_a} < ${letter_b} ]] && eshopts_pop && return 1;
  3788. [[ ${letter_a} > ${letter_b} ]] && eshopts_pop && return 3;
  3789. inf_loop=0;
  3790. while true; do
  3791. inf_loop+=1;
  3792. ((inf_loop > 20)) && die "versionator compare bug [numbers, ${ver_a}, ${ver_b}]";
  3793. [[ ${parts_a[cur_idx_a]} == _ ]] && ((cur_idx_a++));
  3794. [[ ${parts_b[cur_idx_b]} == _ ]] && ((cur_idx_b++));
  3795. cur_tok_a=${parts_a[cur_idx_a]};
  3796. cur_tok_b=${parts_b[cur_idx_b]};
  3797. num_part_a=0;
  3798. num_part_b=0;
  3799. if has ${cur_tok_a%%+([0-9])} "alpha" "beta" "pre" "rc" "p"; then
  3800. cur_idx_a+=1;
  3801. num_part_a=${cur_tok_a##+([a-z])};
  3802. num_part_a=${num_part_a##+(0)};
  3803. : ${num_part_a:=0};
  3804. cur_tok_a=${cur_tok_a%%+([0-9])};
  3805. else
  3806. cur_tok_a=;
  3807. fi;
  3808. if has ${cur_tok_b%%+([0-9])} alpha beta pre rc p; then
  3809. cur_idx_b+=1;
  3810. num_part_b=${cur_tok_b##+([a-z])};
  3811. num_part_b=${num_part_b##+(0)};
  3812. : ${num_part_b:=0};
  3813. cur_tok_b=${cur_tok_b%%+([0-9])};
  3814. else
  3815. cur_tok_b=;
  3816. fi;
  3817. if [[ ${cur_tok_a} != ${cur_tok_b} ]]; then
  3818. local suffix;
  3819. for suffix in alpha beta pre rc "" p;
  3820. do
  3821. [[ ${cur_tok_a} == ${suffix} ]] && eshopts_pop && return 1;
  3822. [[ ${cur_tok_b} == ${suffix} ]] && eshopts_pop && return 3;
  3823. done;
  3824. else
  3825. if [[ -z ${cur_tok_a} && -z ${cur_tok_b} ]]; then
  3826. break;
  3827. else
  3828. ((num_part_a < num_part_b)) && eshopts_pop && return 1;
  3829. ((num_part_a > num_part_b)) && eshopts_pop && return 3;
  3830. fi;
  3831. fi;
  3832. done;
  3833. [[ ${parts_a[cur_idx_a]} == - ]] && ((cur_idx_a++));
  3834. [[ ${parts_b[cur_idx_b]} == - ]] && ((cur_idx_b++));
  3835. if [[ -n ${parts_a[cur_idx_a]/r+([0-9])} || -n ${parts_b[cur_idx_b]/r+([0-9])} ]]; then
  3836. die "versionator compare bug [revisions, ${ver_a}, ${ver_b}]";
  3837. fi;
  3838. num_part_a=${parts_a[cur_idx_a]#r};
  3839. num_part_a=${num_part_a##+(0)};
  3840. : ${num_part_a:=0};
  3841. num_part_b=${parts_b[cur_idx_b]#r};
  3842. num_part_b=${num_part_b##+(0)};
  3843. : ${num_part_b:=0};
  3844. ((num_part_a < num_part_b)) && eshopts_pop && return 1;
  3845. ((num_part_a > num_part_b)) && eshopts_pop && return 3;
  3846. eshopts_pop;
  3847. return 2
  3848. }
  3849. version_format_string ()
  3850. {
  3851. local fstr=$1;
  3852. shift;
  3853. set -- $(get_version_components "$@");
  3854. eval echo "${fstr}"
  3855. }
  3856. version_is_at_least ()
  3857. {
  3858. local want_s="$1" have_s="${2:-${PVR}}" r;
  3859. version_compare "${want_s}" "${have_s}";
  3860. r=$?;
  3861. case $r in
  3862. 1 | 2)
  3863. return 0
  3864. ;;
  3865. 3)
  3866. return 1
  3867. ;;
  3868. *)
  3869. die "versionator compare bug [atleast, ${want_s}, ${have_s}, ${r}]"
  3870. ;;
  3871. esac
  3872. }
  3873. version_sort ()
  3874. {
  3875. eshopts_push -s extglob;
  3876. local items=;
  3877. local -i left=0;
  3878. items=("$@");
  3879. while ((left < ${#items[@]})); do
  3880. local -i lowest_idx=left;
  3881. local -i idx=lowest_idx+1;
  3882. while ((idx < ${#items[@]})); do
  3883. version_compare "${items[lowest_idx]}" "${items[idx]}";
  3884. [[ $? -eq 3 ]] && lowest_idx=idx;
  3885. idx+=1;
  3886. done;
  3887. local tmp=${items[lowest_idx]};
  3888. items[lowest_idx]=${items[left]};
  3889. items[left]=${tmp};
  3890. left+=1;
  3891. done;
  3892. echo ${items[@]};
  3893. eshopts_pop
  3894. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement