Advertisement
Guest User

mkinitcpio-0.9.2-r1 environment

a guest
Sep 19th, 2012
580
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 106.82 KB | None | 0 0
  1. declare -x ABI="amd64"
  2. declare -x ALSA_CARDS=""
  3. 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"
  4. declare -x ANDROID_SWT="/usr/share/swt-3.7/lib"
  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 -x BLENDER_SYSTEM_DATAFILES="/usr/share/blender/datafiles"
  9. declare -x BLENDER_SYSTEM_PLUGINS="/usr/lib64/plugins"
  10. declare -x BLENDER_SYSTEM_SCRIPTS="/usr/share/blender/scripts"
  11. declare -x BOOTSTRAP_USE="cxx unicode multilib hardened pax_kernel pic -jit -orc"
  12. declare -x CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump"
  13. declare -x CAMERAS="ptp2"
  14. declare -x CBUILD="x86_64-pc-linux-gnu"
  15. declare -x CFLAGS="-march=k8 -O2 -pipe"
  16. declare -x CFLAGS_amd64="-m64"
  17. declare -x CFLAGS_default
  18. declare -x CFLAGS_x32="-mx32"
  19. declare -x CFLAGS_x86="-m32"
  20. declare -x CHOST="x86_64-pc-linux-gnu"
  21. declare -x CHOST_amd64="x86_64-pc-linux-gnu"
  22. declare -x CHOST_default="x86_64-pc-linux-gnu"
  23. declare -x CHOST_x32="x86_64-pc-linux-gnux32"
  24. declare -x CHOST_x86="i686-pc-linux-gnu"
  25. declare -x COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog"
  26. declare -- CONFIG_CHECK=" ~DEVTMPFS ~MD ~MD_LINEAR ~MD_RAID0 ~MD_RAID1 ~MD_RAID10 ~MD_RAID456 ~BLK_DEV_DM ~DM_SNAPSHOT ~DM_UEVENT"
  27. declare -x CROSSCOMPILE_OPTS=""
  28. declare -x CTARGET_default="x86_64-pc-linux-gnu"
  29. declare -x CXXFLAGS="-march=k8 -O2 -pipe"
  30. declare -x DEFAULT_ABI="amd64"
  31. declare -x DEFINED_PHASES=" install postinst prepare setup"
  32. declare DEPEND="sys-apps/sed "
  33. declare DESCRIPTION="Modular initramfs image creation utility ported from Arch Linux"
  34. declare -x DESTTREE="/usr"
  35. declare -x DIROPTIONS="-m0755"
  36. declare -x EAPI="4"
  37. declare -x ELIBC="glibc"
  38. declare -- EPATCH_COMMON_OPTS="-g0 -E --no-backup-if-mismatch"
  39. declare -- EPATCH_EXCLUDE=""
  40. declare -- EPATCH_FORCE="no"
  41. declare -- EPATCH_MULTI_MSG="Applying various patches (bugfixes/updates) ..."
  42. declare -- EPATCH_OPTS=""
  43. declare -- EPATCH_SINGLE_MSG=""
  44. declare -- EPATCH_SOURCE="/dev/shm/portage/sys-kernel/mkinitcpio-0.9.2-r1/work/patch"
  45. declare -- EPATCH_SUFFIX="patch.bz2"
  46. declare -x EXEOPTIONS="-m0755"
  47. declare -x FCFLAGS="-O2 -pipe"
  48. 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}\""
  49. declare -x FFLAGS="-O2 -pipe"
  50. declare -x GCC_SPECS=""
  51. declare -x GDK_USE_XFT="1"
  52. 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"
  53. declare -x GRUB_PLATFORMS="pc multiboot"
  54. declare -x GSETTINGS_BACKEND="gconf"
  55. declare -x GUILE_LOAD_PATH="/usr/share/guile/1.8"
  56. declare -x HG="/usr/bin/hg"
  57. declare HOMEPAGE="http://www.archlinux.org/"
  58. declare -x INHERITED=" multilib toolchain-funcs user eutils versionator linux-info"
  59. declare -x INPUT_DEVICES="evdev"
  60. declare -x INSDESTTREE=""
  61. declare -x INSOPTIONS="-m0644"
  62. declare IUSE="cryptsetup device-mapper dmraid mdadm pcmcia udev "
  63. declare -x IUSE_IMPLICIT=""
  64. declare -x JAVACC_HOME="/usr/share/javacc/"
  65. declare -x KERNEL="linux"
  66. declare -x KERNEL_ABI="amd64"
  67. declare -- KERNEL_DIR="/usr/src/linux"
  68. declare -- KERNEL_MAKEFILE="/usr/src/linux/Makefile"
  69. declare -x KEYWORDS="~amd64 ~x86"
  70. declare -- KV_DIR="/usr/src/linux"
  71. declare -- KV_EXTRA="-hardened"
  72. declare -- KV_FULL="3.5.4-hardened-120920_0200"
  73. declare -- KV_LOCAL="-120920_0200"
  74. declare -- KV_MAJOR="3"
  75. declare -- KV_MINOR="5"
  76. declare -- KV_OUT_DIR="/usr/src/linux"
  77. declare -- KV_PATCH="4"
  78. declare -x LADSPA_PATH="/usr/lib64/ladspa"
  79. declare -x LANG="en_GB.UTF-8"
  80. declare -x LANGUAGE=""
  81. declare -x LCD_DEVICES=""
  82. declare -x LC_ALL="en_GB.UTF-8"
  83. declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed"
  84. declare -x LDFLAGS_amd64="-m elf_x86_64"
  85. declare -x LDFLAGS_default
  86. declare -x LDFLAGS_x32="-m elf32_x86_64"
  87. declare -x LDFLAGS_x86="-m elf_i386"
  88. declare -x LIBDIR_amd64="lib64"
  89. declare -x LIBDIR_amd64_fbsd="lib64"
  90. declare -x LIBDIR_default="lib"
  91. declare -x LIBDIR_n32="lib32"
  92. declare -x LIBDIR_n64="lib64"
  93. declare -x LIBDIR_o32="lib"
  94. declare -x LIBDIR_ppc="lib32"
  95. declare -x LIBDIR_ppc64="lib64"
  96. declare -x LIBDIR_s390="lib32"
  97. declare -x LIBDIR_s390x="lib64"
  98. declare -x LIBDIR_sparc32="lib32"
  99. declare -x LIBDIR_sparc64="lib64"
  100. declare -x LIBDIR_x32="libx32"
  101. declare -x LIBDIR_x86="lib32"
  102. declare -x LIBDIR_x86_fbsd="lib32"
  103. declare -x LIBOPTIONS="-m0644"
  104. declare -x LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer"
  105. declare -x LICENSE="GPL-2"
  106. declare -x LINGUAS="en_GB"
  107. declare -x LINUX_CONFIG_EXISTS_DONE=""
  108. declare -x LIRC_DEVICES="devinput"
  109. declare -x MAIL="/var/mail/root"
  110. declare -x MULTILIB_ABIS="amd64 x86"
  111. declare -x MULTILIB_STRICT_DENY="64-bit.*shared object"
  112. 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"
  113. declare -x MULTILIB_STRICT_EXEMPT="(perl5|gcc|gcc-lib|binutils|eclipse-3|debug|portage|udev)"
  114. declare -- MY_MODULES_VER="0_p20120704"
  115. declare -x NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
  116. declare -x OPENGL_PROFILE="xorg-x11"
  117. declare -- OUTPUT_DIR="/lib/modules/3.5.4-hardened/build"
  118. 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.6.3"
  119. declare PDEPEND=""
  120. declare -x PHP_INI_VERSION="development"
  121. declare -x PHP_TARGETS=""
  122. declare -x PKG_CONFIG_PATH="/usr/lib64/pkgconfig"
  123. declare -a PORTAGE_DOCOMPRESS='([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")'
  124. declare -a PORTAGE_DOCOMPRESS_SKIP='([0]="/usr/share/doc/mkinitcpio-0.9.2-r1/html")'
  125. declare -x PRELINK_PATH_MASK="/usr/lib64/klibc:/usr/lib64/libfreebl3.so:/usr/lib64/libnssdbm3.so:/usr/lib64/libsoftokn3.so"
  126. declare -x PROFILE_ONLY_VARIABLES="ARCH ELIBC IUSE_IMPLICIT KERNEL USERLAND USE_EXPAND_IMPLICIT USE_EXPAND_UNPREFIXED USE_EXPAND_VALUES_ARCH USE_EXPAND_VALUES_ELIBC USE_EXPAND_VALUES_KERNEL USE_EXPAND_VALUES_USERLAND"
  127. declare -x PROPERTIES=""
  128. declare -x PROVIDE=""
  129. declare -x PYTHONDONTWRITEBYTECODE="1"
  130. declare -x PYTHONPATH="/usr/lib/portage/pym"
  131. declare -x PYTHON_TARGETS=""
  132. declare -x QT_GRAPHICSSYSTEM="raster"
  133. declare -x QT_PLUGIN_PATH="/usr/lib64/kde4/plugins"
  134. declare RDEPEND="app-arch/cpio
  135. app-arch/gzip
  136. app-arch/libarchive
  137. app-shells/bash
  138. >=sys-apps/busybox-1.20[static]
  139. sys-apps/coreutils
  140. sys-apps/file
  141. sys-apps/findutils
  142. sys-apps/grep
  143. >=sys-apps/kmod-7
  144. >=sys-apps/util-linux-2.21
  145. udev? ( >sys-fs/udev-171-r6 )
  146. device-mapper? ( sys-fs/lvm2[static] )
  147. cryptsetup? ( sys-fs/cryptsetup[static] )
  148. mdadm? ( sys-fs/mdadm[static] )
  149. dmraid? ( sys-fs/dmraid[static] )
  150. pcmcia? ( sys-apps/pcmciautils[static] ) "
  151. declare REPOSITORY
  152. declare REQUIRED_USE=""
  153. declare -x RESTRICT=""
  154. 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}\""
  155. declare -x RUBYOPT="-rauto_gem"
  156. declare -x RUBY_TARGETS="ruby18 ruby19"
  157. declare -x S="/dev/shm/portage/sys-kernel/mkinitcpio-0.9.2-r1/work/mkinitcpio-0.9.2"
  158. declare -x SANDBOX_DEBUG="0"
  159. declare -x SANDBOX_DENY=""
  160. declare -x SANDBOX_PID="12052"
  161. declare -x SANDBOX_PREDICT="/dev/shm/portage/sys-kernel/mkinitcpio-0.9.2-r1/homedir:/dev/crypto:/proc/self/coredump_filter:/dev/random:/var/cache/fontconfig"
  162. declare -x SANDBOX_READ="/:/dev/shm"
  163. declare -x SANDBOX_VERBOSE="1"
  164. declare -x SANDBOX_WRITE=":/dev/console:/dev/fd:/dev/full:/dev/null:/dev/pts/:/dev/pty:/dev/shm:/dev/shm/portage/sys-kernel/mkinitcpio-0.9.2-r1/homedir/.bash_history:/dev/tts:/dev/tty:/dev/vc/:/dev/zero:/proc/self/fd:/tmp/:/usr/lib32/cf:/usr/lib32/conftest:/usr/lib64/cf:/usr/lib64/conftest:/usr/lib/cf:/usr/lib/conftest:/usr/tmp/cf:/usr/tmp/conftest:/var/tmp/"
  165. declare -x SLOT="0"
  166. declare SRC_URI="ftp://ftp.archlinux.org/other/mkinitcpio/mkinitcpio-0.9.2.tar.gz
  167. http://xmw.de/mirror/mkinitcpio-modules/mkinitcpio-modules-0_p20120704.tar.bz2"
  168. declare -x SSH_ASKPASS="/usr/bin/ssh-askpass-fullscreen"
  169. declare -x SUDO_COMMAND="/bin/bash"
  170. declare -x SUDO_GID="1000"
  171. declare -x SUDO_UID="1000"
  172. declare -x SUDO_USER="miro"
  173. declare -x SYMLINK_LIB="yes"
  174. declare -x TIME_STYLE="posix-long-iso"
  175. declare -x USE="amd64 device-mapper elibc_glibc kernel_linux mdadm multilib udev userland_GNU"
  176. declare -x USERLAND="GNU"
  177. declare -x USERNAME="root"
  178. declare -x USE_EXPAND_IMPLICIT="ARCH ELIBC KERNEL USERLAND"
  179. declare -x USE_EXPAND_UNPREFIXED="ARCH"
  180. declare -x USE_EXPAND_VALUES_ARCH="alpha amd64 amd64-fbsd amd64-linux arm arm-linux hppa hppa-hpux ia64 ia64-hpux ia64-linux m68k m68k-mint mips ppc ppc64 ppc64-linux ppc-aix ppc-macos ppc-openbsd s390 sh sparc sparc64-freebsd sparc64-solaris sparc-fbsd sparc-solaris x64-freebsd x64-macos x64-openbsd x64-solaris x86 x86-cygwin x86-fbsd x86-freebsd x86-interix x86-linux x86-macos x86-netbsd x86-openbsd x86-solaris x86-winnt"
  181. declare -x USE_EXPAND_VALUES_ELIBC="AIX Cygwin Darwin FreeBSD glibc HPUX Interix mintlib NetBSD OpenBSD SunOS uclibc Winnt"
  182. declare -x USE_EXPAND_VALUES_KERNEL="AIX Cygwin Darwin FreeBSD freemint HPUX Interix linux NetBSD OpenBSD SunOS Winnt"
  183. declare -x USE_EXPAND_VALUES_USERLAND="BSD GNU"
  184. declare -x VIDEO_CARDS=""
  185. declare -x XDG_CONFIG_DIRS="/etc/xdg"
  186. declare -x XDG_DATA_DIRS="/usr/local/share:/usr/share"
  187. declare -x XSESSION="openbox"
  188. 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"
  189. declare -x _E_DOCDESTTREE_=""
  190. declare -x _E_EXEDESTTREE_=""
  191. declare -x _LINUX_CONFIG_EXISTS_DONE="1"
  192. declare -- ___ECLASS_ONCE_EUTILS="recur -_+^+_- spank"
  193. declare -- ___ECLASS_ONCE_MULTILIB="recur -_+^+_- spank"
  194. declare -- ___ECLASS_ONCE_TOOLCHAIN_FUNCS="recur -_+^+_- spank"
  195. declare -- ___ECLASS_ONCE_USER="recur -_+^+_- spank"
  196. declare -- ___ECLASS_ONCE_VERSIONATOR="recur -_+^+_- spank"
  197. declare -- get_version_warning_done=""
  198. declare -- phase_func
  199. _assert_pkg_ebuild_phase ()
  200. {
  201. case ${EBUILD_PHASE} in
  202. setup | preinst | postinst)
  203.  
  204. ;;
  205. *)
  206. eerror "'$1()' called from '${EBUILD_PHASE}' phase which is not OK:";
  207. eerror "You may only call from pkg_{setup,preinst,postinst} functions.";
  208. eerror "Package fails at QA and at life. Please file a bug.";
  209. die "Bad package! $1 is only for use in some pkg_* functions!"
  210. ;;
  211. esac
  212. }
  213. _epatch_draw_line ()
  214. {
  215. [[ -z $1 ]] && set "$(printf "%65s" '')";
  216. echo "${1//?/=}"
  217. }
  218. _gcc-install-dir ()
  219. {
  220. echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null | awk '$1=="install:" {print $2}')"
  221. }
  222. _gcc-specs-directive_raw ()
  223. {
  224. local cc=$(tc-getCC);
  225. local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  226. ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  227. $1=="*"directive":" { pspec=spec; spec=""; outside=0; next }
  228. outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  229. spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  230. { spec=spec $0 }
  231. END { print spec }';
  232. return 0
  233. }
  234. _gcc-specs-exists ()
  235. {
  236. [[ -f $(_gcc-install-dir)/$1 ]]
  237. }
  238. _gcc_fullversion ()
  239. {
  240. local ver="$1";
  241. shift;
  242. set -- `$(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__"`;
  243. eval echo "$ver"
  244. }
  245. _iconins ()
  246. {
  247. ( local funcname=$1;
  248. shift;
  249. local size dir;
  250. local context=apps;
  251. local theme=hicolor;
  252. while [[ $# -gt 0 ]]; do
  253. case $1 in
  254. -s | --size)
  255. if [[ ${2%%x*}x${2%%x*} == "$2" ]]; then
  256. size=${2%%x*};
  257. else
  258. size=${2};
  259. fi;
  260. case ${size} in
  261. 16 | 22 | 24 | 32 | 36 | 48 | 64 | 72 | 96 | 128 | 192 | 256)
  262. size=${size}x${size}
  263. ;;
  264. scalable)
  265.  
  266. ;;
  267. *)
  268. eerror "${size} is an unsupported icon size!";
  269. exit 1
  270. ;;
  271. esac;
  272. shift 2
  273. ;;
  274. -t | --theme)
  275. theme=${2};
  276. shift 2
  277. ;;
  278. -c | --context)
  279. context=${2};
  280. shift 2
  281. ;;
  282. *)
  283. if [[ -z ${size} ]]; then
  284. insinto /usr/share/pixmaps;
  285. else
  286. insinto /usr/share/icons/${theme}/${size}/${context};
  287. fi;
  288. if [[ ${funcname} == doicon ]]; then
  289. if [[ -f $1 ]]; then
  290. doins "${1}";
  291. else
  292. if [[ -d $1 ]]; then
  293. shopt -s nullglob;
  294. doins "${1}"/*.{png,svg};
  295. shopt -u nullglob;
  296. else
  297. eerror "${1} is not a valid file/directory!";
  298. exit 1;
  299. fi;
  300. fi;
  301. else
  302. break;
  303. fi;
  304. shift 1
  305. ;;
  306. esac;
  307. done;
  308. if [[ ${funcname} == newicon ]]; then
  309. newins "$@";
  310. fi ) || die
  311. }
  312. _tc-getPROG ()
  313. {
  314. local tuple=$1;
  315. local v var vars=$2;
  316. local prog=$3;
  317. var=${vars%% *};
  318. for v in ${vars};
  319. do
  320. if [[ -n ${!v} ]]; then
  321. export ${var}="${!v}";
  322. echo "${!v}";
  323. return 0;
  324. fi;
  325. done;
  326. local search=;
  327. [[ -n $4 ]] && search=$(type -p "$4-${prog}");
  328. [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p "${!tuple}-${prog}");
  329. [[ -n ${search} ]] && prog=${search##*/};
  330. export ${var}=${prog};
  331. echo "${!var}"
  332. }
  333. built_with_use ()
  334. {
  335. local hidden="no";
  336. if [[ $1 == "--hidden" ]]; then
  337. hidden="yes";
  338. shift;
  339. fi;
  340. local missing_action="die";
  341. if [[ $1 == "--missing" ]]; then
  342. missing_action=$2;
  343. shift;
  344. shift;
  345. case ${missing_action} in
  346. true | false | die)
  347.  
  348. ;;
  349. *)
  350. die "unknown action '${missing_action}'"
  351. ;;
  352. esac;
  353. fi;
  354. local opt=$1;
  355. [[ ${opt:0:1} = "-" ]] && shift || opt="-a";
  356. local PKG=$(best_version $1);
  357. [[ -z ${PKG} ]] && die "Unable to resolve $1 to an installed package";
  358. shift;
  359. local USEFILE=${ROOT}/var/db/pkg/${PKG}/USE;
  360. local IUSEFILE=${ROOT}/var/db/pkg/${PKG}/IUSE;
  361. if [[ ! -e ${USEFILE} ]] || [[ ! -e ${IUSEFILE} && ${hidden} == "no" ]]; then
  362. case ${missing_action} in
  363. true)
  364. return 0
  365. ;;
  366. false)
  367. return 1
  368. ;;
  369. die)
  370. die "Unable to determine what USE flags $PKG was built with"
  371. ;;
  372. esac;
  373. fi;
  374. if [[ ${hidden} == "no" ]]; then
  375. local IUSE_BUILT=($(<"${IUSEFILE}"));
  376. local expand;
  377. for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]');
  378. do
  379. if [[ $1 == ${expand}_* ]]; then
  380. expand="";
  381. break;
  382. fi;
  383. done;
  384. if [[ -n ${expand} ]]; then
  385. if ! has $1 ${IUSE_BUILT[@]#[-+]}; then
  386. case ${missing_action} in
  387. true)
  388. return 0
  389. ;;
  390. false)
  391. return 1
  392. ;;
  393. die)
  394. die "$PKG does not actually support the $1 USE flag!"
  395. ;;
  396. esac;
  397. fi;
  398. fi;
  399. fi;
  400. local USE_BUILT=$(<${USEFILE});
  401. while [[ $# -gt 0 ]]; do
  402. if [[ ${opt} = "-o" ]]; then
  403. has $1 ${USE_BUILT} && return 0;
  404. else
  405. has $1 ${USE_BUILT} || return 1;
  406. fi;
  407. shift;
  408. done;
  409. [[ ${opt} = "-a" ]]
  410. }
  411. check_extra_config ()
  412. {
  413. local config negate die error reworkmodulenames;
  414. local soft_errors_count=0 hard_errors_count=0 config_required=0;
  415. local old_LINUX_CONFIG_EXISTS_DONE="${_LINUX_CONFIG_EXISTS_DONE}";
  416. linux-info_get_any_version;
  417. for config in ${CONFIG_CHECK};
  418. do
  419. if [[ "${config:0:1}" != "~" ]]; then
  420. config_required=1;
  421. break;
  422. fi;
  423. done;
  424. if [[ ${config_required} == 0 ]]; then
  425. if ! linux_config_exists; then
  426. ewarn "Unable to check for the following kernel config options due";
  427. ewarn "to absence of any configured kernel sources or compiled";
  428. ewarn "config:";
  429. for config in ${CONFIG_CHECK};
  430. do
  431. local_error="ERROR_${config#\~}";
  432. msg="${!local_error}";
  433. if [[ "x${msg}" == "x" ]]; then
  434. local_error="WARNING_${config#\~}";
  435. msg="${!local_error}";
  436. fi;
  437. ewarn " - ${config#\~}${msg:+ - }${msg}";
  438. done;
  439. ewarn "You're on your own to make sure they are set if needed.";
  440. export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}";
  441. return 0;
  442. fi;
  443. else
  444. require_configured_kernel;
  445. fi;
  446. einfo "Checking for suitable kernel configuration options...";
  447. for config in ${CONFIG_CHECK};
  448. do
  449. die=1;
  450. error=0;
  451. negate=0;
  452. reworkmodulenames=0;
  453. if [[ ${config:0:1} == "~" ]]; then
  454. die=0;
  455. config=${config:1};
  456. else
  457. if [[ ${config:0:1} == "@" ]]; then
  458. die=0;
  459. reworkmodulenames=1;
  460. config=${config:1};
  461. fi;
  462. fi;
  463. if [[ ${config:0:1} == "!" ]]; then
  464. negate=1;
  465. config=${config:1};
  466. fi;
  467. if [[ ${negate} == 1 ]]; then
  468. linux_chkconfig_present ${config} && error=2;
  469. else
  470. if [[ ${reworkmodulenames} == 1 ]]; then
  471. local temp_config="${config//*:}" i n;
  472. config="${config//:*}";
  473. if linux_chkconfig_present ${config}; then
  474. for i in ${MODULE_NAMES};
  475. do
  476. n="${i//${temp_config}}";
  477. [[ -z ${n//\(*} ]] && MODULE_IGNORE="${MODULE_IGNORE} ${temp_config}";
  478. done;
  479. error=2;
  480. fi;
  481. else
  482. linux_chkconfig_present ${config} || error=1;
  483. fi;
  484. fi;
  485. if [[ ${error} > 0 ]]; then
  486. local report_func="eerror" local_error;
  487. local_error="ERROR_${config}";
  488. local_error="${!local_error}";
  489. if [[ -z "${local_error}" ]]; then
  490. local_error="${config}_ERROR";
  491. local_error="${!local_error}";
  492. fi;
  493. if [[ ${die} == 0 && -z "${local_error}" ]]; then
  494. local_error="WARNING_${config}";
  495. local_error="${!local_error}";
  496. if [[ -n "${local_error}" ]]; then
  497. report_func="ewarn";
  498. fi;
  499. fi;
  500. if [[ -z "${local_error}" ]]; then
  501. [[ ${error} == 1 ]] && local_error="is not set when it should be." || local_error="should not be set. But it is.";
  502. local_error="CONFIG_${config}:\t ${local_error}";
  503. fi;
  504. if [[ ${die} == 0 ]]; then
  505. ${report_func} " ${local_error}";
  506. soft_errors_count=$[soft_errors_count + 1];
  507. else
  508. ${report_func} " ${local_error}";
  509. hard_errors_count=$[hard_errors_count + 1];
  510. fi;
  511. fi;
  512. done;
  513. if [[ ${hard_errors_count} > 0 ]]; then
  514. eerror "Please check to make sure these options are set correctly.";
  515. eerror "Failure to do so may cause unexpected problems.";
  516. eerror "Once you have satisfied these options, please try merging";
  517. eerror "this package again.";
  518. export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}";
  519. die "Incorrect kernel configuration options";
  520. else
  521. if [[ ${soft_errors_count} > 0 ]]; then
  522. ewarn "Please check to make sure these options are set correctly.";
  523. ewarn "Failure to do so may cause unexpected problems.";
  524. else
  525. eend 0;
  526. fi;
  527. fi;
  528. export LINUX_CONFIG_EXISTS_DONE="${old_LINUX_CONFIG_EXISTS_DONE}"
  529. }
  530. check_kernel_built ()
  531. {
  532. require_configured_kernel;
  533. get_version;
  534. if [ ! -f "${KV_OUT_DIR}/include/linux/version.h" ]; then
  535. eerror "These sources have not yet been prepared.";
  536. eerror "We cannot build against an unprepared tree.";
  537. eerror "To resolve this, please type the following:";
  538. eerror;
  539. eerror "# cd ${KV_DIR}";
  540. eerror "# make oldconfig";
  541. eerror "# make modules_prepare";
  542. eerror;
  543. eerror "Then please try merging this module again.";
  544. die "Kernel sources need compiling first";
  545. fi
  546. }
  547. check_license ()
  548. {
  549. die "you no longer need this as portage supports ACCEPT_LICENSE itself"
  550. }
  551. check_modules_supported ()
  552. {
  553. require_configured_kernel;
  554. get_version;
  555. if ! linux_chkconfig_builtin "MODULES"; then
  556. eerror "These sources do not support loading external modules.";
  557. eerror "to be able to use this module please enable \"Loadable modules support\"";
  558. eerror "in your kernel, recompile and then try merging this module again.";
  559. die "No support for external modules in ${KV_FULL} config";
  560. fi
  561. }
  562. check_zlibinflate ()
  563. {
  564. require_configured_kernel;
  565. get_version;
  566. local INFLATE;
  567. local DEFLATE;
  568. einfo "Determining the usability of ZLIB_INFLATE support in your kernel";
  569. ebegin "checking ZLIB_INFLATE";
  570. linux_chkconfig_builtin CONFIG_ZLIB_INFLATE;
  571. eend $?;
  572. [ "$?" != 0 ] && die;
  573. ebegin "checking ZLIB_DEFLATE";
  574. linux_chkconfig_builtin CONFIG_ZLIB_DEFLATE;
  575. eend $?;
  576. [ "$?" != 0 ] && die;
  577. local LINENO_START;
  578. local LINENO_END;
  579. local SYMBOLS;
  580. local x;
  581. LINENO_END="$(grep -n 'CONFIG_ZLIB_INFLATE y' ${KV_DIR}/lib/Config.in | cut -d : -f 1)";
  582. LINENO_START="$(head -n $LINENO_END ${KV_DIR}/lib/Config.in | grep -n 'if \[' | tail -n 1 | cut -d : -f 1)";
  583. (( LINENO_AMOUNT = $LINENO_END - $LINENO_START ));
  584. (( LINENO_END = $LINENO_END - 1 ));
  585. SYMBOLS="$(head -n $LINENO_END ${KV_DIR}/lib/Config.in | tail -n $LINENO_AMOUNT | sed -e 's/^.*\(CONFIG_[^\" ]*\).*/\1/g;')";
  586. for x in $SYMBOLS;
  587. do
  588. if [ "${!x}" = "y" ]; then
  589. einfo "${x} ensures zlib is linked into your kernel - excellent";
  590. return 0;
  591. fi;
  592. done;
  593. eerror;
  594. eerror "This kernel module requires ZLIB library support.";
  595. eerror "You have enabled zlib support in your kernel, but haven't enabled";
  596. eerror "enabled any option that will ensure that zlib is linked into your";
  597. eerror "kernel.";
  598. eerror;
  599. eerror "Please ensure that you enable at least one of these options:";
  600. eerror;
  601. for x in $SYMBOLS;
  602. do
  603. eerror " * $x";
  604. done;
  605. eerror;
  606. eerror "Please remember to recompile and install your kernel, and reboot";
  607. eerror "into your new kernel before attempting to load this kernel module.";
  608. die "Kernel doesn't include zlib support"
  609. }
  610. delete_all_version_separators ()
  611. {
  612. replace_all_version_separators "" "${1}"
  613. }
  614. delete_version_separator ()
  615. {
  616. replace_version_separator "${1}" "" "${2}"
  617. }
  618. doicon ()
  619. {
  620. _iconins ${FUNCNAME} "$@"
  621. }
  622. domenu ()
  623. {
  624. ( local i j ret=0;
  625. insinto /usr/share/applications;
  626. for i in "$@";
  627. do
  628. if [[ -f ${i} ]]; then
  629. doins "${i}";
  630. ((ret+=$?));
  631. else
  632. if [[ -d ${i} ]]; then
  633. for j in "${i}"/*.desktop;
  634. do
  635. doins "${j}";
  636. ((ret+=$?));
  637. done;
  638. else
  639. ((++ret));
  640. fi;
  641. fi;
  642. done;
  643. exit ${ret} )
  644. }
  645. ebeep ()
  646. {
  647. ewarn "QA Notice: ebeep is not defined in EAPI=${EAPI}, please file a bug at http://bugs.gentoo.org"
  648. }
  649. econf_build ()
  650. {
  651. tc-env_build econf --build=${CBUILD:-${CHOST}} "$@"
  652. }
  653. ecvs_clean ()
  654. {
  655. [[ -z $* ]] && set -- .;
  656. find "$@" -type d -name 'CVS' -prune -print0 | xargs -0 rm -rf;
  657. find "$@" -type f -name '.cvs*' -print0 | xargs -0 rm -rf
  658. }
  659. edos2unix ()
  660. {
  661. [[ $# -eq 0 ]] && return 0;
  662. sed -i 's/\r$//' -- "$@" || die
  663. }
  664. egetent ()
  665. {
  666. local db=$1 key=$2;
  667. [[ $# -ge 3 ]] && die "usage: egetent <database> <key>";
  668. case ${db} in
  669. passwd | group)
  670.  
  671. ;;
  672. *)
  673. die "sorry, database '${db}' not yet supported; file a bug"
  674. ;;
  675. esac;
  676. case ${CHOST} in
  677. *-darwin[678])
  678. case ${key} in
  679. *[!0-9]*)
  680. nidump ${db} . | awk -F: "(\$1 ~ /^${key}\$/) {print;exit;}"
  681. ;;
  682. *)
  683. nidump ${db} . | awk -F: "(\$3 == ${key}) {print;exit;}"
  684. ;;
  685. esac
  686. ;;
  687. *-darwin*)
  688. local mykey;
  689. case ${db} in
  690. passwd)
  691. db="Users" mykey="UniqueID"
  692. ;;
  693. group)
  694. db="Groups" mykey="PrimaryGroupID"
  695. ;;
  696. esac;
  697. case ${key} in
  698. *[!0-9]*)
  699. dscl . -read /${db}/${key} 2> /dev/null | grep RecordName
  700. ;;
  701. *)
  702. dscl . -search /${db} ${mykey} ${key} 2> /dev/null
  703. ;;
  704. esac
  705. ;;
  706. *-freebsd* | *-dragonfly*)
  707. case ${db} in
  708. passwd)
  709. db="user"
  710. ;;
  711. *)
  712.  
  713. ;;
  714. esac;
  715. local opts;
  716. if [[ ${key} == [[:digit:]]* ]]; then
  717. [[ ${db} == "user" ]] && opts="-u" || opts="-g";
  718. fi;
  719. pw show ${db} ${opts} "${key}" -q
  720. ;;
  721. *-netbsd* | *-openbsd*)
  722. grep "${key}:\*:" /etc/${db}
  723. ;;
  724. *)
  725. nscd -i "${db}" 2> /dev/null;
  726. getent "${db}" "${key}"
  727. ;;
  728. esac
  729. }
  730. egethome ()
  731. {
  732. local pos;
  733. [[ $# -eq 1 ]] || die "usage: egethome <user>";
  734. case ${CHOST} in
  735. *-darwin* | *-freebsd* | *-dragonfly*)
  736. pos=9
  737. ;;
  738. *)
  739. pos=6
  740. ;;
  741. esac;
  742. egetent passwd "$1" | cut -d: -f${pos}
  743. }
  744. egetshell ()
  745. {
  746. local pos;
  747. [[ $# -eq 1 ]] || die "usage: egetshell <user>";
  748. case ${CHOST} in
  749. *-darwin* | *-freebsd* | *-dragonfly*)
  750. pos=10
  751. ;;
  752. *)
  753. pos=7
  754. ;;
  755. esac;
  756. egetent passwd "$1" | cut -d: -f${pos}
  757. }
  758. emktemp ()
  759. {
  760. local exe="touch";
  761. [[ $1 == -d ]] && exe="mkdir" && shift;
  762. local topdir=$1;
  763. if [[ -z ${topdir} ]]; then
  764. [[ -z ${T} ]] && topdir="/tmp" || topdir=${T};
  765. fi;
  766. if ! type -P mktemp > /dev/null; then
  767. local tmp=/;
  768. while [[ -e ${tmp} ]]; do
  769. tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM};
  770. done;
  771. ${exe} "${tmp}" || ${exe} -p "${tmp}";
  772. echo "${tmp}";
  773. else
  774. if [[ ${exe} == "touch" ]]; then
  775. TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX;
  776. else
  777. TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX;
  778. fi;
  779. fi
  780. }
  781. enewgroup ()
  782. {
  783. _assert_pkg_ebuild_phase ${FUNCNAME};
  784. local egroup=$1;
  785. shift;
  786. if [[ -z ${egroup} ]]; then
  787. eerror "No group specified !";
  788. die "Cannot call enewgroup without a group";
  789. fi;
  790. if [[ -n $(egetent group "${egroup}") ]]; then
  791. return 0;
  792. fi;
  793. einfo "Adding group '${egroup}' to your system ...";
  794. local egid=$1;
  795. shift;
  796. if [[ ! -z ${egid} ]]; then
  797. if [[ ${egid} -gt 0 ]]; then
  798. if [[ -n $(egetent group ${egid}) ]]; then
  799. egid="next available; requested gid taken";
  800. fi;
  801. else
  802. eerror "Groupid given but is not greater than 0 !";
  803. die "${egid} is not a valid GID";
  804. fi;
  805. else
  806. egid="next available";
  807. fi;
  808. einfo " - Groupid: ${egid}";
  809. if [[ $# -gt 0 ]]; then
  810. die "extra arguments no longer supported; please file a bug";
  811. fi;
  812. function _enewgroup_next_gid ()
  813. {
  814. if [[ ${egid} == *[!0-9]* ]]; then
  815. for ((egid = 101; egid <= 999; egid++))
  816. do
  817. [[ -z $(egetent group ${egid}) ]] && break;
  818. done;
  819. fi
  820. };
  821. case ${CHOST} in
  822. *-darwin*)
  823. _enewgroup_next_gid;
  824. dscl . create "/groups/${egroup}" gid ${egid};
  825. dscl . create "/groups/${egroup}" passwd '*'
  826. ;;
  827. *-freebsd* | *-dragonfly*)
  828. _enewgroup_next_gid;
  829. pw groupadd "${egroup}" -g ${egid} || die
  830. ;;
  831. *-netbsd*)
  832. _enewgroup_next_gid;
  833. groupadd -g ${egid} "${egroup}" || die
  834. ;;
  835. *)
  836. local opts;
  837. if [[ ${egid} == *[!0-9]* ]]; then
  838. opts="";
  839. else
  840. opts="-g ${egid}";
  841. fi;
  842. groupadd -r ${opts} "${egroup}" || die
  843. ;;
  844. esac
  845. }
  846. enewuser ()
  847. {
  848. _assert_pkg_ebuild_phase ${FUNCNAME};
  849. local euser=$1;
  850. shift;
  851. if [[ -z ${euser} ]]; then
  852. eerror "No username specified !";
  853. die "Cannot call enewuser without a username";
  854. fi;
  855. if [[ -n $(egetent passwd "${euser}") ]]; then
  856. return 0;
  857. fi;
  858. einfo "Adding user '${euser}' to your system ...";
  859. local opts=();
  860. local euid=$1;
  861. shift;
  862. if [[ -n ${euid} && ${euid} != -1 ]]; then
  863. if [[ ${euid} -gt 0 ]]; then
  864. if [[ -n $(egetent passwd ${euid}) ]]; then
  865. euid="next";
  866. fi;
  867. else
  868. eerror "Userid given but is not greater than 0 !";
  869. die "${euid} is not a valid UID";
  870. fi;
  871. else
  872. euid="next";
  873. fi;
  874. if [[ ${euid} == "next" ]]; then
  875. for ((euid = 101; euid <= 999; euid++))
  876. do
  877. [[ -z $(egetent passwd ${euid}) ]] && break;
  878. done;
  879. fi;
  880. opts+=(-u ${euid});
  881. einfo " - Userid: ${euid}";
  882. local eshell=$1;
  883. shift;
  884. if [[ ! -z ${eshell} ]] && [[ ${eshell} != "-1" ]]; then
  885. if [[ ! -e ${ROOT}${eshell} ]]; then
  886. eerror "A shell was specified but it does not exist !";
  887. die "${eshell} does not exist in ${ROOT}";
  888. fi;
  889. if [[ ${eshell} == */false || ${eshell} == */nologin ]]; then
  890. eerror "Do not specify ${eshell} yourself, use -1";
  891. die "Pass '-1' as the shell parameter";
  892. fi;
  893. else
  894. for eshell in /sbin/nologin /usr/sbin/nologin /bin/false /usr/bin/false /dev/null;
  895. do
  896. [[ -x ${ROOT}${eshell} ]] && break;
  897. done;
  898. if [[ ${eshell} == "/dev/null" ]]; then
  899. eerror "Unable to identify the shell to use, proceeding with userland default.";
  900. case ${USERLAND} in
  901. GNU)
  902. eshell="/bin/false"
  903. ;;
  904. BSD)
  905. eshell="/sbin/nologin"
  906. ;;
  907. Darwin)
  908. eshell="/usr/sbin/nologin"
  909. ;;
  910. *)
  911. die "Unable to identify the default shell for userland ${USERLAND}"
  912. ;;
  913. esac;
  914. fi;
  915. fi;
  916. einfo " - Shell: ${eshell}";
  917. opts+=(-s "${eshell}");
  918. local ehome=$1;
  919. shift;
  920. if [[ -z ${ehome} ]] || [[ ${ehome} == "-1" ]]; then
  921. ehome="/dev/null";
  922. fi;
  923. einfo " - Home: ${ehome}";
  924. opts+=(-d "${ehome}");
  925. local egroups=$1;
  926. shift;
  927. local g egroups_arr;
  928. IFS="," read -r -a egroups_arr <<< "${egroups}";
  929. shift;
  930. if [[ ${#egroups_arr[@]} -gt 0 ]]; then
  931. local defgroup exgroups;
  932. for g in "${egroups_arr[@]}";
  933. do
  934. if [[ -z $(egetent group "${g}") ]]; then
  935. eerror "You must add group ${g} to the system first";
  936. die "${g} is not a valid GID";
  937. fi;
  938. if [[ -z ${defgroup} ]]; then
  939. defgroup=${g};
  940. else
  941. exgroups+=",${g}";
  942. fi;
  943. done;
  944. opts+=(-g "${defgroup}");
  945. if [[ ! -z ${exgroups} ]]; then
  946. opts+=(-G "${exgroups:1}");
  947. fi;
  948. fi;
  949. einfo " - Groups: ${egroups:-(none)}";
  950. if [[ $# -gt 0 ]]; then
  951. die "extra arguments no longer supported; please file a bug";
  952. else
  953. local comment="added by portage for ${PN}";
  954. opts+=(-c "${comment}");
  955. einfo " - GECOS: ${comment}";
  956. fi;
  957. case ${CHOST} in
  958. *-darwin*)
  959. dscl . create "/users/${euser}" uid ${euid};
  960. dscl . create "/users/${euser}" shell "${eshell}";
  961. dscl . create "/users/${euser}" home "${ehome}";
  962. dscl . create "/users/${euser}" realname "added by portage for ${PN}";
  963. for g in "${egroups_arr[@]}";
  964. do
  965. dscl . merge "/groups/${g}" users "${euser}";
  966. done
  967. ;;
  968. *-freebsd* | *-dragonfly*)
  969. pw useradd "${euser}" "${opts[@]}" || die
  970. ;;
  971. *-netbsd*)
  972. useradd "${opts[@]}" "${euser}" || die
  973. ;;
  974. *-openbsd*)
  975. useradd -u ${euid} -s "${eshell}" -d "${ehome}" -g "${egroups}" "${euser}" || die
  976. ;;
  977. *)
  978. useradd -r "${opts[@]}" "${euser}" || die
  979. ;;
  980. esac;
  981. if [[ ! -e ${ROOT}/${ehome} ]]; then
  982. einfo " - Creating ${ehome} in ${ROOT}";
  983. mkdir -p "${ROOT}/${ehome}";
  984. chown "${euser}" "${ROOT}/${ehome}";
  985. chmod 755 "${ROOT}/${ehome}";
  986. fi
  987. }
  988. epatch ()
  989. {
  990. function _epatch_draw_line ()
  991. {
  992. [[ -z $1 ]] && set "$(printf "%65s" '')";
  993. echo "${1//?/=}"
  994. };
  995. unset P4CONFIG P4PORT P4USER;
  996. local EPATCH_OPTS=(${EPATCH_OPTS[*]});
  997. while [[ $# -gt 0 ]]; do
  998. case $1 in
  999. -*)
  1000. EPATCH_OPTS+=("$1")
  1001. ;;
  1002. *)
  1003. break
  1004. ;;
  1005. esac;
  1006. shift;
  1007. done;
  1008. if [[ $# -gt 1 ]]; then
  1009. local m;
  1010. for m in "$@";
  1011. do
  1012. epatch "${m}";
  1013. done;
  1014. return 0;
  1015. fi;
  1016. local SINGLE_PATCH="no";
  1017. [[ $# -eq 0 ]] && set -- "${EPATCH_SOURCE}";
  1018. if [[ -f $1 ]]; then
  1019. SINGLE_PATCH="yes";
  1020. set -- "$1";
  1021. local EPATCH_SUFFIX=$1;
  1022. else
  1023. if [[ -d $1 ]]; then
  1024. set -- "$1"/*${EPATCH_SUFFIX:+."${EPATCH_SUFFIX}"};
  1025. else
  1026. if [[ -f ${EPATCH_SOURCE}/$1 ]]; then
  1027. epatch "${EPATCH_SOURCE}/$1";
  1028. return $?;
  1029. else
  1030. [[ $# -ne 0 ]] && EPATCH_SOURCE=$1;
  1031. echo;
  1032. eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:";
  1033. eerror;
  1034. eerror " ${EPATCH_SOURCE}";
  1035. eerror " ( ${EPATCH_SOURCE##*/} )";
  1036. echo;
  1037. die "Cannot find \$EPATCH_SOURCE!";
  1038. fi;
  1039. fi;
  1040. fi;
  1041. EPATCH_OPTS="${EPATCH_COMMON_OPTS} ${EPATCH_OPTS[*]}";
  1042. local PIPE_CMD;
  1043. case ${EPATCH_SUFFIX##*\.} in
  1044. xz)
  1045. PIPE_CMD="xz -dc"
  1046. ;;
  1047. lzma)
  1048. PIPE_CMD="lzma -dc"
  1049. ;;
  1050. bz2)
  1051. PIPE_CMD="bzip2 -dc"
  1052. ;;
  1053. gz | Z | z)
  1054. PIPE_CMD="gzip -dc"
  1055. ;;
  1056. ZIP | zip)
  1057. PIPE_CMD="unzip -p"
  1058. ;;
  1059. *)
  1060.  
  1061. ;;
  1062. esac;
  1063. [[ ${SINGLE_PATCH} == "no" ]] && einfo "${EPATCH_MULTI_MSG}";
  1064. local x;
  1065. for x in "$@";
  1066. do
  1067. [[ ! -f ${x} ]] && continue;
  1068. local patchname=${x##*/};
  1069. local a=${patchname#*_};
  1070. a=${a%%_*};
  1071. if ! [[ ${SINGLE_PATCH} == "yes" || ${EPATCH_FORCE} == "yes" || ${a} == all || ${a} == ${ARCH} ]]; then
  1072. continue;
  1073. fi;
  1074. if [[ -n ${EPATCH_EXCLUDE} ]]; then
  1075. eshopts_push -o noglob;
  1076. local ex;
  1077. for ex in ${EPATCH_EXCLUDE};
  1078. do
  1079. if [[ ${patchname} == ${ex} ]]; then
  1080. eshopts_pop;
  1081. continue 2;
  1082. fi;
  1083. done;
  1084. eshopts_pop;
  1085. fi;
  1086. if [[ ${SINGLE_PATCH} == "yes" ]]; then
  1087. if [[ -n ${EPATCH_SINGLE_MSG} ]]; then
  1088. einfo "${EPATCH_SINGLE_MSG}";
  1089. else
  1090. einfo "Applying ${patchname} ...";
  1091. fi;
  1092. else
  1093. einfo " ${patchname} ...";
  1094. fi;
  1095. local STDERR_TARGET="${T}/${patchname}.out";
  1096. if [[ -e ${STDERR_TARGET} ]]; then
  1097. STDERR_TARGET="${T}/${patchname}-$$.out";
  1098. fi;
  1099. printf "***** %s *****\nPWD: %s\n\n" "${patchname}" "${PWD}" > "${STDERR_TARGET}";
  1100. local count=0;
  1101. local PATCH_TARGET;
  1102. if [[ -n ${PIPE_CMD} ]]; then
  1103. PATCH_TARGET="${T}/$$.patch";
  1104. echo "PIPE_COMMAND: ${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> "${STDERR_TARGET}";
  1105. if ! ( ${PIPE_CMD} "${x}" > "${PATCH_TARGET}" ) >> "${STDERR_TARGET}" 2>&1; then
  1106. echo;
  1107. eerror "Could not extract patch!";
  1108. count=5;
  1109. break;
  1110. fi;
  1111. else
  1112. PATCH_TARGET=${x};
  1113. fi;
  1114. local abs_paths=$(egrep -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }');
  1115. if [[ -n ${abs_paths} ]]; then
  1116. count=1;
  1117. printf "NOTE: skipping -p0 due to absolute paths in patch:\n%s\n" "${abs_paths}" >> "${STDERR_TARGET}";
  1118. fi;
  1119. local rel_paths=$(egrep -n '^[-+]{3} [^ ]*[.][.]/' "${PATCH_TARGET}");
  1120. if [[ -n ${rel_paths} ]]; then
  1121. eqawarn "QA Notice: Your patch uses relative paths '../'.";
  1122. eqawarn " In the future this will cause a failure.";
  1123. eqawarn "${rel_paths}";
  1124. fi;
  1125. local patch_cmd;
  1126. while [[ ${count} -lt 5 ]]; do
  1127. patch_cmd="${BASH_ALIASES[patch]:-patch} -p${count} ${EPATCH_OPTS}";
  1128. ( _epatch_draw_line "***** ${patchname} *****";
  1129. echo;
  1130. echo "PATCH COMMAND: ${patch_cmd} < '${PATCH_TARGET}'";
  1131. echo;
  1132. _epatch_draw_line "***** ${patchname} *****";
  1133. ${patch_cmd} --dry-run -f < "${PATCH_TARGET}" 2>&1;
  1134. ret=$?;
  1135. echo;
  1136. echo "patch program exited with status ${ret}";
  1137. exit ${ret} ) >> "${STDERR_TARGET}";
  1138. if [ $? -eq 0 ]; then
  1139. ( _epatch_draw_line "***** ${patchname} *****";
  1140. echo;
  1141. echo "ACTUALLY APPLYING ${patchname} ...";
  1142. echo;
  1143. _epatch_draw_line "***** ${patchname} *****";
  1144. ${patch_cmd} < "${PATCH_TARGET}" 2>&1;
  1145. ret=$?;
  1146. echo;
  1147. echo "patch program exited with status ${ret}";
  1148. exit ${ret} ) >> "${STDERR_TARGET}";
  1149. if [ $? -ne 0 ]; then
  1150. echo;
  1151. eerror "A dry-run of patch command succeeded, but actually";
  1152. eerror "applying the patch failed!";
  1153. count=5;
  1154. fi;
  1155. break;
  1156. fi;
  1157. : $(( count++ ));
  1158. done;
  1159. if [[ -n ${PIPE_CMD} ]]; then
  1160. rm -f "${PATCH_TARGET}";
  1161. fi;
  1162. if [[ ${count} -ge 5 ]]; then
  1163. echo;
  1164. eerror "Failed Patch: ${patchname} !";
  1165. eerror " ( ${PATCH_TARGET} )";
  1166. eerror;
  1167. eerror "Include in your bugreport the contents of:";
  1168. eerror;
  1169. eerror " ${STDERR_TARGET}";
  1170. echo;
  1171. die "Failed Patch: ${patchname}!";
  1172. fi;
  1173. rm -f "${STDERR_TARGET}";
  1174. cat >> "${T}/epatch.log" <<-EOF
  1175. PATCH: ${x}
  1176. CMD: ${patch_cmd}
  1177. PWD: ${PWD}
  1178.  
  1179. EOF
  1180.  
  1181. eend 0;
  1182. done;
  1183. [[ ${SINGLE_PATCH} == "no" ]] && einfo "Done with patching";
  1184. :
  1185. }
  1186. epatch_user ()
  1187. {
  1188. [[ $# -ne 0 ]] && die "epatch_user takes no options";
  1189. local applied="${T}/epatch_user.log";
  1190. [[ -e ${applied} ]] && return 2;
  1191. local EPATCH_SOURCE check base=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
  1192. for check in ${CATEGORY}/{${P}-${PR},${P},${PN}};
  1193. do
  1194. EPATCH_SOURCE=${base}/${CTARGET}/${check};
  1195. [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${CHOST}/${check};
  1196. [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${check};
  1197. if [[ -d ${EPATCH_SOURCE} ]]; then
  1198. EPATCH_SOURCE=${EPATCH_SOURCE} EPATCH_SUFFIX="patch" EPATCH_FORCE="yes" EPATCH_MULTI_MSG="Applying user patches from ${EPATCH_SOURCE} ..." epatch;
  1199. echo "${EPATCH_SOURCE}" > "${applied}";
  1200. return 0;
  1201. fi;
  1202. done;
  1203. echo "none" > "${applied}";
  1204. return 1
  1205. }
  1206. epause ()
  1207. {
  1208. ewarn "QA Notice: epause is not defined in EAPI=${EAPI}, please file a bug at http://bugs.gentoo.org"
  1209. }
  1210. epunt_cxx ()
  1211. {
  1212. local dir=$1;
  1213. [[ -z ${dir} ]] && dir=${S};
  1214. ebegin "Removing useless C++ checks";
  1215. local f;
  1216. find "${dir}" -name configure | while read f; do
  1217. patch --no-backup-if-mismatch -p0 "${f}" "${PORTDIR}/eclass/ELT-patches/nocxx/nocxx.patch" > /dev/null;
  1218. done;
  1219. eend 0
  1220. }
  1221. esethome ()
  1222. {
  1223. _assert_pkg_ebuild_phase ${FUNCNAME};
  1224. local euser=$1;
  1225. shift;
  1226. if [[ -z ${euser} ]]; then
  1227. eerror "No username specified !";
  1228. die "Cannot call esethome without a username";
  1229. fi;
  1230. if [[ -z $(egetent passwd "${euser}") ]]; then
  1231. ewarn "User does not exist, cannot set home dir -- skipping.";
  1232. return 1;
  1233. fi;
  1234. local ehome=$1;
  1235. shift;
  1236. if [[ -z ${ehome} ]]; then
  1237. eerror "No home directory specified !";
  1238. die "Cannot call esethome without a home directory or '-1'";
  1239. fi;
  1240. if [[ ${ehome} == "-1" ]]; then
  1241. ehome="/dev/null";
  1242. fi;
  1243. if [[ $(egethome "${euser}") == ${ehome} ]]; then
  1244. return 0;
  1245. fi;
  1246. einfo "Updating home for user '${euser}' ...";
  1247. einfo " - Home: ${ehome}";
  1248. if [[ ! -e ${ROOT}/${ehome} ]]; then
  1249. einfo " - Creating ${ehome} in ${ROOT}";
  1250. mkdir -p "${ROOT}/${ehome}";
  1251. chown "${euser}" "${ROOT}/${ehome}";
  1252. chmod 755 "${ROOT}/${ehome}";
  1253. fi;
  1254. case ${CHOST} in
  1255. *-darwin*)
  1256. dscl . change "/users/${euser}" home "${ehome}"
  1257. ;;
  1258. *-freebsd* | *-dragonfly*)
  1259. pw usermod "${euser}" -d "${ehome}" && return 0;
  1260. [[ $? == 8 ]] && eerror "${euser} is in use, cannot update home";
  1261. eerror "There was an error when attempting to update the home directory for ${euser}";
  1262. eerror "Please update it manually on your system:";
  1263. eerror "\t pw usermod \"${euser}\" -d \"${ehome}\""
  1264. ;;
  1265. *)
  1266. usermod -d "${ehome}" "${euser}" && return 0;
  1267. [[ $? == 8 ]] && eerror "${euser} is in use, cannot update home";
  1268. eerror "There was an error when attempting to update the home directory for ${euser}";
  1269. eerror "Please update it manually on your system (as root):";
  1270. eerror "\t usermod -d \"${ehome}\" \"${euser}\""
  1271. ;;
  1272. esac
  1273. }
  1274. eshopts_pop ()
  1275. {
  1276. local s;
  1277. estack_pop eshopts s || die "${FUNCNAME}: unbalanced push";
  1278. if [[ ${s} == "shopt -"* ]]; then
  1279. eval "${s}" || die "${FUNCNAME}: sanity: invalid shopt options: ${s}";
  1280. else
  1281. set +$- || die "${FUNCNAME}: sanity: invalid shell settings: $-";
  1282. set -${s} || die "${FUNCNAME}: sanity: unable to restore saved shell settings: ${s}";
  1283. fi
  1284. }
  1285. eshopts_push ()
  1286. {
  1287. if [[ $1 == -[su] ]]; then
  1288. estack_push eshopts "$(shopt -p)";
  1289. [[ $# -eq 0 ]] && return 0;
  1290. shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*";
  1291. else
  1292. estack_push eshopts $-;
  1293. [[ $# -eq 0 ]] && return 0;
  1294. set "$@" || die "${FUNCNAME}: bad options to set: $*";
  1295. fi
  1296. }
  1297. estack_pop ()
  1298. {
  1299. [[ $# -eq 0 || $# -gt 2 ]] && die "estack_pop: incorrect # of arguments";
  1300. local __estack_name="__ESTACK_$1__";
  1301. shift;
  1302. local __estack_retvar=$1;
  1303. shift;
  1304. eval local __estack_i=\${#${__estack_name}\[@\]};
  1305. [[ $(( --__estack_i )) -eq -1 ]] && return 1;
  1306. if [[ -n ${__estack_retvar} ]]; then
  1307. eval ${__estack_retvar}=\"\${${__estack_name}\[${__estack_i}\]}\";
  1308. fi;
  1309. eval unset ${__estack_name}\[${__estack_i}\]
  1310. }
  1311. estack_push ()
  1312. {
  1313. [[ $# -eq 0 ]] && die "estack_push: incorrect # of arguments";
  1314. local stack_name="__ESTACK_$1__";
  1315. shift;
  1316. eval ${stack_name}+=\( \"\$@\" \)
  1317. }
  1318. esvn_clean ()
  1319. {
  1320. [[ -z $* ]] && set -- .;
  1321. find "$@" -type d -name '.svn' -prune -print0 | xargs -0 rm -rf
  1322. }
  1323. eumask_pop ()
  1324. {
  1325. [[ $# -eq 0 ]] || die "${FUNCNAME}: we take no options";
  1326. local s;
  1327. estack_pop eumask s || die "${FUNCNAME}: unbalanced push";
  1328. umask ${s} || die "${FUNCNAME}: sanity: could not restore umask: ${s}"
  1329. }
  1330. eumask_push ()
  1331. {
  1332. estack_push eumask "$(umask)";
  1333. umask "$@" || die "${FUNCNAME}: bad options to umask: $*"
  1334. }
  1335. gcc-fullversion ()
  1336. {
  1337. _gcc_fullversion '$1.$2.$3' "$@"
  1338. }
  1339. gcc-major-version ()
  1340. {
  1341. _gcc_fullversion '$1' "$@"
  1342. }
  1343. gcc-micro-version ()
  1344. {
  1345. _gcc_fullversion '$3' "$@"
  1346. }
  1347. gcc-minor-version ()
  1348. {
  1349. _gcc_fullversion '$2' "$@"
  1350. }
  1351. gcc-specs-directive ()
  1352. {
  1353. local directive subdname subdirective;
  1354. directive="$(_gcc-specs-directive_raw $1)";
  1355. while [[ ${directive} == *%\(*\)* ]]; do
  1356. subdname=${directive/*%\(};
  1357. subdname=${subdname/\)*};
  1358. subdirective="$(_gcc-specs-directive_raw ${subdname})";
  1359. directive="${directive//\%(${subdname})/${subdirective}}";
  1360. done;
  1361. echo "${directive}";
  1362. return 0
  1363. }
  1364. gcc-specs-nostrict ()
  1365. {
  1366. local directive;
  1367. directive=$(gcc-specs-directive cc1);
  1368. return $([[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]])
  1369. }
  1370. gcc-specs-now ()
  1371. {
  1372. local directive;
  1373. directive=$(gcc-specs-directive link_command);
  1374. return $([[ "${directive/\{!nonow:}" != "${directive}" ]])
  1375. }
  1376. gcc-specs-pie ()
  1377. {
  1378. local directive;
  1379. directive=$(gcc-specs-directive cc1);
  1380. return $([[ "${directive/\{!nopie:}" != "${directive}" ]])
  1381. }
  1382. gcc-specs-relro ()
  1383. {
  1384. local directive;
  1385. directive=$(gcc-specs-directive link_command);
  1386. return $([[ "${directive/\{!norelro:}" != "${directive}" ]])
  1387. }
  1388. gcc-specs-ssp ()
  1389. {
  1390. local directive;
  1391. directive=$(gcc-specs-directive cc1);
  1392. return $([[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]])
  1393. }
  1394. gcc-specs-ssp-to-all ()
  1395. {
  1396. local directive;
  1397. directive=$(gcc-specs-directive cc1);
  1398. return $([[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]])
  1399. }
  1400. gcc-version ()
  1401. {
  1402. _gcc_fullversion '$1.$2' "$@"
  1403. }
  1404. gen_usr_ldscript ()
  1405. {
  1406. local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  1407. [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  1408. tc-is-static-only && return;
  1409. case ${CTARGET:-${CHOST}} in
  1410. *-darwin*)
  1411.  
  1412. ;;
  1413. *linux* | *-freebsd* | *-openbsd* | *-netbsd*)
  1414. use prefix && return 0
  1415. ;;
  1416. *)
  1417. return 0
  1418. ;;
  1419. esac;
  1420. dodir /usr/${libdir};
  1421. if [[ $1 == "-a" ]]; then
  1422. auto=true;
  1423. shift;
  1424. dodir /${libdir};
  1425. fi;
  1426. output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  1427. [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  1428. for lib in "$@";
  1429. do
  1430. local tlib;
  1431. if ${auto}; then
  1432. lib="lib${lib}${suffix}";
  1433. else
  1434. [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  1435. fi;
  1436. case ${CTARGET:-${CHOST}} in
  1437. *-darwin*)
  1438. if ${auto}; then
  1439. tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1440. else
  1441. tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  1442. fi;
  1443. [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  1444. tlib=${tlib##*/};
  1445. if ${auto}; then
  1446. mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1447. if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  1448. mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  1449. fi;
  1450. rm -f "${ED}"/${libdir}/${lib};
  1451. fi;
  1452. if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  1453. chmod u+w "${ED}${libdir}/${tlib}";
  1454. local nowrite=yes;
  1455. fi;
  1456. install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  1457. [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  1458. pushd "${ED}/usr/${libdir}" > /dev/null;
  1459. ln -snf "../../${libdir}/${tlib}" "${lib}";
  1460. popd > /dev/null
  1461. ;;
  1462. *)
  1463. if ${auto}; then
  1464. tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  1465. [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  1466. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  1467. if [[ ${tlib} != ${lib}* ]]; then
  1468. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  1469. fi;
  1470. rm -f "${ED}"/${libdir}/${lib};
  1471. else
  1472. tlib=${lib};
  1473. fi;
  1474. cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
  1475. /* GNU ld script
  1476. Since Gentoo has critical dynamic libraries in /lib, and the static versions
  1477. in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  1478. run into linking problems. This "fake" dynamic lib is a linker script that
  1479. redirects the linker to the real lib. And yes, this works in the cross-
  1480. compiling scenario as the sysroot-ed linker will prepend the real path.
  1481.  
  1482. See bug http://bugs.gentoo.org/4411 for more info.
  1483. */
  1484. ${output_format}
  1485. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  1486. END_LDSCRIPT
  1487.  
  1488. ;;
  1489. esac
  1490. fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  1491. done
  1492. }
  1493. get_abi_CFLAGS ()
  1494. {
  1495. get_abi_var CFLAGS "$@"
  1496. }
  1497. get_abi_CHOST ()
  1498. {
  1499. get_abi_var CHOST "$@"
  1500. }
  1501. get_abi_CTARGET ()
  1502. {
  1503. get_abi_var CTARGET "$@"
  1504. }
  1505. get_abi_FAKE_TARGETS ()
  1506. {
  1507. get_abi_var FAKE_TARGETS "$@"
  1508. }
  1509. get_abi_LDFLAGS ()
  1510. {
  1511. get_abi_var LDFLAGS "$@"
  1512. }
  1513. get_abi_LIBDIR ()
  1514. {
  1515. get_abi_var LIBDIR "$@"
  1516. }
  1517. get_abi_var ()
  1518. {
  1519. local flag=$1;
  1520. local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  1521. local var="${flag}_${abi}";
  1522. echo ${!var}
  1523. }
  1524. get_after_major_version ()
  1525. {
  1526. echo $(get_version_component_range 2- "${1:-${PV}}")
  1527. }
  1528. get_all_abis ()
  1529. {
  1530. local x order="" mvar dvar;
  1531. mvar="MULTILIB_ABIS";
  1532. dvar="DEFAULT_ABI";
  1533. if [[ -n $1 ]]; then
  1534. mvar="$1_${mvar}";
  1535. dvar="$1_${dvar}";
  1536. fi;
  1537. if [[ -z ${!mvar} ]]; then
  1538. echo "default";
  1539. return 0;
  1540. fi;
  1541. for x in ${!mvar};
  1542. do
  1543. if [[ ${x} != ${!dvar} ]]; then
  1544. order="${order:+${order} }${x}";
  1545. fi;
  1546. done;
  1547. order="${order:+${order} }${!dvar}";
  1548. echo ${order};
  1549. return 0
  1550. }
  1551. get_all_libdirs ()
  1552. {
  1553. local libdirs abi;
  1554. for abi in ${MULTILIB_ABIS};
  1555. do
  1556. libdirs+=" $(get_abi_LIBDIR ${abi})";
  1557. done;
  1558. [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  1559. echo "${libdirs}"
  1560. }
  1561. get_all_version_components ()
  1562. {
  1563. eshopts_push -s extglob;
  1564. local ver_str=${1:-${PV}} result;
  1565. result=();
  1566. if [[ ${VERSIONATOR_CACHE_VER_STR} == ${ver_str} ]]; then
  1567. echo ${VERSIONATOR_CACHE_RESULT};
  1568. eshopts_pop;
  1569. return;
  1570. fi;
  1571. export VERSIONATOR_CACHE_VER_STR=${ver_str};
  1572. while [[ -n $ver_str ]]; do
  1573. case "${ver_str::1}" in
  1574. [[:digit:]])
  1575. result+=("${ver_str%%[^[:digit:]]*}");
  1576. ver_str=${ver_str##+([[:digit:]])}
  1577. ;;
  1578. [-_.])
  1579. result+=("${ver_str::1}");
  1580. ver_str=${ver_str:1}
  1581. ;;
  1582. [[:alpha:]])
  1583. local not_match=${ver_str##+([[:alpha:]])*([[:digit:]])};
  1584. result+=("${ver_str::${#ver_str} - ${#not_match}}");
  1585. ver_str=${not_match}
  1586. ;;
  1587. *)
  1588. result+=("${ver_str::1}");
  1589. ver_str=${ver_str:1}
  1590. ;;
  1591. esac;
  1592. done;
  1593. export VERSIONATOR_CACHE_RESULT=${result[*]};
  1594. echo ${result[@]};
  1595. eshopts_pop
  1596. }
  1597. get_install_abis ()
  1598. {
  1599. local x order="";
  1600. if [[ -z ${MULTILIB_ABIS} ]]; then
  1601. echo "default";
  1602. return 0;
  1603. fi;
  1604. if [[ ${EMULTILIB_PKG} == "true" ]]; then
  1605. for x in ${MULTILIB_ABIS};
  1606. do
  1607. if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  1608. has ${x} ${ABI_DENY} || order="${order} ${x}";
  1609. fi;
  1610. done;
  1611. has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  1612. if [[ -n ${ABI_ALLOW} ]]; then
  1613. local ordera="";
  1614. for x in ${order};
  1615. do
  1616. if has ${x} ${ABI_ALLOW}; then
  1617. ordera="${ordera} ${x}";
  1618. fi;
  1619. done;
  1620. order=${ordera};
  1621. fi;
  1622. else
  1623. order=${DEFAULT_ABI};
  1624. fi;
  1625. if [[ -z ${order} ]]; then
  1626. 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.";
  1627. fi;
  1628. echo ${order};
  1629. return 0
  1630. }
  1631. get_last_version_component_index ()
  1632. {
  1633. echo $(($(get_version_component_count "${1:-${PV}}" ) - 1))
  1634. }
  1635. get_libdir ()
  1636. {
  1637. local CONF_LIBDIR;
  1638. if [ -n "${CONF_LIBDIR_OVERRIDE}" ]; then
  1639. echo ${CONF_LIBDIR_OVERRIDE};
  1640. else
  1641. get_abi_LIBDIR;
  1642. fi
  1643. }
  1644. get_libname ()
  1645. {
  1646. local libname;
  1647. local ver=$1;
  1648. case ${CHOST} in
  1649. *-cygwin | mingw* | *-mingw*)
  1650. libname="dll"
  1651. ;;
  1652. *-darwin*)
  1653. libname="dylib"
  1654. ;;
  1655. *-mint*)
  1656. libname="irrelevant"
  1657. ;;
  1658. hppa*-hpux*)
  1659. libname="sl"
  1660. ;;
  1661. *)
  1662. libname="so"
  1663. ;;
  1664. esac;
  1665. if [[ -z $* ]]; then
  1666. echo ".${libname}";
  1667. else
  1668. for ver in "$@";
  1669. do
  1670. case ${CHOST} in
  1671. *-darwin*)
  1672. echo ".${ver}.${libname}"
  1673. ;;
  1674. *-mint*)
  1675. echo ".${libname}"
  1676. ;;
  1677. *)
  1678. echo ".${libname}.${ver}"
  1679. ;;
  1680. esac;
  1681. done;
  1682. fi
  1683. }
  1684. get_localversion ()
  1685. {
  1686. local lv_list i x;
  1687. for i in $(ls ${1}/localversion* 2>/dev/null);
  1688. do
  1689. [[ -n ${i//*~*} ]] && lv_list="${lv_list} ${i}";
  1690. done;
  1691. for i in ${lv_list};
  1692. do
  1693. x="${x}$(<${i})";
  1694. done;
  1695. x=${x/ /};
  1696. echo ${x}
  1697. }
  1698. get_major_version ()
  1699. {
  1700. local c=($(get_all_version_components "${1:-${PV}}"));
  1701. echo ${c[0]}
  1702. }
  1703. get_makefile_extract_function ()
  1704. {
  1705. local a='' b='' mkfunc='getfilevar';
  1706. a="$(getfilevar VERSION ${KERNEL_MAKEFILE})";
  1707. b="$(getfilevar_noexec VERSION ${KERNEL_MAKEFILE})";
  1708. [[ "${a}" != "${b}" ]] && mkfunc='getfilevar_noexec';
  1709. echo "${mkfunc}"
  1710. }
  1711. get_modname ()
  1712. {
  1713. local modname;
  1714. local ver=$1;
  1715. case ${CHOST} in
  1716. *-darwin*)
  1717. modname="bundle"
  1718. ;;
  1719. *)
  1720. modname="so"
  1721. ;;
  1722. esac;
  1723. echo ".${modname}"
  1724. }
  1725. get_running_version ()
  1726. {
  1727. KV_FULL=$(uname -r);
  1728. if [[ -f ${ROOT}/lib/modules/${KV_FULL}/source/Makefile && -f ${ROOT}/lib/modules/${KV_FULL}/build/Makefile ]]; then
  1729. KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/source);
  1730. KBUILD_OUTPUT=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/build);
  1731. unset KV_FULL;
  1732. get_version;
  1733. return $?;
  1734. else
  1735. if [[ -f ${ROOT}/lib/modules/${KV_FULL}/source/Makefile ]]; then
  1736. KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/source);
  1737. unset KV_FULL;
  1738. get_version;
  1739. return $?;
  1740. else
  1741. if [[ -f ${ROOT}/lib/modules/${KV_FULL}/build/Makefile ]]; then
  1742. KERNEL_DIR=$(readlink -f ${ROOT}/lib/modules/${KV_FULL}/build);
  1743. unset KV_FULL;
  1744. get_version;
  1745. return $?;
  1746. else
  1747. KV_MAJOR=$(get_version_component_range 1 ${KV_FULL});
  1748. KV_MINOR=$(get_version_component_range 2 ${KV_FULL});
  1749. KV_PATCH=$(get_version_component_range 3 ${KV_FULL});
  1750. KV_PATCH=${KV_PATCH//-*};
  1751. KV_EXTRA="${KV_FULL#${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}}";
  1752. fi;
  1753. fi;
  1754. fi;
  1755. return 0
  1756. }
  1757. get_version ()
  1758. {
  1759. local kbuild_output mkfunc tmplocal;
  1760. [ -n "${KV_FULL}" ] && return 0;
  1761. unset KV_DIR;
  1762. [ -z "${get_version_warning_done}" ] && qeinfo "Determining the location of the kernel source code";
  1763. [ -h "${KERNEL_DIR}" ] && KV_DIR="$(readlink -f ${KERNEL_DIR})";
  1764. [ -d "${KERNEL_DIR}" ] && KV_DIR="${KERNEL_DIR}";
  1765. if [ -z "${KV_DIR}" ]; then
  1766. if [ -z "${get_version_warning_done}" ]; then
  1767. get_version_warning_done=1;
  1768. qeerror "Unable to find kernel sources at ${KERNEL_DIR}";
  1769. if [ "${KERNEL_DIR}" == "/usr/src/linux" ]; then
  1770. qeinfo "Please make sure that ${KERNEL_DIR} points at your running kernel, ";
  1771. qeinfo "(or the kernel you wish to build against).";
  1772. qeinfo "Alternatively, set the KERNEL_DIR environment variable to the kernel sources location";
  1773. else
  1774. qeinfo "Please ensure that the KERNEL_DIR environment variable points at full Linux sources of the kernel you wish to compile against.";
  1775. fi;
  1776. fi;
  1777. return 1;
  1778. fi;
  1779. if [ -z "${get_version_warning_done}" ]; then
  1780. qeinfo "Found kernel source directory:";
  1781. qeinfo " ${KV_DIR}";
  1782. fi;
  1783. if [ ! -s "${KV_DIR}/Makefile" ]; then
  1784. if [ -z "${get_version_warning_done}" ]; then
  1785. get_version_warning_done=1;
  1786. qeerror "Could not find a Makefile in the kernel source directory.";
  1787. qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources";
  1788. fi;
  1789. return 1;
  1790. fi;
  1791. OUTPUT_DIR="${OUTPUT_DIR:-${KBUILD_OUTPUT}}";
  1792. KERNEL_MAKEFILE="${KV_DIR}/Makefile";
  1793. mkfunc="$(get_makefile_extract_function "${KERNEL_MAKEFILE}")";
  1794. kbuild_output="$(${mkfunc} KBUILD_OUTPUT ${KERNEL_MAKEFILE})";
  1795. OUTPUT_DIR="${OUTPUT_DIR:-${kbuild_output}}";
  1796. KV_MAJOR="$(${mkfunc} VERSION ${KERNEL_MAKEFILE})";
  1797. KV_MINOR="$(${mkfunc} PATCHLEVEL ${KERNEL_MAKEFILE})";
  1798. KV_PATCH="$(${mkfunc} SUBLEVEL ${KERNEL_MAKEFILE})";
  1799. KV_EXTRA="$(${mkfunc} EXTRAVERSION ${KERNEL_MAKEFILE})";
  1800. if [ -z "${KV_MAJOR}" -o -z "${KV_MINOR}" -o -z "${KV_PATCH}" ]; then
  1801. if [ -z "${get_version_warning_done}" ]; then
  1802. get_version_warning_done=1;
  1803. qeerror "Could not detect kernel version.";
  1804. qeerror "Please ensure that ${KERNEL_DIR} points to a complete set of Linux sources.";
  1805. fi;
  1806. return 1;
  1807. fi;
  1808. OUTPUT_DIR="${OUTPUT_DIR:-/lib/modules/${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}/build}";
  1809. [ -h "${OUTPUT_DIR}" ] && KV_OUT_DIR="$(readlink -f ${OUTPUT_DIR})";
  1810. [ -d "${OUTPUT_DIR}" ] && KV_OUT_DIR="${OUTPUT_DIR}";
  1811. if [ -n "${KV_OUT_DIR}" ]; then
  1812. qeinfo "Found kernel object directory:";
  1813. qeinfo " ${KV_OUT_DIR}";
  1814. fi;
  1815. KV_OUT_DIR="${KV_OUT_DIR:-${KV_DIR}}";
  1816. if [ -s "${KV_OUT_DIR}"/include/config/kernel.release ]; then
  1817. KV_LOCAL=$(<"${KV_OUT_DIR}"/include/config/kernel.release);
  1818. else
  1819. if [ -s "${KV_OUT_DIR}"/.kernelrelease ]; then
  1820. KV_LOCAL=$(<"${KV_OUT_DIR}"/.kernelrelease);
  1821. else
  1822. KV_LOCAL=;
  1823. fi;
  1824. fi;
  1825. tmplocal=${KV_LOCAL#${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}};
  1826. if [ "$KV_LOCAL" = "$tmplocal" ]; then
  1827. KV_LOCAL=;
  1828. else
  1829. KV_LOCAL=$tmplocal;
  1830. fi;
  1831. KV_FULL="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${KV_EXTRA}${KV_LOCAL}";
  1832. qeinfo "Found sources for kernel version:";
  1833. qeinfo " ${KV_FULL}";
  1834. return 0
  1835. }
  1836. get_version_component_count ()
  1837. {
  1838. local a=($(get_version_components "${1:-${PV}}"));
  1839. echo ${#a[@]}
  1840. }
  1841. get_version_component_range ()
  1842. {
  1843. eshopts_push -s extglob;
  1844. local c v="${2:-${PV}}" range="${1}" range_start range_end;
  1845. local -i i=-1 j=0;
  1846. c=($(get_all_version_components "${v}"));
  1847. range_start=${range%-*};
  1848. range_start=${range_start:-1};
  1849. range_end=${range#*-};
  1850. range_end=${range_end:-${#c[@]}};
  1851. while ((j < range_start)); do
  1852. i+=1;
  1853. ((i > ${#c[@]})) && eshopts_pop && return;
  1854. [[ -n "${c[i]//[-._]}" ]] && j+=1;
  1855. done;
  1856. while ((j <= range_end)); do
  1857. echo -n ${c[i]};
  1858. ((i > ${#c[@]})) && eshopts_pop && return;
  1859. [[ -n "${c[i]//[-._]}" ]] && j+=1;
  1860. i+=1;
  1861. done;
  1862. eshopts_pop
  1863. }
  1864. get_version_components ()
  1865. {
  1866. local c=$(get_all_version_components "${1:-${PV}}");
  1867. echo ${c//[-._]/ }
  1868. }
  1869. getfilevar ()
  1870. {
  1871. local ERROR basefname basedname myARCH="${ARCH}";
  1872. ERROR=0;
  1873. [ -z "${1}" ] && ERROR=1;
  1874. [ ! -f "${2}" ] && ERROR=1;
  1875. if [ "${ERROR}" = 1 ]; then
  1876. echo -e "\n";
  1877. eerror "getfilevar requires 2 variables, with the second a valid file.";
  1878. eerror " getfilevar <VARIABLE> <CONFIGFILE>";
  1879. else
  1880. basefname="$(basename ${2})";
  1881. basedname="$(dirname ${2})";
  1882. unset ARCH;
  1883. echo -e "e:\\n\\t@echo \$(${1})\\ninclude ${basefname}" | make -C "${basedname}" M="${S}" ${BUILD_FIXES} -s -f - 2> /dev/null;
  1884. ARCH=${myARCH};
  1885. fi
  1886. }
  1887. getfilevar_noexec ()
  1888. {
  1889. local ERROR basefname basedname mycat myARCH="${ARCH}";
  1890. ERROR=0;
  1891. mycat='cat';
  1892. [ -z "${1}" ] && ERROR=1;
  1893. [ ! -f "${2}" ] && ERROR=1;
  1894. [ "${2%.gz}" != "${2}" ] && mycat='zcat';
  1895. if [ "${ERROR}" = 1 ]; then
  1896. echo -e "\n";
  1897. eerror "getfilevar_noexec requires 2 variables, with the second a valid file.";
  1898. eerror " getfilevar_noexec <VARIABLE> <CONFIGFILE>";
  1899. else
  1900. ${mycat} "${2}" | sed -n -e "/^[[:space:]]*${1}[[:space:]]*:\\?=[[:space:]]*\(.*\)\$/{
  1901. s,^[^=]*[[:space:]]*=[[:space:]]*,,g ;
  1902. s,[[:space:]]*\$,,g ;
  1903. p
  1904. }";
  1905. fi
  1906. }
  1907. has_multilib_profile ()
  1908. {
  1909. [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  1910. }
  1911. in_iuse ()
  1912. {
  1913. debug-print-function ${FUNCNAME} "${@}";
  1914. [[ ${#} -eq 1 ]] || die "Invalid args to ${FUNCNAME}()";
  1915. local flag=${1};
  1916. local liuse=(${IUSE});
  1917. has "${flag}" "${liuse[@]#[+-]}"
  1918. }
  1919. is_final_abi ()
  1920. {
  1921. has_multilib_profile || return 0;
  1922. set -- $(get_install_abis);
  1923. local LAST_ABI=$#;
  1924. [[ ${!LAST_ABI} == ${ABI} ]]
  1925. }
  1926. kernel_is ()
  1927. {
  1928. linux-info_get_any_version;
  1929. local operator test value;
  1930. case ${1#-} in
  1931. lt)
  1932. operator="-lt";
  1933. shift
  1934. ;;
  1935. gt)
  1936. operator="-gt";
  1937. shift
  1938. ;;
  1939. le)
  1940. operator="-le";
  1941. shift
  1942. ;;
  1943. ge)
  1944. operator="-ge";
  1945. shift
  1946. ;;
  1947. eq)
  1948. operator="-eq";
  1949. shift
  1950. ;;
  1951. *)
  1952. operator="-eq"
  1953. ;;
  1954. esac;
  1955. [[ $# -gt 3 ]] && die "Error in kernel-2_kernel_is(): too many parameters";
  1956. : $(( test = (KV_MAJOR << 16) + (KV_MINOR << 8) + KV_PATCH ));
  1957. : $(( value = (${1:-${KV_MAJOR}} << 16) + (${2:-${KV_MINOR}} << 8) + ${3:-${KV_PATCH}} ));
  1958. [ ${test} ${operator} ${value} ]
  1959. }
  1960. linux-info_get_any_version ()
  1961. {
  1962. get_version;
  1963. if [[ $? -ne 0 ]]; then
  1964. ewarn "Unable to calculate Linux Kernel version for build, attempting to use running version";
  1965. get_running_version;
  1966. fi
  1967. }
  1968. linux-info_pkg_setup ()
  1969. {
  1970. linux-info_get_any_version;
  1971. if kernel_is 2 4; then
  1972. if [ "$( gcc-major-version )" -eq "4" ]; then
  1973. echo;
  1974. ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with";
  1975. ewarn "linux-2.4 (or modules building against a linux-2.4 kernel)!";
  1976. echo;
  1977. ewarn "Either switch to another gcc-version (via gcc-config) or use a";
  1978. ewarn "newer kernel that supports gcc-4.";
  1979. echo;
  1980. ewarn "Also be aware that bugreports about gcc-4 not working";
  1981. ewarn "with linux-2.4 based ebuilds will be closed as INVALID!";
  1982. echo;
  1983. epause 10;
  1984. fi;
  1985. fi;
  1986. [ -n "${CONFIG_CHECK}" ] && check_extra_config
  1987. }
  1988. linux_chkconfig_builtin ()
  1989. {
  1990. linux_config_qa_check linux_chkconfig_builtin;
  1991. local RESULT;
  1992. local config;
  1993. config="${KV_OUT_DIR}/.config";
  1994. [ ! -f "${config}" ] && config="/proc/config.gz";
  1995. RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")";
  1996. [ "${RESULT}" = "y" ] && return 0 || return 1
  1997. }
  1998. linux_chkconfig_module ()
  1999. {
  2000. linux_config_qa_check linux_chkconfig_module;
  2001. local RESULT;
  2002. local config;
  2003. config="${KV_OUT_DIR}/.config";
  2004. [ ! -f "${config}" ] && config="/proc/config.gz";
  2005. RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")";
  2006. [ "${RESULT}" = "m" ] && return 0 || return 1
  2007. }
  2008. linux_chkconfig_present ()
  2009. {
  2010. linux_config_qa_check linux_chkconfig_present;
  2011. local RESULT;
  2012. local config;
  2013. config="${KV_OUT_DIR}/.config";
  2014. [ ! -f "${config}" ] && config="/proc/config.gz";
  2015. RESULT="$(getfilevar_noexec CONFIG_${1} "${config}")";
  2016. [ "${RESULT}" = "m" -o "${RESULT}" = "y" ] && return 0 || return 1
  2017. }
  2018. linux_chkconfig_string ()
  2019. {
  2020. linux_config_qa_check linux_chkconfig_string;
  2021. local config;
  2022. config="${KV_OUT_DIR}/.config";
  2023. [ ! -f "${config}" ] && config="/proc/config.gz";
  2024. getfilevar_noexec "CONFIG_${1}" "${config}"
  2025. }
  2026. linux_config_bin_exists ()
  2027. {
  2028. export _LINUX_CONFIG_EXISTS_DONE=1;
  2029. [ -s "/proc/config.gz" ]
  2030. }
  2031. linux_config_exists ()
  2032. {
  2033. linux_config_src_exists || linux_config_bin_exists
  2034. }
  2035. linux_config_qa_check ()
  2036. {
  2037. local f="$1";
  2038. if [ -z "${_LINUX_CONFIG_EXISTS_DONE}" ]; then
  2039. ewarn "QA: You called $f before any linux_config_exists!";
  2040. ewarn "QA: The return value of $f will NOT guaranteed later!";
  2041. fi
  2042. }
  2043. linux_config_src_exists ()
  2044. {
  2045. export _LINUX_CONFIG_EXISTS_DONE=1;
  2046. [ -s "${KV_OUT_DIR}/.config" ]
  2047. }
  2048. make_desktop_entry ()
  2049. {
  2050. [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable";
  2051. local exec=${1};
  2052. local name=${2:-${PN}};
  2053. local icon=${3:-${PN}};
  2054. local type=${4};
  2055. local fields=${5};
  2056. if [[ -z ${type} ]]; then
  2057. local catmaj=${CATEGORY%%-*};
  2058. local catmin=${CATEGORY##*-};
  2059. case ${catmaj} in
  2060. app)
  2061. case ${catmin} in
  2062. accessibility)
  2063. type="Utility;Accessibility"
  2064. ;;
  2065. admin)
  2066. type=System
  2067. ;;
  2068. antivirus)
  2069. type=System
  2070. ;;
  2071. arch)
  2072. type="Utility;Archiving"
  2073. ;;
  2074. backup)
  2075. type="Utility;Archiving"
  2076. ;;
  2077. cdr)
  2078. type="AudioVideo;DiscBurning"
  2079. ;;
  2080. dicts)
  2081. type="Office;Dictionary"
  2082. ;;
  2083. doc)
  2084. type=Documentation
  2085. ;;
  2086. editors)
  2087. type="Utility;TextEditor"
  2088. ;;
  2089. emacs)
  2090. type="Development;TextEditor"
  2091. ;;
  2092. emulation)
  2093. type="System;Emulator"
  2094. ;;
  2095. laptop)
  2096. type="Settings;HardwareSettings"
  2097. ;;
  2098. office)
  2099. type=Office
  2100. ;;
  2101. pda)
  2102. type="Office;PDA"
  2103. ;;
  2104. vim)
  2105. type="Development;TextEditor"
  2106. ;;
  2107. xemacs)
  2108. type="Development;TextEditor"
  2109. ;;
  2110. esac
  2111. ;;
  2112. dev)
  2113. type="Development"
  2114. ;;
  2115. games)
  2116. case ${catmin} in
  2117. action | fps)
  2118. type=ActionGame
  2119. ;;
  2120. arcade)
  2121. type=ArcadeGame
  2122. ;;
  2123. board)
  2124. type=BoardGame
  2125. ;;
  2126. emulation)
  2127. type=Emulator
  2128. ;;
  2129. kids)
  2130. type=KidsGame
  2131. ;;
  2132. puzzle)
  2133. type=LogicGame
  2134. ;;
  2135. roguelike)
  2136. type=RolePlaying
  2137. ;;
  2138. rpg)
  2139. type=RolePlaying
  2140. ;;
  2141. simulation)
  2142. type=Simulation
  2143. ;;
  2144. sports)
  2145. type=SportsGame
  2146. ;;
  2147. strategy)
  2148. type=StrategyGame
  2149. ;;
  2150. esac;
  2151. type="Game;${type}"
  2152. ;;
  2153. gnome)
  2154. type="Gnome;GTK"
  2155. ;;
  2156. kde)
  2157. type="KDE;Qt"
  2158. ;;
  2159. mail)
  2160. type="Network;Email"
  2161. ;;
  2162. media)
  2163. case ${catmin} in
  2164. gfx)
  2165. type=Graphics
  2166. ;;
  2167. *)
  2168. case ${catmin} in
  2169. radio)
  2170. type=Tuner
  2171. ;;
  2172. sound)
  2173. type=Audio
  2174. ;;
  2175. tv)
  2176. type=TV
  2177. ;;
  2178. video)
  2179. type=Video
  2180. ;;
  2181. esac;
  2182. type="AudioVideo;${type}"
  2183. ;;
  2184. esac
  2185. ;;
  2186. net)
  2187. case ${catmin} in
  2188. dialup)
  2189. type=Dialup
  2190. ;;
  2191. ftp)
  2192. type=FileTransfer
  2193. ;;
  2194. im)
  2195. type=InstantMessaging
  2196. ;;
  2197. irc)
  2198. type=IRCClient
  2199. ;;
  2200. mail)
  2201. type=Email
  2202. ;;
  2203. news)
  2204. type=News
  2205. ;;
  2206. nntp)
  2207. type=News
  2208. ;;
  2209. p2p)
  2210. type=FileTransfer
  2211. ;;
  2212. voip)
  2213. type=Telephony
  2214. ;;
  2215. esac;
  2216. type="Network;${type}"
  2217. ;;
  2218. sci)
  2219. case ${catmin} in
  2220. astro*)
  2221. type=Astronomy
  2222. ;;
  2223. bio*)
  2224. type=Biology
  2225. ;;
  2226. calc*)
  2227. type=Calculator
  2228. ;;
  2229. chem*)
  2230. type=Chemistry
  2231. ;;
  2232. elec*)
  2233. type=Electronics
  2234. ;;
  2235. geo*)
  2236. type=Geology
  2237. ;;
  2238. math*)
  2239. type=Math
  2240. ;;
  2241. physics)
  2242. type=Physics
  2243. ;;
  2244. visual*)
  2245. type=DataVisualization
  2246. ;;
  2247. esac;
  2248. type="Education;Science;${type}"
  2249. ;;
  2250. sys)
  2251. type="System"
  2252. ;;
  2253. www)
  2254. case ${catmin} in
  2255. client)
  2256. type=WebBrowser
  2257. ;;
  2258. esac;
  2259. type="Network;${type}"
  2260. ;;
  2261. *)
  2262. type=
  2263. ;;
  2264. esac;
  2265. fi;
  2266. if [ "${SLOT}" == "0" ]; then
  2267. local desktop_name="${PN}";
  2268. else
  2269. local desktop_name="${PN}-${SLOT}";
  2270. fi;
  2271. local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop";
  2272. type=${type%;}${type:+;};
  2273. eshopts_push -s extglob;
  2274. if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then
  2275. ewarn "As described in the Icon Theme Specification, icon file extensions are not";
  2276. ewarn "allowed in .desktop files if the value is not an absolute path.";
  2277. icon=${icon%.@(xpm|png|svg)};
  2278. fi;
  2279. eshopts_pop;
  2280. cat > "${desktop}" <<-EOF
  2281. [Desktop Entry]
  2282. Name=${name}
  2283. Type=Application
  2284. Comment=${DESCRIPTION}
  2285. Exec=${exec}
  2286. TryExec=${exec%% *}
  2287. Icon=${icon}
  2288. Categories=${type}
  2289. EOF
  2290.  
  2291. if [[ ${fields:-=} != *=* ]]; then
  2292. ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}";
  2293. fields="Path=${fields}";
  2294. fi;
  2295. [[ -n ${fields} ]] && printf '%b\n' "${fields}" >> "${desktop}";
  2296. ( insinto /usr/share/applications;
  2297. doins "${desktop}" ) || die "installing desktop file failed"
  2298. }
  2299. make_session_desktop ()
  2300. {
  2301. [[ -z $1 ]] && eerror "$0: You must specify the title" && return 1;
  2302. [[ -z $2 ]] && eerror "$0: You must specify the command" && return 1;
  2303. local title=$1;
  2304. local command=$2;
  2305. local desktop=${T}/${wm:-${PN}}.desktop;
  2306. shift 2;
  2307. cat > "${desktop}" <<-EOF
  2308. [Desktop Entry]
  2309. Name=${title}
  2310. Comment=This session logs you into ${title}
  2311. Exec=${command} $*
  2312. TryExec=${command}
  2313. Type=XSession
  2314. EOF
  2315.  
  2316. ( insinto /usr/share/xsessions;
  2317. doins "${desktop}" )
  2318. }
  2319. make_wrapper ()
  2320. {
  2321. local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5;
  2322. local tmpwrapper=$(emktemp);
  2323. cat > "${tmpwrapper}" <<EOF
  2324. #!/bin/sh
  2325. cd "${chdir:-.}"
  2326. if [ -n "${libdir}" ] ; then
  2327. if [ "\${LD_LIBRARY_PATH+set}" = "set" ] ; then
  2328. export LD_LIBRARY_PATH="\${LD_LIBRARY_PATH}:${libdir}"
  2329. else
  2330. export LD_LIBRARY_PATH="${libdir}"
  2331. fi
  2332. fi
  2333. exec ${bin} "\$@"
  2334. EOF
  2335.  
  2336. chmod go+rx "${tmpwrapper}";
  2337. if [[ -n ${path} ]]; then
  2338. ( exeinto "${path}";
  2339. newexe "${tmpwrapper}" "${wrapper}" ) || die;
  2340. else
  2341. newbin "${tmpwrapper}" "${wrapper}" || die;
  2342. fi
  2343. }
  2344. multilib_env ()
  2345. {
  2346. local CTARGET=${1:-${CTARGET}};
  2347. case ${CTARGET} in
  2348. x86_64*)
  2349. export CFLAGS_x86=${CFLAGS_x86--m32};
  2350. export CHOST_x86=${CTARGET/x86_64/i686};
  2351. CHOST_x86=${CHOST_x86/%-gnux32/-gnu};
  2352. export CTARGET_x86=${CHOST_x86};
  2353. if [[ ${SYMLINK_LIB} == "yes" ]]; then
  2354. export LIBDIR_x86="lib32";
  2355. else
  2356. export LIBDIR_x86="lib";
  2357. fi;
  2358. export CFLAGS_amd64=${CFLAGS_amd64--m64};
  2359. export CHOST_amd64=${CTARGET/%-gnux32/-gnu};
  2360. export CTARGET_amd64=${CHOST_amd64};
  2361. export LIBDIR_amd64="lib64";
  2362. export CFLAGS_x32=${CFLAGS_x32--mx32};
  2363. export CHOST_x32=${CTARGET/%-gnu/-gnux32};
  2364. export CTARGET_x32=${CHOST_x32};
  2365. export LIBDIR_x32="libx32";
  2366. case ${CTARGET} in
  2367. *-gnux32)
  2368. : ${MULTILIB_ABIS=x32 amd64 x86};
  2369. : ${DEFAULT_ABI=x32}
  2370. ;;
  2371. *)
  2372. : ${MULTILIB_ABIS=amd64 x86};
  2373. : ${DEFAULT_ABI=amd64}
  2374. ;;
  2375. esac
  2376. ;;
  2377. mips64*)
  2378. export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  2379. export CHOST_o32=${CTARGET/mips64/mips};
  2380. export CTARGET_o32=${CHOST_o32};
  2381. export LIBDIR_o32="lib";
  2382. export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  2383. export CHOST_n32=${CTARGET};
  2384. export CTARGET_n32=${CHOST_n32};
  2385. export LIBDIR_n32="lib32";
  2386. export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  2387. export CHOST_n64=${CTARGET};
  2388. export CTARGET_n64=${CHOST_n64};
  2389. export LIBDIR_n64="lib64";
  2390. : ${MULTILIB_ABIS=n64 n32 o32};
  2391. : ${DEFAULT_ABI=n32}
  2392. ;;
  2393. powerpc64*)
  2394. export CFLAGS_ppc=${CFLAGS_ppc--m32};
  2395. export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  2396. export CTARGET_ppc=${CHOST_ppc};
  2397. export LIBDIR_ppc="lib";
  2398. export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  2399. export CHOST_ppc64=${CTARGET};
  2400. export CTARGET_ppc64=${CHOST_ppc64};
  2401. export LIBDIR_ppc64="lib64";
  2402. : ${MULTILIB_ABIS=ppc64 ppc};
  2403. : ${DEFAULT_ABI=ppc64}
  2404. ;;
  2405. s390x*)
  2406. export CFLAGS_s390=${CFLAGS_s390--m31};
  2407. export CHOST_s390=${CTARGET/s390x/s390};
  2408. export CTARGET_s390=${CHOST_s390};
  2409. export LIBDIR_s390="lib";
  2410. export CFLAGS_s390x=${CFLAGS_s390x--m64};
  2411. export CHOST_s390x=${CTARGET};
  2412. export CTARGET_s390x=${CHOST_s390x};
  2413. export LIBDIR_s390x="lib64";
  2414. : ${MULTILIB_ABIS=s390x s390};
  2415. : ${DEFAULT_ABI=s390x}
  2416. ;;
  2417. sparc*)
  2418. export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
  2419. export CHOST_sparc32=${CTARGET/sparc64/sparc};
  2420. export CTARGET_sparc32=${CHOST_sparc32};
  2421. export LIBDIR_sparc32="lib";
  2422. export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  2423. export CHOST_sparc64=${CTARGET};
  2424. export CTARGET_sparc64=${CHOST_sparc64};
  2425. export LIBDIR_sparc64="lib64";
  2426. : ${MULTILIB_ABIS=sparc64 sparc32};
  2427. : ${DEFAULT_ABI=sparc64}
  2428. ;;
  2429. *)
  2430. : ${MULTILIB_ABIS=default};
  2431. : ${DEFAULT_ABI=default}
  2432. ;;
  2433. esac;
  2434. export MULTILIB_ABIS DEFAULT_ABI
  2435. }
  2436. multilib_toolchain_setup ()
  2437. {
  2438. local v vv;
  2439. export ABI=$1;
  2440. if [[ ${__DEFAULT_ABI_SAVED} == "true" ]]; then
  2441. for v in CHOST CBUILD AS CC CXX LD;
  2442. do
  2443. vv="__abi_saved_${v}";
  2444. export ${v}="${!vv}";
  2445. unset ${vv};
  2446. done;
  2447. unset __DEFAULT_ABI_SAVED;
  2448. fi;
  2449. if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  2450. for v in CHOST CBUILD AS CC CXX LD;
  2451. do
  2452. export __abi_saved_${v}="${!v}";
  2453. done;
  2454. export __DEFAULT_ABI_SAVED="true";
  2455. export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  2456. export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  2457. export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  2458. export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  2459. export CHOST=$(get_abi_CHOST $1);
  2460. export CBUILD=$(get_abi_CHOST $1);
  2461. fi
  2462. }
  2463. newicon ()
  2464. {
  2465. _iconins ${FUNCNAME} "$@"
  2466. }
  2467. newmenu ()
  2468. {
  2469. ( insinto /usr/share/applications;
  2470. newins "$@" )
  2471. }
  2472. number_abis ()
  2473. {
  2474. set -- `get_install_abis`;
  2475. echo $#
  2476. }
  2477. path_exists ()
  2478. {
  2479. local opt=$1;
  2480. [[ ${opt} == -[ao] ]] && shift || opt="-a";
  2481. [[ $# -eq 0 ]] && return 1;
  2482. local p r=0;
  2483. for p in "$@";
  2484. do
  2485. [[ -e ${p} ]];
  2486. : $(( r += $? ));
  2487. done;
  2488. case ${opt} in
  2489. -a)
  2490. return $(( r != 0 ))
  2491. ;;
  2492. -o)
  2493. return $(( r == $# ))
  2494. ;;
  2495. esac
  2496. }
  2497. pkg_nofetch ()
  2498. {
  2499. __eapi0_pkg_nofetch "$@"
  2500. }
  2501. pkg_postinst ()
  2502. {
  2503. einfo;
  2504. elog "Set your hooks in /etc/mkinitcpio.conf accordingly!";
  2505. elog "Missing hooks can lead to an unbootanle system!";
  2506. einfo
  2507. }
  2508. pkg_setup ()
  2509. {
  2510. if kernel_is -lt 2 6 32; then
  2511. eerror "Sorry, your kernel must be 2.6.32-r103 or newer!";
  2512. fi;
  2513. use udev && CONFIG_CHECK+=" ~DEVTMPFS";
  2514. use mdadm && CONFIG_CHECK+=" ~MD ~MD_LINEAR ~MD_RAID0 ~MD_RAID1 ~MD_RAID10 ~MD_RAID456";
  2515. use dmraid && CONFIG_CHECK+=" ~BLK_DEV_DM ~DM_SNAPSHOT ~DM_MIRROR ~DM_RAID ~DM_UEVENT";
  2516. use device-mapper && CONFIG_CHECK+=" ~BLK_DEV_DM ~DM_SNAPSHOT ~DM_UEVENT";
  2517. use cryptsetup && CONFIG_CHECK+=" ~DM_CRYPT";
  2518. linux-info_pkg_setup
  2519. }
  2520. preserve_old_lib ()
  2521. {
  2522. if [[ ${EBUILD_PHASE} != "preinst" ]]; then
  2523. eerror "preserve_old_lib() must be called from pkg_preinst() only";
  2524. die "Invalid preserve_old_lib() usage";
  2525. fi;
  2526. [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]";
  2527. has preserve-libs ${FEATURES} && return 0;
  2528. local lib dir;
  2529. for lib in "$@";
  2530. do
  2531. [[ -e ${ROOT}/${lib} ]] || continue;
  2532. dir=${lib%/*};
  2533. dodir ${dir} || die "dodir ${dir} failed";
  2534. cp "${ROOT}"/${lib} "${D}"/${lib} || die "cp ${lib} failed";
  2535. touch "${D}"/${lib};
  2536. done
  2537. }
  2538. preserve_old_lib_notify ()
  2539. {
  2540. if [[ ${EBUILD_PHASE} != "postinst" ]]; then
  2541. eerror "preserve_old_lib_notify() must be called from pkg_postinst() only";
  2542. die "Invalid preserve_old_lib_notify() usage";
  2543. fi;
  2544. has preserve-libs ${FEATURES} && return 0;
  2545. local lib notice=0;
  2546. for lib in "$@";
  2547. do
  2548. [[ -e ${ROOT}/${lib} ]] || continue;
  2549. if [[ ${notice} -eq 0 ]]; then
  2550. notice=1;
  2551. ewarn "Old versions of installed libraries were detected on your system.";
  2552. ewarn "In order to avoid breaking packages that depend on these old libs,";
  2553. ewarn "the libraries are not being removed. You need to run revdep-rebuild";
  2554. ewarn "in order to remove these old dependencies. If you do not have this";
  2555. ewarn "helper program, simply emerge the 'gentoolkit' package.";
  2556. ewarn;
  2557. fi;
  2558. ewarn " # revdep-rebuild --library '${lib}' && rm '${lib}'";
  2559. done
  2560. }
  2561. prune_libtool_files ()
  2562. {
  2563. debug-print-function ${FUNCNAME} "$@";
  2564. local removing_all opt;
  2565. for opt in "$@";
  2566. do
  2567. case "${opt}" in
  2568. --all)
  2569. removing_all=1
  2570. ;;
  2571. *)
  2572. die "Invalid argument to ${FUNCNAME}(): ${opt}"
  2573. ;;
  2574. esac;
  2575. done;
  2576. local f;
  2577. while IFS= read -r -d '' f; do
  2578. local archivefile=${f/%.la/.a};
  2579. [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed';
  2580. if grep -q '^shouldnotlink=yes$' "${f}"; then
  2581. if [[ -f ${archivefile} ]]; then
  2582. einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)";
  2583. rm -f "${archivefile}";
  2584. fi;
  2585. [[ -n ${removing_all} ]] || continue;
  2586. fi;
  2587. local reason pkgconfig_scanned;
  2588. if [[ -n ${removing_all} ]]; then
  2589. reason='requested';
  2590. else
  2591. if [[ ! -f ${archivefile} ]]; then
  2592. reason='no static archive';
  2593. else
  2594. if [[ ! -n $(sed -nre "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" "${f}") ]]; then
  2595. reason='no libs & flags';
  2596. else
  2597. if [[ ! -n ${pkgconfig_scanned} ]]; then
  2598. local pc_libs=();
  2599. if [[ ! -n ${removing_all} ]]; then
  2600. local f;
  2601. local tf=${T}/prune-lt-files.pc;
  2602. local pkgconf=$(tc-getPKG_CONFIG);
  2603. while IFS= read -r -d '' f; do
  2604. local arg;
  2605. sed -e '/^Requires:/d' "${f}" > "${tf}";
  2606. for arg in $("${pkgconf}" --libs "${tf}");
  2607. do
  2608. [[ ${arg} == -l* ]] && pc_libs+=(lib${arg#-l}.la);
  2609. done;
  2610. done < <(find "${D}" -type f -name '*.pc' -print0);
  2611. rm -f "${tf}";
  2612. fi;
  2613. pkgconfig_scanned=1;
  2614. fi;
  2615. has "${f##*/}" "${pc_libs[@]}" && reason='covered by .pc';
  2616. fi;
  2617. fi;
  2618. fi;
  2619. if [[ -n ${reason} ]]; then
  2620. einfo "Removing unnecessary ${f#${D%/}} (${reason})";
  2621. rm -f "${f}";
  2622. fi;
  2623. done < <(find "${D}" -type f -name '*.la' -print0)
  2624. }
  2625. qeerror ()
  2626. {
  2627. qout eerror "${@}"
  2628. }
  2629. qeinfo ()
  2630. {
  2631. qout einfo "${@}"
  2632. }
  2633. qewarn ()
  2634. {
  2635. qout ewarn "${@}"
  2636. }
  2637. qout ()
  2638. {
  2639. local outputmsg type;
  2640. type=${1};
  2641. shift;
  2642. outputmsg="${@}";
  2643. case "${EBUILD_PHASE}" in
  2644. depend)
  2645. unset outputmsg
  2646. ;;
  2647. clean)
  2648. unset outputmsg
  2649. ;;
  2650. preinst)
  2651. unset outputmsg
  2652. ;;
  2653. esac;
  2654. [ -n "${outputmsg}" ] && ${type} "${outputmsg}"
  2655. }
  2656. replace_all_version_separators ()
  2657. {
  2658. local c=($(get_all_version_components "${2:-${PV}}"));
  2659. c=${c[@]//[-._]/$1};
  2660. echo ${c// }
  2661. }
  2662. replace_version_separator ()
  2663. {
  2664. eshopts_push -s extglob;
  2665. local w c v="${3:-${PV}}";
  2666. declare -i i found=0;
  2667. w=${1:-1};
  2668. c=($(get_all_version_components ${v}));
  2669. if [[ ${w} != *[[:digit:]]* ]]; then
  2670. for ((i = 0; i < ${#c[@]}; i++))
  2671. do
  2672. if [[ ${c[i]} == ${w} ]]; then
  2673. c[i]=${2};
  2674. break;
  2675. fi;
  2676. done;
  2677. else
  2678. for ((i = 0; i < ${#c[@]}; i++))
  2679. do
  2680. if [[ -n "${c[i]//[^-._]}" ]]; then
  2681. found+=1;
  2682. if ((found == w)); then
  2683. c[i]=${2};
  2684. break;
  2685. fi;
  2686. fi;
  2687. done;
  2688. fi;
  2689. c=${c[*]};
  2690. echo ${c// };
  2691. eshopts_pop
  2692. }
  2693. require_configured_kernel ()
  2694. {
  2695. if ! linux_config_src_exists; then
  2696. qeerror "Could not find a usable .config in the kernel source directory.";
  2697. qeerror "Please ensure that ${KERNEL_DIR} points to a configured set of Linux sources.";
  2698. qeerror "If you are using KBUILD_OUTPUT, please set the environment var so that";
  2699. qeerror "it points to the necessary object directory so that it might find .config.";
  2700. die "Kernel not configured; no .config found in ${KV_OUT_DIR}";
  2701. fi
  2702. }
  2703. set_arch_to_kernel ()
  2704. {
  2705. export ARCH=$(tc-arch-kernel)
  2706. }
  2707. set_arch_to_portage ()
  2708. {
  2709. export ARCH=$(tc-arch)
  2710. }
  2711. src_compile ()
  2712. {
  2713. __eapi2_src_compile "$@"
  2714. }
  2715. src_configure ()
  2716. {
  2717. __eapi2_src_configure "$@"
  2718. }
  2719. src_install ()
  2720. {
  2721. emake DESTDIR="${D}" install;
  2722. cd "${WORKDIR}/${PN}-modules-${MY_MODULES_VER}";
  2723. insinto /usr/lib/initcpio/hooks;
  2724. use udev && doins hooks/udev;
  2725. use device-mapper && doins hooks/lvm2;
  2726. if use mdadm; then
  2727. doins hooks/mdadm;
  2728. dosym mdadm /usr/lib/initcpio/hooks/raid;
  2729. fi;
  2730. use dmraid && doins hooks/dmraid;
  2731. use cryptsetup && doins hooks/encrypt;
  2732. insinto /usr/lib/initcpio/install;
  2733. use udev && doins install/udev;
  2734. use device-mapper && doins install/lvm2;
  2735. use mdadm && doins install/{mdadm{,_udev}};
  2736. use dmraid && doins install/dmraid;
  2737. use cryptsetup && doins install/encrypt;
  2738. use pcmcia && doins install/pcmcia;
  2739. if use device-mapper; then
  2740. if use udev; then
  2741. insinto /usr/lib/initcpio/udev/;
  2742. doins udev/11-dm-initramfs.rules;
  2743. fi;
  2744. fi;
  2745. dodir /etc/mkinitcpio.d;
  2746. sed -e "s/KV/${KV_FULL}/g" "${FILESDIR}"/gentoo.preset > "${D}"/etc/mkinitcpio.d/${KV_FULL}.preset || die;
  2747. insinto /usr/lib/modprobe.d;
  2748. doins "${FILESDIR}/usb-load-ehci-first.conf"
  2749. }
  2750. src_prepare ()
  2751. {
  2752. epatch "${FILESDIR}"/${PN}-base-install.patch;
  2753. epatch "${FILESDIR}"/${PN}-consolefont-install.patch;
  2754. epatch "${FILESDIR}"/${PN}-keymap-install.patch;
  2755. cd "${WORKDIR}";
  2756. epatch "${FILESDIR}"/${PN}-udev-install.patch;
  2757. epatch "${FILESDIR}"/${PN}-lvm2-install.patch;
  2758. epatch "${FILESDIR}"/${PN}-mdadm_udev-install.patch;
  2759. epatch "${FILESDIR}"/${PN}-dmraid-install.patch;
  2760. epatch "${FILESDIR}"/${PN}-pcmcia-install.patch;
  2761. epatch "${FILESDIR}"/${PN}-encrypt-install.patch
  2762. }
  2763. src_test ()
  2764. {
  2765. __eapi0_src_test "$@"
  2766. }
  2767. src_unpack ()
  2768. {
  2769. __eapi0_src_unpack "$@"
  2770. }
  2771. strip-linguas ()
  2772. {
  2773. local ls newls nols;
  2774. if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
  2775. local op=$1;
  2776. shift;
  2777. ls=$(find "$1" -name '*.po' -exec basename {} .po ';');
  2778. shift;
  2779. local d f;
  2780. for d in "$@";
  2781. do
  2782. if [[ ${op} == "-u" ]]; then
  2783. newls=${ls};
  2784. else
  2785. newls="";
  2786. fi;
  2787. for f in $(find "$d" -name '*.po' -exec basename {} .po ';');
  2788. do
  2789. if [[ ${op} == "-i" ]]; then
  2790. has ${f} ${ls} && newls="${newls} ${f}";
  2791. else
  2792. has ${f} ${ls} || newls="${newls} ${f}";
  2793. fi;
  2794. done;
  2795. ls=${newls};
  2796. done;
  2797. else
  2798. ls="$@";
  2799. fi;
  2800. nols="";
  2801. newls="";
  2802. for f in ${LINGUAS};
  2803. do
  2804. if has ${f} ${ls}; then
  2805. newls="${newls} ${f}";
  2806. else
  2807. nols="${nols} ${f}";
  2808. fi;
  2809. done;
  2810. [[ -n ${nols} ]] && einfo "Sorry, but ${PN} does not support the LINGUAS:" ${nols};
  2811. export LINGUAS=${newls:1}
  2812. }
  2813. tc-arch ()
  2814. {
  2815. tc-ninja_magic_to_arch portage "$@"
  2816. }
  2817. tc-arch-kernel ()
  2818. {
  2819. tc-ninja_magic_to_arch kern "$@"
  2820. }
  2821. tc-endian ()
  2822. {
  2823. local host=$1;
  2824. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  2825. host=${host%%-*};
  2826. case ${host} in
  2827. aarch64*be)
  2828. echo big
  2829. ;;
  2830. aarch64)
  2831. echo little
  2832. ;;
  2833. alpha*)
  2834. echo big
  2835. ;;
  2836. arm*b*)
  2837. echo big
  2838. ;;
  2839. arm*)
  2840. echo little
  2841. ;;
  2842. cris*)
  2843. echo little
  2844. ;;
  2845. hppa*)
  2846. echo big
  2847. ;;
  2848. i?86*)
  2849. echo little
  2850. ;;
  2851. ia64*)
  2852. echo little
  2853. ;;
  2854. m68*)
  2855. echo big
  2856. ;;
  2857. mips*l*)
  2858. echo little
  2859. ;;
  2860. mips*)
  2861. echo big
  2862. ;;
  2863. powerpc*)
  2864. echo big
  2865. ;;
  2866. s390*)
  2867. echo big
  2868. ;;
  2869. sh*b*)
  2870. echo big
  2871. ;;
  2872. sh*)
  2873. echo little
  2874. ;;
  2875. sparc*)
  2876. echo big
  2877. ;;
  2878. x86_64*)
  2879. echo little
  2880. ;;
  2881. *)
  2882. echo wtf
  2883. ;;
  2884. esac
  2885. }
  2886. tc-env_build ()
  2887. {
  2888. tc-export_build_env;
  2889. 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) "$@"
  2890. }
  2891. tc-export ()
  2892. {
  2893. local var;
  2894. for var in "$@";
  2895. do
  2896. [[ $(type -t tc-get${var}) != "function" ]] && die "tc-export: invalid export variable '${var}'";
  2897. eval tc-get${var} > /dev/null;
  2898. done
  2899. }
  2900. tc-export_build_env ()
  2901. {
  2902. tc-export "$@";
  2903. : ${BUILD_CFLAGS:=-O1 -pipe};
  2904. : ${BUILD_CXXFLAGS:=-O1 -pipe};
  2905. : ${BUILD_CPPFLAGS:=};
  2906. : ${BUILD_LDFLAGS:=};
  2907. export BUILD_{C,CXX,CPP,LD}FLAGS
  2908. }
  2909. tc-getAR ()
  2910. {
  2911. tc-getPROG AR ar "$@"
  2912. }
  2913. tc-getAS ()
  2914. {
  2915. tc-getPROG AS as "$@"
  2916. }
  2917. tc-getBUILD_AR ()
  2918. {
  2919. tc-getBUILD_PROG AR ar "$@"
  2920. }
  2921. tc-getBUILD_AS ()
  2922. {
  2923. tc-getBUILD_PROG AS as "$@"
  2924. }
  2925. tc-getBUILD_CC ()
  2926. {
  2927. tc-getBUILD_PROG CC gcc "$@"
  2928. }
  2929. tc-getBUILD_CPP ()
  2930. {
  2931. tc-getBUILD_PROG CPP cpp "$@"
  2932. }
  2933. tc-getBUILD_CXX ()
  2934. {
  2935. tc-getBUILD_PROG CXX g++ "$@"
  2936. }
  2937. tc-getBUILD_LD ()
  2938. {
  2939. tc-getBUILD_PROG LD ld "$@"
  2940. }
  2941. tc-getBUILD_NM ()
  2942. {
  2943. tc-getBUILD_PROG NM nm "$@"
  2944. }
  2945. tc-getBUILD_OBJCOPY ()
  2946. {
  2947. tc-getBUILD_PROG OBJCOPY objcopy "$@"
  2948. }
  2949. tc-getBUILD_PKG_CONFIG ()
  2950. {
  2951. tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  2952. }
  2953. tc-getBUILD_PROG ()
  2954. {
  2955. _tc-getPROG CBUILD "BUILD_$1 $1_FOR_BUILD HOST$1" "${@:2}"
  2956. }
  2957. tc-getBUILD_RANLIB ()
  2958. {
  2959. tc-getBUILD_PROG RANLIB ranlib "$@"
  2960. }
  2961. tc-getBUILD_STRIP ()
  2962. {
  2963. tc-getBUILD_PROG STRIP strip "$@"
  2964. }
  2965. tc-getCC ()
  2966. {
  2967. tc-getPROG CC gcc "$@"
  2968. }
  2969. tc-getCPP ()
  2970. {
  2971. tc-getPROG CPP cpp "$@"
  2972. }
  2973. tc-getCXX ()
  2974. {
  2975. tc-getPROG CXX g++ "$@"
  2976. }
  2977. tc-getDLLWRAP ()
  2978. {
  2979. tc-getPROG DLLWRAP dllwrap "$@"
  2980. }
  2981. tc-getF77 ()
  2982. {
  2983. tc-getPROG F77 gfortran "$@"
  2984. }
  2985. tc-getFC ()
  2986. {
  2987. tc-getPROG FC gfortran "$@"
  2988. }
  2989. tc-getGCJ ()
  2990. {
  2991. tc-getPROG GCJ gcj "$@"
  2992. }
  2993. tc-getLD ()
  2994. {
  2995. tc-getPROG LD ld "$@"
  2996. }
  2997. tc-getNM ()
  2998. {
  2999. tc-getPROG NM nm "$@"
  3000. }
  3001. tc-getOBJCOPY ()
  3002. {
  3003. tc-getPROG OBJCOPY objcopy "$@"
  3004. }
  3005. tc-getPKG_CONFIG ()
  3006. {
  3007. tc-getPROG PKG_CONFIG pkg-config "$@"
  3008. }
  3009. tc-getPROG ()
  3010. {
  3011. _tc-getPROG CHOST "$@"
  3012. }
  3013. tc-getRANLIB ()
  3014. {
  3015. tc-getPROG RANLIB ranlib "$@"
  3016. }
  3017. tc-getRC ()
  3018. {
  3019. tc-getPROG RC windres "$@"
  3020. }
  3021. tc-getSTRIP ()
  3022. {
  3023. tc-getPROG STRIP strip "$@"
  3024. }
  3025. tc-has-openmp ()
  3026. {
  3027. local base="${T}/test-tc-openmp";
  3028. cat > "${base}.c" <<-EOF
  3029. #include <omp.h>
  3030. int main() {
  3031. int nthreads, tid, ret = 0;
  3032. #pragma omp parallel private(nthreads, tid)
  3033. {
  3034. tid = omp_get_thread_num();
  3035. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  3036. }
  3037. return ret;
  3038. }
  3039. EOF
  3040.  
  3041. $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &>/dev/null;
  3042. local ret=$?;
  3043. rm -f "${base}"*;
  3044. return ${ret}
  3045. }
  3046. tc-has-tls ()
  3047. {
  3048. local base="${T}/test-tc-tls";
  3049. cat > "${base}.c" <<-EOF
  3050. int foo(int *i) {
  3051. static __thread int j = 0;
  3052. return *i ? j : *i;
  3053. }
  3054. EOF
  3055.  
  3056. local flags;
  3057. case $1 in
  3058. -s)
  3059. flags="-S"
  3060. ;;
  3061. -c)
  3062. flags="-c"
  3063. ;;
  3064. -l)
  3065.  
  3066. ;;
  3067. -*)
  3068. die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  3069. ;;
  3070. esac;
  3071. : ${flags:=-fPIC -shared -Wl,-z,defs};
  3072. [[ $1 == -* ]] && shift;
  3073. $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &>/dev/null;
  3074. local ret=$?;
  3075. rm -f "${base}"*;
  3076. return ${ret}
  3077. }
  3078. tc-is-cross-compiler ()
  3079. {
  3080. return $([[ ${CBUILD:-${CHOST}} != ${CHOST} ]])
  3081. }
  3082. tc-is-softfloat ()
  3083. {
  3084. local CTARGET=${CTARGET:-${CHOST}};
  3085. case ${CTARGET} in
  3086. bfin* | h8300*)
  3087. echo "only"
  3088. ;;
  3089. *)
  3090. if [[ ${CTARGET//_/-} == *-softfloat-* ]]; then
  3091. echo "yes";
  3092. else
  3093. if [[ ${CTARGET//_/-} == *-softfp-* ]]; then
  3094. echo "softfp";
  3095. else
  3096. echo "no";
  3097. fi;
  3098. fi
  3099. ;;
  3100. esac
  3101. }
  3102. tc-is-static-only ()
  3103. {
  3104. local host=${CTARGET:-${CHOST}};
  3105. return $([[ ${host} == *-mint* ]])
  3106. }
  3107. tc-ninja_magic_to_arch ()
  3108. {
  3109. function ninj ()
  3110. {
  3111. [[ ${type} == "kern" ]] && echo $1 || echo $2
  3112. };
  3113. local type=$1;
  3114. local host=$2;
  3115. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  3116. case ${host} in
  3117. aarch64*)
  3118. ninj aarch64 arm
  3119. ;;
  3120. alpha*)
  3121. echo alpha
  3122. ;;
  3123. arm*)
  3124. echo arm
  3125. ;;
  3126. avr*)
  3127. ninj avr32 avr
  3128. ;;
  3129. bfin*)
  3130. ninj blackfin bfin
  3131. ;;
  3132. cris*)
  3133. echo cris
  3134. ;;
  3135. hppa*)
  3136. ninj parisc hppa
  3137. ;;
  3138. i?86*)
  3139. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -lt $(KV_to_int 2.6.24) || ${host} == *freebsd* ]]; then
  3140. echo i386;
  3141. else
  3142. echo x86;
  3143. fi
  3144. ;;
  3145. ia64*)
  3146. echo ia64
  3147. ;;
  3148. m68*)
  3149. echo m68k
  3150. ;;
  3151. mips*)
  3152. echo mips
  3153. ;;
  3154. nios2*)
  3155. echo nios2
  3156. ;;
  3157. nios*)
  3158. echo nios
  3159. ;;
  3160. powerpc*)
  3161. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]]; then
  3162. echo powerpc;
  3163. else
  3164. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -eq $(KV_to_int 2.6.15) ]]; then
  3165. if [[ ${host} == powerpc64* ]] || [[ ${PROFILE_ARCH} == "ppc64" ]]; then
  3166. echo powerpc;
  3167. else
  3168. echo ppc;
  3169. fi;
  3170. else
  3171. if [[ ${host} == powerpc64* ]]; then
  3172. echo ppc64;
  3173. else
  3174. if [[ ${PROFILE_ARCH} == "ppc64" ]]; then
  3175. ninj ppc64 ppc;
  3176. else
  3177. echo ppc;
  3178. fi;
  3179. fi;
  3180. fi;
  3181. fi
  3182. ;;
  3183. s390*)
  3184. echo s390
  3185. ;;
  3186. sh64*)
  3187. ninj sh64 sh
  3188. ;;
  3189. sh*)
  3190. echo sh
  3191. ;;
  3192. sparc64*)
  3193. ninj sparc64 sparc
  3194. ;;
  3195. sparc*)
  3196. [[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
  3197. ;;
  3198. vax*)
  3199. echo vax
  3200. ;;
  3201. x86_64*freebsd*)
  3202. echo amd64
  3203. ;;
  3204. x86_64*)
  3205. if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.24) ]]; then
  3206. echo x86;
  3207. else
  3208. ninj x86_64 amd64;
  3209. fi
  3210. ;;
  3211. *)
  3212. echo unknown
  3213. ;;
  3214. esac
  3215. }
  3216. use_if_iuse ()
  3217. {
  3218. in_iuse $1 || return 1;
  3219. use $1
  3220. }
  3221. usex ()
  3222. {
  3223. use "$1" && echo "${2-yes}$4" || echo "${3-no}$5"
  3224. }
  3225. validate_desktop_entries ()
  3226. {
  3227. if [[ -x /usr/bin/desktop-file-validate ]]; then
  3228. einfo "Checking desktop entry validity";
  3229. local directories="";
  3230. for d in /usr/share/applications $@;
  3231. do
  3232. [[ -d ${D}${d} ]] && directories="${directories} ${D}${d}";
  3233. done;
  3234. if [[ -n ${directories} ]]; then
  3235. for FILE in $(find ${directories} -name "*\.desktop" -not -path '*.hidden*' | sort -u 2>/dev/null);
  3236. do
  3237. local temp=$(desktop-file-validate ${FILE} | grep -v "warning:" | sed -e "s|error: ||" -e "s|${FILE}:|--|g" );
  3238. [[ -n $temp ]] && elog ${temp/--/${FILE/${D}/}:};
  3239. done;
  3240. fi;
  3241. echo "";
  3242. else
  3243. einfo "Passing desktop entry validity check. Install dev-util/desktop-file-utils, if you want to help to improve Gentoo.";
  3244. fi
  3245. }
  3246. version_compare ()
  3247. {
  3248. eshopts_push -s extglob;
  3249. local ver_a=${1} ver_b=${2} parts_a parts_b;
  3250. local cur_tok_a cur_tok_b num_part_a num_part_b;
  3251. local -i cur_idx_a=0 cur_idx_b=0 prev_idx_a prev_idx_b;
  3252. parts_a=($(get_all_version_components "${ver_a}" ));
  3253. parts_b=($(get_all_version_components "${ver_b}" ));
  3254. local -i inf_loop=0;
  3255. while true; do
  3256. inf_loop+=1;
  3257. ((inf_loop > 20)) && die "versionator compare bug [numbers, ${ver_a}, ${ver_b}]";
  3258. prev_idx_a=cur_idx_a;
  3259. prev_idx_b=cur_idx_b;
  3260. cur_tok_a=${parts_a[cur_idx_a]};
  3261. cur_tok_b=${parts_b[cur_idx_b]};
  3262. if [[ -n ${cur_tok_a} ]] && [[ -z ${cur_tok_a//[[:digit:]]} ]]; then
  3263. cur_idx_a+=1;
  3264. [[ ${parts_a[cur_idx_a]} == . ]] && cur_idx_a+=1;
  3265. else
  3266. cur_tok_a=;
  3267. fi;
  3268. if [[ -n ${cur_tok_b} ]] && [[ -z ${cur_tok_b//[[:digit:]]} ]]; then
  3269. cur_idx_b+=1;
  3270. [[ ${parts_b[cur_idx_b]} == . ]] && cur_idx_b+=1;
  3271. else
  3272. cur_tok_b=;
  3273. fi;
  3274. [[ -z ${cur_tok_a} && -z ${cur_tok_b} ]] && break;
  3275. [[ -z ${cur_tok_a} ]] && eshopts_pop && return 1;
  3276. [[ -z ${cur_tok_b} ]] && eshopts_pop && return 3;
  3277. if (( prev_idx_a != 0 && prev_idx_b != 0 )) && [[ ${cur_tok_a} == 0* || ${cur_tok_b} == 0* ]]; then
  3278. cur_tok_a=${cur_tok_a%%+(0)};
  3279. cur_tok_b=${cur_tok_b%%+(0)};
  3280. [[ ${cur_tok_a} < ${cur_tok_b} ]] && eshopts_pop && return 1;
  3281. [[ ${cur_tok_a} > ${cur_tok_b} ]] && eshopts_pop && return 3;
  3282. else
  3283. cur_tok_a=${cur_tok_a##+(0)};
  3284. cur_tok_b=${cur_tok_b##+(0)};
  3285. : ${cur_tok_a:=0};
  3286. : ${cur_tok_b:=0};
  3287. ((cur_tok_a < cur_tok_b)) && eshopts_pop && return 1;
  3288. ((cur_tok_a > cur_tok_b)) && eshopts_pop && return 3;
  3289. fi;
  3290. done;
  3291. local letter_a=;
  3292. letter_a=${parts_a[cur_idx_a]};
  3293. if [[ ${#letter_a} -eq 1 && -z ${letter_a/[a-z]} ]]; then
  3294. cur_idx_a+=1;
  3295. else
  3296. letter_a=@;
  3297. fi;
  3298. local letter_b=;
  3299. letter_b=${parts_b[cur_idx_b]};
  3300. if [[ ${#letter_b} -eq 1 && -z ${letter_b/[a-z]} ]]; then
  3301. cur_idx_b+=1;
  3302. else
  3303. letter_b=@;
  3304. fi;
  3305. [[ ${letter_a} < ${letter_b} ]] && eshopts_pop && return 1;
  3306. [[ ${letter_a} > ${letter_b} ]] && eshopts_pop && return 3;
  3307. inf_loop=0;
  3308. while true; do
  3309. inf_loop+=1;
  3310. ((inf_loop > 20)) && die "versionator compare bug [numbers, ${ver_a}, ${ver_b}]";
  3311. [[ ${parts_a[cur_idx_a]} == _ ]] && ((cur_idx_a++));
  3312. [[ ${parts_b[cur_idx_b]} == _ ]] && ((cur_idx_b++));
  3313. cur_tok_a=${parts_a[cur_idx_a]};
  3314. cur_tok_b=${parts_b[cur_idx_b]};
  3315. num_part_a=0;
  3316. num_part_b=0;
  3317. if has ${cur_tok_a%%+([0-9])} "alpha" "beta" "pre" "rc" "p"; then
  3318. cur_idx_a+=1;
  3319. num_part_a=${cur_tok_a##+([a-z])};
  3320. num_part_a=${num_part_a##+(0)};
  3321. : ${num_part_a:=0};
  3322. cur_tok_a=${cur_tok_a%%+([0-9])};
  3323. else
  3324. cur_tok_a=;
  3325. fi;
  3326. if has ${cur_tok_b%%+([0-9])} alpha beta pre rc p; then
  3327. cur_idx_b+=1;
  3328. num_part_b=${cur_tok_b##+([a-z])};
  3329. num_part_b=${num_part_b##+(0)};
  3330. : ${num_part_b:=0};
  3331. cur_tok_b=${cur_tok_b%%+([0-9])};
  3332. else
  3333. cur_tok_b=;
  3334. fi;
  3335. if [[ ${cur_tok_a} != ${cur_tok_b} ]]; then
  3336. local suffix;
  3337. for suffix in alpha beta pre rc "" p;
  3338. do
  3339. [[ ${cur_tok_a} == ${suffix} ]] && eshopts_pop && return 1;
  3340. [[ ${cur_tok_b} == ${suffix} ]] && eshopts_pop && return 3;
  3341. done;
  3342. else
  3343. if [[ -z ${cur_tok_a} && -z ${cur_tok_b} ]]; then
  3344. break;
  3345. else
  3346. ((num_part_a < num_part_b)) && eshopts_pop && return 1;
  3347. ((num_part_a > num_part_b)) && eshopts_pop && return 3;
  3348. fi;
  3349. fi;
  3350. done;
  3351. [[ ${parts_a[cur_idx_a]} == - ]] && ((cur_idx_a++));
  3352. [[ ${parts_b[cur_idx_b]} == - ]] && ((cur_idx_b++));
  3353. if [[ -n ${parts_a[cur_idx_a]/r+([0-9])} || -n ${parts_b[cur_idx_b]/r+([0-9])} ]]; then
  3354. die "versionator compare bug [revisions, ${ver_a}, ${ver_b}]";
  3355. fi;
  3356. num_part_a=${parts_a[cur_idx_a]#r};
  3357. num_part_a=${num_part_a##+(0)};
  3358. : ${num_part_a:=0};
  3359. num_part_b=${parts_b[cur_idx_b]#r};
  3360. num_part_b=${num_part_b##+(0)};
  3361. : ${num_part_b:=0};
  3362. ((num_part_a < num_part_b)) && eshopts_pop && return 1;
  3363. ((num_part_a > num_part_b)) && eshopts_pop && return 3;
  3364. eshopts_pop;
  3365. return 2
  3366. }
  3367. version_format_string ()
  3368. {
  3369. local fstr=$1;
  3370. shift;
  3371. set -- $(get_version_components "$@");
  3372. eval echo "${fstr}"
  3373. }
  3374. version_is_at_least ()
  3375. {
  3376. local want_s="$1" have_s="${2:-${PVR}}" r;
  3377. version_compare "${want_s}" "${have_s}";
  3378. r=$?;
  3379. case $r in
  3380. 1 | 2)
  3381. return 0
  3382. ;;
  3383. 3)
  3384. return 1
  3385. ;;
  3386. *)
  3387. die "versionator compare bug [atleast, ${want_s}, ${have_s}, ${r}]"
  3388. ;;
  3389. esac
  3390. }
  3391. version_sort ()
  3392. {
  3393. eshopts_push -s extglob;
  3394. local items=;
  3395. local -i left=0;
  3396. items=("$@");
  3397. while ((left < ${#items[@]})); do
  3398. local -i lowest_idx=left;
  3399. local -i idx=lowest_idx+1;
  3400. while ((idx < ${#items[@]})); do
  3401. version_compare "${items[lowest_idx]}" "${items[idx]}";
  3402. [[ $? -eq 3 ]] && lowest_idx=idx;
  3403. idx+=1;
  3404. done;
  3405. local tmp=${items[lowest_idx]};
  3406. items[lowest_idx]=${items[left]};
  3407. items[left]=${tmp};
  3408. left+=1;
  3409. done;
  3410. echo ${items[@]};
  3411. eshopts_pop
  3412. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement