[packagekit] packagekit: Branch 'master' - 7 commits

Richard Hughes hughsient at kemper.freedesktop.org
Thu Dec 20 23:31:45 PST 2007


 backends/conary/helpers/conaryBackend.py  |  150 ++++++++++++++++++------------
 backends/conary/helpers/conaryCallback.py |    3 
 docs/html/img/author-elliot.png           |binary
 docs/html/pk-authors.html                 |   15 +++
 libpackagekit/pk-enum.c                   |  150 ++++++++++++++++++++++++++++++
 libpackagekit/pk-enum.h                   |  122 ++++++++++++++++++++++++
 python/enum-convertor.py                  |    3 
 python/packagekit/backend.py              |   15 ++-
 8 files changed, 397 insertions(+), 61 deletions(-)

New commits:
commit ccbba1ca77b880ac1b42fa5aeb7a6f189bad12e3
Author: Elliot Peele <elliot at localhost.localdomain>
Date:   Thu Dec 20 22:49:00 2007 -0500

    add author info for myself

diff --git a/docs/html/img/author-elliot.png b/docs/html/img/author-elliot.png
new file mode 100644
index 0000000..733eebc
Binary files /dev/null and b/docs/html/img/author-elliot.png differ
diff --git a/docs/html/pk-authors.html b/docs/html/pk-authors.html
index 745e786..8c5a219 100644
--- a/docs/html/pk-authors.html
+++ b/docs/html/pk-authors.html
@@ -173,6 +173,21 @@
  </td>
 </tr>
 
+<tr>
+ <td>
+  <img src="img/author-elliot.png" alt="[img]"/>
+ </td>
+ <td>
+  <h2>Elliot Peele</h2>
+  <p>
+   Elliot is a software engineer for <a href="http://www.rpath.com/">rPath, Inc.</a> working on the distro team. He is a developer for the <a href="http://foresightlinux.org/">Foresight Linux</a> project and a contributor to <a href="http://fedoraproject.org/wiki/Anaconda">Anaconda</a>. Elliot works on the <a href="http://wiki.rpath.com/wiki/Conary">Conary</a> backend of PackageKit.
+  </p>
+  <p>
+   <b>Responsible for: conary backend</b>
+  </p>
+ </td>
+</tr>
+
 </table>
 
 <p>Back to the <a href="index.html">main page</a></p>
commit 42fb1b7f82ac21da172f270d15809413e8e67832
Merge: 9d61096... c6f5607...
Author: Elliot Peele <elliot at localhost.localdomain>
Date:   Thu Dec 20 22:26:05 2007 -0500

    Merge branch 'master' of git+ssh://git.packagekit.org/srv/git/PackageKit

commit 9d61096021f22558288200f097c6d1b0e571f2d1
Author: Elliot Peele <elliot at localhost.localdomain>
Date:   Thu Dec 20 22:25:45 2007 -0500

    add better exception handling
    switch to freezing/thawing versions/flavors

diff --git a/backends/conary/helpers/conaryBackend.py b/backends/conary/helpers/conaryBackend.py
index 18f789f..92e09b0 100644
--- a/backends/conary/helpers/conaryBackend.py
+++ b/backends/conary/helpers/conaryBackend.py
@@ -11,6 +11,7 @@
 import sys
 import os
 
+from conary import errors
 from conary.deps import deps
 from conary import conarycfg, conaryclient
 from conary import dbstore, queryrep, versions, updatecmd
@@ -18,6 +19,29 @@ from conary import dbstore, queryrep, versions, updatecmd
 from packagekit.backend import *
 from conaryCallback import UpdateCallback
 
+#from conary.lib import util
+#sys.excepthook = util.genExcepthook()
+
+def ExceptionHandler(func):
+    def display(error):
+        return str(error).replace('\n', ' ')
+
+    def wrapper(self, *args, **kwargs):
+        try:
+            return func(self, *args, **kwargs)
+        #except Exception:
+        #    raise
+        except conaryclient.NoNewTrovesError:
+            return
+        except conaryclient.DepResolutionFailure, e:
+            self.error(ERROR_DEP_RESOLUTION_FAILED, display(e), exit=True)
+        except conaryclient.UpdateError, e:
+            # FIXME: Need a enum for UpdateError
+            self.error(ERROR_UNKOWN, display(e), exit=True)
+        except Exception, e:
+            self.error(ERROR_UNKNOWN, display(e), exit=True)
+    return wrapper
+
 class PackageKitConaryBackend(PackageKitBaseBackend):
     def __init__(self, args):
         PackageKitBaseBackend.__init__(self, args)
@@ -31,6 +55,17 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
         self.callback = UpdateCallback(self, self.cfg)
         self.client.setUpdateCallback(self.callback)
 
+    def _freezeData(self, version, flavor):
+        frzVersion = version.freeze()
+        frzFlavor = flavor.freeze()
+        return ','.join([frzVersion, frzFlavor])
+
+    def _thawData(self, data):
+        frzVersion, frzFlavor = data.split(',')
+        version = versions.ThawVersion(frzVersion)
+        flavor = deps.ThawFlavor(frzFlavor)
+        return version, flavor
+
     def _get_arch(self, flavor):
         isdep = deps.InstructionSetDependency
         arches = [ x.name for x in flavor.iterDepsByClass(isdep) ]
@@ -38,27 +73,20 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
             arches = [ 'noarch' ]
         return ','.join(arches)
 
+    @ExceptionHandler
     def get_package_id(self, name, versionObj, flavor):
         version = versionObj.trailingRevision()
-        fullVersion = versionObj.asString()
         arch = self._get_arch(flavor)
+        data = self._freezeData(versionObj, flavor)
         return PackageKitBaseBackend.get_package_id(self, name, version, arch,
-                                                    fullVersion)
+                                                    data)
 
