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

Richard Hughes hughsient at kemper.freedesktop.org
Thu Nov 1 11:50:48 PDT 2007


 backends/pisi/helpers/Makefile.am     |    1 
 backends/pisi/helpers/pisiBackend.py  |  106 ++++++++++++++++++++++++++++++++--
 backends/pisi/helpers/search-group.py |   19 ++++++
 backends/pisi/pk-backend-pisi.c       |   36 ++++++++++-
 backends/yum/helpers/yumBackend.py    |  100 +++++++++++++++++++++++---------
 html/pk-faq.html                      |    2 
 python/packagekit/backend.py          |   16 -----
 7 files changed, 230 insertions(+), 50 deletions(-)

New commits:
commit 5e221352f3914f969d6e4f2c857827483693cc70
Author: Tim Lauridsen <tla at rasmil.dk>
Date:   Thu Nov 1 10:10:29 2007 +0100

    yum: make refresh-cache populate the cache with group metadata & let the search-group work in cache only

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 1b9f8b7..70cbae6 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -391,6 +391,8 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         '''
         self.allow_interrupt(True)
         self.percentage(None)
+        self.yumbase.doConfigSetup(errorlevel=0,debuglevel=0)# Setup Yum Config
+        self.yumbase.conf.cache = 1 # Only look in cache.
         try:
             pkgGroupDict = self._buildGroupDict()
             self.yumbase.conf.cache = 1 # Only look in cache.
@@ -622,7 +624,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
                 return
 
             #work out the slice for each one
-            bump = (100/len(self.yumbase.repos.listEnabled()))/2
+            bump = (95/len(self.yumbase.repos.listEnabled()))/2
 
             for repo in self.yumbase.repos.listEnabled():
                 repo.metadata_expire = 0
@@ -633,6 +635,9 @@ class PackageKitYumBackend(PackageKitBaseBackend):
                 pct+=bump
                 self.percentage(pct)
 
+            self.percentage(95)
+            # Setup categories/groups
+            self.yumbase.doGroupSetup()      
             #we might have a rounding error
             self.percentage(100)
 
@@ -994,6 +999,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         self.yumbase.conf.throttle = "40%"                        # Set bandwidth throttle to 40%
         self.dnlCallback = DownloadCallback(self,showNames=True)  # Download callback
         self.yumbase.repos.setProgressBar( self.dnlCallback )     # Setup the download callback class
+        
 
 class DownloadCallback( BaseMeter ):
     """ Customized version of urlgrabber.progress.BaseMeter class """
commit 29b747c4f12e189eaf322df482fed8613f9c029c
Author: Tim Lauridsen <tla at rasmil.dk>
Date:   Thu Nov 1 10:01:56 2007 +0100

    yum: make searcg-groups emit a ERROR_NO_CACHE the cache dont contain updated metadata

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 3ad3933..1b9f8b7 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -383,6 +383,7 @@ class PackageKitYumBackend(PackageKitBaseBackend):
                 for pkg in group.conditional_packages.keys():
                     pkgGroups[pkg] = "%s;%s" % (cat.categoryid,group.groupid)
         return pkgGroups
+            
 
     def search_group(self,filters,key):
         '''
