# 2.1.2 A package name may contain any of the characters [A-Za-z0-9+_-].
# It must not begin with a hyphen,
# and must not end in a hyphen followed by one or more digits.
-# FIXME: this regex doesn't check 'must not end in' clause.
-_pkg = r'[A-Za-z0-9+_][A-Za-z0-9+_-]*'
+_pkg = r'([A-Za-z+_]+[A-Za-z0-9+_]+|([A-Za-z0-9+_](' + \
+ '[A-Za-z0-9+_-]?|' + \
+ '([A-Za-z0-9+_-]*(([A-Za-z0-9+_][A-Za-z+_-]+)|([A-Za-z+_][A-Za-z0-9+_]+))))))'
# 2.1.3 A slot name may contain any of the characters [A-Za-z0-9+_.-].
# It must not begin with a hyphen or a dot.
_cp = _cat + '/' + _pkg
_cpv = _cp + '-' + _version
-_atom = re.compile(r'^(' +
+_atom_re = re.compile(r'^(' +
'(' + _op + _cpv + _slot + _use + ')|' +
'(=' + _cpv + r'\*' + _slot + _use + ')|' +
'(' + _cp + _slot + _use + ')' +
atom = atom[2:]
else:
atom = atom[1:]
- if _atom.match(atom) is None:
+ if _atom_re.match(atom) is None:
return False
try:
use = dep_getusedeps(atom)
( ">=null/portage-2.1", True ),
( "~null/portage-2.1", True ),
( "=null/portage-2.1*", True ),
- ( "=foo/bar-123-1", True ),
- ( "=foo/bar-123-1-r1", True ),
+
+ # These are invalid because pkg name must not end in hyphen
+ # followed by numbers
+ ( "=foo/bar-123-1", False ),
+ ( "=foo/bar-123-1-r1", False ),
+ ( "foo/bar-1", False ),
+
( "=foo/bar--baz-1-r1", True ),
( "=foo/bar-baz--1-r1", True ),
( "=foo/bar-baz---1-r1", True ),
( "=foo/bar-baz---1", True ),
( "=foo/bar-baz-1--r1", False ),
+ ( "games-strategy/ufo2000", True ),
+ ( "~games-strategy/ufo2000-0.1", True ),
+ ( "=media-libs/x264-20060810", True ),
+ ( "foo/b", True ),
]
for test in tests: