Merged from trunk -r14963:14969
authorFabian Groffen <grobian@gentoo.org>
Wed, 9 Dec 2009 17:48:32 +0000 (17:48 -0000)
committerFabian Groffen <grobian@gentoo.org>
Wed, 9 Dec 2009 17:48:32 +0000 (17:48 -0000)
   | 14965   | Bump EAPI conditionals to account for rename of EAPI 3 to 4. |
   | zmedico | Thanks to Jonathan Callen <abcd@g.o> for this patch.         |

   | 14966   | Move ebuild helpers to account for rename of EAPI 3 to 4.    |
   | zmedico |                                                              |

   | 14967   | Add OrderedDict class.                                       |
   | zmedico |                                                              |

   | 14968   | Use OrderedDict in portdbapi.getFetchMap() so that order in  |
   | zmedico | $A corresponds to order in SRC_URI.                          |

   | 14969   | When reading the remote Packages file for --getbinpkg, use   |
   | zmedico | codecs.iterdecode to decode the stream. Also, don't use      |
   |         | finally to close the atomic_ofstream when writing the file   |
   |         | since we want it to abort if an exception is raised.         |

svn path=/main/branches/prefix/; revision=14976

12 files changed:
bin/ebuild-helpers/4/dodoc [moved from bin/ebuild-helpers/3/dodoc with 84% similarity]
bin/ebuild-helpers/4/dohard [moved from bin/ebuild-helpers/3/dohard with 100% similarity]
bin/ebuild-helpers/4/dosed [moved from bin/ebuild-helpers/3/dosed with 100% similarity]
bin/ebuild-helpers/doins
bin/ebuild-helpers/newins
bin/ebuild.sh
bin/isolated-functions.sh
pym/portage/__init__.py
pym/portage/cache/mappings.py
pym/portage/dbapi/bintree.py
pym/portage/dbapi/porttree.py
pym/repoman/checks.py

similarity index 84%
rename from bin/ebuild-helpers/3/dodoc
rename to bin/ebuild-helpers/4/dodoc
index 66d9a4367a6451087577c46bbc9264230cbd242d..4e7c934abeb478f208a951053b4c0628f24fe5cd 100755 (executable)
@@ -1,16 +1,16 @@
-#!@PORTAGE_BASH@
+#!/bin/bash
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Id$
 
-source "${PORTAGE_BIN_PATH:-@PORTAGE_BASE@/bin}"/isolated-functions.sh
+source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
 
 if [ $# -lt 1 ] ; then
        vecho "${0##*/}: at least one argument needed" 1>&2
        exit 1
 fi
 
-dir="${ED}usr/share/doc/${PF}/${_E_DOCDESTTREE_}"
+dir="${D}usr/share/doc/${PF}/${_E_DOCDESTTREE_}"
 if [ ! -d "${dir}" ] ; then
        install -d "${dir}"
 fi
index 73d95e5cbfde33207c984ebd7ad0f28f2a65bc7d..fc5642421cb86304573a0a9353d6e22b41d92d57 100755 (executable)
@@ -26,7 +26,7 @@ if [[ ${INSDESTTREE#${D}} != "${INSDESTTREE}" ]]; then
 fi
 
 case "$EAPI" in
-       0|1|2)
+       0|1|2|3)
                PRESERVE_SYMLINKS=n
                ;;
        *)
index 500db457c71fdff31cd632136e0a29278dcc79dd..af5166c7a9147f3bcf8f6987fa8c77a8753824f4 100755 (executable)
@@ -15,7 +15,7 @@ fi
 
 rm -rf "${T}/${2}" || exit $?
 case "$EAPI" in
-       0|1|2)
+       0|1|2|3)
                cp "$1" "$T/$2" || exit $?
                ;;
        *)