@@ -390,33 +391,36 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         '''
         self.allow_interrupt(True)
         self.percentage(None)
-        pkgGroupDict = self._buildGroupDict()
-        self.yumbase.conf.cache = 1 # Only look in cache.
-        fltlist = filters.split(';')
-        found = {}
-
-        if not FILTER_NON_INSTALLED in fltlist:
-            # Check installed for group
-            for pkg in self.yumbase.rpmdb:
-                group = GROUP_OTHER                    # Default Group
-                if pkgGroupDict.has_key(pkg.name):     # check if pkg name exist in package / group dictinary
-                    cg = pkgGroupDict[pkg.name]
-                    if groupMap.has_key(cg):
-                        group = groupMap[cg]           # use the pk group name, instead of yum 'category/group'
-                if group == key:
-                    if self._do_extra_filtering(pkg, fltlist):
-                        self._show_package(pkg, INFO_INSTALLED)
-        if not FILTER_INSTALLED in fltlist:
-            # Check available for group
-            for pkg in self.yumbase.pkgSack:
-                group = GROUP_OTHER
-                if pkgGroupDict.has_key(pkg.name):
-                    cg = pkgGroupDict[pkg.name]
-                    if groupMap.has_key(cg):
-                        group = groupMap[cg]
-                if group == key:
-                    if self._do_extra_filtering(pkg, fltlist):
-                        self._show_package(pkg, INFO_AVAILABLE)
+        try:
+            pkgGroupDict = self._buildGroupDict()
+            self.yumbase.conf.cache = 1 # Only look in cache.
+            fltlist = filters.split(';')
+            found = {}
+    
+            if not FILTER_NON_INSTALLED in fltlist:
+                # Check installed for group
+                for pkg in self.yumbase.rpmdb:
+                    group = GROUP_OTHER                    # Default Group
+                    if pkgGroupDict.has_key(pkg.name):     # check if pkg name exist in package / group dictinary
+                        cg = pkgGroupDict[pkg.name]
+                        if groupMap.has_key(cg):
+                            group = groupMap[cg]           # use the pk group name, instead of yum 'category/group'
+                    if group == key:
+                        if self._do_extra_filtering(pkg, fltlist):
+                            self._show_package(pkg, INFO_INSTALLED)
+            if not FILTER_INSTALLED in fltlist:
+                # Check available for group
+                for pkg in self.yumbase.pkgSack:
+                    group = GROUP_OTHER
+                    if pkgGroupDict.has_key(pkg.name):
+                        cg = pkgGroupDict[pkg.name]
+                        if groupMap.has_key(cg):
+                            group = groupMap[cg]
+                    if group == key:
+                        if self._do_extra_filtering(pkg, fltlist):
+                            self._show_package(pkg, INFO_AVAILABLE)
+        except yum.Errors.RepoError,e:
+            self.error(ERROR_NO_CACHE,"Yum cache is invalid")
 
     def search_file(self,filters,key):
         '''
commit cee138ad07bbb271f969a74ae87e52fa666368b1
Author: Tim Lauridsen <tla at rasmil.dk>
Date:   Thu Nov 1 09:44:07 2007 +0100

    yum: move UTF convertion to yumBackend, so it don't break other backends (PiSi)

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 04939cf..3ad3933 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -212,6 +212,42 @@ class PackageKitYumBackend(PackageKitBaseBackend):
         if lock:
             self.doLock()
 
+    def description(self,id,licence,group,desc,url,bytes,file_list):
+        '''
+        Send 'description' signal
+        @param id: The package ID name, e.g. openoffice-clipart;2.6.22;ppc64;fedora
+        @param licence: The licence of the package
+        @param group: The enumerated group
+        @param desc: The multi line package description
+        @param url: The upstream project homepage
+        @param bytes: The size of the package, in bytes
+        @param file_list: List of the files in the package, separated by ';'
+        '''
+        desc = self._toUTF(desc)
+        PackageKitBaseBackend.description(self,id,licence,group,desc,url,bytes,file_list)
+
+    def package(self,id,status,summary):
+        '''
+        send 'package' signal
+        @param info: the enumerated INFO_* string
+        @param id: The package ID name, e.g. openoffice-clipart;2.6.22;ppc64;fedora
+        @param summary: The package Summary
+        '''
+        summary = self._toUTF(summary)
+        PackageKitBaseBackend.package(self,id,status,summary)
+
+    def _toUTF( self, txt ):
+        rc=""
+        if isinstance(txt,types.UnicodeType):
+            return txt
+        else:
+            try:
+                rc = unicode( txt, 'utf-8' )
+            except UnicodeDecodeError, e:
+                rc = unicode( txt, 'iso-8859-1' )
+            return rc
+
+
     def doLock(self):
         ''' Lock Yum'''
         retries = 0
diff --git a/python/packagekit/backend.py b/python/packagekit/backend.py
index 9c38a9e..e0285ef 100644
--- a/python/packagekit/backend.py
+++ b/python/packagekit/backend.py
@@ -157,7 +157,6 @@ class PackageKitBaseBackend:
         @param id: The package ID name, e.g. openoffice-clipart;2.6.22;ppc64;fedora
         @param summary: The package Summary
         '''
-        summary = self._toUTF(summary)
         print >> sys.stdout,"package\t%s\t%s\t%s" % (status,id,summary)
 
     def status(self,state):
@@ -193,7 +192,6 @@ class PackageKitBaseBackend:
         @param bytes: The size of the package, in bytes
         @param file_list: List of the files in the package, separated by ';'
         '''
-        desc = self._toUTF(desc)
         print >> sys.stdout,"description\t%s\t%s\t%s\t%s\t%s\t%ld\t%s" % (id,licence,group,desc,url,bytes,file_list)
 
     def files(self, id, file_list):
