diff options
author | 2012-06-16 14:24:40 +0200 | |
---|---|---|
committer | 2012-06-16 14:26:00 +0200 | |
commit | 87e4675f6dc105039af181d203106879ee17a15f (patch) | |
tree | d414d35df1fa69639750081dcb509140c476f036 | |
parent | Bump version to 0.5.1 (diff) | |
download | overlint-87e4675f6dc105039af181d203106879ee17a15f.tar.gz overlint-87e4675f6dc105039af181d203106879ee17a15f.tar.bz2 overlint-87e4675f6dc105039af181d203106879ee17a15f.zip |
Compare ebuilds ourselves rather than invoking sed and cmp
This solves the issue with "sed: [..]: Broken pipe" and saves a few process forkes
-rw-r--r-- | overlint/cli.py | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/overlint/cli.py b/overlint/cli.py index 83e2311..049e826 100644 --- a/overlint/cli.py +++ b/overlint/cli.py @@ -19,6 +19,7 @@ except ImportError: _revision_matcher = re.compile('-r([0-9]+)$') +_ignore_matcher = re.compile('(?:^# (?:\\$Header|Copyright)|KEYWORDS=)') portdir = portage.settings["PORTDIR"] @@ -91,6 +92,19 @@ def find_lagging_behind_gentoo(gentoo_versions, overlay_versions): return lagging_behind_gentoo +def _iter_important_lines(ebuild_f): + return (line_br for line_br in ebuild_f if _ignore_matcher.search(line_br) is None) + + +def ebuilds_are_equivalent(filename_a, filename_b): + fa = open(filename_a, 'r') + fb = open(filename_b, 'r') + for (la, lb) in zip(_iter_important_lines(fa), _iter_important_lines(fb)): + if la != lb: + return False + return True + + def find_ebuild_changes(category_package, overlay_path, gentoo_versions, overlay_versions): ebuild_changes = list() intersection = set(gentoo_versions) & set(overlay_versions) @@ -99,14 +113,11 @@ def find_ebuild_changes(category_package, overlay_path, gentoo_versions, overlay category, package = category_package.split('/') for version in intersection: ebuild_name = '%s-%s.ebuild' % (package, version) - command = """bash -c 'FILTER() { sed -e "/# $Header/d" -e "/# Copyright/d" -e "/KEYWORDS=/d" "$@"; }; """ \ - """cmp --quiet <(FILTER %s/%s/%s) <(FILTER %s/%s/%s) ; """ \ - """exit $?'""" \ - % (portdir, category_package, ebuild_name, overlay_path, category_package, ebuild_name) - ret = os.system(command) - if not ret: + filename_a = os.path.join(portdir, category_package, ebuild_name) + filename_b = os.path.join(overlay_path, category_package, ebuild_name) + if ebuilds_are_equivalent(filename_a, filename_b): continue - # print("meld '/usr/portage/%s/%s' '%s/%s/%s'" % (category_package, ebuild_name, conf.overlay_path, category_package, ebuild_name)) + # print("meld '%s' '%s'" % (filename_a, filename_b)) ebuild_changes.append(version) return ebuild_changes |