+    @ExceptionHandler
     def get_package_from_id(self, id):
-        name, verString, archString, fullVerString = \
+        name, verString, archString, data = \
             PackageKitBaseBackend.get_package_from_id(self, id)
 
-        if verString:
-            version = versions.VersionFromString(fullVerString)
-        else:
-            version = None
-
-        if archString and archString != 'noarch':
-            arches = 'is: %s' %  ' '.join(archString.split(','))
-            flavor = deps.parseFlavor(arches)
-        else:
-            flavor = deps.parseFlavor('')
+        version, flavor = self._thawData(data)
 
         return name, version, flavor
 
@@ -120,12 +148,14 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
         updJob, suggMap = self._do_update(applyList, apply=apply)
         return updJob, suggMap
 
+    @ExceptionHandler
     def resolve(self, filter, package):
         self.allow_interrupt(True)
         self.percentage(None)
         self.status(STATUS_INFO)
         self._do_search(package, filter)
 
+    @ExceptionHandler
     def check_installed(self, troveTuple):
         db = conaryclient.ConaryClient(self.cfg).db
         try:
@@ -136,6 +166,7 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
             installed = INFO_AVAILABLE
         return installed
 
+    @ExceptionHandler
     def search_name(self, options, searchlist):
         '''
         Implement the {backend}-search-name functionality
@@ -152,6 +183,7 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
     def get_requires(self, package_id):
         pass
 
+    @ExceptionHandler
     def get_depends(self, package_id):
         name, version, flavor, installed = self._findPackage(package_id)
 
@@ -175,6 +207,7 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
             self.error(ERROR_PACKAGE_ALREADY_INSTALLED,
                 'Package was not found')
 
+    @ExceptionHandler
     def get_files(self, package_id):
         self.allow_interrupt(True)
         self.percentage(None)
@@ -201,18 +234,21 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
 
         self.files(package_id, ';'.join(files))
 
+    @ExceptionHandler
     def update_system(self):
         self.allow_interrupt(True)
         updateItems = self.client.fullUpdateItemList()
         applyList = [ (x[0], (None, None), x[1:], True) for x in updateItems ]
         updJob, suggMap = self._do_update(applyList, apply=True)
 
+    @ExceptionHandler
     def refresh_cache(self):
         self.percentage()
         self.status(STATUS_REFRESH_CACHE)
         cache = Cache()
         cache.populate_database()
 
+    @ExceptionHandler
     def install(self, package_id):
         '''
         Implement the {backend}-install functionality
@@ -227,15 +263,14 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
             if installed == INFO_INSTALLED:
                 self.error(ERROR_PACKAGE_ALREADY_INSTALLED,
                     'Package already installed')
-            try:
-                self.status(STATUS_INSTALL)
-                self._do_package_update(name, version, flavor, apply=True)
-            except:
-                self.error(ERROR_PACKAGE_NOT_FOUND, 'Package was not found')
+
+            self.status(STATUS_INSTALL)
+            self._do_package_update(name, version, flavor, apply=True)
         else:
             self.error(ERROR_PACKAGE_ALREADY_INSTALLED,
                 'Package was not found')
 
+    @ExceptionHandler
     def remove(self, allowDeps, package_id):
         '''
         Implement the {backend}-remove functionality
@@ -248,12 +283,10 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
             if not installed == INFO_INSTALLED:
                 self.error(ERROR_PACKAGE_NOT_INSTALLED,
                     'Package not installed')
-            try:
-                self.status(STATUS_REMOVE)
-                name = '-%s' % name
-                self._do_package_update(name, version, flavor, apply=True)
-            except:
-                pass
+
+            self.status(STATUS_REMOVE)
+            name = '-%s' % name
+            self._do_package_update(name, version, flavor, apply=True)
         else:
             self.error(ERROR_PACKAGE_ALREADY_INSTALLED,
                 'Package was not found')
@@ -288,6 +321,7 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
             result = trove.getMetadata()[field]
         return result
 
+    @ExceptionHandler
     def get_description(self, id):
         '''
         Print a detailed description for a given package
@@ -325,29 +359,36 @@ class PackageKitConaryBackend(PackageKitBaseBackend):
         #    return INFO_NORMAL
         return INFO_NORMAL
 
+    @ExceptionHandler
     def get_updates(self):
         self.allow_interrupt(True)
         self.percentage()
-        try:
-            updateItems = self.client.fullUpdateItemList()
-            applyList = [ (x[0], (None, None), x[1:], True) for x in updateItems ]
-            updJob, suggMap = self._do_update(applyList, apply=False)
-
-            jobLists = updJob.getJobs()
-
-            totalJobs = len(jobLists)
-            for num, job in enumerate(jobLists):
-                status = '2'
-                name = job[0][0]
-                version = job[0][2][0]
-                flavor = job[0][2][1]
-                troveTuple = []
-                troveTuple.append(name)
-                troveTuple.append(version)
-                installed = self.check_installed(troveTuple)
-                self._show_package(name, version, flavor, INFO_NORMAL)
-        except:
-            pass
+
+        updateItems = self.client.fullUpdateItemList()
+        applyList = [ (x[0], (None, None), x[1:], True) for x in updateItems ]
+        updJob, suggMap = self._do_update(applyList, apply=False)
+
+        jobLists = updJob.getJobs()
+
+        totalJobs = len(jobLists)
+        for num, job in enumerate(jobLists):
+            status = '2'
+            name = job[0][0]
+
+            # On an erase display the old version/flavor information.
+            version = job[0][2][0]
+            if version is None:
+                version = job[0][1][0]
+
+            flavor = job[0][2][1]
+            if flavor is None:
+                flavor = job[0][1][1]
+
+            troveTuple = []
+            troveTuple.append(name)
+            troveTuple.append(version)
+            installed = self.check_installed(troveTuple)
+            self._show_package(name, version, flavor, INFO_NORMAL)
 
     def _do_filtering(self, pkg, filterList, installed):
         ''' Filter the package, based on the filter in filterList '''
