[csw-devel] SF.net SVN: gar:[11234] csw/mgar/gar/v2/lib/python

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Mon Oct 11 07:02:17 CEST 2010


Revision: 11234
          http://gar.svn.sourceforge.net/gar/?rev=11234&view=rev
Author:   wahwah
Date:     2010-10-11 05:02:17 +0000 (Mon, 11 Oct 2010)

Log Message:
-----------
mGAR v2: Fixing imports and moving constants to appropriate locations.

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/opencsw.py
    csw/mgar/gar/v2/lib/python/package.py
    csw/mgar/gar/v2/lib/python/package_checks.py
    csw/mgar/gar/v2/lib/python/package_stats.py

Modified: csw/mgar/gar/v2/lib/python/opencsw.py
===================================================================
--- csw/mgar/gar/v2/lib/python/opencsw.py	2010-10-11 05:01:32 UTC (rev 11233)
+++ csw/mgar/gar/v2/lib/python/opencsw.py	2010-10-11 05:02:17 UTC (rev 11234)
@@ -42,24 +42,6 @@
     'application/x-executable',
     'application/x-sharedlib',
 )
-ADMIN_FILE_CONTENT = """
-basedir=default
-runlevel=nocheck
-conflict=nocheck
-setuid=nocheck
-action=nocheck
-partial=nocheck
-instance=unique
-idepend=quit
-rdepend=quit
-space=quit
-authentication=nocheck
-networktimeout=10
-networkretries=5
-keystore=/var/sadm/security
-proxy=
-"""
-
 SUBMITPKG_TMPL = """From: $from
 To: $to
 #if $cc

Modified: csw/mgar/gar/v2/lib/python/package.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package.py	2010-10-11 05:01:32 UTC (rev 11233)
+++ csw/mgar/gar/v2/lib/python/package.py	2010-10-11 05:02:17 UTC (rev 11234)
@@ -1,12 +1,21 @@
 #!/usr/bin/env python2.6
 
+import datetime
+import difflib
+import hachoir_parser as hp
 import hashlib
 import logging
+import magic
 import os
+import re
+import shutil
 import subprocess
+import tempfile
+import time
 
-import magic
-import hachoir_parser as hp
+import configuration as c
+import opencsw
+import overrides
 
 # Suppress unhelpful warnings
 # http://bitbucket.org/haypo/hachoir/issue/23
@@ -14,6 +23,32 @@
 hachoir_core.config.quiet = True
 
 
+ADMIN_FILE_CONTENT = """
+basedir=default
+runlevel=nocheck
+conflict=nocheck
+setuid=nocheck
+action=nocheck
+partial=nocheck
+instance=unique
+idepend=quit
+rdepend=quit
+space=quit
+authentication=nocheck
+networktimeout=10
+networkretries=5
+keystore=/var/sadm/security
+proxy=
+"""
+
+class Error(Exception):
+  pass
+
+
+class PackageError(Error):
+  pass
+
+
 class ShellMixin(object):
 
   def ShellCommand(self, args, quiet=False):
@@ -218,13 +253,13 @@
   def GetParsedPkginfo(self):
     if not self.pkginfo_dict:
       pkginfo_fd = open(self.GetPkginfoFilename(), "r")
-      self.pkginfo_dict = ParsePkginfo(pkginfo_fd)
+      self.pkginfo_dict = opencsw.ParsePkginfo(pkginfo_fd)
       pkginfo_fd.close()
     return self.pkginfo_dict
 
   def GetSrv4FileName(self):
     """Guesses the Srv4FileName based on the package directory contents."""
-    return PkginfoToSrv4Name(self.GetParsedPkginfo())
+    return opencsw.PkginfoToSrv4Name(self.GetParsedPkginfo())
 
   def ToSrv4(self, target_dir):
     target_file_name = self.GetSrv4FileName()
@@ -242,7 +277,7 @@
 
   def GetPkgmap(self, analyze_permissions=False, strip=None):
     fd = open(os.path.join(self.directory, "pkgmap"), "r")
-    return Pkgmap(fd, analyze_permissions, strip)
+    return opencsw.Pkgmap(fd, analyze_permissions, strip)
 
   def SetPkginfoEntry(self, key, value):
     pkginfo = self.GetParsedPkginfo()
@@ -305,7 +340,7 @@
   def ResetNameProperty(self):
     """Sometimes, NAME= contains useless data. This method resets them."""
     pkginfo_dict = self.GetParsedPkginfo()
-    catalog_name = PkgnameToCatName(pkginfo_dict["PKG"])
+    catalog_name = opencsw.PkgnameToCatName(pkginfo_dict["PKG"])
     description = pkginfo_dict["DESC"]
     pkginfo_name = "%s - %s" % (catalog_name, description)
     self.SetPkginfoEntry("NAME", pkginfo_name)
@@ -365,7 +400,7 @@
           # We really don't want that, as it misses binaries.
           raise PackageError("Could not establish the mime type of %s"
                              % full_path)
-        if IsBinary(file_info):
+        if opencsw.IsBinary(file_info):
           parser = hp.createParser(full_path)
           if not parser:
             logging.warning("Can't parse file %s", file_path)
@@ -404,7 +439,7 @@
       self.binaries = []
       # The nested for-loop looks inefficient.
       for file_info in files_metadata:
-        if IsBinary(file_info):
+        if opencsw.IsBinary(file_info):
           self.binaries.append(file_info["path"])
       self.binaries.sort()
     return self.binaries

Modified: csw/mgar/gar/v2/lib/python/package_checks.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_checks.py	2010-10-11 05:01:32 UTC (rev 11233)
+++ csw/mgar/gar/v2/lib/python/package_checks.py	2010-10-11 05:02:17 UTC (rev 11234)
@@ -1087,7 +1087,7 @@
           messenger.SuggestGarLine("# (If %s-devel doesn't exist yet)" % pkgname)
           messenger.SuggestGarLine("PACKAGES += %s-devel" % pkgname)
           messenger.SuggestGarLine(
-              "PKGFILES_%s-devel += /%s" % (pkgname, entry["path"]))
+              "PKGFILES_%s-devel += %s" % (pkgname, entry["path"]))
           messenger.Message(
               "The package contains shared libraries together with the "
               "symlink of the form libfoo.so -> libfoo.so.1.  "

Modified: csw/mgar/gar/v2/lib/python/package_stats.py
===================================================================
--- csw/mgar/gar/v2/lib/python/package_stats.py	2010-10-11 05:01:32 UTC (rev 11233)
+++ csw/mgar/gar/v2/lib/python/package_stats.py	2010-10-11 05:02:17 UTC (rev 11234)
@@ -1,18 +1,44 @@
 #!/usr/bin/env python2.6
 
+import copy
 import cPickle
+import logging
 import os
 import re
+import sqlobject
+import subprocess
 
 import catalog
+import checkpkg
 import database
 import package
+import opencsw
 import overrides
 import models as m
 import tag
 
+DUMP_BIN = "/usr/ccs/bin/dump"
 PACKAGE_STATS_VERSION = 9L
+BAD_CONTENT_REGEXES = (
+    # Slightly obfuscating these by using the default concatenation of
+    # strings.
+    r'/export' r'/medusa',
+    r'/opt' r'/build',
+)
 
+
+class Error(Exception):
+  pass
+
+
+class PackageError(Error):
+  pass
+
+
+class StdoutSyntaxError(Error):
+  pass
+
+
 class PackageStats(database.DatabaseClient):
   """Collects stats about a package and saves it.
 
@@ -112,7 +138,7 @@
       dump_proc = subprocess.Popen(args, stdout=subprocess.PIPE, env=env)
       stdout, stderr = dump_proc.communicate()
       ret = dump_proc.wait()
-      binary_data = ParseDumpOutput(stdout)
+      binary_data = checkpkg.ParseDumpOutput(stdout)
       binary_data["path"] = binary
       binary_data["base_name"] = binary_base_name
       binaries_dump_info.append(binary_data)
@@ -235,7 +261,7 @@
         "binaries": dir_pkg.ListBinaries(),
         "binaries_dump_info": self.GetBinaryDumpInfo(),
         "depends": dir_pkg.GetDependencies(),
-        "isalist": GetIsalist(),
+        "isalist": checkpkg.GetIsalist(),
         "overrides": override_dicts,
         "pkgchk": self.GetPkgchkData(),
         "pkginfo": dir_pkg.GetParsedPkginfo(),


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