#!/usr/bin/python -tt # -*- coding: utf-8 -*- # debugrepo-check.py -- basic checks for -debuginfo rpms in repositories # Copyright (C) 2007-2009 Ville Skyttä # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import sys from yum import YumBase from yum.misc import getCacheDir def usage(exit): usage = "Usage: %s ..." % sys.argv[0] if exit != 0: sys.stderr.write(usage + "\n") else: print usage sys.exit(exit) if "-h" in sys.argv or "--help" in sys.argv: usage(0) elif len(sys.argv) < 2: usage(1) do_repos = sys.argv[1:] print print "Checking debug packages in repos %s" % ", ".join(do_repos) yum = YumBase() yum.doConfigSetup(init_plugins = False) for repo in yum.repos.repos.values(): if repo.id in do_repos: repo.enable() else: repo.disable() yum.repos.setCacheDir(getCacheDir()) yum.doRepoSetup() yum.doSackSetup() yum.doSackFilelistPopulate() empties = [] nodbgs = [] nosrcs = [] oks = [] for po in yum.pkgSack.returnNewestByNameArch(patterns=("*-debuginfo",)): filenames = po.returnFileEntries() if filenames: src = False dbg = False for fname in filenames: # Ignore stuff below .../.build-id, they're typically just symlinks # to other actual files in the package (metadata doesn't contain # information whether a file entry is a symlink) if fname.find("/.build-id/") != -1: continue if fname.endswith(".debug"): dbg = True else: src = True if dbg and src: oks.append(po) break if dbg and not src: nosrcs.append(po) elif not dbg: nodbgs.append(po) else: empties.append(po) print if empties: empties.sort() print "Empty debuginfo packages:" print " " + "\n ".join(map(str, empties)) print if nodbgs: nodbgs.sort() print "Debuginfo packages without .debug files:" print " " + "\n ".join(map(str, nodbgs)) print if nosrcs: nosrcs.sort() print "Debuginfo packages without sources:" print " " + "\n ".join(map(str, nosrcs)) print total = len(empties) + len(oks) + len(nosrcs) + len(nodbgs) print "Results:" print " %d debuginfo packages, %d empty, %d with no sources." % \ (total, len(empties), len(nosrcs)) print