diff --git a/tests/z_centos_pkg/centos_rpm_checker.py b/tests/z_centos_pkg/centos_rpm_checker.py new file mode 100755 index 0000000..820dc85 --- /dev/null +++ b/tests/z_centos_pkg/centos_rpm_checker.py @@ -0,0 +1,49 @@ +#!/usr/bin/python +# Author: Athmane Madjoudj +# A script that search for CentOS branding issues in installed rpm + +import rpm +import sys +import re + +def is_valide_changelog_entry(entry): + regex = re.compile(r"\w+\ ?\w*\ ?<\b[\w\.-]+@[\w\.-]+\.\w{2,4}\b>\ ?-?\ ?[0-9_\.]+-[a-zA-Z0-9_\.]+") + if regex.match(entry) is None: + return False + else: + return True + +def main(): + ts=rpm.ts() + mi=ts.dbMatch() + # Comment the following line to check all rpms + mi.pattern("release", rpm.RPMMIRE_GLOB, "*centos*") + ret=True + print "Searching for CentOS branding issues in installed rpm..." + for hdr in mi: + if hdr['buildhost'][-11:] != '.centos.org': + print " Build host is not centos.org machine in: %s" % hdr['name'] + ret=False + if hdr['vendor'] != 'CentOS': + print " Vendor is not CentOS in: %s" % hdr['name'] + ret=False + if hdr['packager'] != 'CentOS BuildSystem ': + print " Packager is not CentOS BuildSystem in: %s" % hdr['name'] + ret=False + try: + changelog = hdr['changelogname'][0] + if not is_valide_changelog_entry(changelog): + print " Bad changelog entry in: %s" % hdr['name'] + ret=False + except Exception, e: + print " Errors found when reading changelog entry of: %s" % hdr['name'] + ret=False + return ret + +if __name__ == "__main__": + if main(): + print "All tests PASSED" + sys.exit(0) + else: + print "Some tests FAILED" + sys.exit(1)