@@ -257,19 +255,7 @@ class PackageKitBaseBackend:
             containing (name,ver,arch,data)
         '''
         return tuple(id.split(';', 4))
-        
-
-    def _toUTF( self, txt ):
-        rc=""
-        if isinstance(txt,types.UnicodeType):
-            return txt
-        else:
-            try:
-                rc = unicode( txt, 'utf-8' )
-            except UnicodeDecodeError, e:
-                rc = unicode( txt, 'iso-8859-1' )
-            return rc
-        
+       
 #
 # Backend Action Methods
 #
commit 5ef2114adeaf90805dde45da70fecaff7bc83f6e
Author: S.Çağlar Onur <caglar at pardus.org.tr>
Date:   Thu Nov 1 09:47:37 2007 +0200

    PiSi: implement search_group and get_group

diff --git a/backends/pisi/helpers/Makefile.am b/backends/pisi/helpers/Makefile.am
index b9eef2f..d657cc1 100644
--- a/backends/pisi/helpers/Makefile.am
+++ b/backends/pisi/helpers/Makefile.am
@@ -17,6 +17,7 @@ dist_helper_DATA = 			\
 	resolve.py			\
 	repo-set-data.py		\
 	search-file.py			\
+	search-group.py			\
 	search-name.py			\
 	update.py			\
 	update-system.py		\
diff --git a/backends/pisi/helpers/pisiBackend.py b/backends/pisi/helpers/pisiBackend.py
index 9e2e9de..9ba6999 100644
--- a/backends/pisi/helpers/pisiBackend.py
+++ b/backends/pisi/helpers/pisiBackend.py
@@ -23,6 +23,81 @@ from packagekit.backend import *
 
 class PackageKitPisiBackend(PackageKitBaseBackend):
 
+    # It's an ugly way to sync with PK Groups and PiSi Components
+    # Maybe we can provide these with our index?
+    groups = {
+            "applications" : GROUP_UNKNOWN,
+            "applications.admin" : GROUP_ADMIN_TOOLS,
+            "applications.archive" : GROUP_UNKNOWN,
+            "applications.crypto" : GROUP_SECURITY,
+            "applications.doc" : GROUP_PUBLISHING,
+            "applications.doc.docbook" : GROUP_PUBLISHING,
+            "applications.editors" : GROUP_ACCESSORIES,
+            "applications.editors.emacs" : GROUP_ACCESSORIES,
+            "applications.emulators" : GROUP_UNKNOWN,
+            "applications.filesystems" : GROUP_UNKNOWN,
+            "applications.games" : GROUP_GAMES,
+            "applications.hardware" : GROUP_UNKNOWN,
+            "applications.multimedia" : GROUP_MULTIMEDIA,
+            "applications.network" : GROUP_INTERNET,
+            "applications.network.mozilla" : GROUP_INTERNET,
+            "applications.pda" : GROUP_ACCESSORIES,
+            "applications.powermanagement" : GROUP_UNKNOWN,
+            "applications.printing" : GROUP_PUBLISHING,
+            "applications.science" : GROUP_EDUCATION,
+            "applications.science.astronomy" : GROUP_EDUCATION,
+            "applications.science.electronics" : GROUP_EDUCATION,
+            "applications.science.mathematics" : GROUP_EDUCATION,
+            "applications.security" : GROUP_SECURITY,
+            "applications.shells" : GROUP_UNKNOWN,
+            "applications.tex" : GROUP_PUBLISHING,
+            "applications.util" : GROUP_ACCESSORIES,
+            "applications.virtualization" : GROUP_VIRTUALIZATION,
+            "desktop.fonts" : GROUP_FONTS,
+            "desktop.freedesktop" : GROUP_DESKTOPS,
+            "desktop.freedesktop.inputmethods" : GROUP_LOCALIZATION,
+            "desktop.freedesktop.xorg" : GROUP_DESKTOPS,
+            "desktop.freedesktop.xorg.lib" : GROUP_DESKTOPS,
+            "desktop.gnome" : GROUP_DESKTOPS,
+            "desktop.kde" : GROUP_DESKTOPS,
+            "desktop.kde.base" : GROUP_DESKTOPS,
+            "desktop.kde.i18n" : GROUP_LOCALIZATION,
+            "kernel" : GROUP_SYSTEM,
+            "kernel.drivers" : GROUP_SYSTEM,
+            "kernel.firmware" : GROUP_SYSTEM,
+            "kernel-xen" : GROUP_VIRTUALIZATION,
+            "kernel-xen.dom0" : GROUP_VIRTUALIZATION,
+            "kernel-xen.dom0.drivers" : GROUP_VIRTUALIZATION,
+            "kernel-xen.dom0.firmware" : GROUP_VIRTUALIZATION,
+            "kernel-xen.domU" : GROUP_VIRTUALIZATION,
+            "programming" : GROUP_PROGRAMMING,
+            "programming.environments" : GROUP_PROGRAMMING,
+            "programming.environments.eclipse" : GROUP_PROGRAMMING,
+            "programming.languages" : GROUP_PROGRAMMING,
+            "programming.languages.dotnet" : GROUP_PROGRAMMING,
+            "programming.languages.gambas" : GROUP_PROGRAMMING,
+            "programming.languages.haskell" : GROUP_PROGRAMMING,
+            "programming.languages.java" : GROUP_PROGRAMMING,
+            "programming.languages.lisp" : GROUP_PROGRAMMING,
+            "programming.languages.pascal" : GROUP_PROGRAMMING,
+            "programming.languages.perl" : GROUP_PROGRAMMING,
+            "programming.languages.php" : GROUP_PROGRAMMING,
+            "programming.languages.python" : GROUP_PROGRAMMING,
+            "programming.languages.tcl" : GROUP_PROGRAMMING,
+            "programming.libs" : GROUP_PROGRAMMING,
+            "programming.tools" : GROUP_PROGRAMMING,
+            "server" : GROUP_SERVERS,
+            "server.database" : GROUP_SERVERS,
+            "server.mail" : GROUP_SERVERS,
+            "server.nis" : GROUP_SERVERS,
+            "server.www" : GROUP_SERVERS,
+            "system" : GROUP_SYSTEM,
+            "system.base" : GROUP_SYSTEM,
+            "system.devel" : GROUP_PROGRAMMING,
+            "system.doc" : GROUP_SYSTEM,
+            "system.locale" : GROUP_LOCALIZATION
+        }
+
     def __init__(self, args):
         PackageKitBaseBackend.__init__(self, args)
 
@@ -32,6 +107,10 @@ class PackageKitPisiBackend(PackageKitBaseBackend):
         self.packagedb = pisi.db.packagedb.PackageDB()
         self.repodb = pisi.db.repodb.RepoDB()
 
+        # Do not ask any question to users
+        self.options = pisi.config.Options()
+        self.options.yes_all = True
+
     def __get_package_version(self, package):
         """ Returns version string of given package """
         # Internal FIXME: PiSi may provide this
@@ -52,7 +131,7 @@ class PackageKitPisiBackend(PackageKitBaseBackend):
         else:
             self.error(ERROR_INTERNAL_ERROR, "Package was not found")
 
-        if filters:
+        if filters or "none" not in filters:
             filterlist = filters.split(';')
 
             if FILTER_INSTALLED in filterlist and status != INFO_INSTALLED:
@@ -86,9 +165,15 @@ class PackageKitPisiBackend(PackageKitBaseBackend):
 
         if self.packagedb.has_package(package):
             pkg = self.packagedb.get_package(package)
+
+            if self.groups.has_key(pkg.partOf):
+                group = self.groups[pkg.partOf]
+            else:
+                group = GROUP_UNKNOWN
+
             self.description("%s-%s" % (pkg.name, self.__get_package_version(pkg)),
                             pkg.license,
-                            pkg.partOf,
+                            group,
                             pkg.description,
                             pkg.packageURI,
                             pkg.packageSize, "")
@@ -104,15 +189,13 @@ class PackageKitPisiBackend(PackageKitBaseBackend):
 
         if self.installdb.has_package(package):
             pkg = self.installdb.get_files(package)
-            
+
             # FIXME: Add "/" as suffix
             files = map(lambda y: y.path, pkg.list)
 
             file_list = ";".join(files)
 
             self.files(package, file_list)
-        else:
-            self.error(ERROR_INTERNAL_ERROR, "Package was not found")
 
     def get_repo_list(self):
         """ Prints available repositories """
@@ -260,6 +343,19 @@ class PackageKitPisiBackend(PackageKitBaseBackend):
         for pkg, files in pisi.api.search_file(key):
             self.__get_package(pkg)
 
+    def search_group(self, filters, group):
+        """ Prints a list of packages contains search term """
+        self.allow_interrupt(True)
+        self.percentage(None)
+
+        try:
+            for key in self.groups.keys():
+                if self.groups[key] == group:
+                    for pkg in self.componentdb.get_packages(key, walk = True):
+                        self.__get_package(pkg, filters)
+        except:
+            self.error(ERROR_INTERNAL_ERROR, "Component %s was not found" % group)
+
     def search_name(self, filters, package):
         """ Prints a list of packages contains search term """
         self.allow_interrupt(True)
diff --git a/backends/pisi/helpers/search-group.py b/backends/pisi/helpers/search-group.py
new file mode 100644
index 0000000..064149b
--- /dev/null
+++ b/backends/pisi/helpers/search-group.py
@@ -0,0 +1,19 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2007 S.Çağlar Onur <caglar at pardus.org.tr>
+#
+# Licensed under the GNU General Public License Version 2
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+import sys
+import pisiBackend
+
+backend = pisiBackend.PackageKitPisiBackend(sys.argv[1:])
+backend.search_group(sys.argv[1], sys.argv[2])
+
+sys.exit()
diff --git a/backends/pisi/pk-backend-pisi.c b/backends/pisi/pk-backend-pisi.c
index 0aa410e..2af9f50 100644
--- a/backends/pisi/pk-backend-pisi.c
+++ b/backends/pisi/pk-backend-pisi.c
@@ -24,6 +24,38 @@
 #include <pk-backend-python.h>
 
 /**
+ * backend_get_groups:
+ */
+static void
+backend_get_groups (PkBackend *backend, PkEnumList *elist)
+{
+	g_return_if_fail (backend != NULL);
+	pk_enum_list_append_multiple (elist,
+				         /* PK_GROUP_ENUM_ACCESSIBILITY, */
+				         PK_GROUP_ENUM_ACCESSORIES,
+				         PK_GROUP_ENUM_EDUCATION,
+				         PK_GROUP_ENUM_GAMES,
+				         /* PK_GROUP_ENUM_GRAPHICS, */
+				         PK_GROUP_ENUM_INTERNET,
+				         /* PK_GROUP_ENUM_OFFICE, */
+				         /* PK_GROUP_ENUM_OTHER, */
+				         PK_GROUP_ENUM_PROGRAMMING,
+				         PK_GROUP_ENUM_MULTIMEDIA,
+				         PK_GROUP_ENUM_SYSTEM,
+				         PK_GROUP_ENUM_DESKTOPS,
+				         PK_GROUP_ENUM_PUBLISHING,
+				         PK_GROUP_ENUM_SERVERS,
+				         PK_GROUP_ENUM_FONTS,
+				         PK_GROUP_ENUM_ADMIN_TOOLS,
+				         /* PK_GROUP_ENUM_LEGACY, */
+				         PK_GROUP_ENUM_LOCALIZATION,
+				         PK_GROUP_ENUM_VIRTUALIZATION,
+				         PK_GROUP_ENUM_SECURITY,
+				         PK_GROUP_ENUM_UNKNOWN,
+				         -1);
+}
+
+/**
  * backend_get_filters:
  */
 static void
@@ -42,7 +74,7 @@ PK_BACKEND_OPTIONS (
 	"S.Çağlar Onur <caglar at pardus.org.tr>",		/* author */
 	NULL,						/* initalize */
 	NULL,						/* destroy */
-	NULL,						/* get_groups */
+	backend_get_groups,				/* get_groups */
 	backend_get_filters,				/* get_filters */
 	pk_backend_python_cancel,			/* cancel */
 	pk_backend_python_get_depends,			/* get_depends */
@@ -59,7 +91,7 @@ PK_BACKEND_OPTIONS (
 	NULL,						/* rollback */
 	NULL,						/* search_details */
 	pk_backend_python_search_file,			/* search_file */
-	NULL,						/* search_group */
+	pk_backend_python_search_group,			/* search_group */
 	pk_backend_python_search_name,			/* search_name */
 	pk_backend_python_update_package,		/* update_package */
 	pk_backend_python_update_system,		/* update_system */
diff --git a/html/pk-faq.html b/html/pk-faq.html
index ff4c7b0..82a7849 100644
--- a/html/pk-faq.html
+++ b/html/pk-faq.html
@@ -32,7 +32,7 @@ update-system     |   X    |  X  |     |  X  |      |   X   |   X  |
 search-name       |   X    |  X  |  X  |  X  |  X   |   X   |   X  |
 search-details    |        |  X  |  X  |  X  |      |       |      |
 search-file       |        |  X  |     |  X  |      |       |   X  |
-search-group      |        |  X  |     |     |      |       |      |
+search-group      |        |  X  |     |     |      |       |   X  |
 install-package   |   X    |  X  |     |  X  |  X   |   X   |   X  |
 install-file      |        |  X  |     |  X  |      |       |   X  |
 remove-package    |   X    |  X  |     |  X  |  X   |   X   |   X  |



More information about the PackageKit mailing list