1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: eutils.eclass
6 # base-system@gentoo.org
7 # @BLURB: many extra (but common) functions that are used in ebuilds
9 # The eutils eclass contains a suite of functions that complement
10 # the ones that ebuild.sh already contain. The idea is that the functions
11 # are not required in all ebuilds but enough utilize them to have a common
12 # home rather than having multiple ebuilds implementing the same thing.
14 # Due to the nature of this eclass, some functions may have maintainers
15 # different from the overall eclass!
17 if [[ -z ${_EUTILS_ECLASS} ]]; then
20 # implicitly inherited (now split) eclasses
23 # note: we want to remove epunt-cxx retroactively for #566424
24 inherit epatch epunt-cxx estack ltprune multilib toolchain-funcs
31 # Proxy to ewarn for package managers that don't provide eqawarn and use the PM
32 # implementation if available. Reuses PORTAGE_ELOG_CLASSES as set by the dev
34 if ! declare -F eqawarn >/dev/null ; then
36 has qa ${PORTAGE_ELOG_CLASSES} && ewarn "$@"
41 # @FUNCTION: ecvs_clean
42 # @USAGE: [list of dirs]
44 # Remove CVS directories recursiveley. Useful when a source tarball contains
45 # internal CVS directories. Defaults to $PWD.
47 [[ $# -eq 0 ]] && set -- .
48 find "$@" -type d -name 'CVS' -prune -print0 | xargs -0 rm -rf
49 find "$@" -type f -name '.cvs*' -print0 | xargs -0 rm -rf
52 # @FUNCTION: esvn_clean
53 # @USAGE: [list of dirs]
55 # Remove .svn directories recursiveley. Useful when a source tarball contains
56 # internal Subversion directories. Defaults to $PWD.
58 [[ $# -eq 0 ]] && set -- .
59 find "$@" -type d -name '.svn' -prune -print0 | xargs -0 rm -rf
62 # @FUNCTION: egit_clean
63 # @USAGE: [list of dirs]
65 # Remove .git* directories/files recursiveley. Useful when a source tarball
66 # contains internal Git directories. Defaults to $PWD.
68 [[ $# -eq 0 ]] && set -- .
69 find "$@" -type d -name '.git*' -prune -print0 | xargs -0 rm -rf
75 # Cheap replacement for when debianutils (and thus mktemp)
76 # does not exist on the users system.
79 [[ $1 == -d ]] && exe="mkdir" && shift
82 if [[ -z ${topdir} ]] ; then
88 if ! type -P mktemp > /dev/null ; then
89 # system lacks `mktemp` so we have to fake it
91 while [[ -e ${tmp} ]] ; do
92 tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM}
94 ${exe} "${tmp}" || ${exe} -p "${tmp}"
97 # the args here will give slightly wierd names on BSD,
98 # but should produce a usable file on all userlands
99 if [[ ${exe} == "touch" ]] ; then
100 TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX
102 TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX
107 # @FUNCTION: edos2unix
108 # @USAGE: <file> [more files ...]
110 # A handy replacement for dos2unix, recode, fixdos, etc... This allows you
111 # to remove all of these text utilities from DEPEND variables because this
112 # is a script based solution. Just give it a list of files to convert and
113 # they will all be changed from the DOS CRLF format to the UNIX LF format.
115 [[ $# -eq 0 ]] && return 0
116 sed -i 's/\r$//' -- "$@" || die
119 # @FUNCTION: make_desktop_entry
120 # @USAGE: make_desktop_entry(<command>, [name], [icon], [type], [fields])
122 # Make a .desktop file.
125 # binary: what command does the app run with ?
126 # name: the name that will show up in the menu
127 # icon: the icon to use in the menu entry
128 # this can be relative (to /usr/share/pixmaps) or
129 # a full path to an icon
130 # type: what kind of application is this?
132 # https://specifications.freedesktop.org/menu-spec/latest/apa.html
133 # if unset, function tries to guess from package's category
134 # fields: extra fields to append to the desktop file; a printf string
136 make_desktop_entry() {
137 [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable"
140 local name=${2:-${PN}}
141 local icon=${3:-${PN}}
145 if [[ -z ${type} ]] ; then
146 local catmaj=${CATEGORY%%-*}
147 local catmin=${CATEGORY##*-}
151 accessibility) type="Utility;Accessibility";;
153 antivirus) type=System;;
154 arch) type="Utility;Archiving";;
155 backup) type="Utility;Archiving";;
156 cdr) type="AudioVideo;DiscBurning";;
157 dicts) type="Office;Dictionary";;
158 doc) type=Documentation;;
159 editors) type="Utility;TextEditor";;
160 emacs) type="Development;TextEditor";;
161 emulation) type="System;Emulator";;
162 laptop) type="Settings;HardwareSettings";;
163 office) type=Office;;
164 pda) type="Office;PDA";;
165 vim) type="Development;TextEditor";;
166 xemacs) type="Development;TextEditor";;
176 action|fps) type=ActionGame;;
177 arcade) type=ArcadeGame;;
178 board) type=BoardGame;;
179 emulation) type=Emulator;;
180 kids) type=KidsGame;;
181 puzzle) type=LogicGame;;
182 roguelike) type=RolePlaying;;
183 rpg) type=RolePlaying;;
184 simulation) type=Simulation;;
185 sports) type=SportsGame;;
186 strategy) type=StrategyGame;;
215 type="AudioVideo;${type}"
222 dialup) type=Dialup;;
223 ftp) type=FileTransfer;;
224 im) type=InstantMessaging;;
225 irc) type=IRCClient;;
229 p2p) type=FileTransfer;;
230 voip) type=Telephony;;
232 type="Network;${type}"
237 astro*) type=Astronomy;;
239 calc*) type=Calculator;;
240 chem*) type=Chemistry;;
241 elec*) type=Electronics;;
244 physics) type=Physics;;
245 visual*) type=DataVisualization;;
247 type="Education;Science;${type}"
256 client) type=WebBrowser;;
258 type="Network;${type}"
266 local slot=${SLOT%/*}
267 if [[ ${slot} == "0" ]] ; then
268 local desktop_name="${PN}"
270 local desktop_name="${PN}-${slot}"
272 local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop"
273 #local desktop=${T}/${exec%% *:-${desktop_name}}.desktop
275 # Don't append another ";" when a valid category value is provided.
276 type=${type%;}${type:+;}
278 if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then
279 ewarn "As described in the Icon Theme Specification, icon file extensions are not"
280 ewarn "allowed in .desktop files if the value is not an absolute path."
284 cat <<-EOF > "${desktop}"
288 Comment=${DESCRIPTION}
295 if [[ ${fields:-=} != *=* ]] ; then
296 # 5th arg used to be value to Path=
297 ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}"
298 fields="Path=${fields}"
300 [[ -n ${fields} ]] && printf '%b\n' "${fields}" >> "${desktop}"
303 # wrap the env here so that the 'insinto' call
304 # doesn't corrupt the env of the caller
305 insinto /usr/share/applications
307 ) || die "installing desktop file failed"
310 # @FUNCTION: _eutils_eprefix_init
313 # Initialized prefix variables for EAPI<3.
314 _eutils_eprefix_init() {
315 has "${EAPI:-0}" 0 1 2 && : ${ED:=${D}} ${EPREFIX:=} ${EROOT:=${ROOT}}
318 # @FUNCTION: validate_desktop_entries
319 # @USAGE: [directories]
321 # Validate desktop entries using desktop-file-utils
322 validate_desktop_entries() {
323 eqawarn "validate_desktop_entries is deprecated and should be not be used."
324 eqawarn ".desktop file validation is done implicitly by Portage now."
327 if [[ -x "${EPREFIX}"/usr/bin/desktop-file-validate ]] ; then
328 einfo "Checking desktop entry validity"
330 for d in /usr/share/applications $@ ; do
331 [[ -d ${ED}${d} ]] && directories="${directories} ${ED}${d}"
333 if [[ -n ${directories} ]] ; then
334 for FILE in $(find ${directories} -name "*\.desktop" \
335 -not -path '*.hidden*' | sort -u 2>/dev/null)
337 local temp=$(desktop-file-validate ${FILE} | grep -v "warning:" | \
338 sed -e "s|error: ||" -e "s|${FILE}:|--|g" )
339 [[ -n $temp ]] && elog ${temp/--/${FILE/${ED}/}:}
344 einfo "Passing desktop entry validity check. Install dev-util/desktop-file-utils, if you want to help to improve Gentoo."
348 # @FUNCTION: make_session_desktop
349 # @USAGE: <title> <command> [command args...]
351 # Make a GDM/KDM Session file. The title is the file to execute to start the
352 # Window Manager. The command is the name of the Window Manager.
354 # You can set the name of the file via the ${wm} variable.
355 make_session_desktop() {
356 [[ -z $1 ]] && eerror "$0: You must specify the title" && return 1
357 [[ -z $2 ]] && eerror "$0: You must specify the command" && return 1
361 local desktop=${T}/${wm:-${PN}}.desktop
364 cat <<-EOF > "${desktop}"
367 Comment=This session logs you into ${title}
374 # wrap the env here so that the 'insinto' call
375 # doesn't corrupt the env of the caller
376 insinto /usr/share/xsessions
384 # Install the list of .desktop menu files into the appropriate directory
385 # (/usr/share/applications).
388 # wrap the env here so that the 'insinto' call
389 # doesn't corrupt the env of the caller
391 insinto /usr/share/applications
393 if [[ -f ${i} ]] ; then
396 elif [[ -d ${i} ]] ; then
397 for j in "${i}"/*.desktop ; do
410 # @USAGE: <menu> <newname>
412 # Like all other new* functions, install the specified menu as newname.
415 # wrap the env here so that the 'insinto' call
416 # doesn't corrupt the env of the caller
417 insinto /usr/share/applications
422 # @FUNCTION: _iconins
425 # function for use in doicon and newicon
428 # wrap the env here so that the 'insinto' call
429 # doesn't corrupt the env of the caller
430 local funcname=$1; shift
435 while [[ $# -gt 0 ]] ; do
438 if [[ ${2%%x*}x${2%%x*} == "$2" ]] ; then
444 16|22|24|32|36|48|64|72|96|128|192|256|512)
445 size=${size}x${size};;
449 eerror "${size} is an unsupported icon size!"
460 if [[ -z ${size} ]] ; then
461 insinto /usr/share/pixmaps
463 insinto /usr/share/icons/${theme}/${size}/${context}
466 if [[ ${funcname} == doicon ]] ; then
467 if [[ -f $1 ]] ; then
469 elif [[ -d $1 ]] ; then
471 doins "${1}"/*.{png,svg}
474 eerror "${1} is not a valid file/directory!"
483 if [[ ${funcname} == newicon ]] ; then
490 # @USAGE: [options] <icons>
492 # Install icon into the icon directory /usr/share/icons or into
493 # /usr/share/pixmaps if "--size" is not set.
494 # This is useful in conjunction with creating desktop/menu files.
499 # !!! must specify to install into /usr/share/icons/... !!!
500 # size of the icon, like 48 or 48x48
501 # supported icon sizes are:
502 # 16 22 24 32 36 48 64 72 96 128 192 256 512 scalable
506 # defaults to "hicolor"
508 # icons: list of icons
510 # example 1: doicon foobar.png fuqbar.svg suckbar.png
511 # results in: insinto /usr/share/pixmaps
512 # doins foobar.png fuqbar.svg suckbar.png
514 # example 2: doicon -s 48 foobar.png fuqbar.png blobbar.png
515 # results in: insinto /usr/share/icons/hicolor/48x48/apps
516 # doins foobar.png fuqbar.png blobbar.png
519 _iconins ${FUNCNAME} "$@"
523 # @USAGE: [options] <icon> <newname>
525 # Like doicon, install the specified icon as newname.
528 # example 1: newicon foobar.png NEWNAME.png
529 # results in: insinto /usr/share/pixmaps
530 # newins foobar.png NEWNAME.png
532 # example 2: newicon -s 48 foobar.png NEWNAME.png
533 # results in: insinto /usr/share/icons/hicolor/48x48/apps
534 # newins foobar.png NEWNAME.png
537 _iconins ${FUNCNAME} "$@"
540 # @FUNCTION: strip-linguas
541 # @USAGE: [<allow LINGUAS>|<-i|-u> <directories of .po files>]
543 # Make sure that LINGUAS only contains languages that
544 # a package can support. The first form allows you to
545 # specify a list of LINGUAS. The -i builds a list of po
546 # files found in all the directories and uses the
547 # intersection of the lists. The -u builds a list of po
548 # files found in all the directories and uses the union
552 if [[ $1 == "-i" ]] || [[ $1 == "-u" ]] ; then
554 ls=$(find "$1" -name '*.po' -exec basename {} .po ';'); shift
557 if [[ ${op} == "-u" ]] ; then
562 for f in $(find "$d" -name '*.po' -exec basename {} .po ';') ; do
563 if [[ ${op} == "-i" ]] ; then
564 has ${f} ${ls} && newls="${newls} ${f}"
566 has ${f} ${ls} || newls="${newls} ${f}"
577 for f in ${LINGUAS} ; do
578 if has ${f} ${ls} ; then
579 newls="${newls} ${f}"
585 && einfo "Sorry, but ${PN} does not support the LINGUAS:" ${nols}
586 export LINGUAS=${newls:1}
589 # @FUNCTION: preserve_old_lib
590 # @USAGE: <libs to preserve> [more libs]
592 # These functions are useful when a lib in your package changes ABI SONAME.
593 # An example might be from libogg.so.0 to libogg.so.1. Removing libogg.so.0
594 # would break packages that link against it. Most people get around this
595 # by using the portage SLOT mechanism, but that is not always a relevant
596 # solution, so instead you can call this from pkg_preinst. See also the
597 # preserve_old_lib_notify function.
600 if [[ ${EBUILD_PHASE} != "preinst" ]] ; then
601 eerror "preserve_old_lib() must be called from pkg_preinst() only"
602 die "Invalid preserve_old_lib() usage"
604 [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]"
606 # let portage worry about it
607 has preserve-libs ${FEATURES} && return 0
611 [[ -e ${EROOT}/${lib} ]] || continue
613 dodir ${dir} || die "dodir ${dir} failed"
614 cp "${EROOT}"/${lib} "${ED}"/${lib} || die "cp ${lib} failed"
619 # @FUNCTION: preserve_old_lib_notify
620 # @USAGE: <libs to notify> [more libs]
622 # Spit helpful messages about the libraries preserved by preserve_old_lib.
623 preserve_old_lib_notify() {
624 if [[ ${EBUILD_PHASE} != "postinst" ]] ; then
625 eerror "preserve_old_lib_notify() must be called from pkg_postinst() only"
626 die "Invalid preserve_old_lib_notify() usage"
629 # let portage worry about it
630 has preserve-libs ${FEATURES} && return 0
636 [[ -e ${EROOT}/${lib} ]] || continue
637 if [[ ${notice} -eq 0 ]] ; then
639 ewarn "Old versions of installed libraries were detected on your system."
640 ewarn "In order to avoid breaking packages that depend on these old libs,"
641 ewarn "the libraries are not being removed. You need to run revdep-rebuild"
642 ewarn "in order to remove these old dependencies. If you do not have this"
643 ewarn "helper program, simply emerge the 'gentoolkit' package."
646 ewarn " # revdep-rebuild --library '${lib}' && rm '${lib}'"
650 # @FUNCTION: built_with_use
651 # @USAGE: [--hidden] [--missing <action>] [-a|-o] <DEPEND ATOM> <List of USE flags>
654 # Deprecated: Use EAPI 2 use deps in DEPEND|RDEPEND and with has_version calls.
656 # A temporary hack until portage properly supports DEPENDing on USE
657 # flags being enabled in packages. This will check to see if the specified
658 # DEPEND atom was built with the specified list of USE flags. The
659 # --missing option controls the behavior if called on a package that does
660 # not actually support the defined USE flags (aka listed in IUSE).
661 # The default is to abort (call die). The -a and -o flags control
662 # the requirements of the USE flags. They correspond to "and" and "or"
663 # logic. So the -a flag means all listed USE flags must be enabled
664 # while the -o flag means at least one of the listed IUSE flags must be
665 # enabled. The --hidden option is really for internal use only as it
666 # means the USE flag we're checking is hidden expanded, so it won't be found
667 # in IUSE like normal USE flags.
669 # Remember that this function isn't terribly intelligent so order of optional
674 if [[ $1 == "--hidden" ]] ; then
679 local missing_action="die"
680 if [[ $1 == "--missing" ]] ; then
683 case ${missing_action} in
685 *) die "unknown action '${missing_action}'";;
690 [[ ${opt:0:1} = "-" ]] && shift || opt="-a"
692 local PKG=$(best_version $1)
693 [[ -z ${PKG} ]] && die "Unable to resolve $1 to an installed package"
696 local USEFILE=${EROOT}/var/db/pkg/${PKG}/USE
697 local IUSEFILE=${EROOT}/var/db/pkg/${PKG}/IUSE
699 # if the IUSE file doesn't exist, the read will error out, we need to handle
701 if [[ ! -e ${USEFILE} ]] || [[ ! -e ${IUSEFILE} && ${hidden} == "no" ]] ; then
702 case ${missing_action} in
705 die) die "Unable to determine what USE flags $PKG was built with";;
709 if [[ ${hidden} == "no" ]] ; then
710 local IUSE_BUILT=( $(<"${IUSEFILE}") )
711 # Don't check USE_EXPAND #147237
713 for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]') ; do
714 if [[ $1 == ${expand}_* ]] ; then
719 if [[ -n ${expand} ]] ; then
720 if ! has $1 ${IUSE_BUILT[@]#[-+]} ; then
721 case ${missing_action} in
724 die) die "$PKG does not actually support the $1 USE flag!";;
730 local USE_BUILT=$(<${USEFILE})
731 while [[ $# -gt 0 ]] ; do
732 if [[ ${opt} = "-o" ]] ; then
733 has $1 ${USE_BUILT} && return 0
735 has $1 ${USE_BUILT} || return 1
742 # @FUNCTION: make_wrapper
743 # @USAGE: <wrapper> <target> [chdir] [libpaths] [installpath]
745 # Create a shell wrapper script named wrapper in installpath
746 # (defaults to the bindir) to execute target (default of wrapper) by
747 # first optionally setting LD_LIBRARY_PATH to the colon-delimited
748 # libpaths followed by optionally changing directory to chdir.
751 local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5
752 local tmpwrapper=$(emktemp)
756 [[ -n ${chdir} ]] && printf 'cd "%s"\n' "${EPREFIX}${chdir}"
757 if [[ -n ${libdir} ]] ; then
759 if [[ ${CHOST} == *-darwin* ]] ; then
760 var=DYLD_LIBRARY_PATH
765 if [ "\${${var}+set}" = "set" ] ; then
766 export ${var}="\${${var}}:${EPREFIX}${libdir}"
768 export ${var}="${EPREFIX}${libdir}"
772 # We don't want to quote ${bin} so that people can pass complex
773 # things as ${bin} ... "./someprog --args"
774 printf 'exec %s "$@"\n' "${bin/#\//${EPREFIX}/}"
776 chmod go+rx "${tmpwrapper}"
778 if [[ -n ${path} ]] ; then
781 newexe "${tmpwrapper}" "${wrapper}"
784 newbin "${tmpwrapper}" "${wrapper}" || die
788 # @FUNCTION: path_exists
789 # @USAGE: [-a|-o] <paths>
791 # Check if the specified paths exist. Works for all types of paths
792 # (files/dirs/etc...). The -a and -o flags control the requirements
793 # of the paths. They correspond to "and" and "or" logic. So the -a
794 # flag means all the paths must exist while the -o flag means at least
795 # one of the paths must exist. The default behavior is "and". If no
796 # paths are specified, then the return value is "false".
799 [[ ${opt} == -[ao] ]] && shift || opt="-a"
801 # no paths -> return false
802 # same behavior as: [[ -e "" ]]
803 [[ $# -eq 0 ]] && return 1
812 -a) return $(( r != 0 )) ;;
813 -o) return $(( r == $# )) ;;
817 # @FUNCTION: use_if_iuse
820 # Return true if the given flag is in USE and IUSE.
822 # Note that this function should not be used in the global scope.
824 in_iuse $1 || return 1
828 # @FUNCTION: optfeature
829 # @USAGE: <short description> <package atom to match> [other atoms]
831 # Print out a message suggesting an optional package (or packages) which
832 # provide the described functionality
834 # The following snippet would suggest app-misc/foo for optional foo support,
835 # app-misc/bar or app-misc/baz[bar] for optional bar support
836 # and either both app-misc/a and app-misc/b or app-misc/c for alphabet support.
838 # optfeature "foo support" app-misc/foo
839 # optfeature "bar support" app-misc/bar app-misc/baz[bar]
840 # optfeature "alphabet support" "app-misc/a app-misc/b" app-misc/c
843 debug-print-function ${FUNCNAME} "$@"
850 if has_version "${j}"; then
857 if [[ ${flag} -eq 1 ]]; then
861 if [[ ${flag} -eq 0 ]]; then
867 msg="${msg:0: -4} for ${desc}"
874 die "you no longer need this as portage supports ACCEPT_LICENSE itself"
883 # Sleep for the specified number of seconds (default of 5 seconds). Useful when
884 # printing a message the user should probably be reading and often used in
885 # conjunction with the ebeep function. If the EPAUSE_IGNORE env var is set,
886 # don't wait at all. Defined in EAPIs 0 1 and 2.
888 [[ -z ${EPAUSE_IGNORE} ]] && sleep ${1:-5}
892 # @USAGE: [number of beeps]
894 # Issue the specified number of beeps (default of 5 beeps). Useful when
895 # printing a message the user should probably be reading and often used in
896 # conjunction with the epause function. If the EBEEP_IGNORE env var is set,
897 # don't beep at all. Defined in EAPIs 0 1 and 2.
900 if [[ -z ${EBEEP_IGNORE} ]] ; then
901 for ((n=1 ; n <= ${1:-5} ; n++)) ; do
903 sleep 0.1 &>/dev/null ; sleep 0,1 &>/dev/null
914 ewarn "QA Notice: ebeep is not defined in EAPI=${EAPI}, please file a bug at https://bugs.gentoo.org"
918 ewarn "QA Notice: epause is not defined in EAPI=${EAPI}, please file a bug at https://bugs.gentoo.org"
928 # @USAGE: <USE flag> [true output] [false output] [true suffix] [false suffix]
930 # Proxy to declare usex for package managers or EAPIs that do not provide it
931 # and use the package manager implementation when available (i.e. EAPI >= 5).
932 # If USE flag is set, echo [true output][true suffix] (defaults to "yes"),
933 # otherwise echo [false output][false suffix] (defaults to "no").
934 usex() { use "$1" && echo "${2-yes}$4" || echo "${3-no}$5" ; } #382963
942 # @FUNCTION: einstalldocs
944 # Install documentation using DOCS and HTML_DOCS.
946 # If DOCS is declared and non-empty, all files listed in it are
947 # installed. The files must exist, otherwise the function will fail.
948 # In EAPI 4 and subsequent EAPIs DOCS may specify directories as well,
949 # in other EAPIs using directories is unsupported.
951 # If DOCS is not declared, the files matching patterns given
952 # in the default EAPI implementation of src_install will be installed.
953 # If this is undesired, DOCS can be set to empty value to prevent any
954 # documentation from being installed.
956 # If HTML_DOCS is declared and non-empty, all files and/or directories
957 # listed in it are installed as HTML docs (using dohtml).
959 # Both DOCS and HTML_DOCS can either be an array or a whitespace-
960 # separated list. Whenever directories are allowed, '<directory>/.' may
961 # be specified in order to install all files within the directory
962 # without creating a sub-directory in docdir.
964 # Passing additional options to dodoc and dohtml is not supported.
965 # If you needed such a thing, you need to call those helpers explicitly.
967 debug-print-function ${FUNCNAME} "${@}"
970 has ${EAPI} 0 1 2 3 && dodoc_opts=
972 if ! declare -p DOCS &>/dev/null ; then
974 for d in README* ChangeLog AUTHORS NEWS TODO CHANGES \
975 THANKS BUGS FAQ CREDITS CHANGELOG ; do
976 if [[ -s ${d} ]] ; then
980 elif [[ $(declare -p DOCS) == "declare -a"* ]] ; then
981 if [[ ${DOCS[@]} ]] ; then
982 dodoc ${dodoc_opts} "${DOCS[@]}" || die
985 if [[ ${DOCS} ]] ; then
986 dodoc ${dodoc_opts} ${DOCS} || die
990 if [[ $(declare -p HTML_DOCS 2>/dev/null) == "declare -a"* ]] ; then
991 if [[ ${HTML_DOCS[@]} ]] ; then
992 dohtml -r "${HTML_DOCS[@]}" || die
995 if [[ ${HTML_DOCS} ]] ; then
996 dohtml -r ${HTML_DOCS} || die
1003 # @FUNCTION: in_iuse
1006 # Determines whether the given flag is in IUSE. Strips IUSE default prefixes
1009 # Note that this function should not be used in the global scope.
1011 debug-print-function ${FUNCNAME} "${@}"
1012 [[ ${#} -eq 1 ]] || die "Invalid args to ${FUNCNAME}()"
1015 local liuse=( ${IUSE} )
1017 has "${flag}" "${liuse[@]#[+-]}"