summaryrefslogtreecommitdiffstats
path: root/cron-jobs/check_archlinux
diff options
context:
space:
mode:
authorRémy Oudompheng <remy@archlinux.org>2011-11-05 19:18:00 +0100
committerPierre Schmitz <pierre@archlinux.de>2011-11-05 19:24:46 +0100
commite2efbc58d64c6202fcad66ebefd5dcdcb28f985a (patch)
tree4d2753525634de6b94e61489e00841672b50cea2 /cron-jobs/check_archlinux
parentef69c002a69e5d7983554b68d41f26e06ad8fb7c (diff)
downloaddbscripts-e2efbc58d64c6202fcad66ebefd5dcdcb28f985a.tar.gz
dbscripts-e2efbc58d64c6202fcad66ebefd5dcdcb28f985a.tar.xz
Move global code under a if __name__ == '__main__' block.
This allows running python2 -m doctest on the script. Signed-off-by: Rémy Oudompheng <remy@archlinux.org>
Diffstat (limited to 'cron-jobs/check_archlinux')
-rwxr-xr-xcron-jobs/check_archlinux/check_packages.py241
1 files changed, 121 insertions, 120 deletions
diff --git a/cron-jobs/check_archlinux/check_packages.py b/cron-jobs/check_archlinux/check_packages.py
index 06589ca..d233bf6 100755
--- a/cron-jobs/check_archlinux/check_packages.py
+++ b/cron-jobs/check_archlinux/check_packages.py
@@ -377,131 +377,132 @@ def print_usage():
print " ./check_packages.py --abs-tree=/var/abs --repos=community --arch=i686"
print ""
-## Default path to the abs root directory
-absroots = ["/var/abs"]
-## Default list of repos to check
-repos = ['core', 'extra']
-## Default arch
-arch = "i686"
-## Default repodir
-repodir = "/srv/ftp"
-
-try:
- opts, args = getopt.getopt(sys.argv[1:], "", ["abs-tree=", "repos=",
- "arch=", "repo-dir="])
-except getopt.GetoptError:
- print_usage()
- sys.exit()
-if opts != []:
- for o, a in opts:
- if o in ("--abs-tree"):
- absroots = a.split(',')
- elif o in ("--repos"):
- repos = a.split(",")
- elif o in ("--arch"):
- arch = a
- elif o in ("--repo-dir"):
- repodir = a
- else:
- print_usage()
- sys.exit()
- if args != []:
- print_usage()
+if __name__ == "__main__":
+ ## Default path to the abs root directory
+ absroots = ["/var/abs"]
+ ## Default list of repos to check
+ repos = ['core', 'extra']
+ ## Default arch
+ arch = "i686"
+ ## Default repodir
+ repodir = "/srv/ftp"
+
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], "", ["abs-tree=", "repos=",
+ "arch=", "repo-dir="])
+ except getopt.GetoptError:
+ print_usage()
+ sys.exit()
+ if opts != []:
+ for o, a in opts:
+ if o in ("--abs-tree"):
+ absroots = a.split(',')
+ elif o in ("--repos"):
+ repos = a.split(",")
+ elif o in ("--arch"):
+ arch = a
+ elif o in ("--repo-dir"):
+ repodir = a
+ else:
+ print_usage()
+ sys.exit()
+ if args != []:
+ print_usage()
+ sys.exit()
+
+ for absroot in absroots:
+ if not os.path.isdir(absroot):
+ print "Error : the abs tree " + absroot + " does not exist"
sys.exit()
+ for repo in repos:
+ repopath = absroot + "/" + repo
+ if not os.path.isdir(repopath):
+ print("Warning : the repository " + repo + " does not exist in " + absroot)
-for absroot in absroots:
- if not os.path.isdir(absroot):
- print "Error : the abs tree " + absroot + " does not exist"
+ if not os.path.isdir(repodir):
+ print "Error: the repository directory %s does not exist" % repodir
sys.exit()
for repo in repos:
- repopath = absroot + "/" + repo
- if not os.path.isdir(repopath):
- print("Warning : the repository " + repo + " does not exist in " + absroot)
-
-if not os.path.isdir(repodir):
- print "Error: the repository directory %s does not exist" % repodir
- sys.exit()
-for repo in repos:
- path = os.path.join(repodir,repo,'os',arch,repo + DBEXT)
- if not os.path.isfile(path):
- print "Error : repo DB %s : File not found" % path
- sys.exit()
- if not tarfile.is_tarfile(path):
- print "Error : Cant open repo DB %s, not a valid tar file" % path
- sys.exit()
-# repos which need to be loaded
-loadrepos = set([])
-for repo in repos:
- loadrepos = loadrepos | set(get_repo_hierarchy(repo))
+ path = os.path.join(repodir,repo,'os',arch,repo + DBEXT)
+ if not os.path.isfile(path):
+ print "Error : repo DB %s : File not found" % path
+ sys.exit()
+ if not tarfile.is_tarfile(path):
+ print "Error : Cant open repo DB %s, not a valid tar file" % path
+ sys.exit()
+ # repos which need to be loaded
+ loadrepos = set([])
+ for repo in repos:
+ loadrepos = loadrepos | set(get_repo_hierarchy(repo))
-print_heading("Integrity Check " + arch + " of " + ",".join(repos))
-print("\nPerforming integrity checks...")
+ print_heading("Integrity Check " + arch + " of " + ",".join(repos))
+ print("\nPerforming integrity checks...")
-print("==> parsing pkgbuilds")
-parse_pkgbuilds(loadrepos,arch)
+ print("==> parsing pkgbuilds")
+ parse_pkgbuilds(loadrepos,arch)
-# fill provisions
-for name,pkg in packages.iteritems():
- for prov in pkg.provides:
- provname=prov.split("=")[0]
- if provname not in provisions:
- provisions[provname] = []
- provisions[provname].append(pkg)
-
-# fill repopkgs
-for name,pkg in packages.iteritems():
- if pkg.repo in repos:
- repopkgs[name] = pkg
-
-print("==> parsing db files")
-dbpkgs = parse_dbs(repos,arch)
-
-print("==> checking mismatches")
-for name,pkg in repopkgs.iteritems():
- pkgdirname = pkg.path.split("/")[-1]
- if name != pkgdirname and pkg.base != pkgdirname:
- mismatches.append(name + " vs. " + pkg.path)
-
-print("==> checking archs")
-for name,pkg in repopkgs.iteritems():
- archs = verify_archs(name,pkg.repo,pkg.archs)
- invalid_archs.extend(archs)
-
-deph,makedeph = [],[]
-
-print("==> checking dependencies")
-for name,pkg in repopkgs.iteritems():
- (deps,missdeps,hierarchy) = verify_deps(name,pkg.repo,pkg.deps)
- pkgdeps[pkg] = deps
- missing_deps.extend(missdeps)
- deph.extend(hierarchy)
-
-print("==> checking makedepends")
-for name,pkg in repopkgs.iteritems():
- (makedeps,missdeps,hierarchy) = verify_deps(name,pkg.repo,pkg.makedeps)
- makepkgdeps[pkg] = makedeps
- missing_makedeps.extend(missdeps)
- makedeph.extend(hierarchy)
-
-print("==> checking hierarchy")
-dep_hierarchy = check_hierarchy(deph)
-makedep_hierarchy = check_hierarchy(makedeph)
-
-print("==> checking for circular dependencies")
-# make sure pkgdeps is filled for every package
-for name,pkg in packages.iteritems():
- if pkg not in pkgdeps:
- (deps,missdeps,_) = verify_deps(name,pkg.repo,pkg.deps)
+ # fill provisions
+ for name,pkg in packages.iteritems():
+ for prov in pkg.provides:
+ provname=prov.split("=")[0]
+ if provname not in provisions:
+ provisions[provname] = []
+ provisions[provname].append(pkg)
+
+ # fill repopkgs
+ for name,pkg in packages.iteritems():
+ if pkg.repo in repos:
+ repopkgs[name] = pkg
+
+ print("==> parsing db files")
+ dbpkgs = parse_dbs(repos,arch)
+
+ print("==> checking mismatches")
+ for name,pkg in repopkgs.iteritems():
+ pkgdirname = pkg.path.split("/")[-1]
+ if name != pkgdirname and pkg.base != pkgdirname:
+ mismatches.append(name + " vs. " + pkg.path)
+
+ print("==> checking archs")
+ for name,pkg in repopkgs.iteritems():
+ archs = verify_archs(name,pkg.repo,pkg.archs)
+ invalid_archs.extend(archs)
+
+ deph,makedeph = [],[]
+
+ print("==> checking dependencies")
+ for name,pkg in repopkgs.iteritems():
+ (deps,missdeps,hierarchy) = verify_deps(name,pkg.repo,pkg.deps)
pkgdeps[pkg] = deps
-find_scc(repopkgs.values())
-
-print("==> checking for differences between db files and pkgbuilds")
-for repo in repos:
- for pkg in dbpkgs[repo]:
- if not (pkg in repopkgs and repopkgs[pkg].repo == repo):
- dbonly.append("%s/%s" % (repo,pkg))
-for name,pkg in repopkgs.iteritems():
- if not name in dbpkgs[pkg.repo]:
- absonly.append("%s/%s" % (pkg.repo,name))
-
-print_results()
+ missing_deps.extend(missdeps)
+ deph.extend(hierarchy)
+
+ print("==> checking makedepends")
+ for name,pkg in repopkgs.iteritems():
+ (makedeps,missdeps,hierarchy) = verify_deps(name,pkg.repo,pkg.makedeps)
+ makepkgdeps[pkg] = makedeps
+ missing_makedeps.extend(missdeps)
+ makedeph.extend(hierarchy)
+
+ print("==> checking hierarchy")
+ dep_hierarchy = check_hierarchy(deph)
+ makedep_hierarchy = check_hierarchy(makedeph)
+
+ print("==> checking for circular dependencies")
+ # make sure pkgdeps is filled for every package
+ for name,pkg in packages.iteritems():
+ if pkg not in pkgdeps:
+ (deps,missdeps,_) = verify_deps(name,pkg.repo,pkg.deps)
+ pkgdeps[pkg] = deps
+ find_scc(repopkgs.values())
+
+ print("==> checking for differences between db files and pkgbuilds")
+ for repo in repos:
+ for pkg in dbpkgs[repo]:
+ if not (pkg in repopkgs and repopkgs[pkg].repo == repo):
+ dbonly.append("%s/%s" % (repo,pkg))
+ for name,pkg in repopkgs.iteritems():
+ if not name in dbpkgs[pkg.repo]:
+ absonly.append("%s/%s" % (pkg.repo,name))
+
+ print_results()