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

Diff of /eclass/eutils.eclass

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

Revision 1.383 Revision 1.407
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.383 2012/02/16 00:27:17 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.407 2012/10/11 16:50:53 mgorny 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
16# different from the overall eclass! 16# different from the overall eclass!
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 portability 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]
228# @DESCRIPTION: 226# @DESCRIPTION:
229# Default extension for patches (do not prefix the period yourself). 227# Default extension for patches (do not prefix the period yourself).
230EPATCH_SUFFIX="patch.bz2" 228EPATCH_SUFFIX="patch.bz2"
231# @VARIABLE: EPATCH_OPTS 229# @VARIABLE: EPATCH_OPTS
232# @DESCRIPTION: 230# @DESCRIPTION:
233# Default options for patch: 231# Options to pass to patch. Meant for ebuild/package-specific tweaking
232# such as forcing the patch level (-p#) or fuzz (-F#) factor. Note that
233# for single patch tweaking, you can also pass flags directly to epatch.
234EPATCH_OPTS=""
235# @VARIABLE: EPATCH_COMMON_OPTS
236# @DESCRIPTION:
237# Common options to pass to `patch`. You probably should never need to
238# change these. If you do, please discuss it with base-system first to
239# be sure.
234# @CODE 240# @CODE
235# -g0 - keep RCS, ClearCase, Perforce and SCCS happy #24571 241# -g0 - keep RCS, ClearCase, Perforce and SCCS happy #24571
236# --no-backup-if-mismatch - do not leave .orig files behind 242# --no-backup-if-mismatch - do not leave .orig files behind
237# -E - automatically remove empty files 243# -E - automatically remove empty files
238# @CODE 244# @CODE
239EPATCH_OPTS="-g0 -E --no-backup-if-mismatch" 245EPATCH_COMMON_OPTS="-g0 -E --no-backup-if-mismatch"
240# @VARIABLE: EPATCH_EXCLUDE 246# @VARIABLE: EPATCH_EXCLUDE
241# @DESCRIPTION: 247# @DESCRIPTION:
242# List of patches not to apply. Note this is only file names, 248# List of patches not to apply. Note this is only file names,
243# and not the full path. Globs accepted. 249# and not the full path. Globs accepted.
244EPATCH_EXCLUDE="" 250EPATCH_EXCLUDE=""
255# Only require patches to match EPATCH_SUFFIX rather than the extended 261# Only require patches to match EPATCH_SUFFIX rather than the extended
256# arch naming style. 262# arch naming style.
257EPATCH_FORCE="no" 263EPATCH_FORCE="no"
258 264
259# @FUNCTION: epatch 265# @FUNCTION: epatch
260# @USAGE: [patches] [dirs of patches] 266# @USAGE: [options] [patches] [dirs of patches]
261# @DESCRIPTION: 267# @DESCRIPTION:
262# epatch is designed to greatly simplify the application of patches. It can 268# epatch is designed to greatly simplify the application of patches. It can
263# process patch files directly, or directories of patches. The patches may be 269# process patch files directly, or directories of patches. The patches may be
264# compressed (bzip/gzip/etc...) or plain text. You generally need not specify 270# compressed (bzip/gzip/etc...) or plain text. You generally need not specify
265# the -p option as epatch will automatically attempt -p0 to -p5 until things 271# the -p option as epatch will automatically attempt -p0 to -p5 until things
266# apply successfully. 272# apply successfully.
267# 273#
268# If you do not specify any options, then epatch will default to the directory 274# If you do not specify any patches/dirs, then epatch will default to the
269# specified by EPATCH_SOURCE. 275# directory specified by EPATCH_SOURCE.
276#
277# Any options specified that start with a dash will be passed down to patch
278# for this specific invocation. As soon as an arg w/out a dash is found, then
279# arg processing stops.
270# 280#
271# When processing directories, epatch will apply all patches that match: 281# When processing directories, epatch will apply all patches that match:
272# @CODE 282# @CODE
273# if ${EPATCH_FORCE} != "yes" 283# if ${EPATCH_FORCE} != "yes"
274# ??_${ARCH}_foo.${EPATCH_SUFFIX} 284# ??_${ARCH}_foo.${EPATCH_SUFFIX}
292 echo "${1//?/=}" 302 echo "${1//?/=}"
293 } 303 }
294 304
295 unset P4CONFIG P4PORT P4USER # keep perforce at bay #56402 305 unset P4CONFIG P4PORT P4USER # keep perforce at bay #56402
296 306
307 # First process options. We localize the EPATCH_OPTS setting
308 # from above so that we can pass it on in the loop below with
309 # any additional values the user has specified.
310 local EPATCH_OPTS=( ${EPATCH_OPTS[*]} )
311 while [[ $# -gt 0 ]] ; do
312 case $1 in
313 -*) EPATCH_OPTS+=( "$1" ) ;;
314 *) break ;;
315 esac
316 shift
317 done
318
297 # Let the rest of the code process one user arg at a time -- 319 # Let the rest of the code process one user arg at a time --
298 # each arg may expand into multiple patches, and each arg may 320 # each arg may expand into multiple patches, and each arg may
299 # need to start off with the default global EPATCH_xxx values 321 # need to start off with the default global EPATCH_xxx values
300 if [[ $# -gt 1 ]] ; then 322 if [[ $# -gt 1 ]] ; then
301 local m 323 local m
334 eerror " ${EPATCH_SOURCE}" 356 eerror " ${EPATCH_SOURCE}"
335 eerror " ( ${EPATCH_SOURCE##*/} )" 357 eerror " ( ${EPATCH_SOURCE##*/} )"
336 echo 358 echo
337 die "Cannot find \$EPATCH_SOURCE!" 359 die "Cannot find \$EPATCH_SOURCE!"
338 fi 360 fi
361
362 # Now that we know we're actually going to apply something, merge
363 # all of the patch options back in to a single variable for below.
364 EPATCH_OPTS="${EPATCH_COMMON_OPTS} ${EPATCH_OPTS[*]}"
339 365
340 local PIPE_CMD 366 local PIPE_CMD
341 case ${EPATCH_SUFFIX##*\.} in 367 case ${EPATCH_SUFFIX##*\.} in
342 xz) PIPE_CMD="xz -dc" ;; 368 xz) PIPE_CMD="xz -dc" ;;
343 lzma) PIPE_CMD="lzma -dc" ;; 369 lzma) PIPE_CMD="lzma -dc" ;;
442 fi 468 fi
443 469
444 # Dynamically detect the correct -p# ... i'm lazy, so shoot me :/ 470 # Dynamically detect the correct -p# ... i'm lazy, so shoot me :/
445 local patch_cmd 471 local patch_cmd
446 while [[ ${count} -lt 5 ]] ; do 472 while [[ ${count} -lt 5 ]] ; do
447 patch_cmd="patch -p${count} ${EPATCH_OPTS}" 473 patch_cmd="${BASH_ALIASES[patch]:-patch} -p${count} ${EPATCH_OPTS}"
448 474
449 # Generate some useful debug info ... 475 # Generate some useful debug info ...
450 ( 476 (
451 _epatch_draw_line "***** ${patchname} *****" 477 _epatch_draw_line "***** ${patchname} *****"
452 echo 478 echo
523 549
524# @FUNCTION: epatch_user 550# @FUNCTION: epatch_user
525# @USAGE: 551# @USAGE:
526# @DESCRIPTION: 552# @DESCRIPTION:
527# Applies user-provided patches to the source tree. The patches are 553# Applies user-provided patches to the source tree. The patches are
528# 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
529# 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
530# any more general directories which might exist as well. 556# any more general directories which might exist as well. They must end
557# in ".patch" to be applied.
531# 558#
532# User patches are intended for quick testing of patches without ebuild 559# User patches are intended for quick testing of patches without ebuild
533# modifications, as well as for permanent customizations a user might 560# modifications, as well as for permanent customizations a user might
534# desire. Obviously, there can be no official support for arbitrarily 561# desire. Obviously, there can be no official support for arbitrarily
535# patched ebuilds. So whenever a build log in a bug report mentions that 562# patched ebuilds. So whenever a build log in a bug report mentions that
554 local applied="${T}/epatch_user.log" 581 local applied="${T}/epatch_user.log"
555 [[ -e ${applied} ]] && return 2 582 [[ -e ${applied} ]] && return 2
556 583
557 # don't clobber any EPATCH vars that the parent might want 584 # don't clobber any EPATCH vars that the parent might want
558 local EPATCH_SOURCE check base=${PORTAGE_CONFIGROOT%/}/etc/portage/patches 585 local EPATCH_SOURCE check base=${PORTAGE_CONFIGROOT%/}/etc/portage/patches
559 for check in ${CATEGORY}/{${P}-${PR},${P},${PN}}; do 586 for check in ${CATEGORY}/{${P}-${PR},${P},${PN}}{,:${SLOT}}; do
560 EPATCH_SOURCE=${base}/${CTARGET}/${check} 587 EPATCH_SOURCE=${base}/${CTARGET}/${check}
561 [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${CHOST}/${check} 588 [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${CHOST}/${check}
562 [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${check} 589 [[ -r ${EPATCH_SOURCE} ]] || EPATCH_SOURCE=${base}/${check}
563 if [[ -d ${EPATCH_SOURCE} ]] ; then 590 if [[ -d ${EPATCH_SOURCE} ]] ; then
564 EPATCH_SOURCE=${EPATCH_SOURCE} \ 591 EPATCH_SOURCE=${EPATCH_SOURCE} \
627# Make a .desktop file. 654# Make a .desktop file.
628# 655#
629# @CODE 656# @CODE
630# binary: what command does the app run with ? 657# binary: what command does the app run with ?
631# name: the name that will show up in the menu 658# name: the name that will show up in the menu
632# icon: give your little like a pretty little icon ... 659# icon: the icon to use in the menu entry
633# this can be relative (to /usr/share/pixmaps) or 660# this can be relative (to /usr/share/pixmaps) or
634# a full path to an icon 661# a full path to an icon
635# type: what kind of application is this? 662# type: what kind of application is this?
636# for categories: 663# for categories:
637# http://standards.freedesktop.org/menu-spec/latest/apa.html 664# http://standards.freedesktop.org/menu-spec/latest/apa.html
651 local catmaj=${CATEGORY%%-*} 678 local catmaj=${CATEGORY%%-*}
652 local catmin=${CATEGORY##*-} 679 local catmin=${CATEGORY##*-}
653 case ${catmaj} in 680 case ${catmaj} in
654 app) 681 app)
655 case ${catmin} in 682 case ${catmin} in
656 accessibility) type=Accessibility;; 683 accessibility) type="Utility;Accessibility";;
657 admin) type=System;; 684 admin) type=System;;
658 antivirus) type=System;; 685 antivirus) type=System;;
659 arch) type=Archiving;; 686 arch) type="Utility;Archiving";;
660 backup) type=Archiving;; 687 backup) type="Utility;Archiving";;
661 cdr) type=DiscBurning;; 688 cdr) type="AudioVideo;DiscBurning";;
662 dicts) type=Dictionary;; 689 dicts) type="Office;Dictionary";;
663 doc) type=Documentation;; 690 doc) type=Documentation;;
664 editors) type=TextEditor;; 691 editors) type="Utility;TextEditor";;
665 emacs) type=TextEditor;; 692 emacs) type="Development;TextEditor";;
666 emulation) type=Emulator;; 693 emulation) type="System;Emulator";;
667 laptop) type=HardwareSettings;; 694 laptop) type="Settings;HardwareSettings";;
668 office) type=Office;; 695 office) type=Office;;
669 pda) type=PDA;; 696 pda) type="Office;PDA";;
670 vim) type=TextEditor;; 697 vim) type="Development;TextEditor";;
671 xemacs) type=TextEditor;; 698 xemacs) type="Development;TextEditor";;
672 esac 699 esac
673 ;; 700 ;;
674 701
675 dev) 702 dev)
676 type="Development" 703 type="Development"
913 insinto /usr/share/applications 940 insinto /usr/share/applications
914 newins "$@" 941 newins "$@"
915 ) 942 )
916} 943}
917 944
918# @FUNCTION: doicon 945# @FUNCTION: _iconins
919# @USAGE: <list of icons> 946# @INTERNAL
920# @DESCRIPTION: 947# @DESCRIPTION:
921# Install the list of icons into the icon directory (/usr/share/pixmaps). 948# function for use in doicon and newicon
922# This is useful in conjunction with creating desktop/menu files. 949_iconins() {
923doicon() {
924 ( 950 (
925 # wrap the env here so that the 'insinto' call 951 # wrap the env here so that the 'insinto' call
926 # doesn't corrupt the env of the caller 952 # doesn't corrupt the env of the caller
927 local i j ret 953 local funcname=$1; shift
928 insinto /usr/share/pixmaps 954 local size dir
929 for i in "$@" ; do 955 local context=apps
930 if [[ -f ${i} ]] ; then 956 local theme=hicolor
931 doins "${i}" 957
932 ((ret+=$?)) 958 while [[ $# -gt 0 ]] ; do
933 elif [[ -d ${i} ]] ; then 959 case $1 in
934 for j in "${i}"/*.png ; do 960 -s|--size)
935 doins "${j}" 961 if [[ ${2%%x*}x${2%%x*} == "$2" ]] ; then
936 ((ret+=$?)) 962 size=${2%%x*}
937 done
938 else 963 else
939 ((++ret)) 964 size=${2}
940 fi
941 done
942 exit ${ret}
943 )
944}
945
946# @FUNCTION: newicon
947# @USAGE: <icon> <newname>
948# @DESCRIPTION:
949# Like all other new* functions, install the specified icon as newname.
950newicon() {
951 (
952 # wrap the env here so that the 'insinto' call
953 # doesn't corrupt the env of the caller
954 insinto /usr/share/pixmaps
955 newins "$@"
956 )
957}
958
959# @FUNCTION: cdrom_get_cds
960# @USAGE: <file on cd1> [file on cd2] [file on cd3] [...]
961# @DESCRIPTION:
962# Aquire cd(s) for those lovely cd-based emerges. Yes, this violates
963# the whole 'non-interactive' policy, but damnit I want CD support !
964#
965# With these cdrom functions we handle all the user interaction and
966# standardize everything. All you have to do is call cdrom_get_cds()
967# and when the function returns, you can assume that the cd has been
968# found at CDROM_ROOT.
969#
970# The function will attempt to locate a cd based upon a file that is on
971# the cd. The more files you give this function, the more cds
972# the cdrom functions will handle.
973#
974# Normally the cdrom functions will refer to the cds as 'cd #1', 'cd #2',
975# etc... If you want to give the cds better names, then just export
976# the appropriate CDROM_NAME variable before calling cdrom_get_cds().
977# Use CDROM_NAME for one cd, or CDROM_NAME_# for multiple cds. You can
978# also use the CDROM_NAME_SET bash array.
979#
980# For those multi cd ebuilds, see the cdrom_load_next_cd() function.
981cdrom_get_cds() {
982 # first we figure out how many cds we're dealing with by
983 # the # of files they gave us
984 local cdcnt=0
985 local f=
986 for f in "$@" ; do
987 ((++cdcnt))
988 export CDROM_CHECK_${cdcnt}="$f"
989 done
990 export CDROM_TOTAL_CDS=${cdcnt}
991 export CDROM_CURRENT_CD=1
992
993 # now we see if the user gave use CD_ROOT ...
994 # if they did, let's just believe them that it's correct
995 if [[ -n ${CD_ROOT}${CD_ROOT_1} ]] ; then
996 local var=
997 cdcnt=0
998 while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
999 ((++cdcnt))
1000 var="CD_ROOT_${cdcnt}"
1001 [[ -z ${!var} ]] && var="CD_ROOT"
1002 if [[ -z ${!var} ]] ; then
1003 eerror "You must either use just the CD_ROOT"
1004 eerror "or specify ALL the CD_ROOT_X variables."
1005 eerror "In this case, you will need ${CDROM_TOTAL_CDS} CD_ROOT_X variables."
1006 die "could not locate CD_ROOT_${cdcnt}"
1007 fi 965 fi
1008 done 966 case ${size} in
1009 export CDROM_ROOT=${CD_ROOT_1:-${CD_ROOT}} 967 16|22|24|32|36|48|64|72|96|128|192|256)
1010 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}" 968 size=${size}x${size};;
1011 export CDROM_SET=-1 969 scalable)
1012 for f in ${CDROM_CHECK_1//:/ } ; do 970 ;;
1013 ((++CDROM_SET)) 971 *)
1014 [[ -e ${CDROM_ROOT}/${f} ]] && break 972 eerror "${size} is an unsupported icon size!"
1015 done 973 exit 1;;
1016 export CDROM_MATCH=${f} 974 esac
1017 return 975 shift 2;;
1018 fi 976 -t|--theme)
1019 977 theme=${2}
1020 # User didn't help us out so lets make sure they know they can 978 shift 2;;
1021 # simplify the whole process ... 979 -c|--context)
1022 if [[ ${CDROM_TOTAL_CDS} -eq 1 ]] ; then 980 context=${2}
1023 einfo "This ebuild will need the ${CDROM_NAME:-cdrom for ${PN}}" 981 shift 2;;
1024 echo 982 *)
1025 einfo "If you do not have the CD, but have the data files" 983 if [[ -z ${size} ]] ; then
1026 einfo "mounted somewhere on your filesystem, just export" 984 insinto /usr/share/pixmaps
1027 einfo "the variable CD_ROOT so that it points to the"
1028 einfo "directory containing the files."
1029 echo
1030 einfo "For example:"
1031 einfo "export CD_ROOT=/mnt/cdrom"
1032 echo
1033 else 985 else
1034 if [[ -n ${CDROM_NAME_SET} ]] ; then 986 insinto /usr/share/icons/${theme}/${size}/${context}
1035 # Translate the CDROM_NAME_SET array into CDROM_NAME_#
1036 cdcnt=0
1037 while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
1038 ((++cdcnt))
1039 export CDROM_NAME_${cdcnt}="${CDROM_NAME_SET[$((${cdcnt}-1))]}"
1040 done
1041 fi 987 fi
1042 988
1043 einfo "This package will need access to ${CDROM_TOTAL_CDS} cds." 989 if [[ ${funcname} == doicon ]] ; then
1044 cdcnt=0
1045 while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
1046 ((++cdcnt))
1047 var="CDROM_NAME_${cdcnt}"
1048 [[ ! -z ${!var} ]] && einfo " CD ${cdcnt}: ${!var}"
1049 done
1050 echo
1051 einfo "If you do not have the CDs, but have the data files"
1052 einfo "mounted somewhere on your filesystem, just export"
1053 einfo "the following variables so they point to the right place:"
1054 einfon ""
1055 cdcnt=0
1056 while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]] ; do
1057 ((++cdcnt))
1058 echo -n " CD_ROOT_${cdcnt}"
1059 done
1060 echo
1061 einfo "Or, if you have all the files in the same place, or"
1062 einfo "you only have one cdrom, you can export CD_ROOT"
1063 einfo "and that place will be used as the same data source"
1064 einfo "for all the CDs."
1065 echo
1066 einfo "For example:"
1067 einfo "export CD_ROOT_1=/mnt/cdrom"
1068 echo
1069 fi
1070
1071 export CDROM_SET=""
1072 export CDROM_CURRENT_CD=0
1073 cdrom_load_next_cd
1074}
1075
1076# @FUNCTION: cdrom_load_next_cd
1077# @DESCRIPTION:
1078# Some packages are so big they come on multiple CDs. When you're done reading
1079# files off a CD and want access to the next one, just call this function.
1080# Again, all the messy details of user interaction are taken care of for you.
1081# Once this returns, just read the variable CDROM_ROOT for the location of the
1082# mounted CD. Note that you can only go forward in the CD list, so make sure
1083# you only call this function when you're done using the current CD.
1084cdrom_load_next_cd() {
1085 local var
1086 ((++CDROM_CURRENT_CD))
1087
1088 unset CDROM_ROOT
1089 var=CD_ROOT_${CDROM_CURRENT_CD}
1090 [[ -z ${!var} ]] && var="CD_ROOT"
1091 if [[ -z ${!var} ]] ; then 990 if [[ -f $1 ]] ; then
1092 var="CDROM_CHECK_${CDROM_CURRENT_CD}" 991 doins "${1}"
1093 _cdrom_locate_file_on_cd ${!var} 992 elif [[ -d $1 ]] ; then
1094 else 993 shopt -s nullglob
1095 export CDROM_ROOT=${!var} 994 doins "${1}"/*.{png,svg}
1096 fi 995 shopt -u nullglob
1097
1098 einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}"
1099}
1100
1101# this is used internally by the cdrom_get_cds() and cdrom_load_next_cd()
1102# functions. this should *never* be called from an ebuild.
1103# all it does is try to locate a give file on a cd ... if the cd isn't
1104# found, then a message asking for the user to insert the cdrom will be
1105# displayed and we'll hang out here until:
1106# (1) the file is found on a mounted cdrom
1107# (2) the user hits CTRL+C
1108_cdrom_locate_file_on_cd() {
1109 local mline=""
1110 local showedmsg=0 showjolietmsg=0
1111
1112 while [[ -z ${CDROM_ROOT} ]] ; do
1113 local i=0
1114 local -a cdset=(${*//:/ })
1115 if [[ -n ${CDROM_SET} ]] ; then
1116 cdset=(${cdset[${CDROM_SET}]})
1117 fi
1118
1119 while [[ -n ${cdset[${i}]} ]] ; do
1120 local dir=$(dirname ${cdset[${i}]})
1121 local file=$(basename ${cdset[${i}]})
1122
1123 local point= node= fs= foo=
1124 while read point node fs foo ; do
1125 [[ " cd9660 iso9660 udf " != *" ${fs} "* ]] && \
1126 ! [[ ${fs} == "subfs" && ",${opts}," == *",fs=cdfss,"* ]] \
1127 && continue
1128 point=${point//\040/ }
1129 [[ ! -d ${point}/${dir} ]] && continue
1130 [[ -z $(find "${point}/${dir}" -maxdepth 1 -iname "${file}") ]] && continue
1131 export CDROM_ROOT=${point}
1132 export CDROM_SET=${i}
1133 export CDROM_MATCH=${cdset[${i}]}
1134 return
1135 done <<< "$(get_mounts)"
1136
1137 ((++i))
1138 done
1139
1140 echo
1141 if [[ ${showedmsg} -eq 0 ]] ; then
1142 if [[ ${CDROM_TOTAL_CDS} -eq 1 ]] ; then
1143 if [[ -z ${CDROM_NAME} ]] ; then
1144 einfo "Please insert+mount the cdrom for ${PN} now !"
1145 else 996 else
1146 einfo "Please insert+mount the ${CDROM_NAME} cdrom now !" 997 eerror "${1} is not a valid file/directory!"
998 exit 1
1147 fi 999 fi
1148 else 1000 else
1149 if [[ -z ${CDROM_NAME_1} ]] ; then 1001 break
1150 einfo "Please insert+mount cd #${CDROM_CURRENT_CD} for ${PN} now !"
1151 else
1152 local var="CDROM_NAME_${CDROM_CURRENT_CD}"
1153 einfo "Please insert+mount the ${!var} cdrom now !"
1154 fi
1155 fi 1002 fi
1156 showedmsg=1 1003 shift 1;;
1157 fi 1004 esac
1158 einfo "Press return to scan for the cd again"
1159 einfo "or hit CTRL+C to abort the emerge."
1160 echo
1161 if [[ ${showjolietmsg} -eq 0 ]] ; then
1162 showjolietmsg=1
1163 else
1164 ewarn "If you are having trouble with the detection"
1165 ewarn "of your CD, it is possible that you do not have"
1166 ewarn "Joliet support enabled in your kernel. Please"
1167 ewarn "check that CONFIG_JOLIET is enabled in your kernel."
1168 ebeep 5
1169 fi
1170 read || die "something is screwed with your system"
1171 done 1005 done
1006 if [[ ${funcname} == newicon ]] ; then
1007 newins "$@"
1008 fi
1009 ) || die
1010}
1011
1012# @FUNCTION: doicon
1013# @USAGE: [options] <icons>
1014# @DESCRIPTION:
1015# Install icon into the icon directory /usr/share/icons or into
1016# /usr/share/pixmaps if "--size" is not set.
1017# This is useful in conjunction with creating desktop/menu files.
1018#
1019# @CODE
1020# options:
1021# -s, --size
1022# !!! must specify to install into /usr/share/icons/... !!!
1023# size of the icon, like 48 or 48x48
1024# supported icon sizes are:
1025# 16 22 24 32 36 48 64 72 96 128 192 256 scalable
1026# -c, --context
1027# defaults to "apps"
1028# -t, --theme
1029# defaults to "hicolor"
1030#
1031# icons: list of icons
1032#
1033# example 1: doicon foobar.png fuqbar.svg suckbar.png
1034# results in: insinto /usr/share/pixmaps
1035# doins foobar.png fuqbar.svg suckbar.png
1036#
1037# example 2: doicon -s 48 foobar.png fuqbar.png blobbar.png
1038# results in: insinto /usr/share/icons/hicolor/48x48/apps
1039# doins foobar.png fuqbar.png blobbar.png
1040# @CODE
1041doicon() {
1042 _iconins ${FUNCNAME} "$@"
1043}
1044
1045# @FUNCTION: newicon
1046# @USAGE: [options] <icon> <newname>
1047# @DESCRIPTION:
1048# Like doicon, install the specified icon as newname.
1049#
1050# @CODE
1051# example 1: newicon foobar.png NEWNAME.png
1052# results in: insinto /usr/share/pixmaps
1053# newins foobar.png NEWNAME.png
1054#
1055# example 2: newicon -s 48 foobar.png NEWNAME.png
1056# results in: insinto /usr/share/icons/hicolor/48x48/apps
1057# newins foobar.png NEWNAME.png
1058# @CODE
1059newicon() {
1060 _iconins ${FUNCNAME} "$@"
1172} 1061}
1173 1062
1174# @FUNCTION: strip-linguas 1063# @FUNCTION: strip-linguas
1175# @USAGE: [<allow LINGUAS>|<-i|-u> <directories of .po files>] 1064# @USAGE: [<allow LINGUAS>|<-i|-u> <directories of .po files>]
1176# @DESCRIPTION: 1065# @DESCRIPTION:
1214 else 1103 else
1215 nols="${nols} ${f}" 1104 nols="${nols} ${f}"
1216 fi 1105 fi
1217 done 1106 done
1218 [[ -n ${nols} ]] \ 1107 [[ -n ${nols} ]] \
1219 && ewarn "Sorry, but ${PN} does not support the LINGUAS:" ${nols} 1108 && einfo "Sorry, but ${PN} does not support the LINGUAS:" ${nols}
1220 export LINGUAS=${newls:1} 1109 export LINGUAS=${newls:1}
1221} 1110}
1222 1111
1223# @FUNCTION: preserve_old_lib 1112# @FUNCTION: preserve_old_lib
1224# @USAGE: <libs to preserve> [more libs] 1113# @USAGE: <libs to preserve> [more libs]
1272 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"
1273 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"
1274 ewarn "helper program, simply emerge the 'gentoolkit' package." 1163 ewarn "helper program, simply emerge the 'gentoolkit' package."
1275 ewarn 1164 ewarn
1276 fi 1165 fi
1277 # temp hack for #348634 #357225
1278 [[ ${PN} == "mpfr" ]] && lib=${lib##*/}
1279 ewarn " # revdep-rebuild --library '${lib}'" 1166 ewarn " # revdep-rebuild --library '${lib}' && rm '${lib}'"
1280 done 1167 done
1281 if [[ ${notice} -eq 1 ]] ; then
1282 ewarn
1283 ewarn "Once you've finished running revdep-rebuild, it should be safe to"
1284 ewarn "delete the old libraries. Here is a copy & paste for the lazy:"
1285 for lib in "$@" ; do
1286 ewarn " # rm '${lib}'"
1287 done
1288 fi
1289} 1168}
1290 1169
1291# @FUNCTION: built_with_use 1170# @FUNCTION: built_with_use
1292# @USAGE: [--hidden] [--missing <action>] [-a|-o] <DEPEND ATOM> <List of USE flags> 1171# @USAGE: [--hidden] [--missing <action>] [-a|-o] <DEPEND ATOM> <List of USE flags>
1293# @DESCRIPTION: 1172# @DESCRIPTION:
1490} 1369}
1491 1370
1492# @FUNCTION: usex 1371# @FUNCTION: usex
1493# @USAGE: <USE flag> [true output] [false output] [true suffix] [false suffix] 1372# @USAGE: <USE flag> [true output] [false output] [true suffix] [false suffix]
1494# @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).
1495# 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"),
1496# 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
1497usex() { 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
1382# @FUNCTION: prune_libtool_files
1383# @USAGE: [--all]
1384# @DESCRIPTION:
1385# Locate unnecessary libtool files (.la) and libtool static archives
1386# (.a) and remove them from installation image.
1387#
1388# By default, .la files are removed whenever the static linkage can
1389# either be performed using pkg-config or doesn't introduce additional
1390# flags.
1391#
1392# If '--all' argument is passed, all .la files are removed. This is
1393# usually useful when the package installs plugins and does not use .la
1394# files for loading them.
1395#
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
1398# correspond to plugins.
1399#
1400# Note: if your package installs both static libraries and .pc files,
1401# you need to add pkg-config to your DEPEND.
1402prune_libtool_files() {
1403 debug-print-function ${FUNCNAME} "$@"
1404
1405 local removing_all opt
1406 for opt; do
1407 case "${opt}" in
1408 --all)
1409 removing_all=1
1410 ;;
1411 *)
1412 die "Invalid argument to ${FUNCNAME}(): ${opt}"
1413 esac
1414 done
1415
1416 local f
1417 local queue=()
1418 while IFS= read -r -d '' f; do # for all .la files
1419 local archivefile=${f/%.la/.a}
1420
1421 [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed'
1422
1423 # Remove static libs we're not supposed to link against.
1424 if grep -q '^shouldnotlink=yes$' "${f}"; then
1425 if [[ -f ${archivefile} ]]; then
1426 einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)"
1427 queue+=( "${archivefile}" )
1428 fi
1429
1430 # The .la file may be used by a module loader, so avoid removing it
1431 # unless explicitly requested.
1432 [[ ${removing_all} ]] || continue
1433 fi
1434
1435 # Remove .la files when:
1436 # - user explicitly wants us to remove all .la files,
1437 # - respective static archive doesn't exist,
1438 # - they are covered by a .pc file already,
1439 # - they don't provide any new information (no libs & no flags).
1440 local reason pkgconfig_scanned
1441 if [[ ${removing_all} ]]; then
1442 reason='requested'
1443 elif [[ ! -f ${archivefile} ]]; then
1444 reason='no static archive'
1445 elif [[ ! $(sed -nre \
1446 "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" \
1447 "${f}") ]]; then
1448 reason='no libs & flags'
1449 else
1450 if [[ ! ${pkgconfig_scanned} ]]; then
1451 # Create a list of all .pc-covered libs.
1452 local pc_libs=()
1453 if [[ ! ${removing_all} ]]; then
1454 local f
1455 local tf=${T}/prune-lt-files.pc
1456 local pkgconf=$(tc-getPKG_CONFIG)
1457
1458 while IFS= read -r -d '' f; do # for all .pc files
1459 local arg
1460
1461 sed -e '/^Requires:/d' "${f}" > "${tf}"
1462 for arg in $("${pkgconf}" --libs "${tf}"); do
1463 [[ ${arg} == -l* ]] && pc_libs+=( lib${arg#-l}.la )
1464 done
1465 done < <(find "${D}" -type f -name '*.pc' -print0)
1466
1467 rm -f "${tf}"
1468 fi
1469
1470 pkgconfig_scanned=1
1471 fi
1472
1473 has "${f##*/}" "${pc_libs[@]}" && reason='covered by .pc'
1474 fi
1475
1476 if [[ ${reason} ]]; then
1477 einfo "Removing unnecessary ${f#${D%/}} (${reason})"
1478 queue+=( "${f}" )
1479 fi
1480 done < <(find "${D}" -xtype f -name '*.la' -print0)
1481
1482 if [[ ${queue[@]} ]]; then
1483 rm -f "${queue[@]}"
1484 fi
1485}
1498 1486
1499check_license() { die "you no longer need this as portage supports ACCEPT_LICENSE itself"; } 1487check_license() { die "you no longer need this as portage supports ACCEPT_LICENSE itself"; }
1500 1488
1501fi 1489fi

Legend:
Removed from v.1.383  
changed lines
  Added in v.1.407

  ViewVC Help
Powered by ViewVC 1.1.20