[entropy] add Perl5 bump QA tool

This commit is contained in:
Fabio Erculiani 2011-11-25 10:27:11 +01:00
parent ace3df2945
commit 3a510a4143

View File

@ -46,12 +46,24 @@ import sys
import os import os
import entropy.dep import entropy.dep
def check_unwanted_deps(pkg_deps): def write_attention_msg(msg):
sys.stderr.write("\nATTENTION ATTENTION ATTENTION\n")
sys.stderr.write(msg + "\n")
sys.stderr.write("ATTENTION ATTENTION ATTENTION\n\n")
def write_warning_msg(msg):
sys.stderr.write("\nWARNING WARNING WARNING\n")
sys.stderr.write(msg + "\n")
sys.stderr.write("\nWARNING WARNING WARNING\n")
def check_unwanted_deps():
""" """
Check against forbidden dependencies, those we consider meta packages, Check against forbidden dependencies, those we consider meta packages,
placeholders just to keep Gentoo compatibility, which, if listed as dep in, placeholders just to keep Gentoo compatibility, which, if listed as dep in,
would cause the whole world to be pulled in. would cause the whole world to be pulled in.
""" """
pkg_deps = os.getenv("PKG_DEPS", "")
pkg_deps = pkg_deps.split()
if not pkg_deps: if not pkg_deps:
return 0 return 0
@ -69,44 +81,66 @@ def check_unwanted_deps(pkg_deps):
not x.startswith("!")) not x.startswith("!"))
for unwanted_dep in unwanted_deps: for unwanted_dep in unwanted_deps:
if unwanted_dep in pkg_deps_map: if unwanted_dep in pkg_deps_map:
sys.stderr.write("\nATTENTION ATTENTION ATTENTION\n") write_attention_msg(
sys.stderr.write("%s contains forbidden dependency against %s\n" % ( "%s contains forbidden dependency against %s" % (
pkg_atom, pkg_deps_map[unwanted_dep])) pkg_atom, pkg_deps_map[unwanted_dep]))
sys.stderr.write("ATTENTION ATTENTION ATTENTION\n\n")
func_rc = 2 func_rc = 2
for warning_dep in warning_deps: for warning_dep in warning_deps:
if warning_dep in pkg_deps_map: if warning_dep in pkg_deps_map:
sys.stderr.write("\nATTENTION ATTENTION ATTENTION\n") write_attention_msg(
sys.stderr.write("%s contains a weirdo dependency against %s\n" % ( "%s contains a weirdo dependency against %s" % (
pkg_atom, pkg_deps_map[warning_dep])) pkg_atom, pkg_deps_map[warning_dep]))
sys.stderr.write("ATTENTION ATTENTION ATTENTION\n\n")
if func_rc == 0: if func_rc == 0:
func_rc = 1 func_rc = 1
if pkg_keywords is not None: if pkg_keywords is not None:
keywords = pkg_keywords.split() keywords = pkg_keywords.split()
if not keywords or ("**" in keywords and len(keywords) == 1): if not keywords or ("**" in keywords and len(keywords) == 1):
sys.stderr.write("\nATTENTION ATTENTION ATTENTION\n") write_attention_msg("%s is masked by default, keywords: %s" % (
sys.stderr.write("%s is masked by default, keywords: %s\n" % (
pkg_atom, pkg_keywords)) pkg_atom, pkg_keywords))
sys.stderr.write("ATTENTION ATTENTION ATTENTION\n\n")
if func_rc == 0: if func_rc == 0:
func_rc = 1 func_rc = 1
return func_rc return func_rc
def warn_perl5_bump():
"""
Warn in case of bumping dev-lang/perl. Developer should not
forget about running perl-cleaner.
"""
pkg_key = "%s/%s" % (os.getenv("PKG_CATEGORY", ""),
os.getenv("PKG_NAME", ""))
pkg_version = os.getenv("PKG_VERSION", "")
if pkg_key == "dev-lang/perl" and pkg_version.startswith("5"):
perl_dir = "/usr/lib/perl5/vendor_perl"
try:
perl_versions = os.listdir(perl_dir)
except (OSError, IOError):
perl_versions = []
if len(perl_versions) > 1:
write_warning_msg(
"Adding dev-lang/perl but you forgot to run perl-cleaner?\n"
"These are the versions detected in %s:\n"
"%s" % (perl_dir, ", ".join(perl_versions)))
return 1
return 0
if __name__ == "__main__": if __name__ == "__main__":
pkg_deps = os.getenv("PKG_DEPS")
if pkg_deps is None:
return 0
pkg_deps = pkg_deps.split()
exit_st = 0 exit_st = 0
rc = check_unwanted_deps(pkg_deps) rc = check_unwanted_deps()
if rc != 0: if rc != 0:
exit_st = rc exit_st = rc
rc = warn_perl5_bump()
if rc != 0 and rc > exit_st:
exit_st = rc
# more tests here # more tests here
raise SystemExit(exit_st) raise SystemExit(exit_st)