[csw-devel] SF.net SVN: gar:[8885] csw/mgar/gar/v2
wahwah at users.sourceforge.net
wahwah at users.sourceforge.net
Sun Feb 28 10:54:44 CET 2010
Revision: 8885
http://gar.svn.sourceforge.net/gar/?rev=8885&view=rev
Author: wahwah
Date: 2010-02-28 09:54:43 +0000 (Sun, 28 Feb 2010)
Log Message:
-----------
mGAR v2: checkpkg, ports a number of tests from Korn shell to Python.
Modified Paths:
--------------
csw/mgar/gar/v2/bin/analyze_module_results.py
csw/mgar/gar/v2/bin/checkpkg
csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-basic.py
csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-libs.py
csw/mgar/gar/v2/lib/python/checkpkg.py
csw/mgar/gar/v2/lib/python/checkpkg_test.py
csw/mgar/gar/v2/lib/python/opencsw.py
csw/mgar/gar/v2/lib/python/opencsw_test.py
csw/mgar/gar/v2/lib/python/package_checks.py
csw/mgar/gar/v2/lib/python/package_checks_test.py
Modified: csw/mgar/gar/v2/bin/analyze_module_results.py
===================================================================
--- csw/mgar/gar/v2/bin/analyze_module_results.py 2010-02-28 09:53:07 UTC (rev 8884)
+++ csw/mgar/gar/v2/bin/analyze_module_results.py 2010-02-28 09:54:43 UTC (rev 8885)
@@ -34,18 +34,21 @@
pkgname, tag_name, tag_info = checkpkg.ParseTagLine(line)
error_tags.append(checkpkg.CheckpkgTag(pkgname, tag_name, tag_info))
overrides = reduce(lambda x, y: x + y, overrides_list)
- tags_after_overrides = checkpkg.ApplyOverrides(error_tags, overrides)
+ (tags_after_overrides,
+ unapplied_overrides) = checkpkg.ApplyOverrides(error_tags, overrides)
exit_code = bool(tags_after_overrides)
if tags_after_overrides:
print "There were errors reported."
print "If you know they are false positives, you can override them:"
for tag in tags_after_overrides:
- if tag.tag_info:
- tag_postfix = "|%s" % tag.tag_info.replace(" ", "|")
- else:
- tag_postfix = ""
- print ("CHECKPKG_OVERRIDES_%s += %s%s"
- % (tag.pkgname, tag.tag_name, tag_postfix))
+ print tag.ToGarSyntax()
+ if unapplied_overrides:
+ print "WARNING: Some overrides did not match any errors."
+ print " They can be removed, as they don't take any effect anyway."
+ print " If you're getting errors at the same time, maybe you didn't"
+ print " specify the overrides correctly."
+ for override in unapplied_overrides:
+ print "* %s" % override
sys.exit(exit_code)
Modified: csw/mgar/gar/v2/bin/checkpkg
===================================================================
--- csw/mgar/gar/v2/bin/checkpkg 2010-02-28 09:53:07 UTC (rev 8884)
+++ csw/mgar/gar/v2/bin/checkpkg 2010-02-28 09:54:43 UTC (rev 8885)
@@ -91,8 +91,10 @@
print ERROR: $* >/dev/fd/2
cleanup
cleanupset
- print "To run checkpkg in the debug mode, add the '-d' flag:"
+ print "To run checkpkg in the debug mode, add the '-d' flag, for example:"
print "${selfpath} -d ${selfargs}"
+ print "After you modify any overrides, you need to do gmake remerge repackage"
+ print "or gmake platforms-remerge platforms-repackage."
exit 1
}
@@ -216,109 +218,12 @@
basedir=`sed -n 's/^BASEDIR=//p' $TMPFILE`
pkgarch=`sed -n 's/^ARCH=//p' $TMPFILE|head -1`
-case `basename $f` in
- ${software}-${version}-*)
- # file name looks okay
- ;;
- ${software}-*)
- print ERROR: filename missing full version field $version
- rm -rf $EXTRACTDIR $TMPARCHIVE
- exit 1
- ;;
- *)
- print ERROR: filename should start with $software-$version-
- rm -rf $EXTRACTDIR $TMPARCHIVE
- exit 1
-esac
-
-
-
-if [ "$maintname" = "" ] ; then
- # the old format, in the DESC field
- maintname=`sed -n 's/^DESC=.*for CSW by //p' $TMPFILE`
-
- # Since the DESC field has been coopted, take
- # description from second half of NAME field now.
- desc=`sed -n 's/^NAME=[^ -]* - //p' $TMPFILE`
-else
- if [ "$desc" = "" ] ; then
- desc=`sed -n 's/^NAME=[^ -]* - //p' $TMPFILE`
- fi
-fi
-
rm $TMPFILE
# strip out '' chars, because it interferes with mysql
desc=`print $desc | sed "s/'//g"`
-print Info for pkg $pkgname
-
-print software= "'$software'"
-print arch= "'$pkgarch'"
-print desc="'$desc'"
-print pkgname="'$pkgname'"
-print version="'$version'"
-print maintainer name="'$maintname'"
-print maint email="'$email'"
-print hotline="'$hotline'"
-if [ "$basedir" != "" ] ; then
- print basedir="'$basedir'"
-fi
-
-if [[ ${#software} -gt ${NAME_MAX_LENGTH} ]] ; then
- errmsg "$f: software name longer than ${NAME_MAX_LENGTH} chars"
-fi
-if [[ ${#pkgname} -gt ${NAME_MAX_LENGTH} ]] ; then
- errmsg "$f: pkg name longer than ${NAME_MAX_LENGTH} chars"
-fi
-
-if [ "$software" = "" ] ; then errmsg $f: software field not set properly in NAME ; fi
-if [ "$pkgname" = "" ] ; then errmsg $f: pkgname field blank ; fi
-if [ "$desc" = "" ] ; then errmsg $f: no description in either NAME or DESC field ; fi
-if [ ${#desc} -gt 100 ] ; then errmsg $f: description greater than 100 chars ; fi
-if [ "$version" = "" ] ; then errmsg $f: VERSION field blank ; fi
-if [ "$maintname" = "" ] ; then errmsg $f: maintainer name not detected. Fill out VENDOR field properly ; fi
-if [ "$email" = "" ] ; then errmsg $f: EMAIL field blank ; fi
-if [ "$hotline" = "" ] ; then errmsg $f: HOTLINE field blank ; fi
-
-
-case $version in
- *-*)
- errmsg "VERSION field not allowed to have \"-\" in it"
- ;;
- *,REV=20[01][0-9].[0-9][0-9].[0-9][0-9]*)
- :
- ;;
- *)
- print ERROR: no REV=YYYY.MM.DD field in VERSION
- exit 1
- ;;
-esac
-
-case $pkgarch in
- sparc|i386|all)
- ;;
- sparc.*|i386.*)
- ;;
-
- *)
- print ERROR: non-standard ARCH def in package: $pkgarch
- rm -rf $EXTRACTDIR $TMPARCHIVE
- exit 1
-esac
-
-case $f in
- *${pkgarch}*)
- print "f: $f, pkgarch: $pkgarch"
- ;;
- *)
- print "The file name is '$f'."
- print "The pkgarch is '$pkgarch'."
- errmsg "ERROR: package file name and pkgarch don't match."
- ;;
-esac
-
goodarch=yes
case $f in
*${LOCAL_ARCH}*)
@@ -575,7 +480,8 @@
plugin_name="`echo ${plugin} | sed -e 's+.*/checkpkg-++' | sed -e 's+\.py$++'`"
error_tag_file="tags.${plugin_name}"
printf "${BOLD}${module_name_format}${COLOR_RESET} running..." "${plugin_name}"
- debugmsg "Executing: ${plugin} $extra_options -b \"${checkpkg_stats_basedir}\" -o \"${EXTRACTDIR}/${error_tag_file}\" ${md5sums}"
+ debugmsg "Executing: ${plugin} $extra_options -b \"${checkpkg_stats_basedir}\"" \
+ "-o \"${EXTRACTDIR}/${error_tag_file}\" `echo ${md5sums}`"
${plugin} \
$extra_options \
-b "${checkpkg_stats_basedir}" \
@@ -597,7 +503,9 @@
fi
for log_file in ${log_files}; do
- if [[ `gwc -c "${log_file}" | awk '{print $1}'` -gt 1 ]]; then
+ log_len=`gsed -e 's/\s\+//g' "${log_file}" | gtr -s '\n' | gwc -c | awk '{print $1}'`
+ if [[ "${log_len}" -gt 1 ]]; then
+ print "printing ${log_file}..."
debugmsg ">> LOG START: ${log_file}"
cat "${log_file}"
debugmsg "<< LOG END: ${log_file}"
Modified: csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-basic.py
===================================================================
--- csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-basic.py 2010-02-28 09:53:07 UTC (rev 8884)
+++ csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-basic.py 2010-02-28 09:54:43 UTC (rev 8885)
@@ -31,6 +31,7 @@
# Registering functions defined above.
check_manager.RegisterIndividualCheck(package_checks.CatalognameLowercase)
check_manager.RegisterIndividualCheck(package_checks.FileNameSanity)
+ check_manager.RegisterIndividualCheck(package_checks.PkginfoSanity)
# Running the checks, reporting and exiting.
exit_code, screen_report, tags_report = check_manager.Run()
f = open(options.output, "w")
Modified: csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-libs.py
===================================================================
--- csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-libs.py 2010-02-28 09:53:07 UTC (rev 8884)
+++ csw/mgar/gar/v2/lib/checkpkg.d/checkpkg-libs.py 2010-02-28 09:54:43 UTC (rev 8885)
@@ -124,7 +124,7 @@
for checker in pkgs_data:
pkgname = checker["basic_stats"]["pkgname"]
declared_dependencies = checker["depends"]
- if debug:
+ if debug and False:
sanitized_pkgname = pkgname.replace("-", "_")
data_file_name = "/var/tmp/checkpkg_test_data_%s.py" % sanitized_pkgname
logging.warn("Saving test data to %s." % repr(data_file_name))
Modified: csw/mgar/gar/v2/lib/python/checkpkg.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg.py 2010-02-28 09:53:07 UTC (rev 8884)
+++ csw/mgar/gar/v2/lib/python/checkpkg.py 2010-02-28 09:54:43 UTC (rev 8885)
@@ -15,6 +15,7 @@
import socket
import sqlite3
import subprocess
+import textwrap
import yaml
from Cheetah import Template
import opencsw
@@ -92,6 +93,9 @@
# Tags reported by $name module
#for $pkgname in $errors
#for $tag in $errors[$pkgname]
+#if $tag.msg
+$textwrap.fill($tag.msg, 70, initial_indent="# ", subsequent_indent="# ")
+#end if
$pkgname: ${tag.tag_name}#if $tag.tag_info# $tag.tag_info#end if#
#end for
#end for
@@ -146,6 +150,18 @@
return unicode(t)
+def ExtractDescription(pkginfo):
+ desc_re = re.compile(r"^[\w_]+ - (.*)$")
+ m = re.match(desc_re, pkginfo["NAME"])
+ return m.group(1) if m else None
+
+
+def ExtractMaintainerName(pkginfo):
+ maint_re = re.compile("^.*for CSW by (.*)$")
+ m = re.match(maint_re, pkginfo["VENDOR"])
+ return m.group(1) if m else None
+
+
class SystemPkgmap(object):
"""A class to hold and manipulate the /var/sadm/install/contents file.
@@ -666,10 +682,28 @@
self.msg = msg
def __repr__(self):
- return (u"CheckpkgTag(%s, %s, %s, ...)"
- % (repr(self.pkgname), repr(self.tag_name), repr(self.tag_info)))
+ return (u"CheckpkgTag(%s, %s, %s, %s)"
+ % (repr(self.pkgname),
+ repr(self.tag_name),
+ repr(self.tag_info),
+ repr(self.msg)))
+ def ToGarSyntax(self):
+ msg_lines = []
+ if self.msg:
+ msg_lines.extend(textwrap(self.msg, 70,
+ initial_indent="# ",
+ subsequent_indent="# "))
+ if self.tag_info:
+ tag_postfix = "|%s" % self.tag_info.replace(" ", "|")
+ else:
+ tag_postfix = ""
+ msg_lines.append(u"CHECKPKG_OVERRIDES_%s += %s%s"
+ % (self.pkgname, self.tag_name, tag_postfix))
+ return "\n".join(msg_lines)
+
+
class CheckpkgManager(object):
"""Takes care of calling checking functions"""
@@ -726,6 +760,7 @@
"name": self.name,
"errors": errors,
"debug": self.debug,
+ "textwrap": textwrap,
}
screen_t = Template.Template(SCREEN_ERROR_REPORT_TMPL, searchList=[namespace])
tags_report_t = Template.Template(TAG_REPORT_TMPL, searchList=[namespace])
@@ -779,7 +814,7 @@
def __repr__(self):
return (u"Override(%s, %s, %s)"
- % (self.pkgname, self.tag_name, self.tag_info))
+ % (repr(self.pkgname), repr(self.tag_name), repr(self.tag_info)))
def DoesApply(self, tag):
"""Figures out if this override applies to the given tag."""
@@ -795,6 +830,7 @@
basket_b["tag_name"] = tag.tag_name
return basket_a == basket_b
+
def ParseOverrideLine(line):
level_1 = line.split(":")
if len(level_1) > 1:
@@ -819,14 +855,18 @@
O(N * M), but N and M are always small.
"""
tags_after_overrides = []
+ applied_overrides = set([])
+ provided_overrides = set(copy.copy(overrides))
for tag in error_tags:
override_applies = False
for override in overrides:
if override.DoesApply(tag):
override_applies = True
+ applied_overrides.add(override)
if not override_applies:
tags_after_overrides.append(tag)
- return tags_after_overrides
+ unapplied_overrides = provided_overrides.difference(applied_overrides)
+ return tags_after_overrides, unapplied_overrides
def GetIsalist():
Modified: csw/mgar/gar/v2/lib/python/checkpkg_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/checkpkg_test.py 2010-02-28 09:53:07 UTC (rev 8884)
+++ csw/mgar/gar/v2/lib/python/checkpkg_test.py 2010-02-28 09:54:43 UTC (rev 8885)
@@ -708,47 +708,47 @@
"""One tag, no overrides."""
tags = [checkpkg.CheckpkgTag("CSWfoo", "foo-tag")]
overrides = []
- self.assertEqual(tags, checkpkg.ApplyOverrides(tags, overrides))
+ self.assertEqual((tags, set([])), checkpkg.ApplyOverrides(tags, overrides))
def test_1b(self):
"""One override, matching by tag name only."""
tags = [checkpkg.CheckpkgTag("CSWfoo", "foo-tag")]
overrides = [checkpkg.Override(None, "foo-tag", None)]
- self.assertEqual([], checkpkg.ApplyOverrides(tags, overrides))
+ self.assertEqual(([], set([])), checkpkg.ApplyOverrides(tags, overrides))
def test_1c(self):
"""One override, matching by tag name only, no pkgname."""
tags = [checkpkg.CheckpkgTag("CSWfoo", "foo-tag")]
overrides = [checkpkg.Override(None, "foo-tag", None)]
- self.assertEqual([], checkpkg.ApplyOverrides(tags, overrides))
+ self.assertEqual(([], set([])), checkpkg.ApplyOverrides(tags, overrides))
def test_2(self):
"""One override, matching by tag name and tag info, no pkgname."""
tags = [checkpkg.CheckpkgTag("CSWfoo", "foo-tag")]
overrides = [checkpkg.Override(None, "foo-tag", None)]
- self.assertEqual([], checkpkg.ApplyOverrides(tags, overrides))
+ self.assertEqual(([], set([])), checkpkg.ApplyOverrides(tags, overrides))
def test_3(self):
"""One override, matching by tag name, mismatching tag info, no pkgname."""
tags = [checkpkg.CheckpkgTag("CSWfoo", "foo-tag", "tag-info-1")]
overrides = [checkpkg.Override(None, "foo-tag", "tag-info-2")]
- self.assertEqual(tags, checkpkg.ApplyOverrides(tags, overrides))
+ self.assertEqual((tags, set(overrides)), checkpkg.ApplyOverrides(tags, overrides))
def test_4(self):
tags = [checkpkg.CheckpkgTag("CSWfoo", "foo-tag", "tag-info-1")]
overrides = [checkpkg.Override(None, "foo-tag", "tag-info-1")]
- self.assertEqual([], checkpkg.ApplyOverrides(tags, overrides))
+ self.assertEqual(([], set([])), checkpkg.ApplyOverrides(tags, overrides))
def test_5(self):
tags = [checkpkg.CheckpkgTag("CSWfoo", "foo-tag", "tag-info-1")]
overrides = [checkpkg.Override("CSWfoo", "foo-tag", "tag-info-1")]
- self.assertEqual([], checkpkg.ApplyOverrides(tags, overrides))
+ self.assertEqual(([], set([])), checkpkg.ApplyOverrides(tags, overrides))
def test_6(self):
"""Pkgname mismatch."""
tags = [checkpkg.CheckpkgTag("CSWfoo", "foo-tag", "tag-info-1")]
overrides = [checkpkg.Override("CSWbar", "foo-tag", "tag-info-1")]
- self.assertEqual(tags, checkpkg.ApplyOverrides(tags, overrides))
+ self.assertEqual((tags, set(overrides)), checkpkg.ApplyOverrides(tags, overrides))
class SystemPkgmapUnitTest(unittest.TestCase):
@@ -826,5 +826,20 @@
parsed = self.pkgstats._ParseLddDashRline(line)
+class ExtractorsUnitTest(unittest.TestCase):
+
+ def testExtractDescription_1(self):
+ data = {"NAME": "nspr_devel - Netscape Portable Runtime header files"}
+ result = "Netscape Portable Runtime header files"
+ self.assertEqual(result, checkpkg.ExtractDescription(data))
+
+ def testExtractMaintainerName(self):
+ data = {"VENDOR": "https://ftp.mozilla.org/pub/mozilla.org/"
+ "nspr/releases/v4.8/src/ packaged for CSW by "
+ "Maciej Blizinski"}
+ result = "Maciej Blizinski"
+ self.assertEqual(result, checkpkg.ExtractMaintainerName(data))
+
+
if __name__ == '__main__':
unittest.main()
Modified: csw/mgar/gar/v2/lib/python/opencsw.py
===================================================================
--- csw/mgar/gar/v2/lib/python/opencsw.py 2010-02-28 09:53:07 UTC (rev 8884)
+++ csw/mgar/gar/v2/lib/python/opencsw.py 2010-02-28 09:54:43 UTC (rev 8885)
@@ -93,15 +93,27 @@
def ParsePackageFileName(p):
+ if p.endswith(".gz"):
+ p = p[:-3]
+ if p.endswith(".pkg"):
+ p = p[:-4]
bits = p.split("-")
catalogname = bits[0]
version, version_info, revision_info = ParseVersionString(bits[1])
+ if len(bits) == 5:
+ osrel, arch, vendortag = bits[2:5]
+ else:
+ arch, vendortag = bits[2:4]
+ osrel = "unspecified"
data = {
'catalogname': catalogname,
'full_version_string': bits[1],
'version': version,
'version_info': version_info,
'revision_info': revision_info,
+ 'osrel': osrel,
+ 'arch': arch,
+ 'vendortag': vendortag,
}
return data
Modified: csw/mgar/gar/v2/lib/python/opencsw_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/opencsw_test.py 2010-02-28 09:53:07 UTC (rev 8884)
+++ csw/mgar/gar/v2/lib/python/opencsw_test.py 2010-02-28 09:54:43 UTC (rev 8885)
@@ -118,18 +118,45 @@
self.assertEqual(pkg_version, compiled["full_version_string"])
+class ParsePackageFileNameTest_2(unittest.TestCase):
+
+ def setUp(self):
+ self.file_name = 'mysql5client-5.0.87,REV=2010.02.28-SunOS5.8-i386-CSW.pkg.gz'
+ self.parsed = opencsw.ParsePackageFileName(self.file_name)
+
+ def testParsePackageFileName_2_1(self):
+ self.assertTrue("arch" in self.parsed)
+ self.assertEqual(self.parsed["arch"], "i386")
+
+ def testParsePackageFileName_2_2(self):
+ self.assertTrue("osrel" in self.parsed)
+ self.assertEqual(self.parsed["osrel"], "SunOS5.8")
+
+ def testParsePackageFileName_2_3(self):
+ self.assertTrue("vendortag" in self.parsed)
+ self.assertEqual(self.parsed["vendortag"], "CSW")
+
+ def testParsePackageFileName_OldFormat(self):
+ """Old srv4 file name."""
+ file_name = "achievo-0.8.4-all-CSW.pkg.gz"
+ parsed = opencsw.ParsePackageFileName(file_name)
+ self.assertEqual("unspecified", parsed["osrel"])
+
+
class UpgradeTypeTest(unittest.TestCase):
def testUpgradeType_1(self):
pkg = opencsw.CatalogBasedOpencswPackage("analog")
pkg.LazyDownloadCatalogData(CATALOG_DATA_1.splitlines())
expected_data = {
- 'catalogname': 'analog',
+ 'version': '5.32',
'full_version_string': '5.32,REV=2003.9.12',
- 'version': '5.32',
- 'version_info': {opencsw.MAJOR_VERSION: '5',
- opencsw.MINOR_VERSION: '32'},
+ 'version_info': {'minor version': '32', 'major version': '5'},
+ 'vendortag': 'CSW',
'revision_info': {'REV': '2003.9.12'},
+ 'arch': 'sparc',
+ 'osrel': 'SunOS5.8',
+ 'catalogname': 'analog'
}
self.assertEqual(expected_data, pkg.GetCatalogPkgData())
Modified: csw/mgar/gar/v2/lib/python/package_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks.py 2010-02-28 09:53:07 UTC (rev 8884)
+++ csw/mgar/gar/v2/lib/python/package_checks.py 2010-02-28 09:54:43 UTC (rev 8885)
@@ -76,6 +76,12 @@
ARCH_RE = re.compile(r"(sparcv(8|9)|i386|amd64)")
+MAX_CATALOGNAME_LENGTH = 20
+MAX_PKGNAME_LENGTH = 20
+MAX_DESCRIPTION_LENGTH = 100
+ARCH_LIST = ["sparc", "i386", "all"]
+VERSION_RE = r".*,REV=(20[01][0-9]\.[0-9][0-9]\.[0-9][0-9]).*"
+
def CatalognameLowercase(pkg_data, debug):
errors = []
# Here's how to report an error:
@@ -93,17 +99,123 @@
def FileNameSanity(pkg_data, debug):
errors = []
- # Here's how to report an error:
basic_stats = pkg_data["basic_stats"]
revision_info = basic_stats["parsed_basename"]["revision_info"]
catalogname = pkg_data["basic_stats"]["catalogname"]
+ pkgname = pkg_data["basic_stats"]["pkgname"]
if "REV" not in revision_info:
errors.append(checkpkg.CheckpkgTag(
- pkg_data["basic_stats"]["pkgname"],
- "rev-tag-missing-in-filename"))
+ pkgname, "rev-tag-missing-in-filename"))
+ if len(catalogname) > MAX_CATALOGNAME_LENGTH:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "catalogname-too-long"))
+ if len(pkgname) > MAX_PKGNAME_LENGTH:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "pkgname-too-long"))
+ if basic_stats["parsed_basename"]["osrel"] == "unspecified":
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "osrel-tag-not-specified"))
return errors
+def PkginfoSanity(pkg_data, debug):
+ """pkginfo sanity checks.
+
+if [ "$maintname" = "" ] ; then
+ # the old format, in the DESC field
+ maintname=`sed -n 's/^DESC=.*for CSW by //p' $TMPFILE`
+
+ # Since the DESC field has been coopted, take
+ # description from second half of NAME field now.
+ desc=`sed -n 's/^NAME=[^ -]* - //p' $TMPFILE`
+else
+ if [ "$desc" = "" ] ; then
+ desc=`sed -n 's/^NAME=[^ -]* - //p' $TMPFILE`
+ fi
+fi
+
+software=`sed -n 's/^NAME=\([^ -]*\) -.*$/\1/p' $TMPFILE`
+version=`sed -n 's/^VERSION=//p' $TMPFILE`
+desc=`sed -n 's/^DESC=//p' $TMPFILE`
+email=`sed -n 's/^EMAIL=//p' $TMPFILE`
+maintname=`sed -n 's/^VENDOR=.*for CSW by //p' $TMPFILE`
+hotline=`sed -n 's/^HOTLINE=//p' $TMPFILE`
+basedir=`sed -n 's/^BASEDIR=//p' $TMPFILE`
+pkgarch=`sed -n 's/^ARCH=//p' $TMPFILE|head -1`
+
+if [ "$software" = "" ] ; then errmsg $f: software field not set properly in NAME ; fi
+if [ "$pkgname" = "" ] ; then errmsg $f: pkgname field blank ; fi
+if [ "$desc" = "" ] ; then errmsg $f: no description in either NAME or DESC field ; fi
+if [ ${#desc} -gt 100 ] ; then errmsg $f: description greater than 100 chars ; fi
+if [ "$version" = "" ] ; then errmsg $f: VERSION field blank ; fi
+if [ "$maintname" = "" ] ; then errmsg $f: maintainer name not detected. Fill out VENDOR field properly ; fi
+if [ "$email" = "" ] ; then errmsg $f: EMAIL field blank ; fi
+if [ "$hotline" = "" ] ; then errmsg $f: HOTLINE field blank ; fi
+ """
+ errors = []
+ catalogname = pkg_data["basic_stats"]["catalogname"]
+ pkgname = pkg_data["basic_stats"]["pkgname"]
+ pkginfo = pkg_data["pkginfo"]
+ if not catalogname:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "empty-catalogname"))
+ if not pkgname:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "empty-pkgname"))
+ if not "VERSION" in pkginfo or not pkginfo["VERSION"]:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "pkginfo-version-field-missing"))
+ desc = checkpkg.ExtractDescription(pkginfo)
+ if not desc:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "description-missing"))
+ if len(desc) > MAX_DESCRIPTION_LENGTH:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "description-too-long"))
+ # maintname=`sed -n 's/^VENDOR=.*for CSW by //p' $TMPFILE`
+ maintname = checkpkg.ExtractMaintainerName(pkginfo)
+ if not maintname:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "maintainer-name-not-set"))
+ # email
+ if not pkginfo["EMAIL"]:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "email-blank"))
+ # hotline
+ if not pkginfo["HOTLINE"]:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "hotline-blank"))
+ pkginfo_version = pkg_data["basic_stats"]["parsed_basename"]["full_version_string"]
+ if pkginfo_version != pkginfo["VERSION"]:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "filename-version-does-not-match-pkginfo-version"))
+ if re.search(r"-", pkginfo["VERSION"]):
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "minus-not-allowed-in-version"))
+ if not re.match(VERSION_RE, pkginfo["VERSION"]):
+ msg = ("Version regex: %s, version value: %s."
+ % (repr(VERSION_RE), repr(pkginfo["VERSION"])))
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "version-does-not-match-regex", msg=msg))
+ if pkginfo["ARCH"] not in ARCH_LIST:
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "non-standard-architecture", pkginfo["ARCH"]))
+ return errors
+
+
+def ArchitectureSanity(pkg_data, debug):
+ errors = []
+ basic_stats = pkg_data["basic_stats"]
+ pkgname = basic_stats["pkgname"]
+ pkginfo = pkg_data["pkginfo"]
+ filename = basic_stats["pkg_basename"]
+ arch = pkginfo["ARCH"]
+ filename_re = r"-%s-" % arch
+ if not re.search(filename_re, filename):
+ errors.append(checkpkg.CheckpkgTag(
+ pkgname, "srv4-filename-architecture-mismatch", arch))
+
+
def CheckArchitectureVsContents(pkg_data, debug):
"""Verifies the relationship between package contents and architecture."""
errors = []
Modified: csw/mgar/gar/v2/lib/python/package_checks_test.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks_test.py 2010-02-28 09:53:07 UTC (rev 8884)
+++ csw/mgar/gar/v2/lib/python/package_checks_test.py 2010-02-28 09:54:43 UTC (rev 8885)
@@ -112,5 +112,12 @@
self.failUnless(errors)
+ def testArchitectureSanity(self):
+ self.pkg_data_2["pkginfo"] = {}
+ self.pkg_data_2["pkginfo"]["ARCH"] = "i386"
+ errors = pc.ArchitectureSanity(self.pkg_data_2, False)
+ self.failUnless(errors)
+
+
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