Gentoo Archives: gentoo-commits

From: Sebastian Pipping <sping@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/overlint:master commit in: overlint/
Date: Tue, 03 Apr 2012 21:53:53
Message-Id: 1333489923.818d518ae65523d18032c4e3082e2ca099ca4d06.sping@gentoo
1 commit: 818d518ae65523d18032c4e3082e2ca099ca4d06
2 Author: Sebastian Pipping <sebastian <AT> pipping <DOT> org>
3 AuthorDate: Tue Apr 3 21:52:03 2012 +0000
4 Commit: Sebastian Pipping <sping <AT> gentoo <DOT> org>
5 CommitDate: Tue Apr 3 21:52:03 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/overlint.git;a=commit;h=818d518a
7
8 Require overlay location parameter (using argparse)
9
10 ---
11 overlint/cli.py | 47 +++++++++++++++++++++++++++++++++++++++--------
12 1 files changed, 39 insertions(+), 8 deletions(-)
13
14 diff --git a/overlint/cli.py b/overlint/cli.py
15 index f660d94..10a3ef7 100644
16 --- a/overlint/cli.py
17 +++ b/overlint/cli.py
18 @@ -2,19 +2,29 @@
19 # Licender under GPL v2 or later
20
21 from __future__ import print_function
22 +
23 +VERSION_STR = '0.2'
24 +
25 import sys
26 import os
27 import portage
28 import re
29
30 +try:
31 + import argparse
32 +except ImportError:
33 + print("ERROR: You need Python 2.7+ unless you have module argparse "
34 + "(package dev-python/argparse on Gentoo) installed independently.", file=sys.stderr)
35 + sys.exit(1)
36 +
37
38 _revision_matcher = re.compile('-r([0-9]+)$')
39
40
41 -def find_atoms(repo_folder, category_package):
42 +def find_atoms(repository_path, category_package):
43 versions = list()
44 category, package = category_package.split('/')
45 - for root, dirs, files in os.walk(os.path.join(repo_folder, category_package)):
46 + for root, dirs, files in os.walk(os.path.join(repository_path, category_package)):
47 for f in files:
48 if not f.endswith('.ebuild'):
49 continue
50 @@ -74,7 +84,7 @@ def find_ebuild_changes(category_package, overlay_path, gentoo_versions, overlay
51 ret = os.system(command)
52 if not ret:
53 continue
54 - # print("meld '/usr/portage/%s/%s' '%s/%s/%s'" % (category_package, ebuild_name, overlay_path, category_package, ebuild_name))
55 + # print("meld '/usr/portage/%s/%s' '%s/%s/%s'" % (category_package, ebuild_name, conf.overlay_path, category_package, ebuild_name))
56 ebuild_changes.append(version)
57 return ebuild_changes
58
59 @@ -94,21 +104,42 @@ def dump_tree(tree, title):
60 print()
61
62
63 +def parse_command_line(args):
64 + parser = argparse.ArgumentParser(description='Simple tool for static analysis of Gentoo overlays')
65 + parser.add_argument(
66 + '--version',
67 + action='version', version='%(prog)s ' + VERSION_STR)
68 + parser.add_argument('overlay_path',
69 + metavar='PATH', action='store',
70 + help='Path to Gentoo overlay')
71 + conf = parser.parse_args(args=args[1:])
72 +
73 + return conf
74 +
75 +
76 def main(args):
77 - overlay_path = '/var/lib/layman/pentoo'
78 + conf = parse_command_line(args)
79 +
80 + def sanitize_overlay_path(path):
81 + path = path.rstrip('/')
82 + if path == '':
83 + return '/'
84 + return path
85 +
86 + conf.overlay_path = sanitize_overlay_path(conf.overlay_path)
87
88 missed_revision_bumps_tree = dict()
89 missed_version_bumps_tree = dict()
90 ebuild_changes_tree = dict()
91
92 - for root, dirs, files in os.walk(overlay_path):
93 + for root, dirs, files in os.walk(conf.overlay_path):
94 if '.svn' in dirs:
95 dirs[:] = [d for d in dirs if d != '.svn']
96
97
98 for d in dirs:
99 full_path_overlay = os.path.join(root, d)
100 - category_package = full_path_overlay[len(overlay_path + '/'):]
101 + category_package = full_path_overlay[len(conf.overlay_path + '/'):]
102 if len(category_package.split('/')) != 2:
103 continue
104 full_path_gentoo = os.path.join('/usr/portage/', category_package)
105 @@ -116,10 +147,10 @@ def main(args):
106 if not found:
107 continue
108
109 - overlay_versions = find_atoms(overlay_path, category_package)
110 + overlay_versions = find_atoms(conf.overlay_path, category_package)
111 gentoo_versions = find_atoms('/usr/portage/', category_package)
112 (missed_revision_bumps, missed_version_bumps) = find_missed_bumps(gentoo_versions, overlay_versions)
113 - ebuild_changes = find_ebuild_changes(category_package, overlay_path, gentoo_versions, overlay_versions)
114 + ebuild_changes = find_ebuild_changes(category_package, conf.overlay_path, gentoo_versions, overlay_versions)
115 category, package = category_package.split('/')
116 if missed_revision_bumps:
117 missed_revision_bumps_tree.setdefault(category, dict())[package] = highest_revision_only(missed_revision_bumps)