Changeset ferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv
- Timestamp:
- 06/24/08 17:40:36 (2 years ago)
- branch-nick:
- pkgcore-checks
- Files:
-
- 29 edited
-
NEWS (modified) (2 diffs)
-
TODO (modified) (2 diffs)
-
pkgcore_checks/addons.py (modified) (13 diffs)
-
pkgcore_checks/base.py (modified) (4 diffs)
-
pkgcore_checks/cleanup.py (modified) (2 diffs)
-
pkgcore_checks/deprecated.py (modified) (1 diff)
-
pkgcore_checks/dropped_keywords.py (modified) (1 diff)
-
pkgcore_checks/glsa_scan.py (modified) (5 diffs)
-
pkgcore_checks/imlate.py (modified) (4 diffs)
-
pkgcore_checks/metadata_checks.py (modified) (17 diffs)
-
pkgcore_checks/metadata_xml.py (modified) (7 diffs)
-
pkgcore_checks/pcheck.py (modified) (4 diffs)
-
pkgcore_checks/pkgdir_checks.py (modified) (12 diffs)
-
pkgcore_checks/repo_metadata.py (modified) (11 diffs)
-
pkgcore_checks/report_stream.py (modified) (9 diffs)
-
pkgcore_checks/reporters.py (modified) (3 diffs)
-
pkgcore_checks/stale_unstable.py (modified) (2 diffs)
-
pkgcore_checks/test/misc.py (modified) (6 diffs)
-
pkgcore_checks/test/test_addons.py (modified) (17 diffs)
-
pkgcore_checks/test/test_cleanup.py (modified) (1 diff)
-
pkgcore_checks/test/test_codingstyle.py (modified) (1 diff)
-
pkgcore_checks/test/test_deprecated.py (modified) (1 diff)
-
pkgcore_checks/test/test_dropped_keywords.py (modified) (2 diffs)
-
pkgcore_checks/test/test_glsa.py (modified) (1 diff)
-
pkgcore_checks/test/test_imlate.py (modified) (2 diffs)
-
pkgcore_checks/test/test_metadata_checks.py (modified) (6 diffs)
-
pkgcore_checks/test/test_stale_unstable.py (modified) (2 diffs)
-
pkgcore_checks/unstable_only.py (modified) (2 diffs)
-
pkgcore_checks/visibility.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
NEWS
rferringb@gmail.com-20080318235545-ige2dsuh3lvmfp9m rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 64 64 0.3.3: 65 65 66 * drop digest specific checks; portage now prunes digests on sync regardless 66 * drop digest specific checks; portage now prunes digests on sync regardless 67 67 of whether or not the repo is m2 pure; thus, no way to detect if a missing 68 68 digest is actually a screwup in the repo, or if it's portage being 'special'. … … 102 102 * new PickleStream reporter; used to serialize check results, and flush the 103 103 stream out stdout. If you need to get at the data generated, this is the 104 sanest way to do it (alternatives require trying to deserialize what a 104 sanest way to do it (alternatives require trying to deserialize what a 105 105 reporter does, thus losing data). 106 106 * added new tool replay-pcheck-stream; used to replay a pickle stream through -
TODO
rmarienz@gentoo.org-20061121201623-5bcc0f402b293d88 rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 5 5 - rework filter-env so it dumps a struct representing the parsing instead of 6 6 doing it inline; add python bindings, use that for source flow analysis 7 - look into trying to identify unused functions in an ebuild; eclasses, and 7 - look into trying to identify unused functions in an ebuild; eclasses, and 8 8 bash support for f() { echo "monkeys"; };x=f;${!x}; makes this potentially 9 9 likely to be a major false positive source. … … 14 14 - parallelize the bugger (potentially hard). can probably thread it splitting 15 15 it such that check x handles checks using globals x (cache mainly), other 16 checks being bits that don't; gain may not be much since the major time 16 checks being bits that don't; gain may not be much since the major time 17 17 consumers are visibility and unported_mod_x -
pkgcore_checks/addons.py
rferringb@gmail.com-20080624173954-nab8ouii8xngsv25 rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 13 13 from pkgcore_checks import base, util 14 14 15 from snakeoil import (demandload, currying, containers, mappings, iterables, 15 from snakeoil import (demandload, currying, containers, mappings, iterables, 16 16 lists) 17 17 demandload.demandload(globals(), … … 176 176 177 177 disabled = set(norm_name(x) for x in options.profiles_disabled) 178 enabled = set(x for x in 178 enabled = set(x for x in 179 179 (norm_name(y) for y in options.profiles_enabled) 180 180 if x not in disabled) … … 185 185 util.get_profiles_desc(options.profile_base_dir, 186 186 ignore_dev=options.profile_ignore_dev) 187 187 188 188 for k, v in d.iteritems(): 189 189 l = [x for x in map(norm_name, v) 190 190 if not x in disabled] 191 192 # wipe any enableds that are here already so we don't 191 192 # wipe any enableds that are here already so we don't 193 193 # get a profile twice 194 194 enabled.difference_update(l) … … 203 203 "profile %s lacks arch settings, unable to use it" % x) 204 204 arch_profiles.setdefault(p.arch, []).append((x, p)) 205 205 206 206 for x in options.profiles_enabled: 207 207 options.profile_func(x) … … 219 219 self.keywords_filter = {} 220 220 ignore_deprecated = self.options.profile_ignore_deprecated 221 221 222 222 # we hold onto the profiles as we're going, due to the fact 223 223 # profilenodes are weakly cached; hold onto all for this loop, … … 231 231 stable_key = k.lstrip("~") 232 232 unstable_key = "~"+ stable_key 233 stable_r = packages.PackageRestriction("keywords", 233 stable_r = packages.PackageRestriction("keywords", 234 234 values.ContainmentMatch(stable_key)) 235 unstable_r = packages.PackageRestriction("keywords", 235 unstable_r = packages.PackageRestriction("keywords", 236 236 values.ContainmentMatch(stable_key, unstable_key)) 237 237 238 238 default_masked_use = [(packages.AlwaysTrue, (x,)) for x in 239 239 self.official_arches if x != stable_key] 240 240 241 241 profile_filters.update({stable_key:[], unstable_key:[]}) 242 242 for profile_name in arch_profiles.get(k, []): … … 258 258 [(packages.AlwaysTrue, (stable_key,))], 259 259 profile.forced_use.iteritems()) 260 261 # used to interlink stable/unstable lookups so that if 260 261 # used to interlink stable/unstable lookups so that if 262 262 # unstable says it's not visible, stable doesn't try 263 263 # if stable says something is visible, unstable doesn't try. … … 290 290 self.keywords_filter[stable_key] = stable_r 291 291 self.keywords_filter[unstable_key] = packages.PackageRestriction( 292 "keywords", 292 "keywords", 293 293 values.ContainmentMatch(unstable_key)) 294 294 … … 407 407 408 408 threshold = base.versioned_feed 409 409 410 410 def __init__(self, pkg, attr, flags): 411 411 base.Result.__init__(self) 412 412 self._store_cpv(pkg) 413 413 self.attr, self.flags = attr, tuple(flags) 414 414 415 415 @property 416 416 def short_desc(self): … … 459 459 try: 460 460 estr = entry.rsplit(".", 1)[0].lower()+ "_" 461 unstated_iuse.update(estr + usef.strip() for usef in 461 unstated_iuse.update(estr + usef.strip() for usef in 462 462 read_dict(osutils.join(use_expand_base, entry), 463 463 None).iterkeys()) … … 472 472 self.specific_iuse = tuple((x[0], tuple(x[1])) for x in specific_iuse) 473 473 self.collapsed_iuse = misc.non_incremental_collapsed_restrict_to_data( 474 ((packages.AlwaysTrue, known_iuse),), 474 ((packages.AlwaysTrue, known_iuse),), 475 475 ((packages.AlwaysTrue, unstated_iuse),), 476 476 self.specific_iuse) … … 493 493 return currying.partial(self.use_validate, attr=attr_name) 494 494 return self.use_validate 495 495 496 496 @staticmethod 497 497 def fake_use_validate(klasses, pkg, seq, reporter, attr=None): … … 508 508 skip_filter = (packages.Conditional,) + klasses 509 509 unstated = set() 510 510 511 511 stated = self.iuse_strip(pkg.iuse) 512 512 i = iterables.expandable_chain(lists.iflatten_instance(seq, -
pkgcore_checks/base.py
rferringb@gmail.com-20070408202649-jgels0n569r8my90 rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 175 175 except NotImplementedError: 176 176 return "result from %s" % self.__class__.__name__ 177 177 178 178 @property 179 179 def short_desc(self): … … 183 183 def long_desc(self): 184 184 return self.short_desc 185 185 186 186 def _store_cp(self, pkg): 187 187 self.category = pkg.category 188 188 self.package = pkg.package 189 189 190 190 def _store_cpv(self, pkg): 191 191 self._store_cp(pkg) … … 201 201 raise AttributeError(self.__class__, str(a)) 202 202 return object.__getstate__(self) 203 203 204 204 def __setstate__(self, data): 205 205 attrs = set(getattr(self, '__attrs__', getattr(self, '__slots__', []))) … … 221 221 def start_check(self, source, target): 222 222 pass 223 223 224 224 def end_check(self): 225 225 pass -
pkgcore_checks/cleanup.py
rferringb@gmail.com-20070408202649-jgels0n569r8my90 rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 29 29 class RedundantVersionReport(Template): 30 30 """ 31 scan for versions that are likely shadowed by later versions from a 31 scan for versions that are likely shadowed by later versions from a 32 32 keywords standpoint (ignoring -9999 versioned packages) 33 34 Example: pkga-1 is keyworded amd64, pkga-2 is amd64. 33 34 Example: pkga-1 is keyworded amd64, pkga-2 is amd64. 35 35 pkga-1 can potentially be removed. 36 36 """ … … 42 42 if len(pkgset) == 1: 43 43 return 44 44 45 45 # algo is roughly thus; spot stable versions, hunt for subset 46 46 # keyworded pkgs that are less then the max version; -
pkgcore_checks/deprecated.py
rferringb@gmail.com-20070213122704-diaydvzzeptt2vel rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 7 7 class DeprecatedEclass(Result): 8 8 """pkg uses an eclass that is deprecated/abandoned""" 9 9 10 10 __slots__ = ("category", "package", "version", "eclasses") 11 11 threshold = versioned_feed 12 12 13 13 def __init__(self, pkg, eclasses): 14 14 Result.__init__(self) -
pkgcore_checks/dropped_keywords.py
rjokey@gentoo.org-20071214152518-f29y8pyqvxilpohs rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 57 57 state = oldstate 58 58 lastpkg = pkg 59 59 60 60 for key, pkg in dropped: 61 61 reporter.add_report(DroppedKeywordWarning(key, pkg)) -
pkgcore_checks/glsa_scan.py
rferringb@gmail.com-20070405184154-1nqu8pvp0wnm7zi3 rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 6 6 from pkgcore_checks import base 7 7 from snakeoil.demandload import demandload 8 demandload(globals(), 8 demandload(globals(), 9 9 'pkgcore.pkgsets.glsa:GlsaDirSet', 10 10 'pkgcore.restrictions:packages,values', … … 30 30 arches.update(x.lstrip("~") for x in v.restriction.vals) 31 31 else: 32 raise Exception("unexpected restriction sequence- %s in %s" % 32 raise Exception("unexpected restriction sequence- %s in %s" % 33 33 (v.restriction, glsa)) 34 34 keys = set(x.lstrip("~") for x in pkg.keywords if not x.startswith("-")) … … 39 39 self.arch = tuple(sorted(keys)) 40 40 self.glsa = str(glsa) 41 41 42 42 @property 43 43 def short_desc(self): … … 48 48 """ 49 49 Scan for vulnerabile ebuilds in the tree 50 50 51 51 requires a GLSA directory for vuln. info 52 52 """ … … 113 113 for r in GlsaDirSet(self.glsa_dir): 114 114 if len(r) > 2: 115 self.vulns.setdefault(r[0].key, 115 self.vulns.setdefault(r[0].key, 116 116 []).append(packages.AndRestriction(*r[1:])) 117 117 else: -
pkgcore_checks/imlate.py
rferringb@gmail.com-20070207174621-yb3eqrqc6jtmdgse rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 9 9 10 10 """Arch that is behind another from a stabling standpoint""" 11 11 12 12 __slots__ = ("category", "package", "version", "keywords", 13 13 "stable") 14 14 threshold = base.versioned_feed 15 15 16 16 def __init__(self, pkg, keywords): 17 17 base.Result.__init__(self) … … 20 20 self.stable = tuple(str(x) for x in pkg.keywords 21 21 if not x[0] in ("~", "-")) 22 22 23 23 @property 24 24 def short_desc(self): … … 30 30 31 31 """ 32 scan for ebuilds that can be stabled based upon stabling status for 32 scan for ebuilds that can be stabled based upon stabling status for 33 33 other arches 34 34 """ … … 51 51 base.Template.__init__(self, options) 52 52 arches = frozenset(x.strip().lstrip("~") for x in options.arches) 53 self.target_arches = frozenset("~%s" % x.strip().lstrip("~") 53 self.target_arches = frozenset("~%s" % x.strip().lstrip("~") 54 54 for x in arches) 55 self.source_arches = frozenset(x.lstrip("~") 55 self.source_arches = frozenset(x.lstrip("~") 56 56 for x in options.reference_arches) 57 57 self.source_filter = packages.PackageRestriction("keywords", -
pkgcore_checks/metadata_checks.py
rjokey@gentoo.org-20071230125611-5bk03uu70wtw86bk rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 22 22 __slots__ = ("category", "package", "version", "attr", "msg") 23 23 threshold = base.versioned_feed 24 24 25 25 def __init__(self, pkg, attr, msg): 26 26 base.Result.__init__(self) 27 27 self._store_cpv(pkg) 28 28 self.attr, self.msg = attr, str(msg) 29 29 30 30 @property 31 31 def short_desc(self): … … 38 38 __slots__ = ("category", "package", "version", "licenses") 39 39 threshold = base.versioned_feed 40 40 41 41 def __init__(self, pkg, licenses): 42 42 self._store_cpv(pkg) 43 43 self.licenses = tuple(sorted(licenses)) 44 44 45 45 @property 46 46 def short_desc(self): … … 57 57 58 58 required_addons = (addons.UseAddon, addons.ProfileAddon, 59 addons.LicenseAddon) 59 addons.LicenseAddon) 60 60 61 61 def __init__(self, options, iuse_handler, profiles, licenses): … … 76 76 raise 77 77 except (MetadataException, MalformedAtom, ValueError), e: 78 reporter.add_report(MetadataError(pkg, 'license', 78 reporter.add_report(MetadataError(pkg, 'license', 79 79 "error- %s" % e)) 80 80 del e … … 82 82 logging.exception("unknown exception caught for pkg(%s) attr(%s): " 83 83 "type(%s), %s" % (pkg, 'license', type(e), e)) 84 reporter.add_report(MetadataError(pkg, 'license', 84 reporter.add_report(MetadataError(pkg, 'license', 85 85 "exception- %s" % e)) 86 86 del e … … 120 120 self.iuse_handler.allowed_iuse(pkg)) 121 121 if iuse: 122 reporter.add_report(MetadataError(pkg, "iuse", 122 reporter.add_report(MetadataError(pkg, "iuse", 123 123 "iuse unknown flags- [ %s ]" % ", ".join(iuse))) 124 124 … … 156 156 raise 157 157 except (MetadataException, MalformedAtom, ValueError), e: 158 reporter.add_report(MetadataError(pkg, attr_name, 158 reporter.add_report(MetadataError(pkg, attr_name, 159 159 "error- %s" % e)) 160 160 del e … … 163 163 "unknown exception caught for pkg(%s) attr(%s): " 164 164 "type(%s), %s" % (pkg, attr_name, type(e), e)) 165 reporter.add_report(MetadataError(pkg, attr_name, 165 reporter.add_report(MetadataError(pkg, attr_name, 166 166 "exception- %s" % e)) 167 167 del e … … 177 177 base.Result.__init__(self) 178 178 self._store_cpv(pkg) 179 179 180 180 short_desc = ("keywords contain -*; use package.mask or empty keywords " 181 181 "instead") 182 182 183 183 184 184 class KeywordsReport(base.Template): 185 185 186 186 """ 187 187 check pkgs keywords for sanity; empty keywords, and -* are flagged 188 188 """ 189 189 190 190 feed_type = base.versioned_feed 191 191 known_results = (StupidKeywords, MetadataError) 192 192 193 193 def feed(self, pkg, reporter): 194 194 if "-*" in pkg.keywords and len(pkg.keywords) == 1: … … 205 205 self._store_cpv(pkg) 206 206 self.filename = filename 207 207 208 208 @property 209 209 def short_desc(self): 210 210 return "file %s is unfetchable- no URI available, and RESTRICT=fetch " \ 211 211 "isn't set" % self.filename 212 212 213 213 214 214 class BadProto(base.Result): … … 222 222 self.filename = filename 223 223 self.bad_uri = tuple(sorted(bad_uri)) 224 224 225 225 @property 226 226 def short_desc(self): 227 227 return "file %s: bad protocol/uri: %r " % (self.filename, self.bad_uri) 228 228 229 229 230 230 class SrcUriReport(base.Template): … … 285 285 286 286 class CrappyDescription(base.Result): 287 287 288 288 """pkg's description sucks in some fashion""" 289 289 … … 295 295 self._store_cpv(pkg) 296 296 self.msg = msg 297 297 298 298 @property 299 299 def short_desc(self): 300 300 return "description needs improvement: %s" % self.msg 301 301 302 302 303 303 class DescriptionReport(base.Template): … … 307 307 just using the pkgs name 308 308 """ 309 309 310 310 feed_type = base.versioned_feed 311 311 known_results = (CrappyDescription,) … … 337 337 class BadRestricts(base.Result): 338 338 """pkg's restrict metadata has unknown/deprecated entries""" 339 339 340 340 __slots__ = ("category", "package", "version", "restricts", "deprecated") 341 341 threshold = base.versioned_feed 342 342 343 343 def __init__(self, pkg, restricts, deprecated=None): 344 344 base.Result.__init__(self) … … 348 348 if not restricts and not deprecated: 349 349 raise TypeError("deprecated or restricts must not be empty") 350 350 351 351 @property 352 352 def short_desc(self): … … 360 360 self.deprecated) 361 361 return s 362 362 363 363 364 364 class RestrictsReport(base.Template): 365 365 feed_type = base.versioned_feed 366 known_restricts = frozenset(("confcache", "stricter", "mirror", "fetch", 366 known_restricts = frozenset(("confcache", "stricter", "mirror", "fetch", 367 367 "test", "sandbox", "userpriv", "primaryuri", "binchecks", "strip", 368 368 "multilib-strict")) 369 369 370 370 known_results = (BadRestricts,) + addons.UseAddon.known_results 371 required_addons = (addons.UseAddon,) 371 required_addons = (addons.UseAddon,) 372 372 373 373 __doc__ = "check over RESTRICT, looking for unknown restricts\nvalid " \ -
pkgcore_checks/metadata_xml.py
rferringb@gmail.com-20071026032833-rscc1s9ni1lnqgvf rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 18 18 __slots__ = ('category', 'package', 'filename') 19 19 __attrs__ = __slots__ 20 20 21 21 def __init__(self, filename, category, package=None): 22 22 base.Result.__init__(self) … … 41 41 __slots__ = ("category", "package", "filename") 42 42 __attrs__ = __slots__ 43 43 44 44 def __init__(self, filename, category, package=None): 45 45 base.Result.__init__(self) … … 47 47 self.package = package 48 48 self.filename = filename 49 49 50 50 @property 51 51 def _label(self): … … 57 57 def short_desc(self): 58 58 return "%s %s is not well formed xml" % (self._label, os.path.basename(self.filename)) 59 59 60 60 61 61 class base_InvalidXml(base.Result): … … 64 64 __slots__ = ("category", "package", "filename") 65 65 __attrs__ = __slots__ 66 66 67 67 def __init__(self, filename, category, package=None): 68 68 base.Result.__init__(self, filename, category, package=None) … … 243 243 self.parsed_dtd = self.libxml2.parseDTD(None, loc) 244 244 self.validator = self.libxml2.newValidCtxt() 245 245 246 246 def validate(self, loc): 247 247 """ … … 265 265 self.dtd_loc = loc 266 266 self.bin_loc = find_binary("xmllint") 267 267 268 268 def validate(self, loc): 269 269 """ -
pkgcore_checks/pcheck.py
rferringb@gmail.com-20070405184154-1nqu8pvp0wnm7zi3 rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 347 347 out.first_prefix.pop() 348 348 out.later_prefix.pop() 349 349 350 350 @decorate_forced_wrapping() 351 351 def display_checks(out, checks): … … 358 358 out.write() 359 359 return 360 360 361 361 for module_name in sorted(d): 362 362 out.write(out.bold, "%s:" % module_name) … … 396 396 out.first_prefix.pop() 397 397 out.later_prefix.pop() 398 398 399 399 if plugin_reporters: 400 400 if config_reporters: … … 429 429 options.config.pcheck_reporter_factory.values(), 430 430 list(get_plugins('reporter', plugins))) 431 return 0 431 return 0 432 432 433 433 if not options.repo_bases: -
pkgcore_checks/pkgdir_checks.py
rferringb@gmail.com-20070405184154-1nqu8pvp0wnm7zi3 rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 28 28 29 29 threshold = package_feed 30 30 31 31 def __init__(self, pkg, filename): 32 32 Result.__init__(self) … … 37 37 def short_desc(self): 38 38 return "required file %s doesn't exist" % self.filename 39 39 40 40 41 41 class ExecutableFile(Result): … … 45 45 46 46 threshold = package_feed 47 47 48 48 def __init__(self, pkg, filename): 49 49 Result.__init__(self) 50 50 self._store_cp(pkg) 51 51 self.filename = filename 52 52 53 53 @property 54 54 def short_desc(self): 55 55 return "file %s has unecessary executable bit" % self.filename 56 56 57 57 58 58 class SizeViolation(Result): … … 62 62 63 63 threshold = package_feed 64 64 65 65 def __init__(self, pkg, size): 66 66 Result.__init__(self) 67 67 self._store_cp(pkg) 68 68 self.size = size 69 69 70 70 @property 71 71 def short_desc(self): … … 76 76 77 77 """file doesn't abide by glep31 requirements""" 78 78 79 79 __slots__ = ("category", "package", "filename") 80 80 81 81 threshold = package_feed 82 82 83 83 def __init__(self, pkg, filename): 84 84 Result.__init__(self) 85 85 self._store_cp(pkg) 86 86 self.filename = filename 87 87 88 88 @property 89 89 def short_desc(self): … … 95 95 96 96 """file isn't utf8 compliant""" 97 97 98 98 __slots__ = ("category", "package", "filename", "err") 99 99 100 100 threshold = package_feed 101 101 102 102 def __init__(self, pkg, filename, err): 103 103 Result.__init__(self) … … 105 105 self.filename = filename 106 106 self.err = err 107 107 108 108 @property 109 109 def short_desc(self): … … 113 113 def utf8_check(pkg, base, filename, reporter): 114 114 try: 115 codecs.open(pjoin(base, filename), mode="rb", 115 codecs.open(pjoin(base, filename), mode="rb", 116 116 encoding="utf8", buffering=8192).read() 117 117 except UnicodeDecodeError, e: … … 124 124 125 125 feed_type = package_feed 126 126 127 127 ignore_dirs = set(["cvs", ".svn", ".bzr"]) 128 128 known_results = (MissingFile, ExecutableFile, SizeViolation, … … 137 137 # handed to any, it's a frame switch each 138 138 # char, which adds up. 139 140 if any(True for x in filename if 139 140 if any(True for x in filename if 141 141 x not in allowed_filename_chars_set): 142 142 reporter.add_report(Glep31Violation(pkgset[0], filename)) 143 143 144 144 if filename.endswith(".ebuild") or filename in \ 145 145 ("Manifest", "ChangeLog", "metadata.xml"): 146 146 if os.stat(pjoin(base, filename)).st_mode & 0111: 147 147 reporter.add_report(ExecutableFile(pkgset[0], filename)) 148 148 149 149 if filename.endswith(".ebuild"): 150 150 utf8_check(pkgset[0], base, filename, reporter) … … 157 157 del e 158 158 reporter.add_report(MissingFile(pkgset[0], "ChangeLog")) 159 159 160 160 if not os.path.exists(pjoin(base, "files")): 161 161 if pkgset[0].manifest.version == 1: 162 162 reporter.add_report(MissingFile(pkgset[0], "files")) 163 163 return 164 164 165 165 size = 0 166 166 unprocessed_dirs = deque(["files"]) … … 181 181 if not fn.startswith("digest-"): 182 182 size += st.st_size 183 if any(True for x in fn if 183 if any(True for x in fn if 184 184 x not in allowed_filename_chars_set): 185 185 reporter.add_report(Glep31Violation(pkgset[0], -
pkgcore_checks/repo_metadata.py
rferringb@gmail.com-20080318043726-spb05yn0xqhsbp8k rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 20 20 21 21 class UnusedLocalFlagsResult(base.Result): 22 22 23 23 """ 24 24 unused use.local.desc flag(s) 25 25 """ 26 26 27 27 __slots__ = ("category", "package", "flags") 28 28 … … 34 34 self._store_cp(pkg) 35 35 self.flags = tuple(sorted(flags)) 36 36 37 37 @property 38 38 def short_desc(self): … … 69 69 70 70 class UnusedGlobalFlagsResult(base.Result): 71 71 72 72 """ 73 73 unused use.desc flag(s) 74 74 """ 75 75 76 76 __slots__ = ("flags",) 77 77 … … 82 82 # tricky, but it works; atoms have the same attrs 83 83 self.flags = tuple(sorted(flags)) 84 84 85 85 @property 86 86 def short_desc(self): … … 121 121 unused license(s) detected 122 122 """ 123 123 124 124 __slots__ = ("licenses",) 125 125 126 126 threshold = base.repository_feed 127 127 128 128 def __init__(self, licenses): 129 129 base.Result.__init__(self) … … 173 173 else: 174 174 yield chf, "%x" % val1, "%x" % val2 175 175 176 176 177 177 class ConflictingChksums(base.Result): … … 183 183 __slots__ = ("category", "package", "version", 184 184 "filename", "chksums", "others") 185 185 186 186 threshold = base.versioned_feed 187 187 188 188 _sorter = staticmethod(operator.itemgetter(0)) 189 189 190 190 def __init__(self, pkg, filename, chksums, others): 191 191 base.Result.__init__(self) … … 206 206 manifest2 has a checksum entry digest lacks 207 207 """ 208 208 209 209 __slots__ = ("category", "package", "files") 210 210 … … 215 215 self._store_cp(pkg) 216 216 self.files = tuple(sorted(files)) 217 217 218 218 @property 219 219 def short_desc(self): … … 244 244 a package's checksum data still is manifest1, instead of manifest2 245 245 """ 246 246 247 247 threshold = base.package_feed 248 248 __slots__ = ("category", "package") 249 249 250 250 def __init__(self, pkg): 251 251 self._store_cp(pkg) 252 252 253 253 short_desc = "still is using manifest1 format, should be using manifest2" 254 254 … … 276 276 reporter.add_report(DeprecatedManifest1(pkgset[0])) 277 277 continue 278 278 279 279 seen = set() 280 280 for pkg in pkgset: -
pkgcore_checks/report_stream.py
rferringb@gmail.com-20070405184154-1nqu8pvp0wnm7zi3 rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 5 5 reporter. 6 6 7 Useful if you need to delay acting on results until it can be done in 7 Useful if you need to delay acting on results until it can be done in 8 8 one minimal window (say updating a database), or want to generate 9 9 several different reports without using a config defined multiplex reporter. … … 30 30 for x in checks: 31 31 self.known_results.update(x.known_results) 32 32 33 33 self.known_results = tuple(sorted(self.known_results)) 34 34 self.criteria = str(criteria) 35 35 36 36 37 37 class PickleStream(base.Reporter): … … 39 39 Generate a stream of pickled objects. 40 40 For each specific target for checks, a header is pickled 41 detailing the checks used, possible results, and search 41 detailing the checks used, possible results, and search 42 42 criteria. 43 43 44 44 """ 45 45 priority = -1001 46 46 protocol = 0 47 47 48 48 def __init__(self, out): 49 49 """Initialize. … … 67 67 except TypeError, t: 68 68 raise TypeError(result, str(t)) 69 69 70 70 71 71 class BinaryPickleStream(PickleStream): … … 81 81 82 82 def __init__(self, **kwargs): 83 commandline.OptionParser.__init__(self, description=__doc__, 83 commandline.OptionParser.__init__(self, description=__doc__, 84 84 usage="replay_report_stream <pickle-file> <python namespace path" 85 85 "reporter to replay it into>", … … 92 92 def check_values(self, values, args): 93 93 vals, args = commandline.OptionParser.check_values(self, values, args) 94 94 95 95 if len(args) < 2: 96 96 self.error("need at least two args, pickle file, and reporter") … … 102 102 values.reporter = load_attribute(args[1]) 103 103 values.stream_path = args[0] 104 104 105 105 return values, [] 106 106 … … 113 113 if debug: 114 114 if headers: 115 debug.write("finished processing %i results for %s" % 115 debug.write("finished processing %i results for %s" % 116 116 (count - last_count, headers[-1].criteria)) 117 117 last_count = count … … 127 127 reporter.end_check() 128 128 if debug: 129 debug.write("finished processing %i results for %s" % 129 debug.write("finished processing %i results for %s" % 130 130 (count - last_count, headers[-1].criteria)) 131 131 -
pkgcore_checks/reporters.py
rferringb@gmail.com-20070405184154-1nqu8pvp0wnm7zi3 rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 44 44 self.first_report = False 45 45 if result.threshold == base.versioned_feed: 46 self.out.write("%s/%s-%s: %s" % (result.category, result.package, 46 self.out.write("%s/%s-%s: %s" % (result.category, result.package, 47 47 result.version, result.short_desc)) 48 48 elif result.threshold == base.package_feed: … … 63 63 """ 64 64 groupped colored output, example: 65 65 66 66 sys-apps/portage 67 67 WrongIndentFound: sys-apps/portage-2.1-r2.ebuild has whitespace in indentation on line 169 … … 141 141 142 142 def add_report(self, result): 143 d = dict((k, getattr(result, k, '')) for k in 143 d = dict((k, getattr(result, k, '')) for k in 144 144 ("category", "package", "version")) 145 145 d["msg"] = xml.escape(result.short_desc) -
pkgcore_checks/stale_unstable.py
rferringb@gmail.com-20070215055854-o62wwq2te9476hzj rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 14 14 month 15 15 """ 16 16 17 17 __slots__ = ("category", "package", "version", "keywords", "period") 18 18 19 19 threshold = versioned_feed 20 20 21 21 def __init__(self, pkg, keywords, period): 22 22 Result.__init__(self) … … 29 29 return "no change in %i days for unstable keywords [ %s ]" % ( 30 30 self.period, ', '.join(self.keywords)) 31 31 32 32 33 33 class StaleUnstableReport(Template): -
pkgcore_checks/test/misc.py
rferringb@gmail.com-20070522173125-afguloxkw2ic7664 rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 22 22 for x in ("DEPEND", "RDEPEND", "PDEPEND", "IUSE", "LICENSE"): 23 23 data.setdefault(x, "") 24 24 25 25 cpv = CPV(cpvstr) 26 26 package.__init__(self, shared, parent, cpv.category, cpv.package, … … 31 31 class FakeTimedPkg(package): 32 32 __slots__ = "_mtime_" 33 33 34 34 def __init__(self, cpvstr, mtime, data=None, shared=None, repo=None): 35 35 if data is None: … … 73 73 self.assertTrue(attrs, msg="unknown threshold on %r" % (report.__class__,)) 74 74 for x in attrs: 75 self.assertTrue(hasattr(report, x), msg="threshold %s, missing attr %s: %r %s" % 75 self.assertTrue(hasattr(report, x), msg="threshold %s, missing attr %s: %r %s" % 76 76 (report.threshold, x, report.__class__, report)) 77 77 … … 81 81 check.feed(data, r) 82 82 self.assert_known_results(*l) 83 self.assertTrue(l, msg="must get a report from %r %r, got none" % 83 self.assertTrue(l, msg="must get a report from %r %r, got none" % 84 84 (check, data)) 85 85 self.assertReportSanity(*l) … … 87 87 88 88 def assertIsInstance(self, obj, kls): 89 self.assertTrue(isinstance(obj, kls), 89 self.assertTrue(isinstance(obj, kls), 90 90 msg="%r must be %r" % (obj, kls)) 91 91 return obj … … 130 130 [(AlwaysTrue, default_arches)], 131 131 self.masked_use.iteritems()) 132 132 133 133 def make_virtuals_repo(self, repo): 134 134 return self.virtuals -
pkgcore_checks/test/test_addons.py
rferringb@gmail.com-20070413063232-hw1qtxyy73lt5360 rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 26 26 27 27 addon_kls = None 28 28 29 29 def process_check(self, args, silence=False, preset_values={}, **settings): 30 30 p = parser() 31 31 self.addon_kls.mangle_option_parser(p) 32 32 options, ret_args = p.parse_args(args) 33 self.assertFalse(ret_args, msg="%r args were left after processing %r" % 33 self.assertFalse(ret_args, msg="%r args were left after processing %r" % 34 34 (ret_args, args)) 35 35 orig_out, orig_err = None, None … … 59 59 60 60 addon_kls = addons.ArchesAddon 61 61 62 62 def test_opts(self): 63 63 for arg in ('-a', '--arches'): … … 70 70 71 71 class TestQueryCacheAddon(base_test): 72 72 73 73 addon_kls = addons.QueryCacheAddon 74 74 default_feed = base.package_feed … … 84 84 self.process_check([], silence=True, 85 85 query_caching_freq=self.default_feed) 86 86 87 87 def test_feed(self): 88 88 options = self.process_check([], silence=True) … … 96 96 97 97 class Test_profile_data(TestCase): 98 98 99 99 def assertResults(self, profile, known_flags, required_immutable, 100 100 required_forced, cpv="dev-util/diffball-0.1", key_override=None): … … 109 109 self.assertEqual(immutable, set(required_immutable)) 110 110 self.assertEqual(enabled, set(required_forced)) 111 111 112 112 def test_identify_use(self): 113 113 profile = FakeProfile() … … 191 191 self.assertEqual(sorted(check.profile_evaluate_dict), ['x86', '~x86']) 192 192 self.assertProfiles(check, 'x86', 'profile1', 'profile1/2') 193 193 194 194 def test_profile_base(self): 195 195 self.mk_profiles({"default-linux":["x86", True], … … 203 203 "default-linux/x86":["x86"]}, base='foo') 204 204 options = self.process_check(['--profile-base', pjoin(self.dir, 'foo'), 205 '--profile-disable-dev'], 205 '--profile-disable-dev'], 206 206 profile_ignore_dev=True) 207 207 check = self.addon_kls(options) … … 259 259 self.assertEqual(len(l[0]), 2, msg="checking for proper # of profiles: " 260 260 "%r" % l[0]) 261 self.assertEqual(sorted(x.name for x in l[0]), 261 self.assertEqual(sorted(x.name for x in l[0]), 262 262 sorted(['default-linux', 'default-linux/x86'])) 263 263 264 264 # check keyword collapsing 265 265 l = check.identify_profiles(FakePkg("d-b/ab-2", data={'KEYWORDS':'ppc'})) … … 273 273 self.assertEqual(len(l), 0, msg="checking for profile collapsing: %r" % 274 274 l) 275 275 276 276 277 277 # test collapsing reusing existing profile layout … … 356 356 # sorted(x.name for x in blah); reasoning is that it will catch 357 357 # if duplicates come through, *and* ensure proper profile collapsing 358 358 359 359 # shouldn't return anything due to no profiles matching the keywords. 360 360 self.assertEqual(get_rets("0.0.1", "depends", KEYWORDS="foon"), []) … … 384 384 385 385 self.assertEqual(set(str(l1[0]).split()), 386 set(['dev-util/confcache', 'dev-util/bar', 'dev-util/nobar', 386 set(['dev-util/confcache', 'dev-util/bar', 'dev-util/nobar', 387 387 'x11-libs/xserver'])) 388 388 389 389 self.assertEqual(set(str(l2[0]).split()), 390 set(['dev-util/confcache', 'dev-util/foo', 'dev-util/bar', 390 set(['dev-util/confcache', 'dev-util/foo', 'dev-util/bar', 391 391 'x11-libs/xserver'])) 392 392 … … 400 400 401 401 check.feed(None, None) 402 402 403 403 # ensure it handles arch right. 404 404 l = get_rets("0", "depends", KEYWORDS="ppc x86") … … 414 414 self.assertEqual(sorted(x.name for x in l[0][1]), ['1', '2', '3'], 415 415 msg="should have 3 profiles, got %r\nthis indicates it's " 416 "re-identifying profiles every invocation, which is unwarranted " 416 "re-identifying profiles every invocation, which is unwarranted " 417 417 % l[0][1]) 418 418 419 419 l = get_rets("1", "depends", KEYWORDS="ppc x86", 420 420 DEPEND="ppc? ( dev-util/ppc ) !ppc? ( dev-util/x86 )") … … 424 424 l1 = [x[1] for x in l if str(x[0]).strip() == "dev-util/ppc"][0] 425 425 l2 = [x[1] for x in l if str(x[0]).strip() == "dev-util/x86"][0] 426 426 427 427 self.assertEqual(sorted(x.name for x in l1), ["3"]) 428 428 self.assertEqual(sorted(x.name for x in l2), ["1", "2"]) … … 432 432 433 433 addon_kls = addons.LicenseAddon 434 434 435 435 def test_defaults(self): 436 436 r1 = pjoin(self.dir, "repo1") … … 459 459 460 460 class TestUseAddon(mixins.TempDirMixin, base_test): 461 461 462 462 addon_kls = addons.UseAddon 463 463 -
pkgcore_checks/test/test_cleanup.py
rferringb@gmail.com-20070408202649-jgels0n569r8my90 rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 12 12 return misc.FakePkg("dev-util/diffball-%s" % ver, 13 13 data={"KEYWORDS":' '.join(keywords), "SLOT":slot}) 14 14 15 15 def test_it(self): 16 16 # single version, shouldn't yield. 17 17 check = redundant_ver(None, None) 18 18 self.assertNoReport(check, [self.mk_pkg("0.7.1")]) 19 reports = self.assertReports(check, 19 reports = self.assertReports(check, 20 20 [self.mk_pkg(x) for x in "0.7", "0.8", "0.9"]) 21 self.assertEqual([list(x.later_versions) for x in reports], 21 self.assertEqual([list(x.later_versions) for x in reports], 22 22 [["0.9", "0.8"], ["0.9"]]) 23 23 24 24 # check slots. 25 l = [self.mk_pkg("0.7"), self.mk_pkg("0.8", slot="1"), 25 l = [self.mk_pkg("0.7"), self.mk_pkg("0.8", slot="1"), 26 26 self.mk_pkg("0.9")] 27 27 reports = self.assertReports(check, l) -
pkgcore_checks/test/test_codingstyle.py
rjokey@gentoo.org-20070609214646-diso84llm9pen9qh rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 29 29 30 30 bad = ("/etc/env.d", "/etc/conf.d", "/etc/init.d", "/etc/pam.d", 31 "/usr/share/applications", "/usr/share/applications", 31 "/usr/share/applications", "/usr/share/applications", 32 32 "//usr/share//applications", "/etc/cron.d", "/etc/cron.hourly", 33 33 "/etc/cron.daily", "/etc/cron.weekly") -
pkgcore_checks/test/test_deprecated.py
rferringb@gmail.com-20070211042219-nhmex9beszcf9ool rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 12 12 return misc.FakePkg("dev-util/diffball-%s" % ver, 13 13 data={"_eclasses_":{}.fromkeys(eclasses)}) 14 14 15 15 def test_it(self): 16 16 # single version, shouldn't yield. -
pkgcore_checks/test/test_dropped_keywords.py
rferringb@gmail.com-20070211042219-nhmex9beszcf9ool rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 17 17 check = drop_keys(misc.Options((("arches", ["x86", "amd64"]),))) 18 18 self.assertNoReport(check, [self.mk_pkg('1')]) 19 reports = self.assertReports(check, 19 reports = self.assertReports(check, 20 20 [self.mk_pkg("1", "x86 amd64"), self.mk_pkg("2")]) 21 21 self.assertEqual(set(x.arch for x in reports), set(["x86", "amd64"])) … … 28 28 self.mk_pkg("2", "~amd64 x86"), 29 29 self.mk_pkg("3", "-amd64 x86")]) 30 30 -
pkgcore_checks/test/test_glsa.py
rferringb@gmail.com-20070413063232-hw1qtxyy73lt5360 rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 18 18 def test_it(self): 19 19 # single version, shouldn't yield. 20 check = vuln_report(misc.Options(glsa_location=self.dir, 20 check = vuln_report(misc.Options(glsa_location=self.dir, 21 21 glsa_enabled=True)) 22 22 open(pjoin(self.dir, "glsa-200611-01.xml"), "w").write( -
pkgcore_checks/test/test_imlate.py
rferringb@gmail.com-20070211042219-nhmex9beszcf9ool rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 19 19 reference_arches=("x86", "ppc", "amd64"), 20 20 target_arches=("x86", "ppc")), None) 21 21 22 22 self.assertNoReport(check, 23 23 [mk_pkg(str(x), "~x86 ~amd64") for x in xrange(10)]) … … 33 33 # insert a 0.7 in; it should not show. 34 34 # additionally, insert an arch we don't care about... 35 35 36 36 report = self.assertReports(check, [mk_pkg("0.7", "~x86"), 37 37 mk_pkg("0.8", "~x86 ~foo"), mk_pkg("0.9","~x86 amd64"), -
pkgcore_checks/test/test_metadata_checks.py
rjokey@gentoo.org-20071230130147-ka247psyvw83tzqf rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 43 43 44 44 check_kls = metadata_checks.KeywordsReport 45 45 46 46 def mk_pkg(self, keywords=""): 47 47 return misc.FakePkg("dev-util/diffball-0.7.1", … … 63 63 open(pjoin(repo_base, "profiles", "arch.list"), "w").write( 64 64 "\n".join(kwds.pop("arches", ("x86", "ppc", "amd64")))) 65 65 66 66 open(pjoin(repo_base, "profiles", "use.desc"), "w").write( 67 67 "\n".join(kwds.pop("use_desc", ("foo", "bar")))) 68 68 69 69 open(pjoin(repo_base, "profiles", "use.local.desc"), "w").write( 70 "\n".join("dev-util/diffball:%s - blah" % x for x in 70 "\n".join("dev-util/diffball:%s - blah" % x for x in 71 71 kwds.pop("use_local_desc", ("lfoo", "lbar")))) 72 72 73 73 kwds["repo_bases"] = (repo_base,) 74 return misc.Options(**kwds) 74 return misc.Options(**kwds) 75 75 76 76 … … 220 220 set(os.path.basename(x) for x in src_uri.split()), 221 221 default_chksums) 222 222 223 223 def _get_digests(self, pkg): 224 224 return self.chksums … … 242 242 chk = self.mk_check() 243 243 # ensure it pukes about RESTRICT!=fetch, and no uri 244 244 245 245 r = self.assertIsInstance(self.assertReport(chk, 246 246 self.mk_pkg("foon")), … … 255 255 self.assertNoReport(chk, self.mk_pkg("%s://dar.com/foon" % x), 256 256 msg="testing valid proto %s" % x) 257 257 258 258 # grab a proto, and mangle it. 259 259 bad_proto = list(self.check_kls.valid_protos)[0] 260 260 while bad_proto in self.check_kls.valid_protos: 261 261 bad_proto += "s" 262 262 263 263 r = self.assertIsInstance(self.assertReport(chk, 264 264 self.mk_pkg("%s://foon.com/foon" % bad_proto)), … … 267 267 self.assertEqual(r.filename, 'foon'); 268 268 self.assertEqual(list(r.bad_uri), ['%s://foon.com/foon' % bad_proto]) 269 269 270 270 # check collapsing. 271 271 272 272 r = self.assertIsInstance(self.assertReport(chk, 273 self.mk_pkg("%s://foon.com/foon %s://dar.com/foon" % 273 self.mk_pkg("%s://foon.com/foon %s://dar.com/foon" % 274 274 (bad_proto, bad_proto))), 275 275 metadata_checks.BadProto) -
pkgcore_checks/test/test_stale_unstable.py
rferringb@gmail.com-20080624173954-nab8ouii8xngsv25 rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 24 24 check.start() 25 25 26 old = now - (30 * 24 * 3600) 26 old = now - (30 * 24 * 3600) 27 27 28 28 # a current one … … 39 39 40 40 # ensure it reports only specified arches. 41 report = self.assertReport(check, 41 report = self.assertReport(check, 42 42 mk_pkg("1.0", "~amd64 ~x86 ~asdfasdfasdf", old)) 43 43 self.assertEqual(report.keywords, tuple(sorted(["~amd64", "~x86"]))) -
pkgcore_checks/unstable_only.py
rferringb@gmail.com-20070207174621-yb3eqrqc6jtmdgse rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 12 12 13 13 __slots__ = ("category", "package", "version", "arch") 14 14 15 15 threshold = package_feed 16 16 … … 25 25 return "for arch %s, all versions are unstable: [ %s ]" % ( 26 26 self.arch, ', '.join(self.version)) 27 27 28 28 29 29 class UnstableOnlyReport(Template): -
pkgcore_checks/visibility.py
rferringb@gmail.com-20070708170012-mwbfsn3oy4df1i22 rferringb@gmail.com-20080624174036-q45fk4fxguj9kjlv 23 23 self.arch = arch.lstrip("~") 24 24 self.profile = profile 25 25 26 26 @property 27 27 def short_desc(self): … … 36 36 37 37 threshold = base.versioned_feed 38 38 39 39 def __init__(self, pkg, attr, nonexistant_atoms): 40 40 base.Result.__init__(self) … … 42 42 self.attr = attr 43 43 self.atoms = tuple(str(x) for x in nonexistant_atoms) 44 44 45 45 @property 46 46 def short_desc(self): 47 47 return "depset %s: nonexistant atoms [ %s ]" % ( 48 48 self.attr, ', '.join(self.atoms)) 49 49 50 50 51 51 class NonsolvableDeps(base.Result): … … 56 56 57 57 threshold = base.versioned_feed 58 58 59 59 def __init__(self, pkg, attr, keyword, profile, horked): 60 60 base.Result.__init__(self) … … 64 64 self.keyword = keyword 65 65 self.potentials = tuple(str(x) for x in stable_unique(horked)) 66 66 67 67 @property 68 68 def short_desc(self):
Note: See TracChangeset
for help on using the changeset viewer.
