Ticket #48: environment

File environment, 105.1 KB (added by jc, 3 years ago)
Line 
1ALSA_CARDS=
2ALSA_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'
3APACHE2_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 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'
4ARCH=arm
5AT_GNUCONF_UPDATE=no
6AT_M4DIR=
7CBUILD=armv4tl-softfloat-linux-gnueabi
8CDEFINE_default=__unix__
9CFLAGS='-Os -march=armv4t -mtune=arm920t'
10CFLAGS_default=
11CHOST=armv4tl-softfloat-linux-gnueabi
12CHOST_default=armv4tl-softfloat-linux-gnueabi
13CROSSCOMPILE_OPTS=
14CTARGET_default=armv4tl-softfloat-linux-gnueabi
15CVS_RSH=ssh
16CXXFLAGS='-Os -march=armv4t -mtune=arm920t'
17DCCC_PATH=/usr/lib/distcc/bin
18DEFAULT_ABI=default
19DEPEND=$'>=dev-util/pkgconfig-0.9.0\n\tmedia-libs/edje  =sys-devel/automake-1.10*\n\t>=sys-devel/autoconf-2.61 sys-devel/libtool dev-util/subversion\n\tnet-misc/rsync'
20DESCRIPTION='The Enlightenment emotion library.'
21DESTTREE=/usr
22DIROPTIONS=-m0755
23E17_PATCHES=
24EAPI=0
25EBUILD_OVERLAY_ECLASSES=' /usr/local/portage/layman/openmoko/trunk/openmoko-target/eclass/enlightenment.eclass /usr/local/portage/layman/openmoko/trunk/openmoko-target/eclass/subversion.eclass'
26ECONF_SOURCE=.
27ELIBC=glibc
28ELIBTOOL_VERSION=2.0.2
29ELT_APPLIED_PATCHES=' 1.5.6'
30ELT_LTMAIN_SH=/var/tmp/portage/media-libs/emotion-20090212/work/emotion/ltmain.sh
31ELT_PATCH_DIR=/usr/portage/eclass/ELT-patches
32EPATCH_EXCLUDE=
33EPATCH_FORCE=no
34EPATCH_MULTI_MSG='Applying various patches (bugfixes/updates) ...'
35EPATCH_OPTS='-g0 -E --no-backup-if-mismatch'
36EPATCH_SINGLE_MSG=
37EPATCH_SOURCE=/var/tmp/portage/media-libs/emotion-20090212/work/patch
38EPATCH_SUFFIX=patch.bz2
39ESCM_LOGDIR=
40ESVN=subversion
41ESVN_BOOTSTRAP=
42ESVN_FETCH_CMD='svn checkout'
43ESVN_OFFLINE=
44ESVN_OPTIONS=
45ESVN_PATCHES=
46ESVN_PROJECT=emotion
47ESVN_REPO_URI=http://svn.enlightenment.org/svn/e/trunk/emotion
48ESVN_RESTRICT=
49ESVN_REVISION=r39002
50ESVN_STORE_DIR=/tmp/distfiles/svn-src
51ESVN_SWITCH_CMD='svn switch'
52ESVN_UPDATE_CMD='svn update'
53ESVN_UP_FREQ=
54EXEOPTIONS=-m0755
55FEATURES='distcc distlocks fixpackages parallel-fetch protect-owned sandbox sfperms strict unmerge-orphans userfetch'
56GCC_SPECS=
57GDK_USE_XFT=1
58HOMEPAGE=http://enlightenment.org
59INHERITED='autotools toolchain-funcs portability multilib subversion libtool enlightenment eutils'
60INPUT_DEVICES=
61INSDESTTREE=
62INSOPTIONS=-m0644
63IUSE='gstreamer xine vlc '
64KERNEL=linux
65KERNEL_ABI=default
66KEYWORDS='~arm ~x86 ~amd64'
67KV=2.6.29
68LCD_DEVICES=
69LDFLAGS='-Wl,-O1 -Wl,-z,now'
70LDFLAGS_default=
71LIBDIR_default=lib
72LIBOPTIONS=-m0644
73LICENSE=GPL-2
74MAIL=/var/mail/root
75MAKEOPTS=-j3
76MULTILIB_ABIS=default
77NETBEANS='apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml'
78OPENGL_PROFILE=xorg-x11
79PDEPEND=' '
80PORTAGE_COMPRESS_EXCLUDE_SUFFIXES='css gif htm[l]? jp[e]?g js pdf png'
81PROFILE_ONLY_VARIABLES='ARCH ELIBC KERNEL USERLAND'
82PROPERTIES=
83PROVIDE=
84RDEPEND=$'=dev-libs/eet-20090212\n\t=x11-libs/evas-20090212\n\t=x11-libs/ecore-20090212\n\t=media-libs/edje-20090212\n\tgstreamer? ( media-libs/gstreamer\n\t\t     media-libs/gst-plugins-base )\n\txine?\t   ( media-libs/xine-lib )\n\tvlc?\t   ( media-video/vlc )  '
85RESTRICT=
86S=/var/tmp/portage/media-libs/emotion-20090212/work/emotion
87SANDBOX_DENY=/etc/ld.so.preload
88SANDBOX_PREDICT=:/dev/console:/dev/random:/proc/self/maps:/usr/lib/python2.0/:/usr/lib/python2.1/:/usr/lib/python2.2/:/usr/lib/python2.3/:/usr/lib/python2.4/:/usr/lib/python2.5/:/usr/lib/python3.0/:/var/db/aliases.db:/var/db/ethers.db:/var/db/group.db:/var/db/hosts.db:/var/db/netgroup.db:/var/db/netmasks.db:/var/db/networks.db:/var/db/passwd.db:/var/db/protocols.db:/var/db/rpc.db:/var/db/services.db:/var/tmp/portage/media-libs/emotion-20090212/homedir/.:
89SANDBOX_READ=:/:/dev/shm:/dev/stdin:/etc/subversion:/var/tmp:
90SANDBOX_WRITE=:/dev/console:/dev/fd:/dev/null:/dev/pts/:/dev/pty:/dev/shm:/dev/shm/ngpt:/dev/stderr:/dev/stdout:/dev/tts:/dev/tty:/dev/vc/:/dev/zero:/proc/self/fd:/tmp:/tmp/:/tmp/distfiles/svn-src:/usr/lib/cf:/usr/lib/conftest:/usr/lib32/cf:/usr/lib32/conftest:/usr/lib64/cf:/usr/lib64/conftest:/usr/tmp/cf:/usr/tmp/conftest:/var/log/scrollkeeper.log:/var/tmp:/var/tmp/:/var/tmp/portage/media-libs/emotion-20090212/homedir/.bash_history:/var/tmp/portage/media-libs/emotion-20090212/homedir/.gconfd/lock::/var/tmp/portage/.distcc
91SLOT=0
92SRC_URI=
93SSH_CLIENT='192.168.2.10 51125 22'
94SSH_CONNECTION='192.168.2.10 51125 192.168.2.15 22'
95SSH_TTY=/dev/pts/0
96SVN_SUBDIR=
97USE='arm elibc_glibc gstreamer kernel_linux userland_GNU'
98USERLAND=GNU
99VIDEO_CARDS=
100WANT_AUTOCONF=2.5
101WANT_AUTOMAKE=1.10
102_=PKG_INSTALL_MASK
103_E_DOCDESTTREE_=
104_E_EXEDESTTREE_=
105___ECLASS_RECUR_MULTILIB=yes
106___ECLASS_RECUR_TOOLCHAIN_FUNCS=yes
107conf=emotion-20090212-r0
108ELT_find_ltmain_sh ()
109{
110    local x=;
111    local dirlist=;
112    for x in $(find "${S}" -name 'ltmain.sh');
113    do
114        dirlist="${dirlist} ${x%/*}";
115    done;
116    echo "${dirlist}"
117}
118ELT_libtool_version ()
119{
120    local ltmain_sh=$1;
121    local version=;
122    version=$(eval $(grep -e '^[[:space:]]*VERSION=' "${ltmain_sh}");                    echo "${VERSION}");
123    [[ -z ${version} ]] && version="0";
124    echo "${version}"
125}
126ELT_try_and_apply_patch ()
127{
128    local ret=0;
129    local file=$1;
130    local patch=$2;
131    if patch -p0 --dry-run "${file}" "${patch}" >&"${T}/elibtool.log"; then
132        einfo "  Applying $(basename "$(dirname "${patch}")")-${patch##*/}.patch ...";
133        patch -p0 -g0 --no-backup-if-mismatch "${file}" "${patch}" >&"${T}/elibtool.log";
134        ret=$?;
135        export ELT_APPLIED_PATCHES="${ELT_APPLIED_PATCHES} ${patch##*/}";
136    else
137        ret=1;
138    fi;
139    return "${ret}"
140}
141ELT_walk_patches ()
142{
143    local x=;
144    local y=;
145    local ret=1;
146    local file=$1;
147    local patch_set=$2;
148    local patch_dir=;
149    local rem_int_dep=$3;
150    if [[ -n ${patch_set} ]]; then
151        if [[ -d ${ELT_PATCH_DIR}/${patch_set} ]]; then
152            patch_dir="${ELT_PATCH_DIR}/${patch_set}";
153        else
154            return "${ret}";
155        fi;
156        for x in $(ls -d "${patch_dir}"/* 2> /dev/null | grep -v 'CVS' | sort -r);
157        do
158            if [[ -n ${x} && -f ${x} ]]; then
159                if [[ -n ${rem_int_dep} ]]; then
160                    sed -e "s|@REM_INT_DEP@|${rem_int_dep}|g" ${x} > "${T}/$$.rem_int_deps.patch";
161                    x="${T}/$$.rem_int_deps.patch";
162                fi;
163                if ELT_try_and_apply_patch "${file}" "${x}"; then
164                    ret=0;
165                    break;
166                fi;
167            fi;
168        done;
169    fi;
170    return "${ret}"
171}
172VER_major ()
173{
174    [[ -z $1 ]] && return 1;
175    local VER=$@;
176    echo "${VER%%[^[:digit:]]*}"
177}
178VER_micro ()
179{
180    [[ -z $1 ]] && return 1;
181    local VER=$@;
182    VER=${VER#*.*.};
183    echo "${VER%%[^[:digit:]]*}"
184}
185VER_minor ()
186{
187    [[ -z $1 ]] && return 1;
188    local VER=$@;
189    VER=${VER#*.};
190    echo "${VER%%[^[:digit:]]*}"
191}
192VER_to_int ()
193{
194    [[ -z $1 ]] && return 1;
195    local VER_MAJOR=$(VER_major "$1");
196    local VER_MINOR=$(VER_minor "$1");
197    local VER_MICRO=$(VER_micro "$1");
198    local VER_int=$(( VER_MAJOR * 65536 + VER_MINOR * 256 + VER_MICRO ));
199    if [[ ${VER_int} -ge 65536 ]]; then
200        echo "${VER_int}";
201        return 0;
202    fi;
203    echo 1;
204    return 1
205}
206_cdrom_locate_file_on_cd ()
207{
208    local mline="";
209    local showedmsg=0 showjolietmsg=0;
210    while [[ -z ${CDROM_ROOT} ]]; do
211        local i=0;
212        local -a cdset=(${*//:/ });
213        if [[ -n ${CDROM_SET} ]]; then
214            cdset=(${cdset[${CDROM_SET}]});
215        fi;
216        while [[ -n ${cdset[${i}]} ]]; do
217            local dir=$(dirname ${cdset[${i}]});
218            local file=$(basename ${cdset[${i}]});
219            local point= node= fs= foo=;
220            while read point node fs foo; do
221                [[ " cd9660 iso9660 udf " != *" ${fs} "* ]] && ! [[ ${fs} == "subfs" && ",${opts}," == *",fs=cdfss,"* ]] && continue;
222                point=${point//\040/ };
223                [[ ! -d ${point}/${dir} ]] && continue;
224                [[ -z $(find "${point}/${dir}" -maxdepth 1 -iname "${file}") ]] && continue;
225                export CDROM_ROOT=${point};
226                export CDROM_SET=${i};
227                export CDROM_MATCH=${cdset[${i}]};
228                return;
229            done <<< "$(get_mounts)";
230            ((++i));
231        done;
232        echo;
233        if [[ ${showedmsg} -eq 0 ]]; then
234            if [[ ${CDROM_TOTAL_CDS} -eq 1 ]]; then
235                if [[ -z ${CDROM_NAME} ]]; then
236                    einfo "Please insert+mount the cdrom for ${PN} now !";
237                else
238                    einfo "Please insert+mount the ${CDROM_NAME} cdrom now !";
239                fi;
240            else
241                if [[ -z ${CDROM_NAME_1} ]]; then
242                    einfo "Please insert+mount cd #${CDROM_CURRENT_CD} for ${PN} now !";
243                else
244                    local var="CDROM_NAME_${CDROM_CURRENT_CD}";
245                    einfo "Please insert+mount the ${!var} cdrom now !";
246                fi;
247            fi;
248            showedmsg=1;
249        fi;
250        einfo "Press return to scan for the cd again";
251        einfo "or hit CTRL+C to abort the emerge.";
252        echo;
253        if [[ ${showjolietmsg} -eq 0 ]]; then
254            showjolietmsg=1;
255        else
256            ewarn "If you are having trouble with the detection";
257            ewarn "of your CD, it is possible that you do not have";
258            ewarn "Joliet support enabled in your kernel.  Please";
259            ewarn "check that CONFIG_JOLIET is enabled in your kernel.";
260            ebeep 5;
261        fi;
262        read || die "something is screwed with your system";
263    done
264}
265_elibtoolize ()
266{
267    local opts;
268    [[ -n $(autotools_check_macro AC_PROG_LIBTOOL AM_PROG_LIBTOOL LT_INIT) ]] || return 0;
269    [[ -f GNUmakefile.am || -f Makefile.am ]] && opts="--automake";
270    [[ "${USERLAND}" == "Darwin" ]] && LIBTOOLIZE="glibtoolize";
271    autotools_run_tool ${LIBTOOLIZE:-libtoolize} "$@" ${opts};
272    eaclocal
273}
274_gcc-install-dir ()
275{
276    echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null |              awk '$1=="install:" {print $2}')"
277}
278_gcc-specs-directive_raw ()
279{
280    local cc=$(tc-getCC);
281    local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
282    ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN     { pspec=""; spec=""; outside=1 }
283$1=="*"directive":"  { pspec=spec; spec=""; outside=0; next }
284        outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
285        spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
286        { spec=spec $0 }
287END     { print spec }';
288    return 0
289}
290_gcc-specs-exists ()
291{
292    [[ -f $(_gcc-install-dir)/$1 ]]
293}
294autotools_check_macro ()
295{
296    [[ -f configure.ac || -f configure.in ]] || return 0;
297    local macro;
298    for macro in "$@";
299    do
300        WANT_AUTOCONF="2.5" autoconf --trace="${macro}" 2> /dev/null;
301    done;
302    return 0
303}
304autotools_get_auxdir ()
305{
306    local auxdir_scan_out;
307    auxdir_scan_out=$(autotools_check_macro "AC_CONFIG_AUX_DIR");
308    [[ -n ${auxdir_scan_out} ]] || return 0;
309    echo ${auxdir_scan_out} | gawk '($0 !~ /^[[:space:]]*(#|dnl)/) {
310                if (match($0, /AC_CONFIG_AUX_DIR:(.*)$/, res))
311                        print res[1]
312        }' | uniq;
313    return 0
314}
315autotools_get_subdirs ()
316{
317    local subdirs_scan_out;
318    subdirs_scan_out=$(autotools_check_macro "AC_CONFIG_SUBDIRS");
319    [[ -n ${subdirs_scan_out} ]] || return 0;
320    echo "${subdirs_scan_out}" | gawk '($0 !~ /^[[:space:]]*(#|dnl)/) {
321                if (match($0, /AC_CONFIG_SUBDIRS:(.*)$/, res))
322                        print res[1]
323        }' | uniq;
324    return 0
325}
326autotools_run_tool ()
327{
328    if [[ ${EBUILD_PHASE} != "unpack" && ${EBUILD_PHASE} != "prepare" ]]; then
329        ewarn "QA Warning: running $1 in ${EBUILD_PHASE} phase";
330    fi;
331    local STDERR_TARGET="${T}/$$.out";
332    local ris;
333    printf "***** $1 *****\n***** $*\n\n" > "${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}";
334    ebegin "Running $@";
335    "$@" >> "${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}" 2>&1;
336    ris=$?;
337    eend ${ris};
338    if [[ ${ris} != 0 && ${NO_FAIL} != 1 ]]; then
339        echo;
340        eerror "Failed Running $1 !";
341        eerror;
342        eerror "Include in your bugreport the contents of:";
343        eerror;
344        eerror "  ${STDERR_TARGET%/*}/$1-${STDERR_TARGET##*/}";
345        echo;
346        die "Failed Running $1 !";
347    fi
348}
349built_with_use ()
350{
351    local hidden="no";
352    if [[ $1 == "--hidden" ]]; then
353        hidden="yes";
354        shift;
355    fi;
356    local missing_action="die";
357    if [[ $1 == "--missing" ]]; then
358        missing_action=$2;
359        shift;
360        shift;
361        case ${missing_action} in
362            true | false | die)
363
364            ;;
365            *)
366                die "unknown action '${missing_action}'"
367            ;;
368        esac;
369    fi;
370    local opt=$1;
371    [[ ${opt:0:1} = "-" ]] && shift || opt="-a";
372    local PKG=$(best_version $1);
373    [[ -z ${PKG} ]] && die "Unable to resolve $1 to an installed package";
374    shift;
375    local USEFILE=${ROOT}/var/db/pkg/${PKG}/USE;
376    local IUSEFILE=${ROOT}/var/db/pkg/${PKG}/IUSE;
377    if [[ ! -e ${USEFILE} ]] || [[ ! -e ${IUSEFILE} && ${hidden} == "no" ]]; then
378        case ${missing_action} in
379            true)
380                return 0
381            ;;
382            false)
383                return 1
384            ;;
385            die)
386                die "Unable to determine what USE flags $PKG was built with"
387            ;;
388        esac;
389    fi;
390    if [[ ${hidden} == "no" ]]; then
391        local IUSE_BUILT=($(<"${IUSEFILE}"));
392        local expand;
393        for expand in $(echo ${USE_EXPAND} | tr '[:upper:]' '[:lower:]');
394        do
395            if [[ $1 == ${expand}_* ]]; then
396                expand="";
397                break;
398            fi;
399        done;
400        if [[ -n ${expand} ]]; then
401            if ! has $1 ${IUSE_BUILT[@]#[-+]}; then
402                case ${missing_action} in
403                    true)
404                        return 0
405                    ;;
406                    false)
407                        return 1
408                    ;;
409                    die)
410                        die "$PKG does not actually support the $1 USE flag!"
411                    ;;
412                esac;
413            fi;
414        fi;
415    fi;
416    local USE_BUILT=$(<${USEFILE});
417    while [[ $# -gt 0 ]]; do
418        if [[ ${opt} = "-o" ]]; then
419            has $1 ${USE_BUILT} && return 0;
420        else
421            has $1 ${USE_BUILT} || return 1;
422        fi;
423        shift;
424    done;
425    [[ ${opt} = "-a" ]]
426}
427cdrom_get_cds ()
428{
429    local cdcnt=0;
430    local f=;
431    for f in "$@";
432    do
433        ((++cdcnt));
434        export CDROM_CHECK_${cdcnt}="$f";
435    done;
436    export CDROM_TOTAL_CDS=${cdcnt};
437    export CDROM_CURRENT_CD=1;
438    if [[ -n ${CD_ROOT}${CD_ROOT_1} ]]; then
439        local var=;
440        cdcnt=0;
441        while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]]; do
442            ((++cdcnt));
443            var="CD_ROOT_${cdcnt}";
444            [[ -z ${!var} ]] && var="CD_ROOT";
445            if [[ -z ${!var} ]]; then
446                eerror "You must either use just the CD_ROOT";
447                eerror "or specify ALL the CD_ROOT_X variables.";
448                eerror "In this case, you will need ${CDROM_TOTAL_CDS} CD_ROOT_X variables.";
449                die "could not locate CD_ROOT_${cdcnt}";
450            fi;
451        done;
452        export CDROM_ROOT=${CD_ROOT_1:-${CD_ROOT}};
453        einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}";
454        export CDROM_SET=-1;
455        for f in ${CDROM_CHECK_1//:/ };
456        do
457            ((++CDROM_SET));
458            [[ -e ${CD_ROOT}/${f} ]] && break;
459        done;
460        export CDROM_MATCH=${f};
461        return;
462    fi;
463    if [[ ${CDROM_TOTAL_CDS} -eq 1 ]]; then
464        einfo "This ebuild will need the ${CDROM_NAME:-cdrom for ${PN}}";
465        echo;
466        einfo "If you do not have the CD, but have the data files";
467        einfo "mounted somewhere on your filesystem, just export";
468        einfo "the variable CD_ROOT so that it points to the";
469        einfo "directory containing the files.";
470        echo;
471        einfo "For example:";
472        einfo "export CD_ROOT=/mnt/cdrom";
473        echo;
474    else
475        if [[ -n ${CDROM_NAME_SET} ]]; then
476            cdcnt=0;
477            while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]]; do
478                ((++cdcnt));
479                export CDROM_NAME_${cdcnt}="${CDROM_NAME_SET[$((${cdcnt}-1))]}";
480            done;
481        fi;
482        einfo "This package will need access to ${CDROM_TOTAL_CDS} cds.";
483        cdcnt=0;
484        while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]]; do
485            ((++cdcnt));
486            var="CDROM_NAME_${cdcnt}";
487            [[ ! -z ${!var} ]] && einfo " CD ${cdcnt}: ${!var}";
488        done;
489        echo;
490        einfo "If you do not have the CDs, but have the data files";
491        einfo "mounted somewhere on your filesystem, just export";
492        einfo "the following variables so they point to the right place:";
493        einfon "";
494        cdcnt=0;
495        while [[ ${cdcnt} -lt ${CDROM_TOTAL_CDS} ]]; do
496            ((++cdcnt));
497            echo -n " CD_ROOT_${cdcnt}";
498        done;
499        echo;
500        einfo "Or, if you have all the files in the same place, or";
501        einfo "you only have one cdrom, you can export CD_ROOT";
502        einfo "and that place will be used as the same data source";
503        einfo "for all the CDs.";
504        echo;
505        einfo "For example:";
506        einfo "export CD_ROOT_1=/mnt/cdrom";
507        echo;
508    fi;
509    export CDROM_SET="";
510    export CDROM_CURRENT_CD=0;
511    cdrom_load_next_cd
512}
513cdrom_load_next_cd ()
514{
515    local var;
516    ((++CDROM_CURRENT_CD));
517    unset CDROM_ROOT;
518    var=CD_ROOT_${CDROM_CURRENT_CD};
519    [[ -z ${!var} ]] && var="CD_ROOT";
520    if [[ -z ${!var} ]]; then
521        var="CDROM_CHECK_${CDROM_CURRENT_CD}";
522        _cdrom_locate_file_on_cd ${!var};
523    else
524        export CDROM_ROOT=${!var};
525    fi;
526    einfo "Found CD #${CDROM_CURRENT_CD} root at ${CDROM_ROOT}"
527}
528check_license ()
529{
530    local lic=$1;
531    if [ -z "${lic}" ]; then
532        lic="${PORTDIR}/licenses/${LICENSE}";
533    else
534        if [ -e "${PORTDIR}/licenses/${lic}" ]; then
535            lic="${PORTDIR}/licenses/${lic}";
536        else
537            if [ -e "${PWD}/${lic}" ]; then
538                lic="${PWD}/${lic}";
539            else
540                if [ -e "${lic}" ]; then
541                    lic="${lic}";
542                fi;
543            fi;
544        fi;
545    fi;
546    [ ! -f "${lic}" ] && die "Could not find requested license ${lic}";
547    local l="`basename ${lic}`";
548    local shopts=$-;
549    local alic;
550    set -o noglob;
551    for alic in ${ACCEPT_LICENSE};
552    do
553        if [[ ${alic} == ${l} ]]; then
554            set +o noglob;
555            set -${shopts};
556            return 0;
557        fi;
558    done;
559    set +o noglob;
560    set -$shopts;
561    local licmsg=$(emktemp);
562    cat > ${licmsg}  <<-EOF
563**********************************************************
564The following license outlines the terms of use of this
565package.  You MUST accept this license for installation to
566continue.  When you are done viewing, hit 'q'.  If you
567CTRL+C out of this, the install will not run!
568**********************************************************
569
570EOF
571
572    cat ${lic} >> ${licmsg};
573    ${PAGER:-less} ${licmsg} || die "Could not execute pager (${PAGER}) to accept ${lic}";
574    einfon "Do you accept the terms of this license (${l})? [yes/no] ";
575    read alic;
576    case ${alic} in
577        yes | Yes | y | Y)
578            return 0
579        ;;
580        *)
581            echo;
582            echo;
583            echo;
584            eerror "You MUST accept the license to continue!  Exiting!";
585            die "Failed to accept license"
586        ;;
587    esac
588}
589create_ml_includes ()
590{
591    local dest=$1;
592    shift;
593    local basedirs=$(create_ml_includes-listdirs "$@");
594    create_ml_includes-makedestdirs ${dest} ${basedirs};
595    local file;
596    for file in $(create_ml_includes-allfiles ${basedirs});
597    do
598        ( echo "/* Autogenerated by create_ml_includes() in multilib.eclass */";
599        local dir;
600        for dir in ${basedirs};
601        do
602            if [[ -f ${D}/${dir}/${file} ]]; then
603                echo "";
604                local sym=$(create_ml_includes-sym_for_dir ${dir} "$@");
605                if [[ ${sym/=} != "${sym}" ]]; then
606                    echo "#if ${sym}";
607                else
608                    if [[ ${sym::1} == "!" ]]; then
609                        echo "#ifndef ${sym:1}";
610                    else
611                        echo "#ifdef ${sym}";
612                    fi;
613                fi;
614                echo "# include <$(create_ml_includes-absolute ${dir}/${file})>";
615                echo "#endif /* ${sym} */";
616            fi;
617        done ) > "${D}/${dest}/${file}";
618    done
619}
620create_ml_includes-absolute ()
621{
622    local dst="$(create_ml_includes-tidy_path $1)";
623    dst=(${dst//\// });
624    local i;
625    for ((i=0; i<${#dst[*]}; i++))
626    do
627        [ "${dst[i]}" == "include" ] && break;
628    done;
629    local strip_upto=$i;
630    for ((i=strip_upto+1; i<${#dst[*]}-1; i++))
631    do
632        echo -n ${dst[i]}/;
633    done;
634    echo -n ${dst[i]}
635}
636create_ml_includes-allfiles ()
637{
638    local basedir file;
639    for basedir in "$@";
640    do
641        for file in $(find "${D}"/${basedir} -type f);
642        do
643            echo ${file/${D}\/${basedir}\//};
644        done;
645    done | sort | uniq
646}
647create_ml_includes-listdirs ()
648{
649    local dirs;
650    local data;
651    for data in "$@";
652    do
653        dirs="${dirs} ${data/*:/}";
654    done;
655    echo ${dirs:1}
656}
657create_ml_includes-makedestdirs ()
658{
659    local dest=$1;
660    shift;
661    local basedirs=$@;
662    dodir ${dest};
663    local basedir;
664    for basedir in ${basedirs};
665    do
666        local dir;
667        for dir in $(find "${D}"/${basedir} -type d);
668        do
669            dodir ${dest}/${dir/${D}\/${basedir}/};
670        done;
671    done
672}
673create_ml_includes-sym_for_dir ()
674{
675    local dir=$1;
676    shift;
677    local data;
678    for data in "$@";
679    do
680        if [[ ${data} == *:${dir} ]]; then
681            echo ${data/:*/};
682            return 0;
683        fi;
684    done;
685    echo "Shouldn't be here -- create_ml_includes-sym_for_dir $1 $@";
686    exit 1
687}
688create_ml_includes-tidy_path ()
689{
690    local removed=$1;
691    if [ -n "${removed}" ]; then
692        while [ "${removed}" != "${removed/\/\//\/}" ]; do
693            removed=${removed/\/\//\/};
694        done;
695        while [ "${removed}" != "${removed//\/.\//\/}" ]; do
696            removed=${removed//\/.\//\/};
697        done;
698        [ "${removed##*/}" = "." ] && removed=${removed%/*};
699        while [ "${removed}" != "${removed//\/..\/}" ]; do
700            local p1="${removed%%\/..\/*}";
701            local p2="${removed#*\/..\/}";
702            removed="${p1%\/*}/${p2}";
703        done;
704        [ "${removed##*/}" = ".." ] && removed=${removed%/*/*};
705        [ "${removed##*/}" = "" ] && removed=${removed%/*};
706        echo ${removed};
707    fi
708}
709darwintoolize ()
710{
711    ewarn "darwintoolize() is deprecated, please just use elibtoolize()!";
712    elibtoolize
713}
714dlopen_lib ()
715{
716    if [[ ${ELIBC} != *BSD ]]; then
717        echo "-ldl";
718    fi
719}
720doicon ()
721{
722    ( local i j ret;
723    insinto /usr/share/pixmaps;
724    for i in "$@";
725    do
726        if [[ -f ${i} ]]; then
727            doins "${i}";
728            ((ret+=$?));
729        else
730            if [[ -d ${i} ]]; then
731                for j in "${i}"/*.png;
732                do
733                    doins "${j}";
734                    ((ret+=$?));
735                done;
736            else
737                ((++ret));
738            fi;
739        fi;
740    done;
741    exit ${ret} )
742}
743domenu ()
744{
745    ( local i j ret=0;
746    insinto /usr/share/applications;
747    for i in "$@";
748    do
749        if [[ -f ${i} ]]; then
750            doins "${i}";
751            ((ret+=$?));
752        else
753            if [[ -d ${i} ]]; then
754                for j in "${i}"/*.desktop;
755                do
756                    doins "${j}";
757                    ((ret+=$?));
758                done;
759            else
760                ((++ret));
761            fi;
762        fi;
763    done;
764    exit ${ret} )
765}
766eaclocal ()
767{
768    local aclocal_opts;
769    local amflags_file;
770    for amflags_file in GNUmakefile.am Makefile.am GNUmakefile.in Makefile.in;
771    do
772        [[ -e ${amflags_file} ]] || continue;
773        aclocal_opts=$(sed -n '/^ACLOCAL_AMFLAGS[[:space:]]*=/s:[^=]*=::p' ${amflags_file});
774        eval aclocal_opts=\"${aclocal_opts}\";
775        break;
776    done;
777    if [[ -n ${AT_M4DIR} ]]; then
778        for x in ${AT_M4DIR};
779        do
780            case "${x}" in
781                "-I")
782
783                ;;
784                *)
785                    [[ ! -d ${x} ]] && ewarn "eaclocal: '${x}' does not exist";
786                    aclocal_opts="${aclocal_opts} -I ${x}"
787                ;;
788            esac;
789        done;
790    fi;
791    [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && autotools_run_tool aclocal "$@" ${aclocal_opts}
792}
793eautoconf ()
794{
795    if [[ ! -f configure.ac && ! -f configure.in ]]; then
796        echo;
797        eerror "No configure.{ac,in} present in '$(pwd | sed -e 's:.*/::')'!";
798        echo;
799        die "No configure.{ac,in} present!";
800    fi;
801    autotools_run_tool autoconf "$@"
802}
803eautoheader ()
804{
805    [[ -n $(autotools_check_macro "AC_CONFIG_HEADERS") ]] || return 0;
806    NO_FAIL=1 autotools_run_tool autoheader "$@"
807}
808eautomake ()
809{
810    local extra_opts;
811    local makefile_name;
812    if [[ -f GNUmakefile.am ]]; then
813        makefile_name="GNUmakefile";
814    else
815        if [[ -f Makefile.am ]]; then
816            makefile_name="Makefile";
817        else
818            return 0;
819        fi;
820    fi;
821    if [[ -z ${FROM_EAUTORECONF} && -f ${makefile_name}.in ]]; then
822        local used_automake;
823        local installed_automake;
824        installed_automake=$(automake --version | head -n 1 |                   sed -e 's:.*(GNU automake) ::');
825        used_automake=$(head -n 1 < ${makefile_name}.in |                       sed -e 's:.*by automake \(.*\) from .*:\1:');
826        if [[ ${installed_automake} != ${used_automake} ]]; then
827            einfo "Automake used for the package (${used_automake}) differs from";
828            einfo "the installed version (${installed_automake}).";
829            eautoreconf;
830            return 0;
831        fi;
832    fi;
833    [[ -f INSTALL && -f AUTHORS && -f ChangeLog && -f NEWS ]] || extra_opts="${extra_opts} --foreign";
834    autotools_run_tool automake --add-missing --copy ${extra_opts} "$@"
835}
836eautoreconf ()
837{
838    local pwd=$(pwd) x auxdir;
839    if [[ -z ${AT_NO_RECURSIVE} ]]; then
840        for x in $(autotools_get_subdirs);
841        do
842            if [[ -d ${x} ]]; then
843                cd "${x}";
844                AT_NOELIBTOOLIZE="yes" eautoreconf;
845                cd "${pwd}";
846            fi;
847        done;
848    fi;
849    auxdir=$(autotools_get_auxdir);
850    einfo "Running eautoreconf in '$(pwd)' ...";
851    [[ -n ${auxdir} ]] && mkdir -p ${auxdir};
852    eaclocal;
853    if ${LIBTOOLIZE:-libtoolize} -n --install >&/dev/null; then
854        _elibtoolize --copy --force --install;
855    else
856        _elibtoolize --copy --force;
857    fi;
858    eautoconf;
859    eautoheader;
860    FROM_EAUTORECONF="yes" eautomake ${AM_OPTS};
861    [[ ${AT_NOELIBTOOLIZE} == "yes" ]] && return 0;
862    elibtoolize;
863    return 0
864}
865ebeep ()
866{
867    local n;
868    if [[ -z ${EBEEP_IGNORE} ]]; then
869        for ((n=1 ; n <= ${1:-5} ; n++))
870        do
871            echo -ne "\a";
872            sleep 0.1 >&/dev/null;
873            sleep 0,1 >&/dev/null;
874            echo -ne "\a";
875            sleep 1;
876        done;
877    fi
878}
879ecvs_clean ()
880{
881    [[ -z $* ]] && set -- .;
882    find "$@" -type d -name 'CVS' -prune -print0 | xargs -0 rm -rf;
883    find "$@" -type f -name '.cvs*' -print0 | xargs -0 rm -rf
884}
885edos2unix ()
886{
887    echo "$@" | xargs sed -i 's/\r$//'
888}
889egetent ()
890{
891    case ${CHOST} in
892        *-darwin*)
893            case "$2" in
894                *[!0-9]*)
895                    nidump $1 . | awk -F":" "{ if (\$1 ~ /^$2$/) {print \$0;exit;} }"
896                ;;
897                *)
898                    nidump $1 . | awk -F":" "{ if (\$3 == $2) {print \$0;exit;} }"
899                ;;
900            esac
901        ;;
902        *-freebsd* | *-dragonfly*)
903            local opts action="user";
904            [[ $1 == "passwd" ]] || action="group";
905            if [[ $2 == [[:digit:]]* ]]; then
906                [[ ${action} == "user" ]] && opts="-u" || opts="-g";
907            fi;
908            pw show ${action} ${opts} "$2" -q
909        ;;
910        *-netbsd* | *-openbsd*)
911            grep "$2:\*:" /etc/$1
912        ;;
913        *)
914            type -p nscd >&/dev/null && nscd -i "$1";
915            getent "$1" "$2"
916        ;;
917    esac
918}
919egethome ()
920{
921    ent=$(egetent passwd $1);
922    case ${CHOST} in
923        *-darwin* | *-freebsd* | *-dragonfly*)
924            echo ${ent} | cut -d: -f9
925        ;;
926        *)
927            echo ${ent} | cut -d: -f6
928        ;;
929    esac
930}
931egetshell ()
932{
933    ent=$(egetent passwd "$1");
934    case ${CHOST} in
935        *-darwin* | *-freebsd* | *-dragonfly*)
936            echo ${ent} | cut -d: -f10
937        ;;
938        *)
939            echo ${ent} cut -d: -f7
940        ;;
941    esac
942}
943elibtoolize ()
944{
945    local x=;
946    local y=;
947    local do_portage="no";
948    local do_reversedeps="no";
949    local do_only_patches="no";
950    local do_uclibc="yes";
951    local deptoremove=;
952    local my_dirlist=;
953    local elt_patches="install-sh ltmain portage relink max_cmd_len sed test tmp";
954    local start_dir=${PWD};
955    my_dirlist=$(ELT_find_ltmain_sh);
956    for x in "$@";
957    do
958        case "${x}" in
959            "--portage")
960                do_portage="yes"
961            ;;
962            "--reverse-deps")
963                do_reversedeps="yes";
964                elt_patches="${elt_patches} fix-relink"
965            ;;
966            "--patch-only")
967                do_only_patches="yes"
968            ;;
969            "^--remove-internal-dep="*)
970                deptoremove=$(echo "${x}" | sed -e 's|--remove-internal-dep=||');
971                [[ -n ${deptoremove} ]] && elt_patches="${elt_patches} rem-int-dep"
972            ;;
973            "--shallow")
974                if [[ -f ${S}/ltmain.sh ]]; then
975                    my_dirlist=${S};
976                else
977                    my_dirlist=;
978                fi
979            ;;
980            "--no-uclibc")
981                do_uclibc="no"
982            ;;
983            *)
984                eerror "Invalid elibtoolize option: ${x}";
985                die "elibtoolize called with ${x} ??"
986            ;;
987        esac;
988    done;
989    [[ ${do_uclibc} == "yes" ]] && elt_patches="${elt_patches} uclibc-conf uclibc-ltconf";
990    [[ ${CHOST} == *"-freebsd"* ]] && elt_patches="${elt_patches} fbsd-conf fbsd-ltconf";
991    [[ ${CHOST} == *"-darwin"* ]] && elt_patches="${elt_patches} darwin-ltconf darwin-ltmain";
992    for x in ${my_dirlist};
993    do
994        local tmp=$(echo "${x}" | sed -e "s|${WORKDIR}||");
995        export ELT_APPLIED_PATCHES=;
996        export ELT_LTMAIN_SH="${x}/ltmain.sh";
997        [[ -f ${x}/.elibtoolized ]] && continue;
998        cd ${x};
999        einfo "Running elibtoolize in: $(echo "/${tmp}" | sed -e 's|//|/|g; s|^/||')";
1000        for y in ${elt_patches};
1001        do
1002            local ret=0;
1003            case "${y}" in
1004                "portage")
1005                    if [[ -z $(grep 'We do not want portage' "${x}/ltmain.sh") ]]; then
1006                        ELT_walk_patches "${x}/ltmain.sh" "${y}";
1007                        ret=$?;
1008                    fi
1009                ;;
1010                "rem-int-dep")
1011                    ELT_walk_patches "${x}/ltmain.sh" "${y}" "${deptoremove}";
1012                    ret=$?
1013                ;;
1014                "fix-relink")
1015                    if [[ -n $(grep 'inst_prefix_dir' "${x}/ltmain.sh") ]]; then
1016                        ELT_walk_patches "${x}/ltmain.sh" "${y}";
1017                        ret=$?;
1018                    fi
1019                ;;
1020                "max_cmd_len")
1021                    if [[ -n $(grep 'max_cmd_len' "${x}/ltmain.sh") ]]; then
1022                        ELT_walk_patches "${x}/ltmain.sh" "${y}";
1023                        ret=$?;
1024                    fi
1025                ;;
1026                "uclibc-conf")
1027                    if [[ -e ${x}/configure && -n $(grep 'Transform linux' "${x}/configure") ]]; then
1028                        ELT_walk_patches "${x}/configure" "${y}";
1029                        ret=$?;
1030                    else
1031                        if [[ ! -e ${x}/configure && -e ${x}/../configure && -n $(grep 'Transform linux' "${x}/../configure") ]]; then
1032                            ELT_walk_patches "${x}/../configure" "${y}";
1033                            ret=$?;
1034                        fi;
1035                    fi
1036                ;;
1037                "uclibc-ltconf")
1038                    if [[ -s ${x}/ltconfig ]]; then
1039                        ELT_walk_patches "${x}/ltconfig" "${y}";
1040                        ret=$?;
1041                    fi
1042                ;;
1043                "fbsd-conf")
1044                    if [[ -e ${x}/configure && -n $(grep 'version_type=freebsd-' "${x}/configure") ]]; then
1045                        ELT_walk_patches "${x}/configure" "${y}";
1046                        ret=$?;
1047                    else
1048                        if [[ ! -e ${x}/configure && -e ${x}/../configure && -n $(grep 'version_type=freebsd-' "${x}/../configure") ]]; then
1049                            ELT_walk_patches "${x}/../configure" "${y}";
1050                            ret=$?;
1051                        fi;
1052                    fi
1053                ;;
1054                "fbsd-ltconf")
1055                    if [[ -s ${x}/ltconfig ]]; then
1056                        ELT_walk_patches "${x}/ltconfig" "${y}";
1057                        ret=$?;
1058                    fi
1059                ;;
1060                "darwin-ltconf")
1061                    if [[ -s ${x}/ltconfig ]]; then
1062                        ELT_walk_patches "${x}/ltconfig" "${y}";
1063                        ret=$?;
1064                    fi
1065                ;;
1066                "install-sh")
1067                    ELT_walk_patches "${x}/install-sh" "${y}";
1068                    ret=$?
1069                ;;
1070                *)
1071                    ELT_walk_patches "${x}/ltmain.sh" "${y}";
1072                    ret=$?
1073                ;;
1074            esac;
1075            if [[ ${ret} -ne 0 ]]; then
1076                case ${y} in
1077                    "relink")
1078                        local version=$(ELT_libtool_version "${x}/ltmain.sh");
1079                        if [[ -z $(grep 'inst_prefix_dir' "${x}/ltmain.sh") && $(VER_to_int "${version}") -ge $(VER_to_int "1.4.0") ]]; then
1080                            ewarn "  Could not apply relink.patch!";
1081                        fi
1082                    ;;
1083                    "portage")
1084                        if [[ ${do_portage} == "yes" ]]; then
1085                            if [[ -z $(grep 'We do not want portage' "${x}/ltmain.sh") ]]; then
1086                                echo;
1087                                eerror "Portage patch requested, but failed to apply!";
1088                                eerror "Please bug azarah or vapier to add proper patch.";
1089                                die "Portage patch requested, but failed to apply!";
1090                            fi;
1091                        else
1092                            if [[ -n $(grep 'We do not want portage' "${x}/ltmain.sh") ]]; then
1093                                :;
1094                            else
1095                                local version=$(                                                                        eval $(grep -e '^[[:space:]]*VERSION=' "${x}/ltmain.sh");                                                                       echo "${VERSION}");
1096                                echo;
1097                                eerror "Portage patch failed to apply (ltmain.sh version ${version})!";
1098                                eerror "Please bug azarah or vapier to add proper patch.";
1099                                die "Portage patch failed to apply!";
1100                            fi;
1101                            ELT_APPLIED_PATCHES="portage";
1102                        fi
1103                    ;;
1104                    "uclibc-"*)
1105                        [[ ${CHOST} == *"-uclibc" ]] && ewarn "  uClibc patch set '${y}' failed to apply!"
1106                    ;;
1107                    "fbsd-"*)
1108                        if [[ ${CHOST} == *"-freebsd"* ]]; then
1109                            if [[ -z $(grep 'Handle Gentoo/FreeBSD as it was Linux'                                                             "${x}/configure" "${x}/../configure" 2>/dev/null) ]]; then
1110                                eerror "  FreeBSD patch set '${y}' failed to apply!";
1111                                die "FreeBSD patch set '${y}' failed to apply!";
1112                            fi;
1113                        fi
1114                    ;;
1115                    "darwin-"*)
1116                        [[ ${CHOST} == *"-darwin"* ]] && ewarn "  Darwin patch set '${y}' failed to apply!"
1117                    ;;
1118                esac;
1119            fi;
1120        done;
1121        if [[ -z ${ELT_APPLIED_PATCHES} ]]; then
1122            if [[ ${do_portage} == "no" && ${do_reversedeps} == "no" && ${do_only_patches} == "no" && ${deptoremove} == "" ]]; then
1123                ewarn "Cannot apply any patches, please file a bug about this";
1124                die;
1125            fi;
1126        fi;
1127        [[ -f ${x}/libtool ]] && rm -f "${x}/libtool";
1128         >> "${x}/.elibtoolized";
1129    done;
1130    cd "${start_dir}"
1131}
1132emktemp ()
1133{
1134    local exe="touch";
1135    [[ $1 == -d ]] && exe="mkdir" && shift;
1136    local topdir=$1;
1137    if [[ -z ${topdir} ]]; then
1138        [[ -z ${T} ]] && topdir="/tmp" || topdir=${T};
1139    fi;
1140    if ! type -P mktemp > /dev/null; then
1141        local tmp=/;
1142        while [[ -e ${tmp} ]]; do
1143            tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM};
1144        done;
1145        ${exe} "${tmp}" || ${exe} -p "${tmp}";
1146        echo "${tmp}";
1147    else
1148        if [[ ${exe} == "touch" ]]; then
1149            TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX;
1150        else
1151            TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX;
1152        fi;
1153    fi
1154}
1155enewgroup ()
1156{
1157    case ${EBUILD_PHASE} in
1158        unpack | compile | test | install)
1159            eerror "'enewgroup()' called from '${EBUILD_PHASE}()' which is not a pkg_* function.";
1160            eerror "Package fails at QA and at life.  Please file a bug.";
1161            die "Bad package!  enewgroup is only for use in pkg_* functions!"
1162        ;;
1163    esac;
1164    local egroup="$1";
1165    shift;
1166    if [ -z "${egroup}" ]; then
1167        eerror "No group specified !";
1168        die "Cannot call enewgroup without a group";
1169    fi;
1170    if [[ -n $(egetent group "${egroup}") ]]; then
1171        return 0;
1172    fi;
1173    einfo "Adding group '${egroup}' to your system ...";
1174    local opts=;
1175    local egid="$1";
1176    shift;
1177    if [ ! -z "${egid}" ]; then
1178        if [ "${egid}" -gt 0 ]; then
1179            if [ -z "`egetent group ${egid}`" ]; then
1180                if [[ "${CHOST}" == *-darwin* ]]; then
1181                    opts="${opts} ${egid}";
1182                else
1183                    opts="${opts} -g ${egid}";
1184                fi;
1185            else
1186                egid="next available; requested gid taken";
1187            fi;
1188        else
1189            eerror "Groupid given but is not greater than 0 !";
1190            die "${egid} is not a valid GID";
1191        fi;
1192    else
1193        egid="next available";
1194    fi;
1195    einfo " - Groupid: ${egid}";
1196    local eextra="$@";
1197    opts="${opts} ${eextra}";
1198    local oldsandbox="${SANDBOX_ON}";
1199    export SANDBOX_ON="0";
1200    case ${CHOST} in
1201        *-darwin*)
1202            if [ ! -z "${eextra}" ]; then
1203                einfo "Extra options are not supported on Darwin/OS X yet";
1204                einfo "Please report the ebuild along with the info below";
1205                einfo "eextra: ${eextra}";
1206                die "Required function missing";
1207            fi;
1208            case ${egid} in
1209                *[!0-9]*)
1210                    for ((egid = 101; egid <= 999; egid++))
1211                    do
1212                        [[ -z $(egetent group ${egid}) ]] && break;
1213                    done
1214                ;;
1215            esac;
1216            dscl . create /groups/${egroup} gid ${egid};
1217            dscl . create /groups/${egroup} passwd '*'
1218        ;;
1219        *-freebsd* | *-dragonfly*)
1220            case ${egid} in
1221                *[!0-9]*)
1222                    for ((egid = 101; egid <= 999; egid++))
1223                    do
1224                        [[ -z $(egetent group ${egid}) ]] && break;
1225                    done
1226                ;;
1227            esac;
1228            pw groupadd ${egroup} -g ${egid} || die "enewgroup failed"
1229        ;;
1230        *-netbsd*)
1231            case ${egid} in
1232                *[!0-9]*)
1233                    for ((egid = 101; egid <= 999; egid++))
1234                    do
1235                        [[ -z $(egetent group ${egid}) ]] && break;
1236                    done
1237                ;;
1238            esac;
1239            groupadd -g ${egid} ${egroup} || die "enewgroup failed"
1240        ;;
1241        *)
1242            groupadd ${opts} ${egroup} || die "enewgroup failed"
1243        ;;
1244    esac;
1245    export SANDBOX_ON="${oldsandbox}"
1246}
1247enewuser ()
1248{
1249    case ${EBUILD_PHASE} in
1250        unpack | compile | test | install)
1251            eerror "'enewuser()' called from '${EBUILD_PHASE}()' which is not a pkg_* function.";
1252            eerror "Package fails at QA and at life.  Please file a bug.";
1253            die "Bad package!  enewuser is only for use in pkg_* functions!"
1254        ;;
1255    esac;
1256    local euser=$1;
1257    shift;
1258    if [[ -z ${euser} ]]; then
1259        eerror "No username specified !";
1260        die "Cannot call enewuser without a username";
1261    fi;
1262    if [[ -n $(egetent passwd "${euser}") ]]; then
1263        return 0;
1264    fi;
1265    einfo "Adding user '${euser}' to your system ...";
1266    local opts=;
1267    local euid=$1;
1268    shift;
1269    if [[ -n ${euid} && ${euid} != -1 ]]; then
1270        if [[ ${euid} -gt 0 ]]; then
1271            if [[ -n $(egetent passwd ${euid}) ]]; then
1272                euid="next";
1273            fi;
1274        else
1275            eerror "Userid given but is not greater than 0 !";
1276            die "${euid} is not a valid UID";
1277        fi;
1278    else
1279        euid="next";
1280    fi;
1281    if [[ ${euid} == "next" ]]; then
1282        for ((euid = 101; euid <= 999; euid++))
1283        do
1284            [[ -z $(egetent passwd ${euid}) ]] && break;
1285        done;
1286    fi;
1287    opts="${opts} -u ${euid}";
1288    einfo " - Userid: ${euid}";
1289    local eshell=$1;
1290    shift;
1291    if [[ ! -z ${eshell} ]] && [[ ${eshell} != "-1" ]]; then
1292        if [[ ! -e ${ROOT}${eshell} ]]; then
1293            eerror "A shell was specified but it does not exist !";
1294            die "${eshell} does not exist in ${ROOT}";
1295        fi;
1296        if [[ ${eshell} == */false || ${eshell} == */nologin ]]; then
1297            eerror "Do not specify ${eshell} yourself, use -1";
1298            die "Pass '-1' as the shell parameter";
1299        fi;
1300    else
1301        for shell in /sbin/nologin /usr/sbin/nologin /bin/false /usr/bin/false /dev/null;
1302        do
1303            [[ -x ${ROOT}${shell} ]] && break;
1304        done;
1305        if [[ ${shell} == "/dev/null" ]]; then
1306            eerror "Unable to identify the shell to use, proceeding with userland default.";
1307            case ${USERLAND} in
1308                GNU)
1309                    shell="/bin/false"
1310                ;;
1311                BSD)
1312                    shell="/sbin/nologin"
1313                ;;
1314                Darwin)
1315                    shell="/usr/sbin/nologin"
1316                ;;
1317                *)
1318                    die "Unable to identify the default shell for userland ${USERLAND}"
1319                ;;
1320            esac;
1321        fi;
1322        eshell=${shell};
1323    fi;
1324    einfo " - Shell: ${eshell}";
1325    opts="${opts} -s ${eshell}";
1326    local ehome=$1;
1327    shift;
1328    if [[ -z ${ehome} ]] || [[ ${ehome} == "-1" ]]; then
1329        ehome="/dev/null";
1330    fi;
1331    einfo " - Home: ${ehome}";
1332    opts="${opts} -d ${ehome}";
1333    local egroups=$1;
1334    shift;
1335    if [[ ! -z ${egroups} ]]; then
1336        local oldifs=${IFS};
1337        local defgroup="" exgroups="";
1338        export IFS=",";
1339        for g in ${egroups};
1340        do
1341            export IFS=${oldifs};
1342            if [[ -z $(egetent group "${g}") ]]; then
1343                eerror "You must add group ${g} to the system first";
1344                die "${g} is not a valid GID";
1345            fi;
1346            if [[ -z ${defgroup} ]]; then
1347                defgroup=${g};
1348            else
1349                exgroups="${exgroups},${g}";
1350            fi;
1351            export IFS=",";
1352        done;
1353        export IFS=${oldifs};
1354        opts="${opts} -g ${defgroup}";
1355        if [[ ! -z ${exgroups} ]]; then
1356            opts="${opts} -G ${exgroups:1}";
1357        fi;
1358    else
1359        egroups="(none)";
1360    fi;
1361    einfo " - Groups: ${egroups}";
1362    local oldsandbox=${SANDBOX_ON};
1363    export SANDBOX_ON="0";
1364    case ${CHOST} in
1365        *-darwin*)
1366            if [[ -z $@ ]]; then
1367                dscl . create /users/${euser} uid ${euid};
1368                dscl . create /users/${euser} shell ${eshell};
1369                dscl . create /users/${euser} home ${ehome};
1370                dscl . create /users/${euser} realname "added by portage for ${PN}";
1371                local oldifs=${IFS};
1372                export IFS=",";
1373                for g in ${egroups};
1374                do
1375                    dscl . merge /groups/${g} users ${euser};
1376                done;
1377                export IFS=${oldifs};
1378            else
1379                einfo "Extra options are not supported on Darwin yet";
1380                einfo "Please report the ebuild along with the info below";
1381                einfo "eextra: $@";
1382                die "Required function missing";
1383            fi
1384        ;;
1385        *-freebsd* | *-dragonfly*)
1386            if [[ -z $@ ]]; then
1387                pw useradd ${euser} ${opts} -c "added by portage for ${PN}" die "enewuser failed";
1388            else
1389                einfo " - Extra: $@";
1390                pw useradd ${euser} ${opts} "$@" || die "enewuser failed";
1391            fi
1392        ;;
1393        *-netbsd*)
1394            if [[ -z $@ ]]; then
1395                useradd ${opts} ${euser} || die "enewuser failed";
1396            else
1397                einfo " - Extra: $@";
1398                useradd ${opts} ${euser} "$@" || die "enewuser failed";
1399            fi
1400        ;;
1401        *-openbsd*)
1402            if [[ -z $@ ]]; then
1403                useradd -u ${euid} -s ${eshell} -d ${ehome} -c "Added by portage for ${PN}" -g ${egroups} ${euser} || die "enewuser failed";
1404            else
1405                einfo " - Extra: $@";
1406                useradd -u ${euid} -s ${eshell} -d ${ehome} -c "Added by portage for ${PN}" -g ${egroups} ${euser} "$@" || die "enewuser failed";
1407            fi
1408        ;;
1409        *)
1410            if [[ -z $@ ]]; then
1411                useradd ${opts} ${euser} -c "added by portage for ${PN}" || die "enewuser failed";
1412            else
1413                einfo " - Extra: $@";
1414                useradd ${opts} ${euser} "$@" || die "enewuser failed";
1415            fi
1416        ;;
1417    esac;
1418    if [[ ! -e ${ROOT}/${ehome} ]]; then
1419        einfo " - Creating ${ehome} in ${ROOT}";
1420        mkdir -p "${ROOT}/${ehome}";
1421        chown ${euser} "${ROOT}/${ehome}";
1422        chmod 755 "${ROOT}/${ehome}";
1423    fi;
1424    export SANDBOX_ON=${oldsandbox}
1425}
1426enlightenment_src_compile ()
1427{
1428    econf || die "econf failed";
1429    emake || die "emake failed"
1430}
1431enlightenment_src_install ()
1432{
1433    emake DESTDIR="${D}" install || die "emake install failed";
1434    dodoc AUTHORS NEWS README
1435}
1436enlightenment_src_unpack ()
1437{
1438    subversion_src_unpack;
1439    cd "${S}";
1440    for patch in ${E17_PATCHES};
1441    do
1442        epatch "${FILESDIR}/${patch}";
1443    done;
1444    eautoreconf || die "eautoreconf failed"
1445}
1446epatch ()
1447{
1448    function _epatch_draw_line ()
1449    {
1450        [[ -z $1 ]] && set "$(printf "%65s" '')";
1451        echo "${1//?/=}"
1452    };
1453    function _epatch_assert ()
1454    {
1455        local _pipestatus=${PIPESTATUS[*]};
1456        [[ ${_pipestatus// /} -eq 0 ]]
1457    };
1458    local PIPE_CMD="";
1459    local STDERR_TARGET="${T}/$$.out";
1460    local PATCH_TARGET="${T}/$$.patch";
1461    local PATCH_SUFFIX="";
1462    local SINGLE_PATCH="no";
1463    local x="";
1464    unset P4CONFIG P4PORT P4USER;
1465    if [ "$#" -gt 1 ]; then
1466        local m="";
1467        for m in "$@";
1468        do
1469            epatch "${m}";
1470        done;
1471        return 0;
1472    fi;
1473    if [ -n "$1" -a -f "$1" ]; then
1474        SINGLE_PATCH="yes";
1475        local EPATCH_SOURCE="$1";
1476        local EPATCH_SUFFIX="${1##*\.}";
1477    else
1478        if [ -n "$1" -a -d "$1" ]; then
1479            if [ "${EPATCH_FORCE}" = "yes" ] && [ -z "${EPATCH_SUFFIX}" ]; then
1480                local EPATCH_SOURCE="$1/*";
1481            else
1482                local EPATCH_SOURCE="$1/*.${EPATCH_SUFFIX}";
1483            fi;
1484        else
1485            if [[ ! -d ${EPATCH_SOURCE} ]] || [[ -n $1 ]]; then
1486                if [ -n "$1" -a "${EPATCH_SOURCE}" = "${WORKDIR}/patch" ]; then
1487                    EPATCH_SOURCE="$1";
1488                fi;
1489                echo;
1490                eerror "Cannot find \$EPATCH_SOURCE!  Value for \$EPATCH_SOURCE is:";
1491                eerror;
1492                eerror "  ${EPATCH_SOURCE}";
1493                eerror "  ( ${EPATCH_SOURCE##*/} )";
1494                echo;
1495                die "Cannot find \$EPATCH_SOURCE!";
1496            fi;
1497            local EPATCH_SOURCE="${EPATCH_SOURCE}/*.${EPATCH_SUFFIX}";
1498        fi;
1499    fi;
1500    case ${EPATCH_SUFFIX##*\.} in
1501        lzma)
1502            PIPE_CMD="lzma -dc";
1503            PATCH_SUFFIX="lzma"
1504        ;;
1505        bz2)
1506            PIPE_CMD="bzip2 -dc";
1507            PATCH_SUFFIX="bz2"
1508        ;;
1509        gz | Z | z)
1510            PIPE_CMD="gzip -dc";
1511            PATCH_SUFFIX="gz"
1512        ;;
1513        ZIP | zip)
1514            PIPE_CMD="unzip -p";
1515            PATCH_SUFFIX="zip"
1516        ;;
1517        *)
1518            PIPE_CMD="cat";
1519            PATCH_SUFFIX="patch"
1520        ;;
1521    esac;
1522    if [ "${SINGLE_PATCH}" = "no" ]; then
1523        einfo "${EPATCH_MULTI_MSG}";
1524    fi;
1525    for x in ${EPATCH_SOURCE};
1526    do
1527        if [ -f ${x} ] && ( [ "${SINGLE_PATCH}" = "yes" -o "${x/_all_}" != "${x}" -o "${x/_${ARCH}_}" != "${x}" ] || [ "${EPATCH_FORCE}" = "yes" ] ); then
1528            local count=0;
1529            local popts="${EPATCH_OPTS}";
1530            local patchname=${x##*/};
1531            if [ -n "${EPATCH_EXCLUDE}" ]; then
1532                if [ "${EPATCH_EXCLUDE/${patchname}}" != "${EPATCH_EXCLUDE}" ]; then
1533                    continue;
1534                fi;
1535            fi;
1536            if [ "${SINGLE_PATCH}" = "yes" ]; then
1537                if [ -n "${EPATCH_SINGLE_MSG}" ]; then
1538                    einfo "${EPATCH_SINGLE_MSG}";
1539                else
1540                    einfo "Applying ${patchname} ...";
1541                fi;
1542            else
1543                einfo "  ${patchname} ...";
1544            fi;
1545            echo "***** ${patchname} *****" > ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/};
1546            echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/};
1547            if [[ ${PATCH_SUFFIX} != "patch" ]]; then
1548                echo -n "PIPE_COMMAND:  " >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/};
1549                echo "${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/};
1550                if ! ( ${PIPE_CMD} ${x} > ${PATCH_TARGET} ) >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/} 2>&1; then
1551                    echo;
1552                    eerror "Could not extract patch!";
1553                    count=5;
1554                    break;
1555                fi;
1556            else
1557                PATCH_TARGET="${x}";
1558            fi;
1559            local abs_paths=$(egrep -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }');
1560            if [[ -n ${abs_paths} ]]; then
1561                count=1;
1562                echo "NOTE: skipping -p0 due to absolute paths in patch:" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/};
1563                echo "${abs_paths}" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/};
1564            fi;
1565            while [ "${count}" -lt 5 ]; do
1566                _epatch_draw_line "***** ${patchname} *****" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/};
1567                echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/};
1568                echo -n "PATCH COMMAND:  " >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/};
1569                echo "patch -p${count} ${popts} < ${PATCH_TARGET}" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/};
1570                echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/};
1571                _epatch_draw_line "***** ${patchname} *****" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/};
1572                if ( cat ${PATCH_TARGET} | patch -p${count} ${popts} --dry-run -f;
1573                _epatch_assert ) >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/} 2>&1; then
1574                    _epatch_draw_line "***** ${patchname} *****" > ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real;
1575                    echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real;
1576                    echo "ACTUALLY APPLYING ${patchname} ..." >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real;
1577                    echo >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real;
1578                    _epatch_draw_line "***** ${patchname} *****" >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real;
1579                    cat ${PATCH_TARGET} | patch -p${count} ${popts} >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real 2>&1;
1580                    _epatch_assert;
1581                    if [ "$?" -ne 0 ]; then
1582                        cat ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real >> ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/};
1583                        echo;
1584                        eerror "A dry-run of patch command succeeded, but actually";
1585                        eerror "applying the patch failed!";
1586                        count=5;
1587                    fi;
1588                    rm -f ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}.real;
1589                    break;
1590                fi;
1591                count=$((count + 1));
1592            done;
1593            if [ "${PATCH_SUFFIX}" != "patch" ]; then
1594                rm -f ${PATCH_TARGET};
1595            fi;
1596            if [ "${count}" -eq 5 ]; then
1597                echo;
1598                eerror "Failed Patch: ${patchname} !";
1599                eerror " ( ${PATCH_TARGET} )";
1600                eerror;
1601                eerror "Include in your bugreport the contents of:";
1602                eerror;
1603                eerror "  ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/}";
1604                echo;
1605                die "Failed Patch: ${patchname}!";
1606            fi;
1607            rm -f ${STDERR_TARGET%/*}/${patchname}-${STDERR_TARGET##*/};
1608            eend 0;
1609        fi;
1610    done;
1611    if [ "${SINGLE_PATCH}" = "no" ]; then
1612        einfo "Done with patching";
1613    fi
1614}
1615epause ()
1616{
1617    [[ -z ${EPAUSE_IGNORE} ]] && sleep ${1:-5}
1618}
1619epunt_cxx ()
1620{
1621    local dir=$1;
1622    [[ -z ${dir} ]] && dir=${S};
1623    ebegin "Removing useless C++ checks";
1624    local f;
1625    find "${dir}" -name configure | while read f; do
1626        patch --no-backup-if-mismatch -p0 "${f}" "${PORTDIR}/eclass/ELT-patches/nocxx/nocxx.patch" > /dev/null;
1627    done;
1628    eend 0
1629}
1630esvn_clean ()
1631{
1632    [[ -z $* ]] && set -- .;
1633    find "$@" -type d -name '.svn' -prune -print0 | xargs -0 rm -rf
1634}
1635find_unpackable_file ()
1636{
1637    local src=$1;
1638    if [[ -z ${src} ]]; then
1639        src=${DISTDIR}/${A};
1640    else
1641        if [[ -e ${DISTDIR}/${src} ]]; then
1642            src=${DISTDIR}/${src};
1643        else
1644            if [[ -e ${PWD}/${src} ]]; then
1645                src=${PWD}/${src};
1646            else
1647                if [[ -e ${src} ]]; then
1648                    src=${src};
1649                fi;
1650            fi;
1651        fi;
1652    fi;
1653    [[ ! -e ${src} ]] && return 1;
1654    echo "${src}"
1655}
1656gcc-fullversion ()
1657{
1658    $(tc-getCC "$@") -dumpversion
1659}
1660gcc-major-version ()
1661{
1662    gcc-version "$@" | cut -f1 -d.
1663}
1664gcc-micro-version ()
1665{
1666    gcc-fullversion "$@" | cut -f3 -d. | cut -f1 -d-
1667}
1668gcc-minor-version ()
1669{
1670    gcc-version "$@" | cut -f2 -d.
1671}
1672gcc-specs-directive ()
1673{
1674    local directive subdname subdirective;
1675    directive="$(_gcc-specs-directive_raw $1)";
1676    while [[ ${directive} == *%\(*\)* ]]; do
1677        subdname=${directive/*%\(};
1678        subdname=${subdname/\)*};
1679        subdirective="$(_gcc-specs-directive_raw ${subdname})";
1680        directive="${directive//\%(${subdname})/${subdirective}}";
1681    done;
1682    echo "${directive}";
1683    return 0
1684}
1685gcc-specs-nostrict ()
1686{
1687    local directive;
1688    directive=$(gcc-specs-directive cc1);
1689    return $([[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]])
1690}
1691gcc-specs-now ()
1692{
1693    local directive;
1694    directive=$(gcc-specs-directive link_command);
1695    return $([[ "${directive/\{!nonow:}" != "${directive}" ]])
1696}
1697gcc-specs-pie ()
1698{
1699    local directive;
1700    directive=$(gcc-specs-directive cc1);
1701    return $([[ "${directive/\{!nopie:}" != "${directive}" ]])
1702}
1703gcc-specs-relro ()
1704{
1705    local directive;
1706    directive=$(gcc-specs-directive link_command);
1707    return $([[ "${directive/\{!norelro:}" != "${directive}" ]])
1708}
1709gcc-specs-ssp ()
1710{
1711    local directive;
1712    directive=$(gcc-specs-directive cc1);
1713    return $([[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]])
1714}
1715gcc-specs-ssp-to-all ()
1716{
1717    local directive;
1718    directive=$(gcc-specs-directive cc1);
1719    return $([[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]])
1720}
1721gcc-version ()
1722{
1723    gcc-fullversion "$@" | cut -f1,2 -d.
1724}
1725gen_usr_ldscript ()
1726{
1727    local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
1728    dodir /usr/${libdir};
1729    if [[ $1 == "-a" ]]; then
1730        auto=true;
1731        shift;
1732        dodir /${libdir};
1733    fi;
1734    output_format=$($(tc-getCC) ${CFLAGS} ${LDFLAGS} -Wl,--verbose 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
1735    [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
1736    for lib in "$@";
1737    do
1738        if [[ ${USERLAND} == "Darwin" ]]; then
1739            ewarn "Not creating fake dynamic library for $lib on Darwin;";
1740            ewarn "making a symlink instead.";
1741            dosym "/${libdir}/${lib}" "/usr/${libdir}/${lib}";
1742        else
1743            local tlib;
1744            if ${auto}; then
1745                lib="lib${lib}${suffix}";
1746                mv "${D}"/usr/${libdir}/${lib}* "${D}"/${libdir}/ || die;
1747                tlib=$(scanelf -qF'%S#F' "${D}"/${libdir}/${lib});
1748                [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
1749                rm -f "${D}"/${libdir}/${lib};
1750            else
1751                tlib=${lib};
1752            fi;
1753            cat > "${D}/usr/${libdir}/${lib}"  <<-END_LDSCRIPT
1754/* GNU ld script
1755   Since Gentoo has critical dynamic libraries
1756   in /lib, and the static versions in /usr/lib,
1757   we need to have a "fake" dynamic lib in /usr/lib,
1758   otherwise we run into linking problems.
1759
1760   See bug http://bugs.gentoo.org/4411 for more info.
1761 */
1762${output_format}
1763GROUP ( /${libdir}/${tlib} )
1764END_LDSCRIPT
1765
1766            fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
1767        fi;
1768    done
1769}
1770get_abi_ASFLAGS ()
1771{
1772    get_abi_var ASFLAGS "$@"
1773}
1774get_abi_CDEFINE ()
1775{
1776    get_abi_var CDEFINE "$@"
1777}
1778get_abi_CFLAGS ()
1779{
1780    get_abi_var CFLAGS "$@"
1781}
1782get_abi_CHOST ()
1783{
1784    get_abi_var CHOST "$@"
1785}
1786get_abi_CTARGET ()
1787{
1788    get_abi_var CTARGET "$@"
1789}
1790get_abi_FAKE_TARGETS ()
1791{
1792    get_abi_var FAKE_TARGETS "$@"
1793}
1794get_abi_LDFLAGS ()
1795{
1796    get_abi_var LDFLAGS "$@"
1797}
1798get_abi_LIBDIR ()
1799{
1800    get_abi_var LIBDIR "$@"
1801}
1802get_abi_var ()
1803{
1804    local flag=$1;
1805    local abi;
1806    if [ $# -gt 1 ]; then
1807        abi=${2};
1808    else
1809        if [ -n "${ABI}" ]; then
1810            abi=${ABI};
1811        else
1812            if [ -n "${DEFAULT_ABI}" ]; then
1813                abi=${DEFAULT_ABI};
1814            else
1815                abi="default";
1816            fi;
1817        fi;
1818    fi;
1819    local var="${flag}_${abi}";
1820    echo ${!var}
1821}
1822get_all_abis ()
1823{
1824    local order="";
1825    if [[ -z ${MULTILIB_ABIS} ]]; then
1826        echo "default";
1827        return 0;
1828    fi;
1829    for x in ${MULTILIB_ABIS};
1830    do
1831        if [[ ${x} != ${DEFAULT_ABI} ]]; then
1832            order="${order:+${order} }${x}";
1833        fi;
1834    done;
1835    order="${order:+${order} }${DEFAULT_ABI}";
1836    echo ${order};
1837    return 0
1838}
1839get_all_libdirs ()
1840{
1841    local libdirs="lib";
1842    local abi;
1843    local dir;
1844    for abi in ${MULTILIB_ABIS};
1845    do
1846        [ "$(get_abi_LIBDIR ${abi})" != "lib" ] && libdirs="${libdirs} $(get_abi_LIBDIR ${abi})";
1847    done;
1848    echo "${libdirs}"
1849}
1850get_bmake ()
1851{
1852    if [[ ${USERLAND} == *BSD ]]; then
1853        echo make;
1854    else
1855        if [[ ${USERLAND} == "Darwin" ]]; then
1856            echo bsdmake;
1857        else
1858            echo pmake;
1859        fi;
1860    fi
1861}
1862get_install_abis ()
1863{
1864    local order="";
1865    if [[ -z ${MULTILIB_ABIS} ]]; then
1866        echo "default";
1867        return 0;
1868    fi;
1869    if [[ ${EMULTILIB_PKG} == "true" ]]; then
1870        for x in ${MULTILIB_ABIS};
1871        do
1872            if [[ ${x} != "${DEFAULT_ABI}" ]]; then
1873                hasq ${x} ${ABI_DENY} || ordera="${ordera} ${x}";
1874            fi;
1875        done;
1876        hasq ${DEFAULT_ABI} ${ABI_DENY} || order="${ordera} ${DEFAULT_ABI}";
1877        if [[ -n ${ABI_ALLOW} ]]; then
1878            local ordera="";
1879            for x in ${order};
1880            do
1881                if hasq ${x} ${ABI_ALLOW}; then
1882                    ordera="${ordera} ${x}";
1883                fi;
1884            done;
1885            order=${ordera};
1886        fi;
1887    else
1888        order=${DEFAULT_ABI};
1889    fi;
1890    if [[ -z ${order} ]]; then
1891        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.";
1892    fi;
1893    echo ${order};
1894    return 0
1895}
1896get_libdir ()
1897{
1898    local CONF_LIBDIR;
1899    if [ -n "${CONF_LIBDIR_OVERRIDE}" ]; then
1900        echo ${CONF_LIBDIR_OVERRIDE};
1901    else
1902        get_abi_LIBDIR;
1903    fi
1904}
1905get_libdir_override ()
1906{
1907    if has_multilib_profile; then
1908        eerror "get_libdir_override called, but it shouldn't be needed with the new multilib approach.  Please file a bug at http://bugs.gentoo.org and assign it to eradicator@gentoo.org";
1909        exit 1;
1910    fi;
1911    CONF_LIBDIR="$1";
1912    CONF_LIBDIR_OVERRIDE="$1";
1913    LIBDIR_default="$1"
1914}
1915get_libname ()
1916{
1917    local libname;
1918    local ver=$1;
1919    case ${CHOST} in
1920        *-cygwin | mingw* | *-mingw*)
1921            libname="dll"
1922        ;;
1923        *-darwin*)
1924            libname="dylib"
1925        ;;
1926        *)
1927            libname="so"
1928        ;;
1929    esac;
1930    if [[ -z $* ]]; then
1931        echo ".${libname}";
1932    else
1933        for ver in "$@";
1934        do
1935            case ${CHOST} in
1936                *-darwin*)
1937                    echo ".${ver}.${libname}"
1938                ;;
1939                *)
1940                    echo ".${libname}.${ver}"
1941                ;;
1942            esac;
1943        done;
1944    fi
1945}
1946get_ml_incdir ()
1947{
1948    local dir=/usr/include;
1949    if [[ $# -gt 0 ]]; then
1950        incdir=$1;
1951        shift;
1952    fi;
1953    if [[ -z "${MULTILIB_ABIS}" ]]; then
1954        echo ${incdir};
1955        return 0;
1956    fi;
1957    local abi=${ABI-${DEFAULT_ABI}};
1958    if [[ $# -gt 0 ]]; then
1959        abi=$1;
1960        shift;
1961    fi;
1962    if [[ -d "${dir}/gentoo-multilib/${abi}" ]]; then
1963        echo ${dir}/gentoo-multilib/${abi};
1964    else
1965        echo ${dir};
1966    fi
1967}
1968get_mounts ()
1969{
1970    local point= node= fs= opts= foo=;
1971    if [[ $(uname -s) == "Linux" ]]; then
1972        while read node point fs opts foo; do
1973            echo "${point} ${node} ${fs} ${opts}";
1974        done < /proc/mounts;
1975        return;
1976    fi;
1977    local IFS=' ';
1978    LC_ALL=C mount -p | while read node point fs foo; do
1979        opts=${fs#* };
1980        fs=${fs%% *};
1981        echo "${point// /\040} ${node// /\040} ${fs%% *} ${opts// /\040}";
1982    done
1983}
1984get_multilibdir ()
1985{
1986    if has_multilib_profile; then
1987        eerror "get_multilibdir called, but it shouldn't be needed with the new multilib approach.  Please file a bug at http://bugs.gentoo.org and assign it to eradicator@gentoo.org";
1988        exit 1;
1989    fi;
1990    echo ${CONF_MULTILIBDIR:=lib32}
1991}
1992has_multilib_profile ()
1993{
1994    [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
1995}
1996is-login-disabled ()
1997{
1998    shell=$(egetshell "$1");
1999    case ${shell} in
2000        /bin/false | /usr/bin/false | /sbin/nologin | /usr/sbin/nologin)
2001            return 0
2002        ;;
2003        *)
2004            return 1
2005        ;;
2006    esac
2007}
2008is_final_abi ()
2009{
2010    has_multilib_profile || return 0;
2011    local ALL_ABIS=$(get_install_abis);
2012    local LAST_ABI=${ALL_ABIS/* /};
2013    [[ ${LAST_ABI} == ${ABI} ]]
2014}
2015make_desktop_entry ()
2016{
2017    [[ -z $1 ]] && eerror "make_desktop_entry: You must specify the executable" && return 1;
2018    local exec=${1};
2019    local name=${2:-${PN}};
2020    local icon=${3:-${PN}};
2021    local type=${4};
2022    local path=${5};
2023    if [[ -z ${type} ]]; then
2024        local catmaj=${CATEGORY%%-*};
2025        local catmin=${CATEGORY##*-};
2026        case ${catmaj} in
2027            app)
2028                case ${catmin} in
2029                    accessibility)
2030                        type=Accessibility
2031                    ;;
2032                    admin)
2033                        type=System
2034                    ;;
2035                    antivirus)
2036                        type=System
2037                    ;;
2038                    arch)
2039                        type=Archiving
2040                    ;;
2041                    backup)
2042                        type=Archiving
2043                    ;;
2044                    cdr)
2045                        type=DiscBurning
2046                    ;;
2047                    dicts)
2048                        type=Dictionary
2049                    ;;
2050                    doc)
2051                        type=Documentation
2052                    ;;
2053                    editors)
2054                        type=TextEditor
2055                    ;;
2056                    emacs)
2057                        type=TextEditor
2058                    ;;
2059                    emulation)
2060                        type=Emulator
2061                    ;;
2062                    laptop)
2063                        type=HardwareSettings
2064                    ;;
2065                    office)
2066                        type=Office
2067                    ;;
2068                    pda)
2069                        type=PDA
2070                    ;;
2071                    vim)
2072                        type=TextEditor
2073                    ;;
2074                    xemacs)
2075                        type=TextEditor
2076                    ;;
2077                    *)
2078                        type=
2079                    ;;
2080                esac
2081            ;;
2082            dev)
2083                type="Development"
2084            ;;
2085            games)
2086                case ${catmin} in
2087                    action | fps)
2088                        type=ActionGame
2089                    ;;
2090                    arcade)
2091                        type=ArcadeGame
2092                    ;;
2093                    board)
2094                        type=BoardGame
2095                    ;;
2096                    emulation)
2097                        type=Emulator
2098                    ;;
2099                    kids)
2100                        type=KidsGame
2101                    ;;
2102                    puzzle)
2103                        type=LogicGame
2104                    ;;
2105                    roguelike)
2106                        type=RolePlaying
2107                    ;;
2108                    rpg)
2109                        type=RolePlaying
2110                    ;;
2111                    simulation)
2112                        type=Simulation
2113                    ;;
2114                    sports)
2115                        type=SportsGame
2116                    ;;
2117                    strategy)
2118                        type=StrategyGame
2119                    ;;
2120                    *)
2121                        type=
2122                    ;;
2123                esac;
2124                type="Game;${type}"
2125            ;;
2126            gnome)
2127                type="Gnome;GTK"
2128            ;;
2129            kde)
2130                type="KDE;Qt"
2131            ;;
2132            mail)
2133                type="Network;Email"
2134            ;;
2135            media)
2136                case ${catmin} in
2137                    gfx)
2138                        type=Graphics
2139                    ;;
2140                    radio)
2141                        type=Tuner
2142                    ;;
2143                    sound)
2144                        type=Audio
2145                    ;;
2146                    tv)
2147                        type=TV
2148                    ;;
2149                    video)
2150                        type=Video
2151                    ;;
2152                    *)
2153                        type=
2154                    ;;
2155                esac;
2156                type="AudioVideo;${type}"
2157            ;;
2158            net)
2159                case ${catmin} in
2160                    dialup)
2161                        type=Dialup
2162                    ;;
2163                    ftp)
2164                        type=FileTransfer
2165                    ;;
2166                    im)
2167                        type=InstantMessaging
2168                    ;;
2169                    irc)
2170                        type=IRCClient
2171                    ;;
2172                    mail)
2173                        type=Email
2174                    ;;
2175                    news)
2176                        type=News
2177                    ;;
2178                    nntp)
2179                        type=News
2180                    ;;
2181                    p2p)
2182                        type=FileTransfer
2183                    ;;
2184                    *)
2185                        type=
2186                    ;;
2187                esac;
2188                type="Network;${type}"
2189            ;;
2190            sci)
2191                case ${catmin} in
2192                    astro*)
2193                        type=Astronomy
2194                    ;;
2195                    bio*)
2196                        type=Biology
2197                    ;;
2198                    calc*)
2199                        type=Calculator
2200                    ;;
2201                    chem*)
2202                        type=Chemistry
2203                    ;;
2204                    elec*)
2205                        type=Electronics
2206                    ;;
2207                    geo*)
2208                        type=Geology
2209                    ;;
2210                    math*)
2211                        type=Math
2212                    ;;
2213                    physics)
2214                        type=Physics
2215                    ;;
2216                    visual*)
2217                        type=DataVisualization
2218                    ;;
2219                    *)
2220                        type=
2221                    ;;
2222                esac;
2223                type="Science;${type}"
2224            ;;
2225            sys)
2226                type="System"
2227            ;;
2228            www)
2229                case ${catmin} in
2230                    client)
2231                        type=WebBrowser
2232                    ;;
2233                    *)
2234                        type=
2235                    ;;
2236                esac;
2237                type="Network"
2238            ;;
2239            *)
2240                type=
2241            ;;
2242        esac;
2243    fi;
2244    if [ "${SLOT}" == "0" ]; then
2245        local desktop_name="${PN}";
2246    else
2247        local desktop_name="${PN}-${SLOT}";
2248    fi;
2249    local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop";
2250    cat > "${desktop}"  <<-EOF
2251[Desktop Entry]
2252Version=1.0
2253Name=${name}
2254Type=Application
2255Comment=${DESCRIPTION}
2256Exec=${exec}
2257TryExec=${exec%% *}
2258Icon=${icon}
2259Categories=${type};
2260EOF
2261
2262    [[ -n ${path} ]] && echo "Path=${path}" >> "${desktop}";
2263    ( insinto /usr/share/applications;
2264    doins "${desktop}" )
2265}
2266make_session_desktop ()
2267{
2268    [[ -z $1 ]] && eerror "make_session_desktop: You must specify the title" && return 1;
2269    [[ -z $2 ]] && eerror "make_session_desktop: You must specify the command" && return 1;
2270    local title=$1;
2271    local command=$2;
2272    local desktop=${T}/${wm}.desktop;
2273    cat > "${desktop}"  <<-EOF
2274[Desktop Entry]
2275Name=${title}
2276Comment=This session logs you into ${title}
2277Exec=${command}
2278TryExec=${command}
2279Type=Application
2280EOF
2281
2282    ( insinto /usr/share/xsessions;
2283    doins "${desktop}" )
2284}
2285make_wrapper ()
2286{
2287    local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5;
2288    local tmpwrapper=$(emktemp);
2289    cat > "${tmpwrapper}"  <<EOF
2290#!/bin/sh
2291cd "${chdir:-.}"
2292if [ -n "${libdir}" ] ; then
2293        if [ "\${LD_LIBRARY_PATH+set}" = "set" ] ; then
2294                export LD_LIBRARY_PATH="\${LD_LIBRARY_PATH}:${libdir}"
2295        else
2296                export LD_LIBRARY_PATH="${libdir}"
2297        fi
2298fi
2299exec ${bin} "\$@"
2300EOF
2301
2302    chmod go+rx "${tmpwrapper}";
2303    if [[ -n ${path} ]]; then
2304        ( exeinto "${path}";
2305        newexe "${tmpwrapper}" "${wrapper}" ) || die;
2306    else
2307        newbin "${tmpwrapper}" "${wrapper}" || die;
2308    fi
2309}
2310multilib_env ()
2311{
2312    local CTARGET=${1:-${CTARGET}};
2313    case ${CTARGET} in
2314        x86_64*)
2315            export CFLAGS_x86=${CFLAGS_x86--m32};
2316            export CHOST_x86=${CTARGET/x86_64/i686};
2317            export CTARGET_x86=${CHOST_x86};
2318            export CDEFINE_x86="__i386__";
2319            export LIBDIR_x86="lib";
2320            export CFLAGS_amd64=${CFLAGS_amd64--m64};
2321            export CHOST_amd64=${CTARGET};
2322            export CTARGET_amd64=${CHOST_amd64};
2323            export CDEFINE_amd64="__x86_64__";
2324            export LIBDIR_amd64="lib64";
2325            export MULTILIB_ABIS="amd64 x86";
2326            export DEFAULT_ABI="amd64"
2327        ;;
2328        mips64*)
2329            export CFLAGS_o32=${CFLAGS_o32--mabi=32};
2330            export CHOST_o32=${CTARGET/mips64/mips};
2331            export CTARGET_o32=${CHOST_o32};
2332            export CDEFINE_o32="_MIPS_SIM == _ABIO32";
2333            export LIBDIR_o32="lib";
2334            export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
2335            export CHOST_n32=${CTARGET};
2336            export CTARGET_n32=${CHOST_n32};
2337            export CDEFINE_n32="_MIPS_SIM == _ABIN32";
2338            export LIBDIR_n32="lib32";
2339            export CFLAGS_n64=${CFLAGS_n64--mabi=64};
2340            export CHOST_n64=${CTARGET};
2341            export CTARGET_n64=${CHOST_n64};
2342            export CDEFINE_n64="_MIPS_SIM == _ABI64";
2343            export LIBDIR_n64="lib64";
2344            export MULTILIB_ABIS="n64 n32 o32";
2345            export DEFAULT_ABI="n32"
2346        ;;
2347        powerpc64*)
2348            export CFLAGS_ppc=${CFLAGS_ppc--m32};
2349            export CHOST_ppc=${CTARGET/powerpc64/powerpc};
2350            export CTARGET_ppc=${CHOST_ppc};
2351            export CDEFINE_ppc="!__powerpc64__";
2352            export LIBDIR_ppc="lib";
2353            export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
2354            export CHOST_ppc64=${CTARGET};
2355            export CTARGET_ppc64=${CHOST_ppc64};
2356            export CDEFINE_ppc64="__powerpc64__";
2357            export LIBDIR_ppc64="lib64";
2358            export MULTILIB_ABIS="ppc64 ppc";
2359            export DEFAULT_ABI="ppc64"
2360        ;;
2361        s390x*)
2362            export CFLAGS_s390=${CFLAGS_s390--m31};
2363            export CHOST_s390=${CTARGET/s390x/s390};
2364            export CTARGET_s390=${CHOST_s390};
2365            export CDEFINE_s390="!__s390x__";
2366            export LIBDIR_s390="lib";
2367            export CFLAGS_s390x=${CFLAGS_s390x--m64};
2368            export CHOST_s390x=${CTARGET};
2369            export CTARGET_s390x=${CHOST_s390x};
2370            export CDEFINE_s390x="__s390x__";
2371            export LIBDIR_s390x="lib64";
2372            export MULTILIB_ABIS="s390x s390";
2373            export DEFAULT_ABI="s390x"
2374        ;;
2375        sparc*)
2376            export CFLAGS_sparc32=${CFLAGS_sparc32};
2377            export CHOST_sparc32=${CTARGET/sparc64/sparc};
2378            export CTARGET_sparc32=${CHOST_sparc32};
2379            export CDEFINE_sparc32="!__arch64__";
2380            export LIBDIR_sparc32="lib";
2381            export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
2382            export CHOST_sparc64=${CTARGET};
2383            export CTARGET_sparc64=${CHOST_sparc64};
2384            export CDEFINE_sparc64="__arch64__";
2385            export LIBDIR_sparc64="lib64";
2386            export MULTILIB_ABIS="${MULTILIB_ABIS-sparc64 sparc32}";
2387            export DEFAULT_ABI="${DEFAULT_ABI-sparc64}"
2388        ;;
2389        *)
2390            export MULTILIB_ABIS="default";
2391            export DEFAULT_ABI="default"
2392        ;;
2393    esac
2394}
2395multilib_toolchain_setup ()
2396{
2397    export ABI=$1;
2398    if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
2399        : ${CCACHE_DISABLE:=multilib-disable};
2400    else
2401        if [[ ${CCACHE_DISABLE} == "multilib-disable" ]]; then
2402            unset CCACHE_DISABLE;
2403        fi;
2404    fi;
2405    export CCACHE_DISABLE;
2406    if has_version app-admin/eselect-compiler; then
2407        export LD="ld $(get_abi_LDFLAGS $1)";
2408        export AS="as $(get_abi_ASFLAGS $1)";
2409        export CHOST=$(get_abi_CHOST $1);
2410        export CBUILD=$(get_abi_CHOST $1);
2411    else
2412        tc-export CC;
2413    fi
2414}
2415newicon ()
2416{
2417    ( insinto /usr/share/pixmaps;
2418    newins "$@" )
2419}
2420newmenu ()
2421{
2422    ( insinto /usr/share/applications;
2423    newins "$@" )
2424}
2425number_abis ()
2426{
2427    get_install_abis | wc -w
2428}
2429pkg_nofetch ()
2430{
2431    _eapi0_pkg_nofetch "$@"
2432}
2433pkg_preinst ()
2434{
2435    subversion_pkg_preinst "$@"
2436}
2437prep_ml_includes ()
2438{
2439    if [[ $(number_abis) -gt 1 ]]; then
2440        local dir;
2441        local dirs;
2442        local base;
2443        if [[ $# -eq 0 ]]; then
2444            dirs=/usr/include;
2445        else
2446            dirs="$@";
2447        fi;
2448        for dir in ${dirs};
2449        do
2450            base=${T}/gentoo-multilib/${dir}/gentoo-multilib;
2451            mkdir -p "${base}";
2452            [[ -d ${base}/${ABI} ]] && rm -rf "${base}/${ABI}";
2453            mv "${D}/${dir}" "${base}/${ABI}";
2454        done;
2455        if is_final_abi; then
2456            base=${T}/gentoo-multilib;
2457            pushd "${base}";
2458            find . | tar -c -T - -f - | tar -x --no-same-owner -f - -C "${D}";
2459            popd;
2460            set --;
2461            for dir in ${dirs};
2462            do
2463                set -- "$@" "${dir}";
2464                local abi;
2465                for abi in $(get_install_abis);
2466                do
2467                    set -- "$@" "$(get_abi_CDEFINE ${abi}):${dir}/gentoo-multilib/${abi}";
2468                done;
2469                create_ml_includes "$@";
2470            done;
2471        fi;
2472    fi
2473}
2474preserve_old_lib ()
2475{
2476    if [[ ${EBUILD_PHASE} != "preinst" ]]; then
2477        eerror "preserve_old_lib() must be called from pkg_preinst() only";
2478        die "Invalid preserve_old_lib() usage";
2479    fi;
2480    [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]";
2481    has preserve-libs ${FEATURES} && return 0;
2482    local lib dir;
2483    for lib in "$@";
2484    do
2485        [[ -e ${ROOT}/${lib} ]] || continue;
2486        dir=${lib%/*};
2487        dodir ${dir} || die "dodir ${dir} failed";
2488        cp "${ROOT}"/${lib} "${D}"/${lib} || die "cp ${lib} failed";
2489        touch "${D}"/${lib};
2490    done
2491}
2492preserve_old_lib_notify ()
2493{
2494    if [[ ${EBUILD_PHASE} != "postinst" ]]; then
2495        eerror "preserve_old_lib_notify() must be called from pkg_postinst() only";
2496        die "Invalid preserve_old_lib_notify() usage";
2497    fi;
2498    has preserve-libs ${FEATURES} && return 0;
2499    local lib notice=0;
2500    for lib in "$@";
2501    do
2502        [[ -e ${ROOT}/${lib} ]] || continue;
2503        if [[ ${notice} -eq 0 ]]; then
2504            notice=1;
2505            ewarn "Old versions of installed libraries were detected on your system.";
2506            ewarn "In order to avoid breaking packages that depend on these old libs,";
2507            ewarn "the libraries are not being removed.  You need to run revdep-rebuild";
2508            ewarn "in order to remove these old dependencies.  If you do not have this";
2509            ewarn "helper program, simply emerge the 'gentoolkit' package.";
2510            ewarn;
2511        fi;
2512        ewarn "  # revdep-rebuild --library ${lib##*/}";
2513    done;
2514    if [[ ${notice} -eq 1 ]]; then
2515        ewarn;
2516        ewarn "Once you've finished running revdep-rebuild, it should be safe to";
2517        ewarn "delete the old libraries.  Here is a copy & paste for the lazy:";
2518        for lib in "$@";
2519        do
2520            ewarn "  # rm '${lib}'";
2521        done;
2522    fi
2523}
2524seq ()
2525{
2526    local p=$(type -P seq);
2527    case $# in
2528        1)
2529            min=1 max=$1 step=1
2530        ;;
2531        2)
2532            min=$1 max=$2 step=1
2533        ;;
2534        3)
2535            min=$1 max=$3 step=$2
2536        ;;
2537        *)
2538            die "seq called with wrong number of arguments"
2539        ;;
2540    esac;
2541    if [[ -z ${p} ]]; then
2542        local reps;
2543        if [[ ${step} != 0 ]]; then
2544            reps=$(( ($max-$min) / $step +1 ));
2545        else
2546            reps=0;
2547        fi;
2548        jot $reps $min $max $step;
2549    else
2550        "${p}" $min $step $max;
2551    fi
2552}
2553src_compile ()
2554{
2555    local myconf;
2556    myconf="${myconf}
2557            $(use_enable gstreamer)         $(use_enable xine)                  $(use_enable vlc)";
2558    econf ${myconf} || die "Configuration failed";
2559    emake || die "Make failed"
2560}
2561src_install ()
2562{
2563    enlightenment_src_install "$@"
2564}
2565src_test ()
2566{
2567    _eapi0_src_test "$@"
2568}
2569src_unpack ()
2570{
2571    enlightenment_src_unpack "$@"
2572}
2573strip-linguas ()
2574{
2575    local ls newls nols;
2576    if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
2577        local op=$1;
2578        shift;
2579        ls=$(find "$1" -name '*.po' -exec basename {} .po \;);
2580        shift;
2581        local d f;
2582        for d in "$@";
2583        do
2584            if [[ ${op} == "-u" ]]; then
2585                newls=${ls};
2586            else
2587                newls="";
2588            fi;
2589            for f in $(find "$d" -name '*.po' -exec basename {} .po \;);
2590            do
2591                if [[ ${op} == "-i" ]]; then
2592                    hasq ${f} ${ls} && newls="${newls} ${f}";
2593                else
2594                    hasq ${f} ${ls} || newls="${newls} ${f}";
2595                fi;
2596            done;
2597            ls=${newls};
2598        done;
2599    else
2600        ls="$@";
2601    fi;
2602    nols="";
2603    newls="";
2604    for f in ${LINGUAS};
2605    do
2606        if hasq ${f} ${ls}; then
2607            newls="${newls} ${f}";
2608        else
2609            nols="${nols} ${f}";
2610        fi;
2611    done;
2612    [[ -n ${nols} ]] && ewarn "Sorry, but ${PN} does not support the LINGUAs:" ${nols};
2613    export LINGUAS=${newls:1}
2614}
2615subversion__get_peg_revision ()
2616{
2617    local repo_uri="${1}";
2618    debug-print "${FUNCNAME}: repo_uri = ${repo_uri}";
2619    if [[ ${repo_uri} != *@* ]]; then
2620        debug-print "${FUNCNAME}: repo_uri does not have a peg revision.";
2621    fi;
2622    local peg_rev=;
2623    [[ ${repo_uri} = *@* ]] && peg_rev="${repo_uri##*@}";
2624    debug-print "${FUNCNAME}: peg_rev = ${peg_rev}";
2625    echo "${peg_rev}"
2626}
2627subversion__get_repository_uri ()
2628{
2629    local repo_uri="${1}";
2630    debug-print "${FUNCNAME}: repo_uri = ${repo_uri}";
2631    if [[ -z ${repo_uri} ]]; then
2632        die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty.";
2633    fi;
2634    if [[ -z ${repo_uri##*/} ]]; then
2635        repo_uri="${repo_uri%/}";
2636    fi;
2637    repo_uri="${repo_uri%@*}";
2638    echo "${repo_uri}"
2639}
2640subversion__get_wc_path ()
2641{
2642    local repo_uri="$(subversion__get_repository_uri "${1}")";
2643    debug-print "${FUNCNAME}: repo_uri = ${repo_uri}";
2644    echo "${ESVN_STORE_DIR}/${ESVN_PROJECT}/${repo_uri##*/}"
2645}
2646subversion__svn_info ()
2647{
2648    local target="${1}";
2649    local key="${2}";
2650    env LC_ALL=C svn info "${target}" | grep -i "^${key}" | cut -d" " -f2-
2651}
2652subversion_bootstrap ()
2653{
2654    if has "export" ${ESVN_RESTRICT}; then
2655        return;
2656    fi;
2657    cd "${S}";
2658    if [[ -n ${ESVN_PATCHES} ]]; then
2659        einfo "apply patches -->";
2660        local patch fpatch;
2661        for patch in ${ESVN_PATCHES};
2662        do
2663            if [[ -f ${patch} ]]; then
2664                epatch "${patch}";
2665            else
2666                for fpatch in ${FILESDIR}/${patch};
2667                do
2668                    if [[ -f ${fpatch} ]]; then
2669                        epatch "${fpatch}";
2670                    else
2671                        die "${ESVN}: ${patch} not found";
2672                    fi;
2673                done;
2674            fi;
2675        done;
2676        echo;
2677    fi;
2678    if [[ -n ${ESVN_BOOTSTRAP} ]]; then
2679        einfo "begin bootstrap -->";
2680        if [[ -f ${ESVN_BOOTSTRAP} && -x ${ESVN_BOOTSTRAP} ]]; then
2681            einfo "   bootstrap with a file: ${ESVN_BOOTSTRAP}";
2682            eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP.";
2683        else
2684            einfo "   bootstrap with command: ${ESVN_BOOTSTRAP}";
2685            eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP.";
2686        fi;
2687    fi
2688}
2689subversion_fetch ()
2690{
2691    local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")";
2692    local revision="$(subversion__get_peg_revision "${1:-${ESVN_REPO_URI}}")";
2693    local S_dest="${2}";
2694    if [[ -z ${repo_uri} ]]; then
2695        die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty.";
2696    fi;
2697    [[ -n "${ESVN_REVISION}" ]] && revision="${ESVN_REVISION}";
2698    local protocol="${repo_uri%%:*}";
2699    case "${protocol}" in
2700        http | https)
2701            if [ CHOST = CBUILD ]; then
2702                if ! built_with_use --missing true -o dev-util/subversion webdav-neon webdav-serf || built_with_use --missing false dev-util/subversion nowebdav; then
2703                    echo;
2704                    eerror "In order to emerge this package, you need to";
2705                    eerror "reinstall Subversion with support for WebDAV.";
2706                    eerror "Subversion requires either Neon or Serf to support WebDAV.";
2707                    echo;
2708                    die "${ESVN}: reinstall Subversion with support for WebDAV.";
2709                fi;
2710            fi
2711        ;;
2712        svn | svn+ssh)
2713
2714        ;;
2715        *)
2716            die "${ESVN}: fetch from '${protocol}' is not yet implemented."
2717        ;;
2718    esac;
2719    addread "/etc/subversion";
2720    addwrite "${ESVN_STORE_DIR}";
2721    if [[ ! -d ${ESVN_STORE_DIR} ]]; then
2722        debug-print "${FUNCNAME}: initial checkout. creating subversion directory";
2723        mkdir -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}.";
2724    fi;
2725    cd "${ESVN_STORE_DIR}" || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}";
2726    local wc_path="$(subversion__get_wc_path "${repo_uri}")";
2727    local options="${ESVN_OPTIONS} --config-dir ${ESVN_STORE_DIR}/.subversion";
2728    [[ -n "${revision}" ]] && options="${options} -r ${revision}";
2729    if [[ "${ESVN_OPTIONS}" = *-r* ]]; then
2730        ewarn "\${ESVN_OPTIONS} contains -r, this usage is unsupported. Please";
2731        ewarn "see \${ESVN_REPO_URI}";
2732    fi;
2733    debug-print "${FUNCNAME}: wc_path = \"${wc_path}\"";
2734    debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\"";
2735    debug-print "${FUNCNAME}: options = \"${options}\"";
2736    if [[ ! -d ${wc_path}/.svn ]]; then
2737        if [[ -n ${ESVN_OFFLINE} ]]; then
2738            ewarn "ESVN_OFFLINE cannot be used when the there is no existing checkout.";
2739        fi;
2740        einfo "subversion check out start -->";
2741        einfo "     repository: ${repo_uri}${revision:+@}${revision}";
2742        debug-print "${FUNCNAME}: ${ESVN_FETCH_CMD} ${options} ${repo_uri}${revision:+@}${revision}";
2743        mkdir -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}.";
2744        cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}";
2745        ${ESVN_FETCH_CMD} ${options} "${repo_uri}${revision:+@}${revision}" || die "${ESVN}: can't fetch to ${wc_path} from ${repo_uri}.";
2746    else
2747        if [[ -n ${ESVN_OFFLINE} ]]; then
2748            subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy.";
2749            if [[ -n ${ESVN_REVISION} && ${ESVN_REVISION} != ${ESVN_WC_REVISION} ]]; then
2750                die "${ESVN}: You requested off-line updating and revision ${ESVN_REVISION} but only revision ${ESVN_WC_REVISION} is available locally.";
2751            fi;
2752            einfo "Fetching disabled: Using existing repository copy at revision ${ESVN_WC_REVISION}.";
2753        else
2754            subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy.";
2755            local esvn_up_freq=;
2756            if [[ -n ${ESVN_UP_FREQ} ]]; then
2757                if [[ -n ${ESVN_UP_FREQ//[[:digit:]]} ]]; then
2758                    die "${ESVN}: ESVN_UP_FREQ must be an integer value corresponding to the minimum number of hours between svn up.";
2759                else
2760                    if [[ -z $(find "${wc_path}/.svn/entries" -mmin "+$((ESVN_UP_FREQ*60))") ]]; then
2761                        einfo "Fetching disabled since ${ESVN_UP_FREQ} hours has not passed since last update.";
2762                        einfo "Using existing repository copy at revision ${ESVN_WC_REVISION}.";
2763                        esvn_up_freq=no_update;
2764                    fi;
2765                fi;
2766            fi;
2767            if [[ -z ${esvn_up_freq} ]]; then
2768                if [[ ${ESVN_WC_URL} != $(subversion__get_repository_uri "${repo_uri}") ]]; then
2769                    einfo "subversion switch start -->";
2770                    einfo "     old repository: ${ESVN_WC_URL}@${ESVN_WC_REVISION}";
2771                    einfo "     new repository: ${repo_uri}${revision:+@}${revision}";
2772                    debug-print "${FUNCNAME}: ${ESVN_SWITCH_CMD} ${options} ${repo_uri}";
2773                    cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}";
2774                    ${ESVN_SWITCH_CMD} ${options} ${repo_uri} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}";
2775                else
2776                    einfo "subversion update start -->";
2777                    einfo "     repository: ${repo_uri}${revision:+@}${revision}";
2778                    debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}";
2779                    cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}";
2780                    ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}.";
2781                fi;
2782            fi;
2783        fi;
2784    fi;
2785    einfo "   working copy: ${wc_path}";
2786    if ! has "export" ${ESVN_RESTRICT}; then
2787        cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}";
2788        local S="${S}/${S_dest}";
2789        mkdir -p "${S}";
2790        rsync -rlpgo --exclude=".svn/" . "${S}" || die "${ESVN}: can't export to ${S}.";
2791    fi;
2792    echo
2793}
2794subversion_pkg_preinst ()
2795{
2796    local pkgdate=$(date "+%Y%m%d %H:%M:%S");
2797    subversion_wc_info "${1:-${ESVN_REPO_URI}}";
2798    if [[ -n ${ESCM_LOGDIR} ]]; then
2799        local dir="${ROOT}/${ESCM_LOGDIR}/${CATEGORY}";
2800        if [[ ! -d ${dir} ]]; then
2801            mkdir -p "${dir}" || eerror "Failed to create '${dir}' for logging svn revision to '${PORTDIR_SCM}'";
2802        fi;
2803        local logmessage="svn: ${pkgdate} - ${PF}:${SLOT} was merged at revision ${ESVN_WC_REVISION}";
2804        if [[ -d ${dir} ]]; then
2805            echo "${logmessage}" >> "${dir}/${PN}.log";
2806        else
2807            eerror "Could not log the message '${logmessage}' to '${dir}/${PN}.log'";
2808        fi;
2809    fi
2810}
2811subversion_src_unpack ()
2812{
2813    subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch.";
2814    subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap."
2815}
2816subversion_wc_info ()
2817{
2818    local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")";
2819    local wc_path="$(subversion__get_wc_path "${repo_uri}")";
2820    debug-print "${FUNCNAME}: repo_uri = ${repo_uri}";
2821    debug-print "${FUNCNAME}: wc_path = ${wc_path}";
2822    if [[ ! -d ${wc_path} ]]; then
2823        return 1;
2824    fi;
2825    export ESVN_WC_URL="$(subversion__svn_info "${wc_path}" "URL")";
2826    export ESVN_WC_ROOT="$(subversion__svn_info "${wc_path}" "Repository Root")";
2827    export ESVN_WC_UUID="$(subversion__svn_info "${wc_path}" "Repository UUID")";
2828    export ESVN_WC_REVISION="$(subversion__svn_info "${wc_path}" "Revision")";
2829    export ESVN_WC_PATH="${wc_path}"
2830}
2831tc-arch ()
2832{
2833    tc-ninja_magic_to_arch portage "$@"
2834}
2835tc-arch-kernel ()
2836{
2837    tc-ninja_magic_to_arch kern "$@"
2838}
2839tc-endian ()
2840{
2841    local host=$1;
2842    [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
2843    host=${host%%-*};
2844    case ${host} in
2845        alpha*)
2846            echo big
2847        ;;
2848        arm*b*)
2849            echo big
2850        ;;
2851        arm*)
2852            echo little
2853        ;;
2854        cris*)
2855            echo little
2856        ;;
2857        hppa*)
2858            echo big
2859        ;;
2860        i?86*)
2861            echo little
2862        ;;
2863        ia64*)
2864            echo little
2865        ;;
2866        m68*)
2867            echo big
2868        ;;
2869        mips*l*)
2870            echo little
2871        ;;
2872        mips*)
2873            echo big
2874        ;;
2875        powerpc*)
2876            echo big
2877        ;;
2878        s390*)
2879            echo big
2880        ;;
2881        sh*b*)
2882            echo big
2883        ;;
2884        sh*)
2885            echo little
2886        ;;
2887        sparc*)
2888            echo big
2889        ;;
2890        x86_64*)
2891            echo little
2892        ;;
2893        *)
2894            echo wtf
2895        ;;
2896    esac
2897}
2898tc-export ()
2899{
2900    local var;
2901    for var in "$@";
2902    do
2903        [[ $(type -t tc-get${var}) != "function" ]] && die "tc-export: invalid export variable '${var}'";
2904        eval tc-get${var} > /dev/null;
2905    done
2906}
2907tc-getAR ()
2908{
2909    tc-getPROG AR ar "$@"
2910}
2911tc-getAS ()
2912{
2913    tc-getPROG AS as "$@"
2914}
2915tc-getBUILD_CC ()
2916{
2917    local v;
2918    for v in CC_FOR_BUILD BUILD_CC HOSTCC;
2919    do
2920        if [[ -n ${!v} ]]; then
2921            export BUILD_CC=${!v};
2922            echo "${!v}";
2923            return 0;
2924        fi;
2925    done;
2926    local search=;
2927    if [[ -n ${CBUILD} ]]; then
2928        search=$(type -p ${CBUILD}-gcc);
2929        search=${search##*/};
2930    fi;
2931    search=${search:-gcc};
2932    export BUILD_CC=${search};
2933    echo "${search}"
2934}
2935tc-getCC ()
2936{
2937    tc-getPROG CC gcc "$@"
2938}
2939tc-getCPP ()
2940{
2941    tc-getPROG CPP cpp "$@"
2942}
2943tc-getCXX ()
2944{
2945    tc-getPROG CXX g++ "$@"
2946}
2947tc-getF77 ()
2948{
2949    tc-getPROG F77 f77 "$@"
2950}
2951tc-getFC ()
2952{
2953    tc-getPROG FC gfortran "$@"
2954}
2955tc-getGCJ ()
2956{
2957    tc-getPROG GCJ gcj "$@"
2958}
2959tc-getLD ()
2960{
2961    tc-getPROG LD ld "$@"
2962}
2963tc-getNM ()
2964{
2965    tc-getPROG NM nm "$@"
2966}
2967tc-getPROG ()
2968{
2969    local var=$1;
2970    local prog=$2;
2971    if [[ -n ${!var} ]]; then
2972        echo "${!var}";
2973        return 0;
2974    fi;
2975    local search=;
2976    [[ -n $3 ]] && search=$(type -p "$3-${prog}");
2977    [[ -z ${search} && -n ${CHOST} ]] && search=$(type -p "${CHOST}-${prog}");
2978    [[ -n ${search} ]] && prog=${search##*/};
2979    export ${var}=${prog};
2980    echo "${!var}"
2981}
2982tc-getRANLIB ()
2983{
2984    tc-getPROG RANLIB ranlib "$@"
2985}
2986tc-getSTRIP ()
2987{
2988    tc-getPROG STRIP strip "$@"
2989}
2990tc-is-cross-compiler ()
2991{
2992    return $([[ ${CBUILD:-${CHOST}} != ${CHOST} ]])
2993}
2994tc-is-softfloat ()
2995{
2996    case ${CTARGET} in
2997        bfin* | h8300*)
2998            echo "only"
2999        ;;
3000        *)
3001            [[ ${CTARGET//_/-} == *-softfloat-* ]] && echo "yes" || echo "no"
3002        ;;
3003    esac
3004}
3005tc-ninja_magic_to_arch ()
3006{
3007    function ninj ()
3008    {
3009        [[ ${type} == "kern" ]] && echo $1 || echo $2
3010    };
3011    local type=$1;
3012    local host=$2;
3013    [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
3014    case ${host} in
3015        alpha*)
3016            echo alpha
3017        ;;
3018        arm*)
3019            echo arm
3020        ;;
3021        avr*)
3022            ninj avr32 avr
3023        ;;
3024        bfin*)
3025            ninj blackfin bfin
3026        ;;
3027        cris*)
3028            echo cris
3029        ;;
3030        hppa*)
3031            ninj parisc hppa
3032        ;;
3033        i?86*)
3034            if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -lt $(KV_to_int 2.6.24) || ${host} == *freebsd* ]]; then
3035                echo i386;
3036            else
3037                echo x86;
3038            fi
3039        ;;
3040        ia64*)
3041            echo ia64
3042        ;;
3043        m68*)
3044            echo m68k
3045        ;;
3046        mips*)
3047            echo mips
3048        ;;
3049        nios2*)
3050            echo nios2
3051        ;;
3052        nios*)
3053            echo nios
3054        ;;
3055        powerpc*)
3056            if [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]] && [[ ${type} == "kern" ]]; then
3057                echo powerpc;
3058            else
3059                if [[ $(KV_to_int ${KV}) -eq $(KV_to_int 2.6.15) ]] && [[ ${type} == "kern" ]]; then
3060                    if [[ ${host} == powerpc64* ]] || [[ ${PROFILE_ARCH} == "ppc64" ]]; then
3061                        echo powerpc;
3062                    else
3063                        echo ppc;
3064                    fi;
3065                else
3066                    if [[ ${host} == powerpc64* ]]; then
3067                        echo ppc64;
3068                    else
3069                        if [[ ${PROFILE_ARCH} == "ppc64" ]]; then
3070                            ninj ppc64 ppc;
3071                        else
3072                            echo ppc;
3073                        fi;
3074                    fi;
3075                fi;
3076            fi
3077        ;;
3078        s390*)
3079            echo s390
3080        ;;
3081        sh64*)
3082            ninj sh64 sh
3083        ;;
3084        sh*)
3085            echo sh
3086        ;;
3087        sparc64*)
3088            ninj sparc64 sparc
3089        ;;
3090        sparc*)
3091            [[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
3092        ;;
3093        vax*)
3094            echo vax
3095        ;;
3096        x86_64*)
3097            if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.24) ]]; then
3098                echo x86;
3099            else
3100                ninj x86_64 amd64;
3101            fi
3102        ;;
3103        *)
3104            echo unknown
3105        ;;
3106    esac
3107}
3108treecopy ()
3109{
3110    dest=${!#};
3111    files_count=$#;
3112    while (( $# > 1 )); do
3113        dirstruct=$(dirname "$1");
3114        mkdir -p "${dest}/${dirstruct}";
3115        cp -pPR "$1" "${dest}/${dirstruct}";
3116        shift;
3117    done
3118}
3119uclibctoolize ()
3120{
3121    ewarn "uclibctoolize() is deprecated, please just use elibtoolize()!";
3122    elibtoolize
3123}
3124unpack_makeself ()
3125{
3126    local src_input=${1:-${A}};
3127    local src=$(find_unpackable_file "${src_input}");
3128    local skip=$2;
3129    local exe=$3;
3130    [[ -z ${src} ]] && die "Could not locate source for '${src_input}'";
3131    local shrtsrc=$(basename "${src}");
3132    echo ">>> Unpacking ${shrtsrc} to ${PWD}";
3133    if [[ -z ${skip} ]]; then
3134        local ver=$(grep -a '#.*Makeself' "${src}" | awk '{print $NF}');
3135        local skip=0;
3136        exe=tail;
3137        case ${ver} in
3138            1.5.* | 1.6.0-nv)
3139                skip=$(grep -a ^skip= "${src}" | cut -d= -f2)
3140            ;;
3141            2.0 | 2.0.1)
3142                skip=$(grep -a ^'       'tail "${src}" | awk '{print $2}' | cut -b2-)
3143            ;;
3144            2.1.1)
3145                skip=$(grep -a ^offset= "${src}" | awk '{print $2}' | cut -b2-);
3146                let skip="skip + 1"
3147            ;;
3148            2.1.2)
3149                skip=$(grep -a ^offset= "${src}" | awk '{print $3}' | head -n 1);
3150                let skip="skip + 1"
3151            ;;
3152            2.1.3)
3153                skip=`grep -a ^offset= "${src}" | awk '{print $3}'`;
3154                let skip="skip + 1"
3155            ;;
3156            2.1.4 | 2.1.5)
3157                skip=$(grep -a offset=.*head.*wc "${src}" | awk '{print $3}' | head -n 1);
3158                skip=$(head -n ${skip} "${src}" | wc -c);
3159                exe="dd"
3160            ;;
3161            *)
3162                eerror "I'm sorry, but I was unable to support the Makeself file.";
3163                eerror "The version I detected was '${ver}'.";
3164                eerror "Please file a bug about the file ${shrtsrc} at";
3165                eerror "http://bugs.gentoo.org/ so that support can be added.";
3166                die "makeself version '${ver}' not supported"
3167            ;;
3168        esac;
3169        debug-print "Detected Makeself version ${ver} ... using ${skip} as offset";
3170    fi;
3171    case ${exe} in
3172        tail)
3173            exe="tail -n +${skip} '${src}'"
3174        ;;
3175        dd)
3176            exe="dd ibs=${skip} skip=1 obs=1024 conv=sync if='${src}'"
3177        ;;
3178        *)
3179            die "makeself cant handle exe '${exe}'"
3180        ;;
3181    esac;
3182    local tmpfile=$(emktemp);
3183    eval ${exe} 2> /dev/null | head -c 512 > "${tmpfile}";
3184    local filetype=$(file -b "${tmpfile}");
3185    case ${filetype} in
3186        *tar\ archive*)
3187            eval ${exe} | tar --no-same-owner -xf -
3188        ;;
3189        bzip2*)
3190            eval ${exe} | bzip2 -dc | tar --no-same-owner -xf -
3191        ;;
3192        gzip*)
3193            eval ${exe} | tar --no-same-owner -xzf -
3194        ;;
3195        compress*)
3196            eval ${exe} | gunzip | tar --no-same-owner -xf -
3197        ;;
3198        *)
3199            eerror "Unknown filetype \"${filetype}\" ?";
3200            false
3201        ;;
3202    esac;
3203    _pipestatus="${PIPESTATUS[*]}";
3204    [[ "${_pipestatus// /}" -eq 0 ]] || die "failure unpacking (${filetype}) makeself ${shrtsrc} ('${ver}' +${skip})"
3205}
3206unpack_pdv ()
3207{
3208    local src=$(find_unpackable_file "$1");
3209    local sizeoff_t=$2;
3210    [[ -z ${src} ]] && die "Could not locate source for '$1'";
3211    [[ -z ${sizeoff_t} ]] && die "No idea what off_t size was used for this pdv :(";
3212    local shrtsrc=$(basename "${src}");
3213    echo ">>> Unpacking ${shrtsrc} to ${PWD}";
3214    local metaskip=$(tail -c ${sizeoff_t} "${src}" | hexdump -e \"%i\");
3215    local tailskip=$(tail -c $((${sizeoff_t}*2)) "${src}" | head -c ${sizeoff_t} | hexdump -e \"%i\");
3216    local metafile=$(emktemp);
3217    tail -c +$((${metaskip}+1)) "${src}" > "${metafile}";
3218    local datafile=$(tail -c +$((${metaskip}+1)) "${src}" | strings | head -n 1);
3219    datafile=$(basename "${datafile}");
3220    local tmpfile=$(emktemp);
3221    tail -c +$((${tailskip}+1)) ${src} 2> /dev/null | head -c 512 > ${tmpfile};
3222    local iscompressed=$(file -b "${tmpfile}");
3223    if [[ ${iscompressed:0:8} == "compress" ]]; then
3224        iscompressed=1;
3225        mv ${tmpfile}{,.Z};
3226        gunzip ${tmpfile};
3227    else
3228        iscompressed=0;
3229    fi;
3230    local istar=$(file -b "${tmpfile}");
3231    if [[ ${istar:0:9} == "POSIX tar" ]]; then
3232        istar=1;
3233    else
3234        istar=0;
3235    fi;
3236    if [ ${iscompressed} -eq 1 ]; then
3237        if [ ${istar} -eq 1 ]; then
3238            tail -c +$((${tailskip}+1)) ${src} 2> /dev/null | head -c $((${metaskip}-${tailskip})) | tar -xzf -;
3239        else
3240            tail -c +$((${tailskip}+1)) ${src} 2> /dev/null | head -c $((${metaskip}-${tailskip})) | gzip -dc > ${datafile};
3241        fi;
3242    else
3243        if [ ${istar} -eq 1 ]; then
3244            tail -c +$((${tailskip}+1)) ${src} 2> /dev/null | head -c $((${metaskip}-${tailskip})) | tar --no-same-owner -xf -;
3245        else
3246            tail -c +$((${tailskip}+1)) ${src} 2> /dev/null | head -c $((${metaskip}-${tailskip})) > ${datafile};
3247        fi;
3248    fi;
3249    true
3250}
3251validate_desktop_entries ()
3252{
3253    if [[ -x /usr/bin/desktop-file-validate ]]; then
3254        einfo "Checking desktop entry validity";
3255        local directories="";
3256        for d in /usr/share/applications $@;
3257        do
3258            [[ -d ${D}${d} ]] && directories="${directories} ${D}${d}";
3259        done;
3260        if [[ -n ${directories} ]]; then
3261            for FILE in $(find ${directories} -name "*\.desktop"                                                        -not -path '*.hidden*' | sort -u 2>/dev/null);
3262            do
3263                local temp=$(desktop-file-validate ${FILE} | grep -v "warning:" |                                                               sed -e "s|error: ||" -e "s|${FILE}:|--|g" );
3264                [[ -n $temp ]] && elog ${temp/--/${FILE/${D}/}:};
3265            done;
3266        fi;
3267        echo "";
3268    else
3269        einfo "Passing desktop entry validity check. Install dev-util/desktop-file-utils, if you want to help to improve Gentoo.";
3270    fi
3271}
3272declare -x ALSA_CARDS=""
3273declare -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"
3274declare -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 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"
3275declare -x ARCH="arm"
3276declare -x CBUILD="armv4tl-softfloat-linux-gnueabi"
3277declare -x CDEFINE_default="__unix__"
3278declare -x CFLAGS="-Os -march=armv4t -mtune=arm920t"
3279declare -x CFLAGS_default=""
3280declare -x CHOST="armv4tl-softfloat-linux-gnueabi"
3281declare -x CHOST_default="armv4tl-softfloat-linux-gnueabi"
3282declare -x CROSSCOMPILE_OPTS=""
3283declare -x CTARGET_default="armv4tl-softfloat-linux-gnueabi"
3284declare -x CVS_RSH="ssh"
3285declare -x CXXFLAGS="-Os -march=armv4t -mtune=arm920t"
3286declare -x DCCC_PATH="/usr/lib/distcc/bin"
3287declare -x DEFAULT_ABI="default"
3288declare -x DESTTREE="/usr"
3289declare -x DIROPTIONS="-m0755"
3290declare -x EAPI="0"
3291declare -x ELIBC="glibc"
3292declare -x ELT_APPLIED_PATCHES=" 1.5.6"
3293declare -x ELT_LTMAIN_SH="/var/tmp/portage/media-libs/emotion-20090212/work/emotion/ltmain.sh"
3294declare -x EXEOPTIONS="-m0755"
3295declare -x FEATURES="distcc distlocks fixpackages parallel-fetch protect-owned sandbox sfperms strict unmerge-orphans userfetch"
3296declare -x GCC_SPECS=""
3297declare -x GDK_USE_XFT="1"
3298declare -x INHERITED="autotools toolchain-funcs portability multilib subversion libtool enlightenment eutils"
3299declare -x INPUT_DEVICES=""
3300declare -x INSDESTTREE=""
3301declare -x INSOPTIONS="-m0644"
3302declare -x KERNEL="linux"
3303declare -x KERNEL_ABI="default"
3304declare -x KEYWORDS="~arm ~x86 ~amd64"
3305declare -x KV="2.6.29"
3306declare -x LCD_DEVICES=""
3307declare -x LDFLAGS="-Wl,-O1 -Wl,-z,now"
3308declare -x LDFLAGS_default=""
3309declare -x LIBDIR_default="lib"
3310declare -x LIBOPTIONS="-m0644"
3311declare -x LICENSE="GPL-2"
3312declare -x MAIL="/var/mail/root"
3313declare -x MAKEOPTS="-j3"
3314declare -x MULTILIB_ABIS="default"
3315declare -x NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
3316declare -x OPENGL_PROFILE="xorg-x11"
3317declare -x PORTAGE_COMPRESS_EXCLUDE_SUFFIXES="css gif htm[l]? jp[e]?g js pdf png"
3318declare -x PROFILE_ONLY_VARIABLES="ARCH ELIBC KERNEL USERLAND"
3319declare -x PROPERTIES=""
3320declare -x PROVIDE=""
3321declare -x RESTRICT=""
3322declare -x S="/var/tmp/portage/media-libs/emotion-20090212/work/emotion"
3323declare -x SANDBOX_DENY="/etc/ld.so.preload"
3324declare -x SANDBOX_PREDICT=":/dev/console:/dev/random:/proc/self/maps:/usr/lib/python2.0/:/usr/lib/python2.1/:/usr/lib/python2.2/:/usr/lib/python2.3/:/usr/lib/python2.4/:/usr/lib/python2.5/:/usr/lib/python3.0/:/var/db/aliases.db:/var/db/ethers.db:/var/db/group.db:/var/db/hosts.db:/var/db/netgroup.db:/var/db/netmasks.db:/var/db/networks.db:/var/db/passwd.db:/var/db/protocols.db:/var/db/rpc.db:/var/db/services.db:/var/tmp/portage/media-libs/emotion-20090212/homedir/.:"
3325declare -x SANDBOX_READ=":/:/dev/shm:/dev/stdin:/etc/subversion:/var/tmp:"
3326declare -x SANDBOX_WRITE=":/dev/console:/dev/fd:/dev/null:/dev/pts/:/dev/pty:/dev/shm:/dev/shm/ngpt:/dev/stderr:/dev/stdout:/dev/tts:/dev/tty:/dev/vc/:/dev/zero:/proc/self/fd:/tmp:/tmp/:/tmp/distfiles/svn-src:/usr/lib/cf:/usr/lib/conftest:/usr/lib32/cf:/usr/lib32/conftest:/usr/lib64/cf:/usr/lib64/conftest:/usr/tmp/cf:/usr/tmp/conftest:/var/log/scrollkeeper.log:/var/tmp:/var/tmp/:/var/tmp/portage/media-libs/emotion-20090212/homedir/.bash_history:/var/tmp/portage/media-libs/emotion-20090212/homedir/.gconfd/lock::/var/tmp/portage/.distcc"
3327declare -x SLOT="0"
3328declare -x SSH_CLIENT="192.168.2.10 51125 22"
3329declare -x SSH_CONNECTION="192.168.2.10 51125 192.168.2.15 22"
3330declare -x SSH_TTY="/dev/pts/0"
3331declare -x USE="arm elibc_glibc gstreamer kernel_linux userland_GNU"
3332declare -x USERLAND="GNU"
3333declare -x VIDEO_CARDS=""
3334declare -x WANT_AUTOCONF="2.5"
3335declare -x WANT_AUTOMAKE="1.10"
3336declare -x _E_DOCDESTTREE_=""
3337declare -x _E_EXEDESTTREE_=""