[PackageKit-commit] packagekit: Branch 'master' - 13 commits

Richard Hughes hughsient at kemper.freedesktop.org
Mon Sep 1 05:29:20 PDT 2008


 backends/apt/aptDBUSBackend.py          |  180 ++++++++++++++++++++++++++++++--
 backends/apt/pk-backend-apt.c           |   23 +++-
 backends/smart/helpers/Makefile.am      |    2 
 backends/smart/helpers/repo-set-data.py |   22 +++
 backends/smart/helpers/smartBackend.py  |   18 +++
 backends/smart/helpers/what-provides.py |   23 ++++
 backends/smart/pk-backend-smart.c       |   27 ++++
 configure.ac                            |    4 
 docs/html/pk-download.html              |    9 +
 docs/html/pk-matrix.html                |   22 +--
 libpackagekit/egg-obj-list.c            |    8 -
 src/pk-backend-dbus.c                   |    2 
 12 files changed, 307 insertions(+), 33 deletions(-)

New commits:
commit d00219c36df6c8202687b09aee2d5f625874e86c
Merge: d2b18ce... d44ef68...
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Sep 1 12:52:30 2008 +0100

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

commit d2b18ce3e8f4feb899a2d2057310f967cff3be02
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Sep 1 12:51:16 2008 +0100

    bugfix: fix a compile warning in egg-obj-list.c

diff --git a/configure.ac b/configure.ac
index 0e83b62..2029230 100644
--- a/configure.ac
+++ b/configure.ac
@@ -50,8 +50,8 @@ dnl - Extra verbose warning switches
 dnl ---------------------------------------------------------------------------
 if test "$GCC" = "yes"; then
 	CPPFLAGS="$CPPFLAGS -Werror -Wcast-align -Wno-uninitialized"
-#	CPPFLAGS="$CPPFLAGS -Wall -Wformat-security"
-	CPPFLAGS="$CPPFLAGS -Wall"
+	CPPFLAGS="$CPPFLAGS -Wall -Wformat-security -Wreturn-type"
+#	CPPFLAGS="$CPPFLAGS -Wall"
 fi
 
 dnl ---------------------------------------------------------------------------
diff --git a/libpackagekit/egg-obj-list.c b/libpackagekit/egg-obj-list.c
index cd12df2..0a534ac 100644
--- a/libpackagekit/egg-obj-list.c
+++ b/libpackagekit/egg-obj-list.c
@@ -134,19 +134,19 @@ egg_obj_list_add (EggObjList *list, const gpointer obj)
 /**
  * egg_obj_list_index:
  * @list: a valid #EggObjList instance
- * @id: A #EggPackageId of the item to match
+ * @index: the element to return
  *
  * Gets an object from the list
  **/
 const gpointer
