--- repoman.old 2010-12-04 11:15:35.000000000 +0100 +++ repoman 2010-12-04 11:50:56.000000000 +0100 @@ -333,6 +333,7 @@ "REQUIRED_USE.syntax":"Syntax error in REQUIRED_USE (usually an extra/missing space/parenthesis)", "SRC_URI.syntax":"Syntax error in SRC_URI (usually an extra/missing space/parenthesis)", "SRC_URI.mirror":"A uri listed in profiles/thirdpartymirrors is found in SRC_URI", + "SRC_URI.compression":"A tarball listed in SRC_URI requires decompression tool not found in DEPEND.", "ebuild.syntax":"Error generating cache entry for ebuild; typically caused by ebuild syntax error or digest verification failure", "ebuild.output":"A simple sourcing of the ebuild produces output; this breaks ebuild policy.", "ebuild.nesteddie":"Placing 'die' inside ( ) prints an error, but doesn't stop the ebuild.", @@ -1032,6 +1033,20 @@ for v in repoman_settings.thirdpartymirrors().values(): thirdpartymirrors.extend(v) +# Build list of compressions and their packages +compression_algs = {} +compression_algs['rar'] = [ '.rar' ] +compression_algs['zip'] = [ '.zip' ] +compression_algs['7zip'] = [ '.7z' ] +compression_algs['lzma'] = [ '.xz', '.lzma' ] +compression_algs['bzip'] = [ '.bz2', '.tbz2' ] +compression_pkgs = {} +compression_pkgs['rar'] = [ 'app-arch/unrar', 'app-arch/rar' ] +compression_pkgs['zip'] = [ 'app-arch/unzip', 'app-arch/zip' ] +compression_pkgs['7zip'] = [ 'app-arch/p7zip' ] +compression_pkgs['lzma'] = [ 'app-arch/xz-utils' ] +compression_pkgs['bzip'] = [ 'app-arch/bzip2' ] + class _MetadataTreeBuilder(xml.etree.ElementTree.TreeBuilder): """ Implements doctype() as required to avoid deprecation warnings with @@ -1512,6 +1527,44 @@ "%s: '%s' found in thirdpartymirrors" % \ (relative_path, mirror)) + # Check that URIs don't contain tarball with non-availible compression algorithm + # files we are fetching + distdata = portdb.getFetchMap(pkg.cpv) + mylist = list(distdata) + # depend for the package + mydepstr = myaux['DEPEND'] + try: + atoms = portage.dep.use_reduce(mydepstr, matchall=1, flat=True, \ + is_valid_flag=pkg.iuse.is_valid_flag, token_class=portage.dep.Atom) + except portage.exception.InvalidDependString as e: + atoms = None + badsyntax.append(str(e)) + checkalgs=[] + for filename in mylist: + # find all depends we find suspicious + for alg in compression_algs: + for suffix in compression_algs[alg]: + if filename.endswith(suffix) and alg not in checkalgs: + checkalgs.append(alg) + for alg in checkalgs: + # check compressions with depend + for atom in atoms: + if atom == "||": + continue + if atom.blocker: + continue + for comppkg in compression_pkgs[alg]: + if atom.cp == comppkg: + checkalgs.remove(alg) + break + if alg not in checkalgs: + break + for alg in checkalgs: + # here we already know what failed so just print it out + stats['SRC_URI.compression'] += 1 + fails['SRC_URI.compression'].append('%s: %s decompression algorithm required. Add %s to DEPEND.' % \ + (relative_path, alg, compression_pkgs[alg])) + try: provide = portage.dep.use_reduce(pkg.metadata['PROVIDE'], token_class=portage.dep.Atom, matchall=1, flat=True)