portage.dep.use_reduce: pass is_src_uri when needed
authorSebastian Luther <SebastianLuther@gmx.de>
Tue, 10 Aug 2010 20:45:31 +0000 (22:45 +0200)
committerZac Medico <zmedico@gentoo.org>
Wed, 11 Aug 2010 05:30:34 +0000 (22:30 -0700)
Remove the now unneded _src_uri_validate.

bin/repoman
pym/portage/dbapi/porttree.py
pym/portage/package/ebuild/doebuild.py
pym/portage/tests/dep/test_src_uri.py [deleted file]

index 24065805ceef5ef79e35294409f739486f84af34..ffb435238ade01e0f9ca5103a3be63865c7b8d3a 100755 (executable)
@@ -1445,7 +1445,9 @@ for x in scanlist:
 
                if not src_uri_error:
                        # Check that URIs don't reference a server from thirdpartymirrors.
-                       for uri in portage.flatten(portage.dep.use_reduce(myaux["SRC_URI"], matchall=True)):
+                       for uri in portage.flatten(portage.dep.use_reduce( \
+                               myaux["SRC_URI"], matchall=True, is_src_uri=True, \
+                               allow_src_uri_file_renames=(eapi not in ("0", "1")))):
                                contains_mirror = False
                                for mirror in thirdpartymirrors:
                                        if uri.startswith(mirror):
index f530b6170676e0477e9680377354ac5d7faa1c8f..886b765f75dd3ece9e974f2c13fbf4a9bca1f433 100644 (file)
@@ -10,7 +10,7 @@ portage.proxy.lazyimport.lazyimport(globals(),
        'portage.checksum',
        'portage.data:portage_gid,secpass',
        'portage.dbapi.dep_expand:dep_expand',
-       'portage.dep:dep_getkey,flatten,match_from_list,paren_reduce,use_reduce',
+       'portage.dep:dep_getkey,flatten,match_from_list,use_reduce',
        'portage.env.loaders:KeyValuePairFileLoader',
        'portage.package.ebuild.doebuild:doebuild',
        'portage.util:ensure_dirs,shlex_split,writemsg,writemsg_level',
@@ -49,73 +49,6 @@ if sys.hexversion >= 0x3000000:
        basestring = str
        long = int
 
-def _src_uri_validate(cpv, eapi, src_uri):
-       """
-       Take a SRC_URI structure as returned by paren_reduce or use_reduce
-       and validate it. Raises InvalidDependString if a problem is detected,
-       such as missing operand for a -> operator.
-       """
-       uri = None
-       operator = None
-       for x in src_uri:
-               if isinstance(x, list):
-                       if operator is not None:
-                               raise portage.exception.InvalidDependString(
-                                       ("getFetchMap(): '%s' SRC_URI arrow missing " + \
-                                       "right operand") % (cpv,))
-                       uri = None
-                       _src_uri_validate(cpv, eapi, x)
-                       continue
-               if x == '||':
-                       raise portage.exception.InvalidDependString(
-                               ("getFetchMap(): '%s' SRC_URI contains invalid " + \
-                               "|| operator") % (cpv,))
-
-               if x[-1:] == "?":
-                       if operator is not None:
-                               raise portage.exception.InvalidDependString(
-                                       ("getFetchMap(): '%s' SRC_URI arrow missing " + \
-                                       "right operand") % (cpv,))
-                       uri = None
-                       continue
-               if uri is None:
-                       if x == "->":
-                               raise portage.exception.InvalidDependString(
-                                       ("getFetchMap(): '%s' SRC_URI arrow missing " + \
-                                       "left operand") % (cpv,))
-                       uri = x
-                       continue
-               if x == "->":
-                       if eapi in ("0", "1"):
-                               raise portage.exception.InvalidDependString(
-                                       ("getFetchMap(): '%s' SRC_URI arrows are not " + \
-                                       "supported with EAPI='%s'") % (cpv, eapi))
-                       operator = x
-                       continue
-               if operator is None:
-                       uri = x
-                       continue
-
-               # This should be the right operand of an arrow operator.
-               if "/" in x:
-                       raise portage.exception.InvalidDependString(
-                               ("getFetchMap(): '%s' SRC_URI '/' character in " + \
-                               "file name: '%s'") % (cpv, x))
-
-               if x[-1:] == "?":
-                       raise portage.exception.InvalidDependString(
-                               ("getFetchMap(): '%s' SRC_URI arrow missing " + \
-                               "right operand") % (cpv,))
-
-               # Found the right operand, so reset state.
-               uri = None
-               operator = None
-
-       if operator is not None:
-               raise portage.exception.InvalidDependString(
-                       "getFetchMap(): '%s' SRC_URI arrow missing right operand" % \
-                       (cpv,))
-
 class _repo_info(object):
        __slots__ = ('name', 'path', 'eclass_db', 'portdir', 'portdir_overlay')
        def __init__(self, name, path, eclass_db):
@@ -742,9 +675,8 @@ class portdbapi(dbapi):
                                "getFetchMap(): '%s' has unsupported EAPI: '%s'" % \
                                (mypkg, eapi.lstrip("-")))
 
-               _src_uri_validate(mypkg, eapi, paren_reduce(myuris))
-               myuris = use_reduce(myuris, uselist=useflags,
-                       matchall=(useflags is None))
+               myuris = use_reduce(myuris, uselist=useflags, matchall=(useflags is None), \
+                       is_src_uri=True, allow_src_uri_file_renames=(eapi not in ("0", "1")))
                myuris = flatten(myuris)
 
                uri_map = OrderedDict()
index 6ceafb0e1ea94b0364535caed6a0b9688b99f5ae..f066df7576c080234079bde6e28f996aef905456 100644 (file)
@@ -1050,7 +1050,7 @@ def _validate_deps(mysettings, myroot, mydo, mydbapi):
                set(["clean", "cleanrm", "help", "prerm", "postrm"])
        dep_keys = ["DEPEND", "RDEPEND", "PDEPEND"]
        misc_keys = ["LICENSE", "PROPERTIES", "PROVIDE", "RESTRICT", "SRC_URI"]
-       other_keys = ["SLOT"]
+       other_keys = ["SLOT", "EAPI"]
        all_keys = dep_keys + misc_keys + other_keys
        metadata = dict(zip(all_keys,
                mydbapi.aux_get(mysettings.mycpv, all_keys)))
@@ -1070,9 +1070,11 @@ def _validate_deps(mysettings, myroot, mydo, mydbapi):
                        msgs.append("  %s: %s\n    %s\n" % (
                                dep_type, metadata[dep_type], mycheck[1]))
 
+       eapi = metadata["EAPI"]
        for k in misc_keys:
                try:
-                       use_reduce(metadata[k], matchall=True)
+                       use_reduce(metadata[k], matchall=True, is_src_uri=(k=="SRC_URI"), \
+                               allow_src_uri_file_renames=(eapi not in ("0", "1")))
                except InvalidDependString as e:
                        msgs.append("  %s: %s\n    %s\n" % (
                                k, metadata[k], str(e)))
diff --git a/pym/portage/tests/dep/test_src_uri.py b/pym/portage/tests/dep/test_src_uri.py
deleted file mode 100644 (file)
index 45ba09b..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright 2008 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-from portage.tests import TestCase
-from portage.dep import paren_reduce
-from portage.dbapi.porttree import _src_uri_validate
-from portage.exception import InvalidDependString
-
-class SrcUri(TestCase):
-
-       def testSrcUri(self):
-
-               tests = [
-                       ( "0", "http://foo/bar -> blah.tbz2"                     , False ),
-                       ( "1", "http://foo/bar -> blah.tbz2"                     , False ),
-                       ( "2", "|| ( http://foo/bar -> blah.tbz2 )"              , False ),
-                       ( "2", "http://foo/bar -> blah.tbz2"                     , True  ),
-                       ( "2", "foo? ( http://foo/bar -> blah.tbz2 )"            , True  ),
-                       ( "2", "http://foo/bar -> foo? ( ftp://foo/a )"          , False ),
-                       ( "2", "http://foo/bar -> bar.tbz2 foo? ( ftp://foo/a )" , True  ),
-                       ( "2", "http://foo/bar blah.tbz2 ->"                     , False ),
-                       ( "2", "-> http://foo/bar blah.tbz2 )"                   , False ),
-                       ( "2", "http://foo/bar ->"                               , False ),
-                       ( "2", "http://foo/bar -> foo? ( http://foo.com/foo )"   , False ),
-                       ( "2", "foo? ( http://foo/bar -> ) blah.tbz2"            , False ),
-                       ( "2", "http://foo/bar -> foo/blah.tbz2"                 , False ),
-                       ( "2", "http://foo.com/foo http://foo/bar -> blah.tbz2"  , True  ),
-               ]
-
-               for eapi, src_uri, valid in tests:
-                       try:
-                               _src_uri_validate("cat/pkg-1", eapi, paren_reduce(src_uri))
-                       except InvalidDependString:
-                               self.assertEqual(valid, False)
-                       else:
-                               self.assertEqual(valid, True)