index ee21fed5b6acd937603a2cec189b2034ac8632ff..f6abc0693f432cda31f3bdf29cf64532c3b7f68a 100755 (executable)
@@ -140,7 +140,7 @@ useq() {
                # Skip this for older EAPIs since lots of ebuilds/eclasses
                # have stuff in global scope that really belongs somewhere
                # like pkg_setup or src_configure.
-               if [[ -n $EAPI ]] && ! hasq "$EAPI" 0 1 2 ; then
+               if [[ -n $EAPI ]] && ! hasq "$EAPI" 0 1 2 3 ; then
                        die "use() called during invalid phase: $EBUILD_PHASE"
                fi
 
@@ -435,7 +435,7 @@ unpack() {
                                _unpack_tar lzma
                                ;;
                        xz)
-                               if hasq $eapi 0 1 2 ; then
+                               if hasq $eapi 0 1 2 3 ; then
                                        vecho "unpack ${x}: file format not recognized. Ignoring."
                                else
                                        _unpack_tar xz
@@ -497,7 +497,7 @@ econf() {
                fi
 
                # EAPI=3 adds --disable-dependency-tracking to econf
-               if ! hasq "$EAPI" 0 1 2 ; then
+               if ! hasq "$EAPI" 0 1 2 3 ; then
                        set -- --disable-dependency-tracking "$@"
                fi
 
@@ -644,7 +644,7 @@ _eapi2_src_compile() {
        fi
 }
 
-_eapi3_src_install() {
+_eapi4_src_install() {
        if [[ -f Makefile || -f GNUmakefile || -f makefile ]] ; then
                emake DESTDIR="${D}" install
        fi
@@ -908,7 +908,7 @@ dyn_prepare() {
 
        if [[ -d $S ]] ; then
                cd "${S}"
-       elif hasq $EAPI 0 1 2; then
+       elif hasq $EAPI 0 1 2 3; then
                cd "${WORKDIR}"
        elif [[ -z ${A} ]] && ! has_phase_defined_up_to prepare; then
                cd "${WORKDIR}"
@@ -939,7 +939,7 @@ dyn_configure() {
 
        if [[ -d $S ]] ; then
                cd "${S}"
-       elif hasq $EAPI 0 1 2; then
+       elif hasq $EAPI 0 1 2 3; then
                cd "${WORKDIR}"
        elif [[ -z ${A} ]] && ! has_phase_defined_up_to configure; then
                cd "${WORKDIR}"
@@ -972,7 +972,7 @@ dyn_compile() {
 
        if [[ -d $S ]] ; then
                cd "${S}"
-       elif hasq $EAPI 0 1 2; then
+       elif hasq $EAPI 0 1 2 3; then
                cd "${WORKDIR}"
        elif [[ -z ${A} ]] && ! has_phase_defined_up_to compile; then
                cd "${WORKDIR}"
@@ -1049,7 +1049,7 @@ dyn_install() {
        mkdir "${PORTAGE_BUILDDIR}/image"
        if [[ -d $S ]] ; then
                cd "${S}"
-       elif hasq $EAPI 0 1 2; then
+       elif hasq $EAPI 0 1 2 3; then
                cd "${WORKDIR}"
        elif [[ -z ${A} ]] && ! has_phase_defined_up_to install; then
                cd "${WORKDIR}"
@@ -1404,7 +1404,7 @@ _ebuild_arg_to_phase() {
 
        case "$arg" in
                pretend)
-                       ! hasq $eapi 0 1 2 && \
+                       ! hasq $eapi 0 1 2 3 && \
                                phase_func=pkg_pretend
                        ;;
                setup)
@@ -1500,8 +1500,8 @@ _ebuild_phase_funcs() {
                        declare -F src_compile >/dev/null || \
                                src_compile() { _eapi2_src_compile "$@" ; }
 
-                       [[ $eapi == 2 ]] || declare -F src_install >/dev/null || \
-                               src_install() { _eapi3_src_install "$@" ; }
+                       has $eapi 2 3 || declare -F src_install >/dev/null || \
+                               src_install() { _eapi4_src_install "$@" ; }
 
                        if hasq $phase_func $default_phases ; then
 
@@ -1857,7 +1857,7 @@ if ! hasq "$EBUILD_PHASE" clean cleanrm ; then
 
                [[ -n $EAPI ]] || EAPI=0
 
-               if has "$EAPI" 0 1 2 ; then
+               if has "$EAPI" 0 1 2 3 ; then
                        export RDEPEND=${RDEPEND-${DEPEND}}
                        debug-print "RDEPEND: not set... Setting to: ${DEPEND}"
                fi
@@ -1877,7 +1877,7 @@ if ! hasq "$EBUILD_PHASE" clean cleanrm ; then
                                        pkg_nofetch pkg_postinst pkg_postrm pkg_preinst pkg_prerm
                                        pkg_setup src_test src_unpack"
                                ;;
-                       2)
+                       2|3)
                                _valid_phases="src_compile pkg_config src_configure pkg_info
                                        src_install pkg_nofetch pkg_postinst pkg_postrm pkg_preinst
                                        src_prepare pkg_prerm pkg_setup src_test src_unpack"
@@ -1938,8 +1938,8 @@ ebuild_main() {
        # we may want to make this configurable somewhere else
        local ebuild_helpers_path
        case ${EAPI} in
-               3|3_pre1)
-                       ebuild_helpers_path="${PORTAGE_BIN_PATH}/ebuild-helpers/3:${PORTAGE_BIN_PATH}/ebuild-helpers"
+               4|4_pre1)
+                       ebuild_helpers_path="${PORTAGE_BIN_PATH}/ebuild-helpers/4:${PORTAGE_BIN_PATH}/ebuild-helpers"
                        ;;
                *)
                        ebuild_helpers_path="${PORTAGE_BIN_PATH}/ebuild-helpers"
index 012cd096ef9504346b697afd92f4060c336fb160..792aad925c1773f7441cb95a9153836ed0cce04e 100755 (executable)
@@ -54,7 +54,7 @@ dump_trace() {
 }
 
 nonfatal() {
-       if has "${EAPI:-0}" 0 1 2; then
+       if has "${EAPI:-0}" 0 1 2 3; then
                die "$FUNCNAME() not supported in this EAPI"
        fi
        if [[ $# -lt 1 ]]; then
@@ -523,7 +523,7 @@ save_ebuild_env() {
                for x in pkg_setup pkg_nofetch src_unpack src_prepare src_configure \
                        src_compile src_test src_install pkg_preinst pkg_postinst \
                        pkg_prerm pkg_postrm ; do
-                       unset -f default_$x _eapi{0,1,2}_$x
+                       unset -f default_$x _eapi{0,1,2,3,4}_$x
                done
                unset x
 
index e26b20521b963a10e1db9ffe07f6d36e347aadb4..72afda6e4d55cb9974768ed9f196a61ff2093ade 100644 (file)
@@ -3777,7 +3777,7 @@ class config(object):
                mydict["USE"] = self.get("PORTAGE_USE", "")
 
                # Don't export AA to the ebuild environment in EAPIs that forbid it
-               if eapi not in ("0", "1", "2"):
+               if eapi not in ("0", "1", "2", "3"):
                        mydict.pop("AA", None)
 
                # sandbox's bashrc sources /etc/profile which unsets ROOTPATH,
@@ -5642,7 +5642,7 @@ def spawnebuild(mydo, actionmap, mysettings, debug, alwaysdep=0,
        if mydo == "prepare" and eapi in ("0", "1"):
                return os.EX_OK
 
-       if mydo == "pretend" and eapi in ("0", "1", "2"):
+       if mydo == "pretend" and eapi in ("0", "1", "2", "3"):
                return os.EX_OK
 
        kwargs = actionmap[mydo]["args"]
@@ -6072,8 +6072,8 @@ def _spawn_misc_sh(mysettings, commands, phase=None, **kwargs):
 
        return rval
 
-_testing_eapis = frozenset(["3_pre1"])
-_deprecated_eapis = frozenset(["2_pre3", "2_pre2", "2_pre1"])
+_testing_eapis = frozenset(["4_pre1"])
+_deprecated_eapis = frozenset(["3_pre1", "2_pre3", "2_pre2", "2_pre1"])
 
 def _eapi_is_deprecated(eapi):
        return eapi in _deprecated_eapis
@@ -6295,7 +6295,7 @@ def doebuild_environment(myebuild, mydo, myroot, mysettings, debug, use_cache, m
                mysettings["PORTAGE_BUILDDIR"], ".exit_status")
 
        #set up KV variable -- DEP SPEEDUP :: Don't waste time. Keep var persistent.
-       if eapi not in ('0', '1', '2'):
+       if eapi not in ('0', '1', '2', '3'):
                # Discard KV for EAPIs that don't support it. Cache KV is restored
                # from the backupenv whenever config.reset() is called.
                mysettings.pop('KV', None)
index ed6e19ddd9269c9480fcebf809eff13e3f53be72..2e24a7a8a0a309cf6d5e2bc0fe8e29120b132736 100644 (file)
@@ -188,6 +188,32 @@ class UserDict(MutableMapping):
        if sys.hexversion >= 0x3000000:
                keys = __iter__
 
+class OrderedDict(UserDict):
+
+       def __init__(self, *args, **kwargs):
+               self._order = []
+               UserDict.__init__(self, *args, **kwargs)
+
+       def __iter__(self):
+               return iter(self._order)
+
+       def __setitem__(self, key, item):
+               if key in self:
+                       self._order.remove(key)
+               UserDict.__setitem__(self, key, item)
+               self._order.append(key)
+
+       def __delitem__(self, key):
+               UserDict.__delitem__(self, key)
+               self._order.remove(key)
+
+       def clear(self):
+               UserDict.clear(self)
+               del self._order[:]
+
+       if sys.hexversion >= 0x3000000:
+               keys = __iter__
+
 class ProtectedDict(MutableMapping):
        """
        given an initial dict, this wraps that dict storing changes in a secondary dict, protecting
index 1f317f563011f8f224aa279ac210607bd331b9ac..a7b104fda39e18115449cdd35f3083524be07e1e 100644 (file)
@@ -714,8 +714,10 @@ class binarytree(object):
                                # protocols and requires the base url to have a trailing
                                # slash, so join manually...
                                f = urllib_request_urlopen(base_url.rstrip("/") + "/Packages")
+                               f_dec = codecs.iterdecode(f,
+                                       _encodings['repo.content'], errors='replace')
                                try:
-                                       rmt_idx.readHeader(f)
+                                       rmt_idx.readHeader(f_dec)
                                        remote_timestamp = rmt_idx.header.get("TIMESTAMP", None)
                                        if not remote_timestamp:
                                                # no timestamp in the header, something's wrong
@@ -727,7 +729,7 @@ class binarytree(object):
                                                        rmt_idx.header.get("VERSION"), noiselevel=-1)
                                                        pkgindex = None
                                                elif local_timestamp != remote_timestamp:
-                                                       rmt_idx.readBody(f)
+                                                       rmt_idx.readBody(f_dec)
                                                        pkgindex = rmt_idx
                                finally:
                                        f.close()
@@ -742,10 +744,8 @@ class binarytree(object):
                                from portage.util import atomic_ofstream, ensure_dirs
                                ensure_dirs(os.path.dirname(pkgindex_file))
                                f = atomic_ofstream(pkgindex_file)
-                               try:
-                                       pkgindex.write(f)
-                               finally:
-                                       f.close()
+                               pkgindex.write(f)
+                               f.close()
                        if pkgindex:
                                self._remotepkgs = {}
                                for d in pkgindex.packages:
index a993227cabf75abbdb0d04af5823e58dc5dd22fd..df2c65640838f97a00000da64f6d1e9144693c36 100644 (file)
@@ -16,7 +16,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
 )
 
 from portage.cache.cache_errors import CacheError
-from portage.cache.mappings import slot_dict_class
+from portage.cache.mappings import OrderedDict
 from portage.const import REPO_NAME_LOC
 from portage.data import portage_gid, secpass
 from portage.dbapi import dbapi
@@ -734,7 +734,7 @@ class portdbapi(dbapi):
                        matchall=(useflags is None))
                myuris = flatten(myuris)
 
-               uri_map = {}
+               uri_map = OrderedDict()
 
                myuris.reverse()
                while myuris:
index a754ad46e0a1bbcb71398c71f6bfd357bfd7082e..ce72e36eaca529c7c2782af40c2e88417a817904 100644 (file)
@@ -426,8 +426,8 @@ class SrcUnpackPatches(PhaseCheck):
                                return ("'%s'" % m.group(1)) + \
                                        " call should be moved to src_prepare from line: %d"
 
-# EAPI-3 checks
-class Eapi3IncompatibleFuncs(LineCheck):
+# EAPI-4 checks
+class Eapi4IncompatibleFuncs(LineCheck):
        repoman_check_name = 'EAPI.incompatible'
        ignore_line = re.compile(r'(^\s*#)')
        banned_commands_re = re.compile(r'^\s*(dosed|dohard)')
@@ -436,15 +436,15 @@ class Eapi3IncompatibleFuncs(LineCheck):
                self.eapi = pkg.metadata['EAPI']
 
        def check_eapi(self, eapi):
-               return self.eapi not in ('0', '1', '2')
+               return self.eapi not in ('0', '1', '2', '3')
 
        def check(self, num, line):
                m = self.banned_commands_re.match(line)
                if m is not None:
                        return ("'%s'" % m.group(1)) + \
-                               " has been banned in EAPI=3 on line: %d"
+                               " has been banned in EAPI=4 on line: %d"
 
-class Eapi3GoneVars(LineCheck):
+class Eapi4GoneVars(LineCheck):
        repoman_check_name = 'EAPI.incompatible'
        ignore_line = re.compile(r'(^\s*#)')
        undefined_vars_re = re.compile(r'.*\$(\{(AA|KV)\}|(AA|KV))')
@@ -453,13 +453,13 @@ class Eapi3GoneVars(LineCheck):
                self.eapi = pkg.metadata['EAPI']
 
        def check_eapi(self, eapi):
-               return self.eapi not in ('0', '1', '2')
+               return self.eapi not in ('0', '1', '2', '3')
 
        def check(self, num, line):
                m = self.undefined_vars_re.match(line)
                if m is not None:
                        return ("variable '$%s'" % m.group(1)) + \
-                               " is gone in EAPI=3 on line: %d"
+                               " is gone in EAPI=4 on line: %d"
 
 
 _constant_checks = tuple((c() for c in (
@@ -470,7 +470,7 @@ _constant_checks = tuple((c() for c in (
        IUseUndefined, InheritAutotools,
        EMakeParallelDisabled, EMakeParallelDisabledViaMAKEOPTS,
        DeprecatedBindnowFlags, SrcUnpackPatches, WantAutoDefaultValue,
-       SrcCompileEconf, Eapi3IncompatibleFuncs, Eapi3GoneVars)))
+       SrcCompileEconf, Eapi4IncompatibleFuncs, Eapi4GoneVars)))
 
 _here_doc_re = re.compile(r'.*\s<<[-]?(\w+)$')