/[gentoo-x86]/eclass/eutils.eclass
Gentoo

Diff of /eclass/eutils.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.396 Revision 1.406
1# Copyright 1999-2012 Gentoo Foundation 1# Copyright 1999-2012 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.396 2012/06/07 05:59:20 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.406 2012/10/07 06:22:01 vapier Exp $
4 4
5# @ECLASS: eutils.eclass 5# @ECLASS: eutils.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# base-system@gentoo.org 7# base-system@gentoo.org
8# @BLURB: many extra (but common) functions that are used in ebuilds 8# @BLURB: many extra (but common) functions that are used in ebuilds
17 17
18if [[ ${___ECLASS_ONCE_EUTILS} != "recur -_+^+_- spank" ]] ; then 18if [[ ${___ECLASS_ONCE_EUTILS} != "recur -_+^+_- spank" ]] ; then
19___ECLASS_ONCE_EUTILS="recur -_+^+_- spank" 19___ECLASS_ONCE_EUTILS="recur -_+^+_- spank"
20 20
21inherit multilib toolchain-funcs user 21inherit multilib toolchain-funcs user
22
23DESCRIPTION="Based on the ${ECLASS} eclass"
24 22
25if has "${EAPI:-0}" 0 1 2; then 23if has "${EAPI:-0}" 0 1 2; then
26 24
27# @FUNCTION: epause 25# @FUNCTION: epause
28# @USAGE: [seconds] 26# @USAGE: [seconds]
551 549
552# @FUNCTION: epatch_user 550# @FUNCTION: epatch_user
553# @USAGE: 551# @USAGE:
554# @DESCRIPTION: 552# @DESCRIPTION:
555# Applies user-provided patches to the source tree. The patches are 553# Applies user-provided patches to the source tree. The patches are
556# taken from /etc/portage/patches/<CATEGORY>/<PF|P|PN>/, where the first 554# taken from /etc/portage/patches/<CATEGORY>/<PF|P|PN>[:SLOT]/, where the first
557# of these three directories to exist will be the one to use, ignoring 555# of these three directories to exist will be the one to use, ignoring
558# any more general directories which might exist as well. They must end 556# any more general directories which might exist as well. They must end
559# in ".patch" to be applied. 557# in ".patch" to be applied.
560# 558#
561# User patches are intended for quick testing of patches without ebuild 559# User patches are intended for quick testing of patches without ebuild
583 local applied="${T}/epatch_user.log" 581 local applied="${T}/epatch_user.log"
584 [[ -e ${applied} ]] && return 2 582 [[ -e ${applied} ]] && return 2
585 583
586 # don't clobber any EPATCH vars that the parent might want 584 # don't clobber any EPATCH vars that the parent might want
587 local EPATCH_SOURCE check base=${PORTAGE_CONFIGROOT%/}/etc/portage/patches 585 local EPATCH_SOURCE check base=${PORTAGE_CONFIGROOT%/}/etc/portage/patches
588 for check in ${CATEGORY}/{${P}-${PR},${P},${PN}}; do 586 for check in ${CATEGORY}/{${P}-${PR},${P},${PN}}{,:${SLOT}}; do
589 EPATCH_SOURCE=${base}/${CTARGET}/${check} 587 EPATCH_SOURCE=${base}/${CTARGET}/${check}
590 [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${CHOST}/${check} 588 [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${CHOST}/${check}
591 [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${check} 589 [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${check}
592 if [[ -d ${EPATCH_SOURCE} ]] ; then 590 if [[ -d ${EPATCH_SOURCE} ]] ; then
593 EPATCH_SOURCE=${EPATCH_SOURCE} \ 591 EPATCH_SOURCE=${EPATCH_SOURCE} \
656# Make a .desktop file. 654# Make a .desktop file.
657# 655#
658# @CODE 656# @CODE
659# binary: what command does the app run with ? 657# binary: what command does the app run with ?
660# name: the name that will show up in the menu 658# name: the name that will show up in the menu
661# icon: give your little like a pretty little icon ... 659# icon: the icon to use in the menu entry
662# this can be relative (to /usr/share/pixmaps) or 660# this can be relative (to /usr/share/pixmaps) or
663# a full path to an icon 661# a full path to an icon
664# type: what kind of application is this? 662# type: what kind of application is this?
665# for categories: 663# for categories:
666# http://standards.freedesktop.org/menu-spec/latest/apa.html 664# http://standards.freedesktop.org/menu-spec/latest/apa.html
1030# -t, --theme 1028# -t, --theme
1031# defaults to "hicolor" 1029# defaults to "hicolor"
1032# 1030#
1033# icons: list of icons 1031# icons: list of icons
1034# 1032#
1035# example 1: doicon foobar.png fuqbar.svg 1033# example 1: doicon foobar.png fuqbar.svg suckbar.png
1036# results in: insinto /usr/share/pixmaps 1034# results in: insinto /usr/share/pixmaps
1037# doins foobar.png fuqbar.svg 1035# doins foobar.png fuqbar.svg suckbar.png
1038# 1036#
1039# example 2: doicon -s 48 foobar.png fuqbar.png 1037# example 2: doicon -s 48 foobar.png fuqbar.png blobbar.png
1040# results in: insinto /usr/share/icons/hicolor/48x48/apps 1038# results in: insinto /usr/share/icons/hicolor/48x48/apps
1041# doins foobar.png fuqbar.png 1039# doins foobar.png fuqbar.png blobbar.png
1042# @CODE 1040# @CODE
1043doicon() { 1041doicon() {
1044 _iconins ${FUNCNAME} "$@" 1042 _iconins ${FUNCNAME} "$@"
1045} 1043}
1046 1044
1163 ewarn "the libraries are not being removed. You need to run revdep-rebuild" 1161 ewarn "the libraries are not being removed. You need to run revdep-rebuild"
1164 ewarn "in order to remove these old dependencies. If you do not have this" 1162 ewarn "in order to remove these old dependencies. If you do not have this"
1165 ewarn "helper program, simply emerge the 'gentoolkit' package." 1163 ewarn "helper program, simply emerge the 'gentoolkit' package."
1166 ewarn 1164 ewarn
1167 fi 1165 fi
1168 # temp hack for #348634 #357225
1169 [[ ${PN} == "mpfr" ]] && lib=${lib##*/}
1170 ewarn " # revdep-rebuild --library '${lib}' && rm '${lib}'" 1166 ewarn " # revdep-rebuild --library '${lib}' && rm '${lib}'"
1171 done 1167 done
1172} 1168}
1173 1169
1174# @FUNCTION: built_with_use 1170# @FUNCTION: built_with_use
1373} 1369}
1374 1370
1375# @FUNCTION: usex 1371# @FUNCTION: usex
1376# @USAGE: <USE flag> [true output] [false output] [true suffix] [false suffix] 1372# @USAGE: <USE flag> [true output] [false output] [true suffix] [false suffix]
1377# @DESCRIPTION: 1373# @DESCRIPTION:
1374# Proxy to declare usex for package managers or EAPIs that do not provide it
1375# and use the package manager implementation when available (i.e. EAPI >= 5).
1378# If USE flag is set, echo [true output][true suffix] (defaults to "yes"), 1376# If USE flag is set, echo [true output][true suffix] (defaults to "yes"),
1379# otherwise echo [false output][false suffix] (defaults to "no"). 1377# otherwise echo [false output][false suffix] (defaults to "no").
1378if has "${EAPI:-0}" 0 1 2 3 4; then
1380usex() { use "$1" && echo "${2-yes}$4" || echo "${3-no}$5" ; } #382963 1379 usex() { use "$1" && echo "${2-yes}$4" || echo "${3-no}$5" ; } #382963
1380fi
1381 1381
1382# @FUNCTION: prune_libtool_files 1382# @FUNCTION: prune_libtool_files
1383# @USAGE: [--all] 1383# @USAGE: [--all]
1384# @DESCRIPTION: 1384# @DESCRIPTION:
1385# Locate unnecessary libtool files (.la) and libtool static archives 1385# Locate unnecessary libtool files (.la) and libtool static archives
1395# 1395#
1396# The .a files are only removed whenever corresponding .la files state 1396# The .a files are only removed whenever corresponding .la files state
1397# that they should not be linked to, i.e. whenever these files 1397# that they should not be linked to, i.e. whenever these files
1398# correspond to plugins. 1398# correspond to plugins.
1399# 1399#
1400# Note: if your package installs any .pc files, this function implicitly 1400# Note: if your package installs both static libraries and .pc files,
1401# calls pkg-config. You should add it to your DEPEND in that case. 1401# you need to add pkg-config to your DEPEND.
1402prune_libtool_files() { 1402prune_libtool_files() {
1403 debug-print-function ${FUNCNAME} "$@" 1403 debug-print-function ${FUNCNAME} "$@"
1404 1404
1405 local removing_all opt 1405 local removing_all opt
1406 for opt; do 1406 for opt; do
1411 *) 1411 *)
1412 die "Invalid argument to ${FUNCNAME}(): ${opt}" 1412 die "Invalid argument to ${FUNCNAME}(): ${opt}"
1413 esac 1413 esac
1414 done 1414 done
1415 1415
1416 # Create a list of all .pc-covered libs.
1417 local pc_libs=()
1418 if [[ ! ${removing_all} ]]; then
1419 local f
1420 local tf=${T}/prune-lt-files.pc
1421 local pkgconf=$(tc-getPKG_CONFIG)
1422
1423 while IFS= read -r -d '' f; do # for all .pc files
1424 local arg
1425
1426 sed -e '/^Requires:/d' "${f}" > "${tf}"
1427 for arg in $("${pkgconf}" --libs "${tf}"); do
1428 [[ ${arg} == -l* ]] && pc_libs+=( lib${arg#-l}.la )
1429 done
1430 done < <(find "${D}" -type f -name '*.pc' -print0)
1431
1432 rm -f "${tf}"
1433 fi
1434
1435 local f 1416 local f
1436 while IFS= read -r -d '' f; do # for all .la files 1417 while IFS= read -r -d '' f; do # for all .la files
1437 local archivefile=${f/%.la/.a} 1418 local archivefile=${f/%.la/.a}
1438 1419
1439 [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed' 1420 [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed'
1440 1421
1441 # Remove static libs we're not supposed to link against. 1422 # Remove static libs we're not supposed to link against.
1442 if grep -q '^shouldnotlink=yes$' "${f}"; then 1423 if grep -q '^shouldnotlink=yes$' "${f}"; then
1424 if [[ -f ${archivefile} ]]; then
1443 einfo "Removing unnecessary ${archivefile#${D%/}}" 1425 einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)"
1444 rm -f "${archivefile}" 1426 rm -f "${archivefile}"
1427 fi
1445 1428
1446 # The .la file may be used by a module loader, so avoid removing it 1429 # The .la file may be used by a module loader, so avoid removing it
1447 # unless explicitly requested. 1430 # unless explicitly requested.
1448 [[ ${removing_all} ]] || continue 1431 [[ ${removing_all} ]] || continue
1449 fi 1432 fi
1451 # Remove .la files when: 1434 # Remove .la files when:
1452 # - user explicitly wants us to remove all .la files, 1435 # - user explicitly wants us to remove all .la files,
1453 # - respective static archive doesn't exist, 1436 # - respective static archive doesn't exist,
1454 # - they are covered by a .pc file already, 1437 # - they are covered by a .pc file already,
1455 # - they don't provide any new information (no libs & no flags). 1438 # - they don't provide any new information (no libs & no flags).
1456 local reason 1439 local reason pkgconfig_scanned
1457 if [[ ${removing_all} ]]; then 1440 if [[ ${removing_all} ]]; then
1458 reason='requested' 1441 reason='requested'
1459 elif [[ ! -f ${archivefile} ]]; then 1442 elif [[ ! -f ${archivefile} ]]; then
1460 reason='no static archive' 1443 reason='no static archive'
1461 elif has "${f##*/}" "${pc_libs[@]}"; then
1462 reason='covered by .pc'
1463 elif [[ ! $(sed -nre \ 1444 elif [[ ! $(sed -nre \
1464 "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" \ 1445 "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" \
1465 "${f}") ]]; then 1446 "${f}") ]]; then
1466 reason='no libs & flags' 1447 reason='no libs & flags'
1448 else
1449 if [[ ! ${pkgconfig_scanned} ]]; then
1450 # Create a list of all .pc-covered libs.
1451 local pc_libs=()
1452 if [[ ! ${removing_all} ]]; then
1453 local f
1454 local tf=${T}/prune-lt-files.pc
1455 local pkgconf=$(tc-getPKG_CONFIG)
1456
1457 while IFS= read -r -d '' f; do # for all .pc files
1458 local arg
1459
1460 sed -e '/^Requires:/d' "${f}" > "${tf}"
1461 for arg in $("${pkgconf}" --libs "${tf}"); do
1462 [[ ${arg} == -l* ]] && pc_libs+=( lib${arg#-l}.la )
1463 done
1464 done < <(find "${D}" -type f -name '*.pc' -print0)
1465
1466 rm -f "${tf}"
1467 fi
1468
1469 pkgconfig_scanned=1
1470 fi
1471
1472 has "${f##*/}" "${pc_libs[@]}" && reason='covered by .pc'
1467 fi 1473 fi
1468 1474
1469 if [[ ${reason} ]]; then 1475 if [[ ${reason} ]]; then
1470 einfo "Removing unnecessary ${f#${D%/}} (${reason})" 1476 einfo "Removing unnecessary ${f#${D%/}} (${reason})"
1471 rm -f "${f}" 1477 rm -f "${f}"

Legend:
Removed from v.1.396  
changed lines
  Added in v.1.406

  ViewVC Help
Powered by ViewVC 1.1.20