-egg_obj_list_index (EggObjList *list, guint i)
+egg_obj_list_index (EggObjList *list, guint index)
 {
 	gpointer obj;
 
 	g_return_val_if_fail (EGG_IS_OBJ_LIST (list), NULL);
 
-	obj = g_ptr_array_index (list->priv->array, i);
-	return obj;
+	obj = g_ptr_array_index (list->priv->array, index);
+	return (const gpointer) obj;
 }
 
 /**
commit d44ef688c47f3ace87f54714ff1d69fb375cfe9c
Author: Sebastian Heinlein <devel at glatzor.de>
Date:   Mon Sep 1 12:16:09 2008 +0200

    Add a more detailed instruction to get the latest PackageKit on Ubuntu

diff --git a/docs/html/pk-download.html b/docs/html/pk-download.html
index 75e2d35..5c4e358 100644
--- a/docs/html/pk-download.html
+++ b/docs/html/pk-download.html
@@ -32,8 +32,13 @@ easier to install.
    Fedora 9: Yes, just run: <code>yum install PackageKit gnome-packagekit</code> (as root)
   </li>
   <li>
-   Ubuntu: Yes, just run: <code>apt-get install PackageKit gnome-packagekit</code> (as root).
-   With hardy expect the obsolete 0.1.6 release, but intrepid has the stable 0.2.4 release.
+  Ubuntu: Ubuntu 8.04 Hardy Heron ships an obsolete version (0.1.6) of PackageKit by default.
+  Intrepid, the upcoming Ubuntu release, features 0.2.4, but we plan to ship 0.3.2.<br>
+  You can find the latest version of the 0.3 series for Hardy and Intrepid in this 
+  <a href="https://edge.launchpad.net/~packagekit/+archive">Personal Package Archive</a>.
+  <a href="https://help.ubuntu.com/8.04/add-applications/C/extra-repositories-adding.html">Add</a> 
+  the repository and <a hfref="https://help.ubuntu.com/8.04/add-applications/C/advanced.html">
+  install</a> the packages <code>packagekit</code> and <code>gnome-packagekit</code>.
   </li>
   <li>
    openSUSE 11: Yes, add <a href="http://download.opensuse.org/distribution/SL-OSS-factory/inst-source">this</a>
commit 19b457c095364b768e41af6cc0f6e030d02d823c
Merge: f99548f... 359b0f5...
Author: Sebastian Heinlein <devel at glatzor.de>
Date:   Mon Sep 1 12:01:06 2008 +0200

    Merge branch 'master' into glatzor

commit f99548f8739e45dbb61e7be5d9e72665d6565184
Author: Sebastian Heinlein <devel at glatzor.de>
Date:   Mon Sep 1 11:58:38 2008 +0200

    Update feature matrix for APT.

diff --git a/docs/html/pk-matrix.html b/docs/html/pk-matrix.html
index ed11f7b..57e21e3 100644
--- a/docs/html/pk-matrix.html
+++ b/docs/html/pk-matrix.html
@@ -306,7 +306,7 @@
 </tr>
 <tr>
 <td><b>GetRepoList</b></td>
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- apt -->
+<td><img src="img/status-good.png" alt="[yes]"/></td><!-- apt -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- alpm -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- box -->
 <td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary -->
@@ -321,7 +321,7 @@
 </tr>
 <tr>
 <td><b>RepoEnable</b></td>
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- apt -->
+<td><img src="img/status-good.png" alt="[yes]"/></td><!-- apt -->
 <td><img src="img/status-bad.png" alt="[no]"/></td><!-- alpm -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- box -->
 <td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary -->
commit 5d1ef0896913f8980d96978a9027552a448799bf
Author: Sebastian Heinlein <devel at glatzor.de>
Date:   Mon Sep 1 11:57:44 2008 +0200

    APT: Implement RepoEnable()

diff --git a/backends/apt/aptDBUSBackend.py b/backends/apt/aptDBUSBackend.py
index 45acedd..6974740 100755
--- a/backends/apt/aptDBUSBackend.py
+++ b/backends/apt/aptDBUSBackend.py
@@ -365,6 +365,14 @@ class PackageKitDpkgInstallProgress(DpkgInstallProgress,
             os.write(self.master_fd, chr(3))
 
 
+class PackageKitSoftwareProperties(softwareproperties.SoftwareProperties.SoftwareProperties):
+    """
+    Helper class to fix a siily bug in python-software-properties
+    """
+    def set_modified_sourceslist(self):
+        self.save_sourceslist()
+
+
 class PackageKitAptBackend(PackageKitBaseBackend):
     '''
     PackageKit backend for apt
@@ -782,7 +790,7 @@ class PackageKitAptBackend(PackageKitBaseBackend):
             self.Finished(EXIT_KILLED)
             return
         filter_list = filters.split(";")
-        repos = softwareproperties.SoftwareProperties.SoftwareProperties()
+        repos = PackageKitSoftwareProperties()
         # Emit distro components as virtual repositories
         for comp in repos.distro.source_template.components:
             repo_id = "%s_comp_%s" % (repos.distro.id, comp.name)
@@ -802,7 +810,7 @@ class PackageKitAptBackend(PackageKitBaseBackend):
                                                template.description,
                                                template.name)
             #FIXME: There is no inconsitent state in PackageKit
-            enabled = repos.get_comp_child_state(comp)[0]
+            enabled = repos.get_comp_child_state(template)[0]
             if not FILTER_DEVELOPMENT in filter_list:
                 self.RepoDetail(repo_id, description, enabled)
         # Emit distro's virtual source code repositoriy
@@ -829,6 +837,80 @@ class PackageKitAptBackend(PackageKitBaseBackend):
 
     @threaded
     @async
+    def doRepoEnable(self, repo_id, enable):
+        '''
+        Implement the {backend}-repo-enable functionality
+
+        FIXME: should we use the abstration of software-properties or provide
+               low level access using pure aptsources?
+        '''
+        pklog.info("Enabling repository: %s %s" % (repo_id, enable))
+        self.StatusChanged(STATUS_RUNNING)
+        self.AllowCancel(False)
+        self.PercentageChanged(0)
+        if REPOS_SUPPORT == False:
+            if self._cache.has_key("python-software-properties") and \
+               self._cache["python-software-properties"].isInstalled == False:
+                self.ErrorCode(ERROR_UNKNOWN,
+                               "Please install the package "
+                               "python-software-properties to handle repositories")
+            else:
+                self.ErrorCode(ERROR_UNKNOWN,
+                               "Please make sure that python-software-properties is"
+                               "correctly installed.")
+            self.Finished(EXIT_KILLED)
+            return
+        repos = PackageKitSoftwareProperties()
+
+        found = False
+        # Check if the repo_id matches a distro component, e.g. main
+        if repo_id.startswith("%s_comp_" % repos.distro.id):
+            for comp in repos.distro.source_template.components:
+                if repo_id == "%s_comp_%s" % (repos.distro.id, comp.name):
+                    if enable == repos.get_comp_download_state(comp)[0]:
+                        pklog.debug("Repository is already enabled")
+                        pass
+                    if enable == True:
+                        repos.enable_component(comp.name)
+                    else:
+                        repos.disable_component(comp.name)
+                    found = True
+                    break
+        # Check if the repo_id matches a distro child repository, e.g. hardy-updates
+        elif repo_id.startswith("%s_child_" % repos.distro.id):
+            for template in repos.distro.source_template.children:
+                if repo_id == "%s_child_%s" % (repos.distro.id, template.name):
+                    if enable == repos.get_comp_child_state(template)[0]:
+                        pklog.debug("Repository is already enabled")
+                        pass
+                    elif enable == True:
+                        repos.enable_child_source(template)
+                    else:
+                        repos.disable_child_source(template)
+                    found = True
+                    break
+        # Check if the repo_id matches an isv repository
+        elif repo_id.startswith("isv_"):
+            for source in repos.get_isv_sources():
+                source_id = "isv_%s_%s" % (source.uri, source.dist)
+                source_id.join(map(lambda c: "_%s" % c, source.comps))
+                if repo_id == source_id:
+                    if source.disabled == enable:
+                        source.disabled = not enable
+                        repos.save_sourceslist()
+                    else:
+                        pklog.debug("Repository is already enabled")
+                    found = True
+                    break
+        if found == False:
+            self.ErrorCode(ERROR_REPO_NOT_AVAILABLE,
+                           "The repository of the id %s isn't available" % repo_id)
+            self.Finished(EXIT_FAILED)
+            return
+        self.Finished(EXIT_SUCCESS)
+
+    @threaded
+    @async
     def doUpdatePackages(self, ids):
         '''
         Implement the {backend}-update functionality
diff --git a/backends/apt/pk-backend-apt.c b/backends/apt/pk-backend-apt.c
index e292174..7f51e65 100644
--- a/backends/apt/pk-backend-apt.c
+++ b/backends/apt/pk-backend-apt.c
@@ -314,6 +314,16 @@ backend_what_provides (PkBackend *backend, PkBitfield filters, PkProvidesEnum pr
 	        pk_backend_dbus_what_provides (dbus, filters, provides, search);
 }
 
+/**
+ *  * pk_backend_repo_enable
+ *   */
+static void
+backend_repo_enable (PkBackend *backend, const gchar *repo_id, gboolean enable )
+{
+	        pk_backend_dbus_repo_enable (dbus, repo_id, enable);
+}
+
+
 
 PK_BACKEND_OPTIONS (
 	"Apt",					/* description */
@@ -338,7 +348,7 @@ PK_BACKEND_OPTIONS (
 	NULL,					/* install_signature */
 	backend_refresh_cache,			/* refresh_cache */
 	backend_remove_packages,		/* remove_packages */
-	NULL,					/* repo_enable */
+	backend_repo_enable,			/* repo_enable */
 	NULL,					/* repo_set_data */
 	backend_resolve,			/* resolve */
 	NULL,					/* rollback */
commit 359b0f57fe00dfd086b9be1718574da8bd949617
Author: Anders F Bjorklund <afb at users.sourceforge.net>
Date:   Mon Sep 1 11:00:36 2008 +0200

    Update feature matrix for smart.

diff --git a/docs/html/pk-matrix.html b/docs/html/pk-matrix.html
index ed11f7b..81cab0b 100644
--- a/docs/html/pk-matrix.html
+++ b/docs/html/pk-matrix.html
@@ -148,7 +148,7 @@
 <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- smart -->
+<td><img src="img/status-good.png" alt="[yes]"/></td><!-- smart -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- urpmi -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum2 -->
@@ -163,7 +163,7 @@
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- opkg -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- smart -->
+<td><img src="img/status-good.png" alt="[yes]"/></td><!-- smart -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- urpmi -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum2 -->
@@ -253,7 +253,7 @@
 <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- smart -->
+<td><img src="img/status-good.png" alt="[yes]"/></td><!-- smart -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- urpmi -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum2 -->
@@ -343,7 +343,7 @@
 <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi -->
 <td><img src="img/status-bad.png" alt="[no]"/></td><!-- poldek -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- smart -->
+<td><img src="img/status-good.png" alt="[yes]"/></td><!-- smart -->
 <td><img src="img/status-bad.png" alt="[no]"/></td><!-- urpmi -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum2 -->
@@ -388,7 +388,7 @@
 <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg -->
 <td><img src="img/status-bad.png" alt="[no]"/></td><!-- pisi -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- smart -->
+<td><img src="img/status-good.png" alt="[yes]"/></td><!-- smart -->
 <td><img src="img/status-bad.png" alt="[no]"/></td><!-- urpmi -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum -->
 <td><img src="img/status-bad.png" alt="[no]"/></td><!-- yum2 -->
@@ -403,7 +403,7 @@
 <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg -->
 <td><img src="img/status-bad.png" alt="[no]"/></td><!-- pisi -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- smart -->
+<td><img src="img/status-good.png" alt="[yes]"/></td><!-- smart -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- urpmi -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum -->
 <td><img src="img/status-bad.png" alt="[no]"/></td><!-- yum2 -->
@@ -452,7 +452,7 @@
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- opkg -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- smart -->
+<td><img src="img/status-good.png" alt="[yes]"/></td><!-- smart -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- urpmi -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum2 -->
@@ -467,7 +467,7 @@
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- opkg -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- pisi -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- poldek -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- smart -->
+<td><img src="img/status-good.png" alt="[yes]"/></td><!-- smart -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- urpmi -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum2 -->
@@ -482,7 +482,7 @@
 <td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg -->
 <td><img src="img/status-bad.png" alt="[no]"/></td><!-- pisi -->
 <td><img src="img/status-bad.png" alt="[no]"/></td><!-- poldek -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- smart -->
+<td><img src="img/status-good.png" alt="[yes]"/></td><!-- smart -->
 <td><img src="img/status-bad.png" alt="[no]"/></td><!-- urpmi -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum -->
 <td><img src="img/status-bad.png" alt="[no]"/></td><!-- yum2 -->
commit 95a997c08c0f4faa7b999552b160e3d545b31456
Author: Anders F Bjorklund <afb at users.sourceforge.net>
Date:   Mon Sep 1 10:51:10 2008 +0200

    smart: add repo_set_data

diff --git a/backends/smart/helpers/Makefile.am b/backends/smart/helpers/Makefile.am
index 3020376..bceff02 100644
--- a/backends/smart/helpers/Makefile.am
+++ b/backends/smart/helpers/Makefile.am
@@ -16,6 +16,7 @@ dist_helper_DATA = 			\
 	refresh-cache.py		\
 	remove-packages.py		\
 	repo-enable.py			\
+	repo-set-data.py		\
 	resolve.py			\
 	search-name.py			\
 	search-file.py			\
diff --git a/backends/smart/helpers/repo-set-data.py b/backends/smart/helpers/repo-set-data.py
new file mode 100755
index 0000000..221e4ac
--- /dev/null
+++ b/backends/smart/helpers/repo-set-data.py
@@ -0,0 +1,22 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
+# Copyright (C) 2007 James Bowes <jbowes at dangerouslyinc.com>
+#
+# 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
+
+from smartBackend import PackageKitSmartBackend
+
+repoid = sys.argv[1]
+para=sys.argv[2]
+value=sys.argv[3]
+backend = PackageKitSmartBackend(sys.argv[2:])
+backend.repo_set_data(repoid,para,value)
+sys.exit(0)
diff --git a/backends/smart/helpers/smartBackend.py b/backends/smart/helpers/smartBackend.py
index a01ca32..aff0c8c 100644
--- a/backends/smart/helpers/smartBackend.py
+++ b/backends/smart/helpers/smartBackend.py
@@ -537,6 +537,14 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
         else:
             self.error(ERROR_REPO_NOT_FOUND, "repo %s was not found" % repoid)
 
+    def repo_set_data(self, repoid, param, value):
+        self.status(STATUS_INFO)
+        if smart.sysconf.has(("channels", repoid)):
+            smart.sysconf.set(("channels", repoid, param), value)
+            self.ctrl.saveSysConf()
+        else:
+            self.error(ERROR_REPO_NOT_FOUND, "repo %s was not found" % repoid)
+
     systemchannel = None # unfortunately package strings depend on system
 
     def _splitpackage(self, package):
diff --git a/backends/smart/pk-backend-smart.c b/backends/smart/pk-backend-smart.c
index 51c9a43..0290b18 100644
--- a/backends/smart/pk-backend-smart.c
+++ b/backends/smart/pk-backend-smart.c
@@ -386,6 +386,15 @@ backend_repo_enable (PkBackend *backend, const gchar *rid, gboolean enabled)
 }
 
 /**
+ * pk_backend_repo_set_data:
+ */
+static void
+backend_repo_set_data (PkBackend *backend, const gchar *rid, const gchar *parameter, const gchar *value)
+{
+	pk_backend_spawn_helper (spawn, "repo-set-data.py", rid, parameter, value, NULL);
+}
+
+/**
  * pk_backend_what_provides:
  */
 static void
@@ -423,7 +432,7 @@ PK_BACKEND_OPTIONS (
 	backend_refresh_cache,				/* refresh_cache */
 	backend_remove_packages,			/* remove_packages */
 	backend_repo_enable,				/* repo_enable */
-	NULL,						/* repo_set_data */
+	backend_repo_set_data,				/* repo_set_data */
 	backend_resolve,				/* resolve */
 	NULL,						/* rollback */
 	backend_search_details,				/* search_details */
commit 3902eb012de0eee2eff9ec4774838574126276ea
Merge: 2c74182... fdaf81a...
Author: Anders F Bjorklund <afb at users.sourceforge.net>
Date:   Mon Sep 1 10:31:31 2008 +0200

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

commit 2c7418266f11efc6657bffa059721e3d178fa10b
Author: Anders F Bjorklund <afb at users.sourceforge.net>
Date:   Mon Sep 1 10:31:11 2008 +0200

    smart: add what_provides

diff --git a/backends/smart/helpers/Makefile.am b/backends/smart/helpers/Makefile.am
index 3291cf5..3020376 100644
--- a/backends/smart/helpers/Makefile.am
+++ b/backends/smart/helpers/Makefile.am
@@ -25,6 +25,7 @@ dist_helper_DATA = 			\
 	update-packages.py		\
 	update-system.py		\
 	download-packages.py		\
+	what-provides.py		\
 	$(NULL)
 
 install-data-hook:
diff --git a/backends/smart/helpers/smartBackend.py b/backends/smart/helpers/smartBackend.py
index ff6b200..a01ca32 100644
--- a/backends/smart/helpers/smartBackend.py
+++ b/backends/smart/helpers/smartBackend.py
@@ -290,6 +290,16 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
             if self._passes_filters(package, filters):
                 self._show_package(package)
 
+    @needs_cache
+    def what_provides(self, filters, provides_type, search):
+        self.status(STATUS_QUERY)
+        # FIXME: provides_type is not used (== PROVIDES_ANY)
+        providers = self.ctrl.getCache().getProvides(search)
+        for provider in providers:
+            for package in provider.packages:
+                if self._passes_filters(package, filters):
+                    self._show_package(package)
+
     def refresh_cache(self):
         self.status(STATUS_REFRESH_CACHE)
         self.ctrl.rebuildSysConfChannels()
diff --git a/backends/smart/helpers/what-provides.py b/backends/smart/helpers/what-provides.py
new file mode 100755
index 0000000..d5ec4ba
--- /dev/null
+++ b/backends/smart/helpers/what-provides.py
@@ -0,0 +1,23 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
+# Copyright (C) 2007 James Bowes <jbowes at dangerouslyinc.com>
+#
+# 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
+
+from smartBackend import PackageKitSmartBackend
+
+filters = sys.argv[1]
+provides_type = sys.argv[2]
+search = sys.argv[3]
+
+backend = PackageKitSmartBackend(sys.argv[1:])
+backend.what_provides(filters, provides_type, search)
+sys.exit(0)
diff --git a/backends/smart/pk-backend-smart.c b/backends/smart/pk-backend-smart.c
index e17ad59..51c9a43 100644
--- a/backends/smart/pk-backend-smart.c
+++ b/backends/smart/pk-backend-smart.c
@@ -385,6 +385,20 @@ backend_repo_enable (PkBackend *backend, const gchar *rid, gboolean enabled)
 	}
 }
 
