[csw-devel] SF.net SVN: gar:[7915] csw/mgar/gar/v2/bin/checkpkg.d
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Fri Jan 8 12:02:14 CET 2010
Revision: 7915
http://gar.svn.sourceforge.net/gar/?rev=7915&view=rev
Author: wahwah
Date: 2010-01-08 11:02:13 +0000 (Fri, 08 Jan 2010)
Log Message:
-----------
mGAR v2: Rewrote part of output formatting to use a template
Modified Paths:
--------------
csw/mgar/gar/v2/bin/checkpkg.d/checkpkg.py
csw/mgar/gar/v2/bin/checkpkg.d/checkpkg_test.py
Modified: csw/mgar/gar/v2/bin/checkpkg.d/checkpkg.py
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg.d/checkpkg.py 2010-01-08 00:43:06 UTC (rev 7914)
+++ csw/mgar/gar/v2/bin/checkpkg.d/checkpkg.py 2010-01-08 11:02:13 UTC (rev 7915)
@@ -13,6 +13,7 @@
import sqlite3
import subprocess
import StringIO
+from Cheetah import Template
SYSTEM_PKGMAP = "/var/sadm/install/contents"
WS_RE = re.compile(r"\s+")
@@ -28,6 +29,31 @@
# Solaris 8 on i386. It's okay if it's missing.
ALLOWED_ORPHAN_SONAMES = set([u"libm.so.2"])
+REPORT_TMPL = u"""$pkgname:
+#if $missing_deps
+SUGGESTION: you may want to add some or all of the following as depends:
+ (Feel free to ignore SUNW or SPRO packages)
+#for $pkg in $sorted($missing_deps)
+> $pkg
+#end for
+#end if
+#if $surplus_deps
+The following packages might be unnecessary dependencies:
+#for $pkg in $sorted($surplus_deps)
+? $pkg
+#end for
+#end if
+#if $orphan_sonames
+The following sonames don't belong to any package:
+#for $soname in $sorted($orphan_sonames)
+! $soname
+#end for
+#end if
+#if not $missing_deps and not $surplus_deps and not $orphan_sonames
++ Dependencies of $pkgname look good.
+#end if
+"""
+
class Error(Exception):
pass
@@ -115,29 +141,14 @@
def FormatDepsReport(self, missing_deps, surplus_deps, orphan_sonames):
"""A intermediate version in which StringIO is used."""
- s = StringIO.StringIO()
- print >>s, "%s:" % self.pkgname
- msg_printed = False
- if missing_deps:
- print >>s, "SUGGESTION: you may want to add some or all of the following as depends:"
- print >>s, " (Feel free to ignore SUNW or SPRO packages)"
- for dep_pkgname in sorted(missing_deps):
- print >>s, ">", dep_pkgname
- msg_printed = True
- if surplus_deps:
- print >>s, "The following packages might be unnecessary dependencies:"
- for dep_pkgname in surplus_deps:
- print >>s, "? ", dep_pkgname
- msg_printed = True
- if orphan_sonames:
- print >>s, "The following sonames don't belong to any package:"
- for soname in sorted(orphan_sonames):
- print >>s, "! ", soname
- msg_printed = True
- if not msg_printed:
- print >>s, "+ Dependencies of %s look good." % self.pkgname
- s.seek(0)
- return s.read()
+ namespace = {
+ "pkgname": self.pkgname,
+ "missing_deps": missing_deps,
+ "surplus_deps": surplus_deps,
+ "orphan_sonames": orphan_sonames,
+ }
+ t = Template.Template(REPORT_TMPL, searchList=[namespace])
+ return unicode(t)
class SystemPkgmap(object):
Modified: csw/mgar/gar/v2/bin/checkpkg.d/checkpkg_test.py
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg.d/checkpkg_test.py 2010-01-08 00:43:06 UTC (rev 7914)
+++ csw/mgar/gar/v2/bin/checkpkg.d/checkpkg_test.py 2010-01-08 11:02:13 UTC (rev 7915)
@@ -441,10 +441,10 @@
difference = "\n".join(difflib.context_diff(text2.splitlines(), text1.splitlines()))
self.assertEqual(text1, text2, difference)
- def test_1(self):
+ def testAll(self):
missing_deps = set([u'SUNWgss', u'*SUNWlxsl'])
surplus_deps = set(['CSWsudo', 'CSWlibxslt'])
- orphan_sonames = set([])
+ orphan_sonames = set([u'libm.so.2'])
testdata = (missing_deps, surplus_deps, orphan_sonames)
checker = checkpkg.CheckpkgBase("/tmp/nonexistent", "CSWfoo")
expected = u"""CSWfoo:
@@ -453,12 +453,26 @@
> *SUNWlxsl
> SUNWgss
The following packages might be unnecessary dependencies:
-? CSWsudo
-? CSWlibxslt
+? CSWlibxslt
+? CSWsudo
+The following sonames don't belong to any package:
+! libm.so.2
"""
result = checker.FormatDepsReport(*testdata)
self.AssertTextEqual(result, expected)
+ def testNone(self):
+ missing_deps = set([])
+ surplus_deps = set([])
+ orphan_sonames = set([])
+ testdata = (missing_deps, surplus_deps, orphan_sonames)
+ checker = checkpkg.CheckpkgBase("/tmp/nonexistent", "CSWfoo")
+ expected = u"""CSWfoo:
++ Dependencies of CSWfoo look good.
+"""
+ result = checker.FormatDepsReport(*testdata)
+ self.AssertTextEqual(result, expected)
+
if __name__ == '__main__':
unittest.main()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the devel
mailing list