diff options
author | 2012-04-03 23:16:38 +0200 | |
---|---|---|
committer | 2012-04-03 23:16:38 +0200 | |
commit | 667a977a691945d32a76e0e193d02b8fda35b468 (patch) | |
tree | d7ac6b8feb83ed5abe3d94c25864eeada40a58cd | |
parent | Zero (diff) | |
download | overlint-667a977a691945d32a76e0e193d02b8fda35b468.tar.gz overlint-667a977a691945d32a76e0e193d02b8fda35b468.tar.bz2 overlint-667a977a691945d32a76e0e193d02b8fda35b468.zip |
Add releasable version of initial codev0.1
-rw-r--r-- | .gitignore | 2 | ||||
-rwxr-xr-x | overlint-cli | 6 | ||||
-rw-r--r-- | overlint/__init__.py | 0 | ||||
-rw-r--r-- | overlint/cli.py | 138 |
4 files changed, 146 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2f78cf5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.pyc + diff --git a/overlint-cli b/overlint-cli new file mode 100755 index 0000000..6fa9aff --- /dev/null +++ b/overlint-cli @@ -0,0 +1,6 @@ +#! /usr/bin/env python +# Copyright (C) 2012 Sebastian Pipping <sebastian@pipping.org> +# Licender under GPL v2 or later + +from overlint.cli import go +go() diff --git a/overlint/__init__.py b/overlint/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/overlint/__init__.py diff --git a/overlint/cli.py b/overlint/cli.py new file mode 100644 index 0000000..5ee42d7 --- /dev/null +++ b/overlint/cli.py @@ -0,0 +1,138 @@ +# Copyright (C) 2012 Sebastian Pipping <sebastian@pipping.org> +# Licender under GPL v2 or later + +import sys +import os +import portage +import re + + +_revision_matcher = re.compile('-r([0-9]+)$') + + +def find_atoms(repo_folder, category_package): + versions = list() + category, package = category_package.split('/') + for root, dirs, files in os.walk(os.path.join(repo_folder, category_package)): + for f in files: + if not f.endswith('.ebuild'): + continue + versions.append(f[len(package) + 1:-len('.ebuild')]) + return versions + + +def highest_revision_only(versions): + def make_version(version, revison): + if revision == 0: + return version + return '%s-r%s' % (version, revison) + + d = dict() + for v in versions: + match = _revision_matcher.search(v) + if match is None: + revision = 0 + version = v + else: + revision = int(match.group(1)) + version = v[:-len(match.group(0))] + d[version] = max(d.get(version, 0), revision) + return [make_version(version, revison) for version, revison in d.items()] + + +def find_missed_bumps(gentoo_versions, overlay_versions): + missed_version_bumps = list() + missed_revision_bumps = list() + for ov in overlay_versions: + if '999' in ov: + continue + newer_than_gentoo = True + for gv in gentoo_versions: + if '999' in gv: + continue + if portage.vercmp(ov, gv) <= 0: + newer_than_gentoo = False + break + if newer_than_gentoo: + ov_without_revision = _revision_matcher.sub('', ov) + if ov_without_revision in gentoo_versions: + missed_revision_bumps.append(ov) + else: + missed_version_bumps.append(ov) + return (missed_revision_bumps, missed_version_bumps) + +def find_ebuild_changes(category_package, overlay_path, gentoo_versions, overlay_versions): + ebuild_changes = list() + intersection = set(gentoo_versions) & set(overlay_versions) + if not intersection: + return list() + category, package = category_package.split('/') + for version in intersection: + ebuild_name = '%s-%s.ebuild' % (package, version) + command = "bash -c 'cmp --quiet <(fgrep -v KEYWORDS= /usr/portage/%s/%s) <(fgrep -v KEYWORDS= %s/%s/%s) ; exit $?'" % (category_package, ebuild_name, overlay_path, category_package, ebuild_name) + ret = os.system(command) + if not ret: + continue + # print "meld '/usr/portage/%s/%s' '%s/%s/%s'" % (category_package, ebuild_name, overlay_path, category_package, ebuild_name) + ebuild_changes.append(version) + return ebuild_changes + + +def sorted_versions(versions): + return sorted(versions, cmp=portage.vercmp) + + +def dump_tree(tree, title): + print '===============================================================' + print title + print '===============================================================' + for category, package_versions in sorted(tree.items()): + print '%s/' % category + for package, versions in sorted(package_versions.items()): + print ' %s :: %s' % (package, ', '.join(sorted_versions(versions))) + print + + +def main(args): + overlay_path = '/var/lib/layman/pentoo' + + missed_revision_bumps_tree = dict() + missed_version_bumps_tree = dict() + ebuild_changes_tree = dict() + + for root, dirs, files in os.walk(overlay_path): + if '.svn' in dirs: + dirs[:] = [d for d in dirs if d != '.svn'] + + + for d in dirs: + full_path_overlay = os.path.join(root, d) + category_package = full_path_overlay[len(overlay_path + '/'):] + if len(category_package.split('/')) != 2: + continue + full_path_gentoo = os.path.join('/usr/portage/', category_package) + found = os.path.exists(full_path_gentoo) + if not found: + continue + + overlay_versions = find_atoms(overlay_path, category_package) + gentoo_versions = find_atoms('/usr/portage/', category_package) + (missed_revision_bumps, missed_version_bumps) = find_missed_bumps(gentoo_versions, overlay_versions) + ebuild_changes = find_ebuild_changes(category_package, overlay_path, gentoo_versions, overlay_versions) + category, package = category_package.split('/') + if missed_revision_bumps: + missed_revision_bumps_tree.setdefault(category, dict())[package] = highest_revision_only(missed_revision_bumps) + if missed_version_bumps: + missed_version_bumps_tree.setdefault(category, dict())[package] = highest_revision_only(missed_version_bumps) + if ebuild_changes: + ebuild_changes_tree.setdefault(category, dict())[package] = ebuild_changes + + dump_tree(missed_version_bumps_tree, 'Version bumps missing from Gentoo main tree') + dump_tree(missed_revision_bumps_tree, 'Revision bumps missing from Gentoo main tree') + dump_tree(ebuild_changes_tree, 'Ebuils that differ at same revision') + return 0 + + +def go(): + ret = main(sys.argv) + sys.exit(ret) |