@@ -519,12 +560,8 @@ class Cache(object):
         stmt = ("select distinct trove, version, flavor, description, "
                 "category, packagegroup, size from conary_packages")
 
-        try:
-            self.cursor.execute(stmt)
-            return self.cursor.fetchall()
-        except Exception, e:
-            print str(e)
-            return None
+        self.cursor.execute(stmt)
+        return self.cursor.fetchall()
 
     def search(self, package, fullVersion=None):
         """
@@ -571,11 +608,8 @@ class Cache(object):
         self.cursor.execute(stmt)
 
     def populate_database(self):
-        try:
-            packages = self.conaryquery()
-            # Clear table first
-            self._clear_table()
-            for package in packages:
-                self._insert(package)
-        except Exception, e:
-            print str(e)
+        packages = self.conaryquery()
+        # Clear table first
+        self._clear_table()
+        for package in packages:
+            self._insert(package)
commit 0599164888d2985f8dc199b3f58c224c71c4d2d0
Author: Elliot Peele <elliot at localhost.localdomain>
Date:   Thu Dec 20 22:25:03 2007 -0500

    remove debugging

diff --git a/backends/conary/helpers/conaryCallback.py b/backends/conary/helpers/conaryCallback.py
index fb9e9a0..e61ac96 100644
--- a/backends/conary/helpers/conaryCallback.py
+++ b/backends/conary/helpers/conaryCallback.py
@@ -48,8 +48,6 @@ class UpdateCallback(callbacks.UpdateCallback):
         if not self.currentJob or len(self.currentJob) == 0 or troveNum > troveCount:
             return
 
-        print "troveNum: %s, troveCount: %s" % (troveNum, troveCount)
-
         if troveNum > 0 and troveCount > 0:
             sub_percent = (add + troveNum) / (2 * float(troveCount)) * 100
             self.backend.sub_percentage(sub_percent)
commit c6f5607d0868734d7737eb5568da0d9b8388afb6
Author: Robin Norwood <rnorwood at redhat.com>
Date:   Thu Dec 20 18:10:17 2007 -0500

    o Update list of valid licenses
    o Update enum converter to:
      - Allow for numbers in enums
      - Advertise that python/packagekit/enums.py is generated
    o Fix license tag parser to ignore trailing "+"es

diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index 0beb23c..7e941f6 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -257,19 +257,14 @@ static PkEnumMatch enum_fsf_free_licenses[] = {
 	{PK_LICENSE_ENUM_LGPLV2_WITH_EXCEPTIONS, "LGPLv2 with exceptions"},
 	{PK_LICENSE_ENUM_FTL,                  "FTL"},
 	{PK_LICENSE_ENUM_GIFTWARE,             "Giftware"},
-	{PK_LICENSE_ENUM_GPL_PLUS,             "GPL+"},
 	{PK_LICENSE_ENUM_GPLV2,                "GPLv2"},
 	{PK_LICENSE_ENUM_GPLV2_WITH_EXCEPTIONS, "GPLv2 with exceptions"},
-	{PK_LICENSE_ENUM_GPLV2_PLUS,           "GPLv2+"},
 	{PK_LICENSE_ENUM_GPLV2_PLUS_WITH_EXCEPTIONS, "GPLv2+ with exceptions"},
 	{PK_LICENSE_ENUM_GPLV3,                "GPLv3"},
 	{PK_LICENSE_ENUM_GPLV3_WITH_EXCEPTIONS, "GPLv3 with exceptions"},
-	{PK_LICENSE_ENUM_GPLV3_PLUS,           "GPLv3+"},
 	{PK_LICENSE_ENUM_GPLV3_PLUS_WITH_EXCEPTIONS, "GPLv3+ with exceptions"},
 	{PK_LICENSE_ENUM_LGPLV2,               "LGPLv2"},
-	{PK_LICENSE_ENUM_LGPLV2_PLUS,          "LGPLv2+"},
 	{PK_LICENSE_ENUM_LGPLV3,               "LGPLv3"},
-	{PK_LICENSE_ENUM_LGPLV3_PLUS,          "LGPLv3+"},
 	{PK_LICENSE_ENUM_GNUPLOT,              "gnuplot"},
 	{PK_LICENSE_ENUM_IBM,                  "IBM"},
 	{PK_LICENSE_ENUM_IMATIX,               "iMatix"},
@@ -301,8 +296,6 @@ static PkEnumMatch enum_fsf_free_licenses[] = {
 	{PK_LICENSE_ENUM_OSL_3_DOT_0,          "OSL 3.0"},
 	{PK_LICENSE_ENUM_OPENSSL,              "OpenSSL"},
 	{PK_LICENSE_ENUM_OREILLY,              "OReilly"},
-	{PK_LICENSE_ENUM_GPL_PLUS_OR_ARTISTIC, "GPL+ or Artistic"},
-	{PK_LICENSE_ENUM_GPLV2_PLUS_OR_ARTISTIC, "GPLv2+ or Artistic"},
 	{PK_LICENSE_ENUM_PHORUM,               "Phorum"},
 	{PK_LICENSE_ENUM_PHP,                  "PHP"},
 	{PK_LICENSE_ENUM_PUBLIC_DOMAIN,        "Public Domain"},
@@ -326,7 +319,27 @@ static PkEnumMatch enum_fsf_free_licenses[] = {
 	{PK_LICENSE_ENUM_ZPLV1_DOT_0,          "ZPLv1.0"},
 	{PK_LICENSE_ENUM_ZPLV2_DOT_0,          "ZPLv2.0"},
 	{PK_LICENSE_ENUM_ZPLV2_DOT_1,          "ZPLv2.1"},
-	{PK_LICENSE_ENUM_ZLIB,                 "zlib "},
+	{PK_LICENSE_ENUM_ZLIB,                 "zlib"},
+	{PK_LICENSE_ENUM_CDL,                  "CDL"},
+	{PK_LICENSE_ENUM_FBSDDL,               "FBSDDL"},
+	{PK_LICENSE_ENUM_GFDL,                 "GFDL"},
+	{PK_LICENSE_ENUM_IEEE,                 "IEEE"},
+	{PK_LICENSE_ENUM_OFSFDL,               "OFSFDL"},
+	{PK_LICENSE_ENUM_OPEN_PUBLICATION,     "Open Publication"},
+	{PK_LICENSE_ENUM_CC_BY,                "CC-BY"},
+	{PK_LICENSE_ENUM_CC_BY_SA,             "CC-BY-SA"},
+	{PK_LICENSE_ENUM_CC_BY_ND,             "CC-BY-ND"},
+	{PK_LICENSE_ENUM_DSL,                  "DSL"},
+	{PK_LICENSE_ENUM_FREE_ART,             "Free Art"},
+	{PK_LICENSE_ENUM_OFL,                  "OFL"},
+	{PK_LICENSE_ENUM_UTOPIA,               "Utopia"},
+	{PK_LICENSE_ENUM_ARPHIC,               "Arphic"},
+	{PK_LICENSE_ENUM_BAEKMUK,              "Baekmuk"},
+	{PK_LICENSE_ENUM_BITSTREAM_VERA,       "Bitstream Vera"},
+	{PK_LICENSE_ENUM_LUCIDA,               "Lucida"},
+	{PK_LICENSE_ENUM_MPLUS,                "mplus"},
+	{PK_LICENSE_ENUM_STIX,                 "STIX"},
+	{PK_LICENSE_ENUM_XANO,                 "XANO"},
 	{0, NULL},
 };
 
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index 1557df1..63b9ec3 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -311,19 +311,14 @@ typedef enum {
 	PK_LICENSE_ENUM_LGPLV2_WITH_EXCEPTIONS,
 	PK_LICENSE_ENUM_FTL,
 	PK_LICENSE_ENUM_GIFTWARE,
-	PK_LICENSE_ENUM_GPL_PLUS,
 	PK_LICENSE_ENUM_GPLV2,
 	PK_LICENSE_ENUM_GPLV2_WITH_EXCEPTIONS,
-	PK_LICENSE_ENUM_GPLV2_PLUS,
 	PK_LICENSE_ENUM_GPLV2_PLUS_WITH_EXCEPTIONS,
 	PK_LICENSE_ENUM_GPLV3,
 	PK_LICENSE_ENUM_GPLV3_WITH_EXCEPTIONS,
-	PK_LICENSE_ENUM_GPLV3_PLUS,
 	PK_LICENSE_ENUM_GPLV3_PLUS_WITH_EXCEPTIONS,
 	PK_LICENSE_ENUM_LGPLV2,
-	PK_LICENSE_ENUM_LGPLV2_PLUS,
 	PK_LICENSE_ENUM_LGPLV3,
-	PK_LICENSE_ENUM_LGPLV3_PLUS,
 	PK_LICENSE_ENUM_GNUPLOT,
 	PK_LICENSE_ENUM_IBM,
 	PK_LICENSE_ENUM_IMATIX,
@@ -355,8 +350,6 @@ typedef enum {
 	PK_LICENSE_ENUM_OSL_3_DOT_0,
 	PK_LICENSE_ENUM_OPENSSL,
 	PK_LICENSE_ENUM_OREILLY,
-	PK_LICENSE_ENUM_GPL_PLUS_OR_ARTISTIC,
-	PK_LICENSE_ENUM_GPLV2_PLUS_OR_ARTISTIC,
 	PK_LICENSE_ENUM_PHORUM,
 	PK_LICENSE_ENUM_PHP,
 	PK_LICENSE_ENUM_PUBLIC_DOMAIN,
@@ -381,6 +374,26 @@ typedef enum {
 	PK_LICENSE_ENUM_ZPLV2_DOT_0,
 	PK_LICENSE_ENUM_ZPLV2_DOT_1,
 	PK_LICENSE_ENUM_ZLIB,
+	PK_LICENSE_ENUM_CDL,
+	PK_LICENSE_ENUM_FBSDDL,
+	PK_LICENSE_ENUM_GFDL,
+	PK_LICENSE_ENUM_IEEE,
+	PK_LICENSE_ENUM_OFSFDL,
+	PK_LICENSE_ENUM_OPEN_PUBLICATION,
+	PK_LICENSE_ENUM_CC_BY,
+	PK_LICENSE_ENUM_CC_BY_SA,
+	PK_LICENSE_ENUM_CC_BY_ND,
+	PK_LICENSE_ENUM_DSL,
+	PK_LICENSE_ENUM_FREE_ART,
+	PK_LICENSE_ENUM_OFL,
+	PK_LICENSE_ENUM_UTOPIA,
+	PK_LICENSE_ENUM_ARPHIC,
+	PK_LICENSE_ENUM_BAEKMUK,
+	PK_LICENSE_ENUM_BITSTREAM_VERA,
+	PK_LICENSE_ENUM_LUCIDA,
+	PK_LICENSE_ENUM_MPLUS,
+	PK_LICENSE_ENUM_STIX,
+	PK_LICENSE_ENUM_XANO,
 	PK_LICENSE_ENUM_UNKNOWN
 } PkLicenseEnum;
 
diff --git a/python/enum-convertor.py b/python/enum-convertor.py
index eb111f2..6ac1fc5 100644
--- a/python/enum-convertor.py
+++ b/python/enum-convertor.py
@@ -3,7 +3,7 @@
 from re import compile,DOTALL,MULTILINE
 
 enum = compile("static PkEnumMatch enum_([^\]]+)\[\] = {(.*?)};", DOTALL|MULTILINE)
-value = compile("PK_([A-Z]+)_ENUM_([A-Z_]+),\s+\"([^\"]+)\"")
+value = compile("PK_([A-Z]+)_ENUM_([A-Z0-9_]+),\s+\"([^\"]+)\"")
 
 inp = open("../libpackagekit/pk-enum.c").read()
 
diff --git a/python/packagekit/backend.py b/python/packagekit/backend.py
index d7128f2..170d9cc 100644
--- a/python/packagekit/backend.py
+++ b/python/packagekit/backend.py
@@ -193,11 +193,16 @@ class PackageKitBaseBackend:
         can be redistributed under any of the licenses in the group.
         For instance: GPLv2+ or Artistic or FooLicense.
 
+        Also, if a license ends with "+", the "+" is removed before
+        comparing it to the list of valid licenses.  So if license
+        "FooLicense" is free, then "FooLicense+" is considered free.
+
         Groups of licenses can be grouped with " and " to indicate
         that parts of the package are distributed under one group of
         licenses, while other parts of the package are distributed
         under another group.  Groups may be wrapped in parenthesis.
-        For instance: (GPLv2+ or Artistic) and (GPL+ or Artistic) and FooLicense.
+        For instance:
+          (GPLv2+ or Artistic) and (GPL+ or Artistic) and FooLicense.
 
         At least one license in each group must be free for the
         package to be considered Free Software.  If the license_field
@@ -221,6 +226,12 @@ class PackageKitBaseBackend:
             for license in licenses:
                 license = license.strip()
 
+                if len(license) < 1:
+                    continue
+
+                if license[-1] == "+":
+                    license = license[0:-1]
+
                 if license in PackageKitEnum.fsf_free_licenses:
                     one_free_group = True
                     group_is_free = True
@@ -478,4 +489,4 @@ def exceptionHandler(typ, value, tb, base):
     
 def installExceptionHandler(base):
     sys.excepthook = lambda typ, value, tb: exceptionHandler(typ, value, tb,base)
-    
\ No newline at end of file
+    
commit de85e116a3ac14e542cec5b7478ce406b71a37e4
Author: Robin Norwood <rnorwood at redhat.com>
Date:   Thu Dec 20 14:28:56 2007 -0500

    Add FSF free license enum

diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index 59f4b6b..0beb23c 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -223,6 +223,114 @@ static PkEnumMatch enum_sig_type[] = {
 	{0, NULL},
 };
 
+static PkEnumMatch enum_fsf_free_licenses[] = {
+	{PK_LICENSE_ENUM_UNKNOWN,              "unknown"},	/* fall though value */
+	{PK_LICENSE_ENUM_GLIDE,                "Glide"},
+	{PK_LICENSE_ENUM_AFL,                  "AFL"},
+	{PK_LICENSE_ENUM_AMPAS_BSD,            "AMPAS BSD"},
+	{PK_LICENSE_ENUM_ADOBE,                "Adobe"},
+	{PK_LICENSE_ENUM_AGPLV1,               "AGPLv1"},
+	{PK_LICENSE_ENUM_AGPLV3,               "AGPLv3"},
+	{PK_LICENSE_ENUM_ASL_1_DOT_0,          "ASL 1.0"},
+	{PK_LICENSE_ENUM_ASL_1_DOT_1,          "ASL 1.1"},
+	{PK_LICENSE_ENUM_ASL_2_DOT_0,          "ASL 2.0"},
+	{PK_LICENSE_ENUM_APSL_2_DOT_0,         "APSL 2.0"},
+	{PK_LICENSE_ENUM_ARTISTIC_CLARIFIED,   "Artistic clarified"},
+	{PK_LICENSE_ENUM_ARTISTIC_2_DOT_0,     "Artistic 2.0"},
+	{PK_LICENSE_ENUM_ARL,                  "ARL"},
+	{PK_LICENSE_ENUM_BITTORRENT,           "BitTorrent"},
+	{PK_LICENSE_ENUM_BOOST,                "Boost"},
+	{PK_LICENSE_ENUM_BSD_WITH_ADVERTISING, "BSD with advertising"},
+	{PK_LICENSE_ENUM_BSD,                  "BSD"},
+	{PK_LICENSE_ENUM_CECILL,               "CeCILL"},
+	{PK_LICENSE_ENUM_CDDL,                 "CDDL"},
+	{PK_LICENSE_ENUM_CPL,                  "CPL"},
+	{PK_LICENSE_ENUM_CONDOR,               "Condor"},
+	{PK_LICENSE_ENUM_COPYRIGHT_ONLY,       "Copyright only"},
+	{PK_LICENSE_ENUM_CRYPTIX,              "Cryptix"},
+	{PK_LICENSE_ENUM_CRYSTAL_STACKER,      "Crystal Stacker"},
+	{PK_LICENSE_ENUM_WTFPL,                "WTFPL"},
+	{PK_LICENSE_ENUM_EPL,                  "EPL"},
+	{PK_LICENSE_ENUM_ECOS,                 "eCos"},
+	{PK_LICENSE_ENUM_EFL_2_DOT_0,          "EFL 2.0"},
+	{PK_LICENSE_ENUM_EU_DATAGRID,          "EU Datagrid"},
+	{PK_LICENSE_ENUM_LGPLV2_WITH_EXCEPTIONS, "LGPLv2 with exceptions"},
+	{PK_LICENSE_ENUM_FTL,                  "FTL"},
+	{PK_LICENSE_ENUM_GIFTWARE,             "Giftware"},
+	{PK_LICENSE_ENUM_GPL_PLUS,             "GPL+"},
+	{PK_LICENSE_ENUM_GPLV2,                "GPLv2"},
+	{PK_LICENSE_ENUM_GPLV2_WITH_EXCEPTIONS, "GPLv2 with exceptions"},
+	{PK_LICENSE_ENUM_GPLV2_PLUS,           "GPLv2+"},
+	{PK_LICENSE_ENUM_GPLV2_PLUS_WITH_EXCEPTIONS, "GPLv2+ with exceptions"},
+	{PK_LICENSE_ENUM_GPLV3,                "GPLv3"},
+	{PK_LICENSE_ENUM_GPLV3_WITH_EXCEPTIONS, "GPLv3 with exceptions"},
+	{PK_LICENSE_ENUM_GPLV3_PLUS,           "GPLv3+"},
+	{PK_LICENSE_ENUM_GPLV3_PLUS_WITH_EXCEPTIONS, "GPLv3+ with exceptions"},
+	{PK_LICENSE_ENUM_LGPLV2,               "LGPLv2"},
+	{PK_LICENSE_ENUM_LGPLV2_PLUS,          "LGPLv2+"},
+	{PK_LICENSE_ENUM_LGPLV3,               "LGPLv3"},
+	{PK_LICENSE_ENUM_LGPLV3_PLUS,          "LGPLv3+"},
+	{PK_LICENSE_ENUM_GNUPLOT,              "gnuplot"},
+	{PK_LICENSE_ENUM_IBM,                  "IBM"},
+	{PK_LICENSE_ENUM_IMATIX,               "iMatix"},
+	{PK_LICENSE_ENUM_IMAGEMAGICK,          "ImageMagick"},
+	{PK_LICENSE_ENUM_IMLIB2,               "Imlib2"},
+	{PK_LICENSE_ENUM_IJG,                  "IJG"},
+	{PK_LICENSE_ENUM_INTEL_ACPI,           "Intel ACPI"},
+	{PK_LICENSE_ENUM_INTERBASE,            "Interbase"},
+	{PK_LICENSE_ENUM_ISC,                  "ISC"},
+	{PK_LICENSE_ENUM_JABBER,               "Jabber"},
+	{PK_LICENSE_ENUM_JASPER,               "JasPer"},
+	{PK_LICENSE_ENUM_LPPL,                 "LPPL"},
+	{PK_LICENSE_ENUM_LIBTIFF,              "libtiff"},
+	{PK_LICENSE_ENUM_LPL,                  "LPL"},
+	{PK_LICENSE_ENUM_MECAB_IPADIC,         "mecab-ipadic"},
+	{PK_LICENSE_ENUM_MIT,                  "MIT"},
+	{PK_LICENSE_ENUM_MPLV1_DOT_0,          "MPLv1.0"},
+	{PK_LICENSE_ENUM_MPLV1_DOT_1,          "MPLv1.1"},
+	{PK_LICENSE_ENUM_NCSA,                 "NCSA"},
+	{PK_LICENSE_ENUM_NGPL,                 "NGPL"},
+	{PK_LICENSE_ENUM_NOSL,                 "NOSL"},
+	{PK_LICENSE_ENUM_NETSCAPE,             "Netscape"},
+	{PK_LICENSE_ENUM_NOKIA,                "Nokia"},
+	{PK_LICENSE_ENUM_OPENLDAP,             "OpenLDAP"},
+	{PK_LICENSE_ENUM_OPENPBS,              "OpenPBS"},
+	{PK_LICENSE_ENUM_OSL_1_DOT_0,          "OSL 1.0"},
+	{PK_LICENSE_ENUM_OSL_1_DOT_1,          "OSL 1.1"},
+	{PK_LICENSE_ENUM_OSL_2_DOT_0,          "OSL 2.0"},
+	{PK_LICENSE_ENUM_OSL_3_DOT_0,          "OSL 3.0"},
+	{PK_LICENSE_ENUM_OPENSSL,              "OpenSSL"},
+	{PK_LICENSE_ENUM_OREILLY,              "OReilly"},
+	{PK_LICENSE_ENUM_GPL_PLUS_OR_ARTISTIC, "GPL+ or Artistic"},
+	{PK_LICENSE_ENUM_GPLV2_PLUS_OR_ARTISTIC, "GPLv2+ or Artistic"},
+	{PK_LICENSE_ENUM_PHORUM,               "Phorum"},
+	{PK_LICENSE_ENUM_PHP,                  "PHP"},
+	{PK_LICENSE_ENUM_PUBLIC_DOMAIN,        "Public Domain"},
+	{PK_LICENSE_ENUM_PYTHON,               "Python"},
+	{PK_LICENSE_ENUM_QPL,                  "QPL"},
+	{PK_LICENSE_ENUM_RPSL,                 "RPSL"},
+	{PK_LICENSE_ENUM_RUBY,                 "Ruby"},
+	{PK_LICENSE_ENUM_SLEEPYCAT,            "Sleepycat"},
+	{PK_LICENSE_ENUM_SLIB,                 "SLIB"},
+	{PK_LICENSE_ENUM_SISSL,                "SISSL"},
+	{PK_LICENSE_ENUM_SPL,                  "SPL"},
+	{PK_LICENSE_ENUM_TCL,                  "TCL"},
+	{PK_LICENSE_ENUM_UCD,                  "UCD"},
+	{PK_LICENSE_ENUM_VIM,                  "Vim"},
+	{PK_LICENSE_ENUM_VNLSL,                "VNLSL"},
+	{PK_LICENSE_ENUM_VSL,                  "VSL"},
+	{PK_LICENSE_ENUM_W3C,                  "W3C"},
+	{PK_LICENSE_ENUM_WXWIDGETS,            "wxWidgets"},
+	{PK_LICENSE_ENUM_XINETD,               "xinetd"},
+	{PK_LICENSE_ENUM_ZEND,                 "Zend"},
+	{PK_LICENSE_ENUM_ZPLV1_DOT_0,          "ZPLv1.0"},
+	{PK_LICENSE_ENUM_ZPLV2_DOT_0,          "ZPLv2.0"},
+	{PK_LICENSE_ENUM_ZPLV2_DOT_1,          "ZPLv2.1"},
+	{PK_LICENSE_ENUM_ZLIB,                 "zlib "},
+	{0, NULL},
+};
+
+
 /**
  * pk_enum_find_value:
  * @table: A #PkEnumMatch enum table of values
@@ -500,6 +608,24 @@ pk_filter_enum_to_text (PkFilterEnum filter)
 	return pk_enum_find_string (enum_filter, filter);
 }
 
+/**
+ * pk_license_enum_from_text:
+ **/
+PkLicenseEnum
+pk_license_enum_from_text (const gchar *license)
+{
+	return pk_enum_find_value (enum_fsf_free_licenses, license);
+}
+
+/**
+ * pk_license_enum_to_text:
+ **/
+const gchar *
+pk_license_enum_to_text (PkLicenseEnum license)
+{
+	return pk_enum_find_string (enum_fsf_free_licenses, license);
+}
+
 /***************************************************************************
  ***                          MAKE CHECK TESTS                           ***
  ***************************************************************************/
@@ -674,6 +800,17 @@ libst_enum (LibSelfTest *test)
 	}
 	libst_success (test, NULL);
 
+	/************************************************************/
+	libst_title (test, "check we convert all the license enums");
+	for (i=0; i<=PK_LICENSE_ENUM_UNKNOWN; i++) {
+		string = pk_license_enum_to_text (i);
+		if (string == NULL) {
+			libst_failed (test, "failed to get %i", i);
+			break;
+		}
+	}
+	libst_success (test, NULL);
+
 	libst_end (test);
 }
 #endif
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index c6b290d..1557df1 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -278,6 +278,112 @@ typedef enum {
 	PK_SIGTYPE_ENUM_UNKNOWN
 } PkSigTypeEnum;
 
+typedef enum {
+	PK_LICENSE_ENUM_GLIDE,
+	PK_LICENSE_ENUM_AFL,
+	PK_LICENSE_ENUM_AMPAS_BSD,
+	PK_LICENSE_ENUM_ADOBE,
+	PK_LICENSE_ENUM_AGPLV1,
+	PK_LICENSE_ENUM_AGPLV3,
+	PK_LICENSE_ENUM_ASL_1_DOT_0,
+	PK_LICENSE_ENUM_ASL_1_DOT_1,
+	PK_LICENSE_ENUM_ASL_2_DOT_0,
+	PK_LICENSE_ENUM_APSL_2_DOT_0,
+	PK_LICENSE_ENUM_ARTISTIC_CLARIFIED,
+	PK_LICENSE_ENUM_ARTISTIC_2_DOT_0,
+	PK_LICENSE_ENUM_ARL,
+	PK_LICENSE_ENUM_BITTORRENT,
+	PK_LICENSE_ENUM_BOOST,
+	PK_LICENSE_ENUM_BSD_WITH_ADVERTISING,
+	PK_LICENSE_ENUM_BSD,
+	PK_LICENSE_ENUM_CECILL,
+	PK_LICENSE_ENUM_CDDL,
+	PK_LICENSE_ENUM_CPL,
+	PK_LICENSE_ENUM_CONDOR,
+	PK_LICENSE_ENUM_COPYRIGHT_ONLY,
+	PK_LICENSE_ENUM_CRYPTIX,
+	PK_LICENSE_ENUM_CRYSTAL_STACKER,
+	PK_LICENSE_ENUM_WTFPL,
+	PK_LICENSE_ENUM_EPL,
+	PK_LICENSE_ENUM_ECOS,
+	PK_LICENSE_ENUM_EFL_2_DOT_0,
+	PK_LICENSE_ENUM_EU_DATAGRID,
+	PK_LICENSE_ENUM_LGPLV2_WITH_EXCEPTIONS,
+	PK_LICENSE_ENUM_FTL,
+	PK_LICENSE_ENUM_GIFTWARE,
+	PK_LICENSE_ENUM_GPL_PLUS,
+	PK_LICENSE_ENUM_GPLV2,
+	PK_LICENSE_ENUM_GPLV2_WITH_EXCEPTIONS,
+	PK_LICENSE_ENUM_GPLV2_PLUS,
+	PK_LICENSE_ENUM_GPLV2_PLUS_WITH_EXCEPTIONS,
+	PK_LICENSE_ENUM_GPLV3,
+	PK_LICENSE_ENUM_GPLV3_WITH_EXCEPTIONS,
+	PK_LICENSE_ENUM_GPLV3_PLUS,
+	PK_LICENSE_ENUM_GPLV3_PLUS_WITH_EXCEPTIONS,
+	PK_LICENSE_ENUM_LGPLV2,
+	PK_LICENSE_ENUM_LGPLV2_PLUS,
+	PK_LICENSE_ENUM_LGPLV3,
+	PK_LICENSE_ENUM_LGPLV3_PLUS,
+	PK_LICENSE_ENUM_GNUPLOT,
+	PK_LICENSE_ENUM_IBM,
+	PK_LICENSE_ENUM_IMATIX,
+	PK_LICENSE_ENUM_IMAGEMAGICK,
+	PK_LICENSE_ENUM_IMLIB2,
+	PK_LICENSE_ENUM_IJG,
+	PK_LICENSE_ENUM_INTEL_ACPI,
+	PK_LICENSE_ENUM_INTERBASE,
+	PK_LICENSE_ENUM_ISC,
+	PK_LICENSE_ENUM_JABBER,
+	PK_LICENSE_ENUM_JASPER,
+	PK_LICENSE_ENUM_LPPL,
+	PK_LICENSE_ENUM_LIBTIFF,
+	PK_LICENSE_ENUM_LPL,
+	PK_LICENSE_ENUM_MECAB_IPADIC,
+	PK_LICENSE_ENUM_MIT,
+	PK_LICENSE_ENUM_MPLV1_DOT_0,
+	PK_LICENSE_ENUM_MPLV1_DOT_1,
+	PK_LICENSE_ENUM_NCSA,
+	PK_LICENSE_ENUM_NGPL,
+	PK_LICENSE_ENUM_NOSL,
+	PK_LICENSE_ENUM_NETSCAPE,
+	PK_LICENSE_ENUM_NOKIA,
+	PK_LICENSE_ENUM_OPENLDAP,
+	PK_LICENSE_ENUM_OPENPBS,
+	PK_LICENSE_ENUM_OSL_1_DOT_0,
+	PK_LICENSE_ENUM_OSL_1_DOT_1,
+	PK_LICENSE_ENUM_OSL_2_DOT_0,
+	PK_LICENSE_ENUM_OSL_3_DOT_0,
+	PK_LICENSE_ENUM_OPENSSL,
+	PK_LICENSE_ENUM_OREILLY,
+	PK_LICENSE_ENUM_GPL_PLUS_OR_ARTISTIC,
+	PK_LICENSE_ENUM_GPLV2_PLUS_OR_ARTISTIC,
+	PK_LICENSE_ENUM_PHORUM,
+	PK_LICENSE_ENUM_PHP,
+	PK_LICENSE_ENUM_PUBLIC_DOMAIN,
+	PK_LICENSE_ENUM_PYTHON,
+	PK_LICENSE_ENUM_QPL,
+	PK_LICENSE_ENUM_RPSL,
+	PK_LICENSE_ENUM_RUBY,
+	PK_LICENSE_ENUM_SLEEPYCAT,
+	PK_LICENSE_ENUM_SLIB,
+	PK_LICENSE_ENUM_SISSL,
+	PK_LICENSE_ENUM_SPL,
+	PK_LICENSE_ENUM_TCL,
+	PK_LICENSE_ENUM_UCD,
+	PK_LICENSE_ENUM_VIM,
+	PK_LICENSE_ENUM_VNLSL,
+	PK_LICENSE_ENUM_VSL,
+	PK_LICENSE_ENUM_W3C,
+	PK_LICENSE_ENUM_WXWIDGETS,
+	PK_LICENSE_ENUM_XINETD,
+	PK_LICENSE_ENUM_ZEND,
+	PK_LICENSE_ENUM_ZPLV1_DOT_0,
+	PK_LICENSE_ENUM_ZPLV2_DOT_0,
+	PK_LICENSE_ENUM_ZPLV2_DOT_1,
+	PK_LICENSE_ENUM_ZLIB,
+	PK_LICENSE_ENUM_UNKNOWN
+} PkLicenseEnum;
+
 /* general */
 guint		 pk_enum_find_value			(PkEnumMatch	*table,
 							 const gchar	*string);
@@ -320,6 +426,9 @@ const gchar	*pk_group_enum_to_text			(PkGroupEnum	 group);
 PkFilterEnum	 pk_filter_enum_from_text		(const gchar	*filter);
 const gchar	*pk_filter_enum_to_text			(PkFilterEnum	 filter);
 
+PkLicenseEnum	 pk_license_enum_from_text		(const gchar	*license);
+const gchar	*pk_license_enum_to_text		(PkLicenseEnum	 license);
+
 G_END_DECLS
 
 #endif /* __PK_ENUM_H */
diff --git a/python/enum-convertor.py b/python/enum-convertor.py
index 42958e2..eb111f2 100644
--- a/python/enum-convertor.py
+++ b/python/enum-convertor.py
@@ -9,6 +9,7 @@ inp = open("../libpackagekit/pk-enum.c").read()
 
 names = {}
 
+print "# This file was autogenerated from libpackagekit/pk-enum.c by enum-converter.py\n"
 print "class PackageKitEnum:"
 for (name,data) in enum.findall(inp):
 	print "\t%s = ("%name,
commit 94d78a29fb47893725fda890ebb32a28ff00ab9e
Author: Elliot Peele <elliot at localhost.localdomain>
Date:   Mon Dec 3 18:08:02 2007 -0500

    add some extra sanity checks

diff --git a/backends/conary/helpers/conaryCallback.py b/backends/conary/helpers/conaryCallback.py
index ce500d7..fb9e9a0 100644
--- a/backends/conary/helpers/conaryCallback.py
+++ b/backends/conary/helpers/conaryCallback.py
@@ -45,6 +45,11 @@ class UpdateCallback(callbacks.UpdateCallback):
         pass
 
     def preparingUpdate(self, troveNum, troveCount, add=0):
+        if not self.currentJob or len(self.currentJob) == 0 or troveNum > troveCount:
+            return
+
+        print "troveNum: %s, troveCount: %s" % (troveNum, troveCount)
+
         if troveNum > 0 and troveCount > 0:
             sub_percent = (add + troveNum) / (2 * float(troveCount)) * 100
             self.backend.sub_percentage(sub_percent)



More information about the PackageKit mailing list