+/**
+ * pk_backend_what_provides:
+ */
+static void
+backend_what_provides (PkBackend *backend, PkBitfield filters, PkProvidesEnum provides, const gchar *search)
+{
+	gchar *filters_text;
+	const gchar *provides_text;
+	provides_text = pk_provides_enum_to_text (provides);
+	filters_text = pk_filter_bitfield_to_text (filters);
+	pk_backend_spawn_helper (spawn, "what-provides.py", filters_text, provides_text, search, NULL);
+	g_free (filters_text);
+}
+
 PK_BACKEND_OPTIONS (
 	"SMART",					/* description */
 	"James Bowes <jbowes at dangerouslyinc.com>",	/* author */
@@ -419,5 +433,5 @@ PK_BACKEND_OPTIONS (
 	NULL,						/* service_pack */
 	backend_update_packages,			/* update_packages */
 	backend_update_system,				/* update_system */
-	NULL						/* what_provides */
+	backend_what_provides				/* what_provides */
 );
commit 239c341a95d3b61879108980f175cf4bea0a8c21
Author: Sebastian Heinlein <devel at glatzor.de>
Date:   Mon Sep 1 00:11:23 2008 +0200

    Fix a wrong type in repo_enable in the dbus backend

diff --git a/src/pk-backend-dbus.c b/src/pk-backend-dbus.c
index 2ff5c8b..c88723d 100644
--- a/src/pk-backend-dbus.c
+++ b/src/pk-backend-dbus.c
@@ -794,7 +794,7 @@ pk_backend_dbus_repo_enable (PkBackendDbus *backend_dbus, const gchar *rid, gboo
 	pk_backend_dbus_time_reset (backend_dbus);
 	ret = dbus_g_proxy_call (backend_dbus->priv->proxy, "RepoEnable", &error,
 				 G_TYPE_STRING, rid,
-				 G_TYPE_STRING, enabled,
+				 G_TYPE_BOOLEAN, enabled,
 				 G_TYPE_INVALID, G_TYPE_INVALID);
 	if (error != NULL) {
 		egg_warning ("%s", error->message);
commit 52e7ccc97e7383b484ced667b52078c15c212fa2
Author: Sebastian Heinlein <devel at glatzor.de>
Date:   Sun Aug 31 22:24:20 2008 +0200

    APT: Implement GetRepoList

diff --git a/backends/apt/aptDBUSBackend.py b/backends/apt/aptDBUSBackend.py
index e84041f..45acedd 100755
--- a/backends/apt/aptDBUSBackend.py
+++ b/backends/apt/aptDBUSBackend.py
@@ -67,7 +67,16 @@ else:
         pklog.debug("Use XAPIAN for the search")
         XAPIAN_SUPPORT = True
 
-# Check if update-manager-core is installed to get aware of the latest distro releases
+# SoftwareProperties is required to proivde information about repositories
+try:
+    import softwareproperties.SoftwareProperties
+except ImportError:
+    REPOS_SUPPORT = False
+else:
+    REPOS_SUPPORT = True
+
+# Check if update-manager-core is installed to get aware of the
+# latest distro releases
 try:
     from UpdateManager.Core.MetaRelease import MetaReleaseCore
 except ImportError:
@@ -749,6 +758,77 @@ class PackageKitAptBackend(PackageKitBaseBackend):
 
     @threaded
     @async
+    def doGetRepoList(self, filters):
+        '''
+        Implement the {backend}-get-repo-list functionality
+
+        FIXME: should we use the abstration of software-properties or provide
+               low level access using pure aptsources?
+        '''
+        pklog.info("Getting repository list: %s" % filters)
+        self.StatusChanged(STATUS_INFO)
+        self.AllowCancel(False)
+        self.PercentageChanged(0)
+        if REPOS_SUPPORT == False:
+            if self._cache.has_key("python-software-properties") and \
+               self._cache["python-software-properties"].isInstalled == False:
+                self.ErrorCode(ERROR_UNKNOWN,
+                               "Please install the package "
+                               "python-software-properties to handle repositories")
+            else:
+                self.ErrorCode(ERROR_UNKNOWN,
+                               "Please make sure that python-software-properties is"
+                               "correctly installed.")
+            self.Finished(EXIT_KILLED)
+            return
+        filter_list = filters.split(";")
+        repos = softwareproperties.SoftwareProperties.SoftwareProperties()
+        # Emit distro components as virtual repositories
+        for comp in repos.distro.source_template.components:
+            repo_id = "%s_comp_%s" % (repos.distro.id, comp.name)
+            description = "%s %s - %s (%s)" % (repos.distro.id,
+                                               repos.distro.release,
+                                               comp.get_description(),
+                                               comp.name)
+            #FIXME: There is no inconsitent state in PackageKit
+            enabled = repos.get_comp_download_state(comp)[0]
+            if not FILTER_DEVELOPMENT in filter_list:
+                self.RepoDetail(repo_id, description, enabled)
+        # Emit distro's virtual update repositories
+        for template in repos.distro.source_template.children:
+            repo_id = "%s_child_%s" % (repos.distro.id, template.name)
+            description = "%s %s - %s (%s)" % (repos.distro.id,
+                                               repos.distro.release,
+                                               template.description,
+                                               template.name)
+            #FIXME: There is no inconsitent state in PackageKit
+            enabled = repos.get_comp_child_state(comp)[0]
+            if not FILTER_DEVELOPMENT in filter_list:
+                self.RepoDetail(repo_id, description, enabled)
+        # Emit distro's virtual source code repositoriy
+        if not FILTER_NOT_DEVELOPMENT in filter_list:
+            repo_id = "%s_source" % repos.distro.id
+            enabled = repos.get_source_code_state()
+            #FIXME: no translation :(
+            description = "%s %s - Source code" % (repos.distro.id, 
+                                                   repos.distro.release)
+            self.RepoDetail(repo_id, description, enabled)
+        # Emit third party repositories
+        for source in repos.get_isv_sources():
+            #FIXME: There isn't any inconsistent state in PackageKit
+            if FILTER_NOT_DEVELOPMENT in filter_list and \
+               source.type in ("deb-src", "rpm-src"):
+                continue
+            enabled = not source.disabled
+            # Remove markups from the description
+            description = re.sub(r"</?b>", "", repos.render_source(source))
+            repo_id = "isv_%s_%s" % (source.uri, source.dist)
+            repo_id.join(map(lambda c: "_%s" % c, source.comps))
+            self.RepoDetail(repo_id, description, enabled)
+        self.Finished(EXIT_SUCCESS)
+
+    @threaded
+    @async
     def doUpdatePackages(self, ids):
         '''
         Implement the {backend}-update functionality
diff --git a/backends/apt/pk-backend-apt.c b/backends/apt/pk-backend-apt.c
index 2778039..e292174 100644
--- a/backends/apt/pk-backend-apt.c
+++ b/backends/apt/pk-backend-apt.c
@@ -270,6 +270,15 @@ backend_get_packages (PkBackend *backend, PkBitfield filters)
 }
 
 /**
+ *  * pk_backend_get_repo_list:
+ *   */
+static void
+backend_get_repo_list (PkBackend *backend, PkBitfield filters)
+{
+	        pk_backend_dbus_get_repo_list (dbus, filters);
+}
+
+/**
  *  * pk_backend_get_requires:
  *   */
 static void
@@ -320,7 +329,7 @@ PK_BACKEND_OPTIONS (
 	backend_get_distro_upgrades,		/* get_distro_upgrades */
 	backend_get_files,			/* get_files */
 	backend_get_packages,			/* get_packages */
-	NULL,					/* get_repo_list */
+	backend_get_repo_list,			/* get_repo_list */
 	backend_get_requires,			/* get_requires */
 	backend_get_update_detail,		/* get_update_detail */
 	backend_get_updates,			/* get_updates */
commit ac946d2fe3c6d953483826d8955c0c74a0de10f8
Author: Sebastian Heinlein <devel at glatzor.de>
Date:   Sun Aug 31 13:16:23 2008 +0200

    APT: Trivial. Use the more nicer PackageKitCache.clear() method instead of Cache._depcache.Init()

diff --git a/backends/apt/aptDBUSBackend.py b/backends/apt/aptDBUSBackend.py
index bde2228..e84041f 100755
--- a/backends/apt/aptDBUSBackend.py
+++ b/backends/apt/aptDBUSBackend.py
@@ -587,7 +587,7 @@ class PackageKitAptBackend(PackageKitBaseBackend):
         # Report packages that are upgradable but cannot be upgraded
         for missed in updates:
              self._emit_package(self._cache[missed], INFO_BLOCKED)
-        self._cache._depcache.Init()
+        self._cache.clear()
         self.Finished(EXIT_SUCCESS)
 
     @threaded
@@ -819,7 +819,7 @@ class PackageKitAptBackend(PackageKitBaseBackend):
             return
         # Setup the fetcher
         self._check_init(prange=(0,10))
-        self._cache._depcache.Init()
+        self._cache.clear()
         progress = PackageKitFetchProgress(self, prange=(10,90))
         fetcher = apt_pkg.GetAcquire(progress)
         pm = apt_pkg.GetPackageManager(self._cache._depcache)
@@ -843,7 +843,7 @@ class PackageKitAptBackend(PackageKitBaseBackend):
         # Download 
         pm.GetArchives(fetcher, list, recs)
         res = fetcher.Run()
-        self._cache._depcache.Init()
+        self._cache.clear()
         self.PercentageChanged(95)
         # Copy files from cache to final destination
         for item in fetcher.Items:
@@ -933,7 +933,7 @@ class PackageKitAptBackend(PackageKitBaseBackend):
         self.AllowCancel(False)
         self.PercentageChanged(0)
         self._check_init(prange=(0,10))
-        self._cache._depcache.Init()
+        self._cache.clear()
         dependencies = []
         packages = []
         # Collect all dependencies which need to be installed
@@ -1089,7 +1089,7 @@ class PackageKitAptBackend(PackageKitBaseBackend):
         self.AllowCancel(True)
 
         # Mark all packages for installation
-        self._cache._depcache.Init()
+        self._cache.clear()
         pkgs = []
         for id in ids:
             if self._is_canceled(): return
@@ -1130,7 +1130,7 @@ class PackageKitAptBackend(PackageKitBaseBackend):
                 self.Finished(EXIT_FAILED)
                 return
         # Clean up
-        self._cache._depcache.Init()
+        self._cache.clear()
         self.Finished(EXIT_SUCCESS)
 
     @threaded
@@ -1149,7 +1149,7 @@ class PackageKitAptBackend(PackageKitBaseBackend):
         pkgs = []
 
         # Mark all packages for installation
-        self._cache._depcache.Init()
+        self._cache.clear()
         for id in ids:
             if self._is_canceled(): return
             pkg = self._find_package_by_id(id)
@@ -1187,7 +1187,7 @@ class PackageKitAptBackend(PackageKitBaseBackend):
                 self.Finished(EXIT_FAILED)
                 return
         # Clean up
-        self._cache._depcache.Init()
+        self._cache.clear()
         self.Finished(EXIT_SUCCESS)
 
     @threaded


More information about the PackageKit-commit mailing list