From d1e8847f628676ec96cee92da59f1ea365a7a44b Mon Sep 17 00:00:00 2001
From: Maciej Blizinski <maciej@opencsw.org>
Date: Sat, 25 Jun 2011 12:24:31 +0200
Subject: [PATCH] checkpkg: Report if catalog release not in db
Organization: OpenCSW

https://www.opencsw.org/mantis/view.php?id=4795

Improve the error message by providing additional logging: What was the
catalog release requested, and what are the available catalog releases.
---
 gar/v2/lib/python/checkpkg2.py |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/gar/v2/lib/python/checkpkg2.py b/gar/v2/lib/python/checkpkg2.py
index e8a0d71..a72d6fa 100755
--- a/gar/v2/lib/python/checkpkg2.py
+++ b/gar/v2/lib/python/checkpkg2.py
@@ -123,8 +123,17 @@ def main():
   sqo_pkgs = list(models.Srv4FileStats.select(
     sqlobject.IN(models.Srv4FileStats.q.md5_sum, md5_sums)))
   tags_for_all_osrels = []
+  try:
+    sqo_catrel = models.CatalogRelease.selectBy(name=options.catrel).getOne()
+  except sqlobject.main.SQLObjectNotFound, e:
+    logging.fatal("Fetching from the db has failed: catrel=%s",
+                  repr(str(options.catrel)))
+    logging.fatal("Available catalog releases:")
+    sqo_catrels = models.CatalogRelease.select()
+    for sqo_catrel in sqo_catrels:
+      logging.fatal(" - %s", sqo_catrel.name)
+    raise
   sqo_arch = models.Architecture.selectBy(name=options.arch).getOne()
-  sqo_catrel = models.CatalogRelease.selectBy(name=options.catrel).getOne()
   for osrel in osrel_list:
     sqo_osrel = models.OsRelease.selectBy(short_name=osrel).getOne()
     dm.VerifyContents(sqo_osrel, sqo_arch)
-- 
1.7.5.4

