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

Richard Hughes hughsient at kemper.freedesktop.org
Fri Nov 2 00:15:22 PDT 2007


 backends/smart/helpers/install-file.py |   20 ++++++++++++
 backends/smart/helpers/smartBackend.py |   51 ++++++++++++++++++++-------------
 backends/smart/pk-backend-smart.c      |    2 -
 html/pk-faq.html                       |    2 -
 4 files changed, 54 insertions(+), 21 deletions(-)

New commits:
commit 7b38f9615b7f3af98041ee7c147029a60b51f41d
Merge: ab6c3fe... 75f85f4...
Author: James Bowes <jbowes at dangerouslyinc.com>
Date:   Thu Nov 1 19:13:40 2007 -0400

    Merge branch 'smart'

diff --cc html/pk-faq.html
index 9c77f2f,d232d5d..998b808
--- a/html/pk-faq.html
+++ b/html/pk-faq.html
@@@ -27,10 -31,10 +27,10 @@@ get-updates       |   X    |  X  |     
  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  |      |       |      |
 -search-group      |        |  X  |     |     |      |       |      |
 +search-file       |        |  X  |     |  X  |      |       |   X  |
 +search-group      |        |  X  |     |     |      |       |   X  |
  install-package   |   X    |  X  |     |  X  |  X   |   X   |   X  |
- install-file      |        |  X  |     |  X  |      |       |   X  |
+ install-file      |        |  X  |     |  X  |      |   X   |   X  |
  remove-package    |   X    |  X  |     |  X  |  X   |   X   |   X  |
  update-package    |        |  X  |     |  X  |      |   X   |   X  |
  get-depends       |        |  X  |     |  X  |      |   X   |   X  |
commit 75f85f40d4f41334d68cfba6ca41e987c28a8af9
Author: James Bowes <jbowes at dangerouslyinc.com>
Date:   Thu Nov 1 17:44:15 2007 -0400

    smart: Implement install-file.

diff --git a/backends/smart/helpers/install-file.py b/backends/smart/helpers/install-file.py
new file mode 100755
index 0000000..0cf1d2a
--- /dev/null
+++ b/backends/smart/helpers/install-file.py
@@ -0,0 +1,20 @@
+#!/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
+
+file_to_inst = sys.argv[1]
+backend = PackageKitSmartBackend(sys.argv[1:])
+backend.install_file(file_to_inst)
+sys.exit(0)
diff --git a/backends/smart/helpers/smartBackend.py b/backends/smart/helpers/smartBackend.py
index 77c81b4..478a607 100644
--- a/backends/smart/helpers/smartBackend.py
+++ b/backends/smart/helpers/smartBackend.py
@@ -19,7 +19,7 @@
 import smart
 from packagekit.backend import PackageKitBaseBackend, INFO_INSTALLED, \
         INFO_AVAILABLE, INFO_NORMAL, FILTER_NON_INSTALLED, FILTER_INSTALLED, \
-        ERROR_REPO_NOT_FOUND
+        ERROR_REPO_NOT_FOUND, ERROR_PACKAGE_ALREADY_INSTALLED
 
 
 def needs_cache(func):
@@ -63,6 +63,24 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
         self.ctrl.commitTransaction(trans, confirm=False)
 
     @needs_cache
+    def install_file(self, path):
+        self.ctrl.addFileChannel(path)
+        self.ctrl.reloadChannels()
+        trans = smart.transaction.Transaction(self.ctrl.getCache(),
+                smart.transaction.PolicyInstall)
+
+        for channel in self.ctrl.getFileChannels():
+            for loader in channel.getLoaders():
+                for package in loader.getPackages():
+                    if package.installed:
+                        self.error(ERROR_PACKAGE_ALREADY_INSTALLED,
+                                'Package %s is already installed' % package)
+                    trans.enqueue(package, smart.transaction.INSTALL)
+
+        trans.run()
+        self.ctrl.commitTransaction(trans, confirm=False)
+
+    @needs_cache
     def remove(self, allowdeps, packageid):
         ratio, results, suggestions = self._search_packageid(packageid)
 
diff --git a/backends/smart/pk-backend-smart.c b/backends/smart/pk-backend-smart.c
index 6736589..e7172b1 100644
--- a/backends/smart/pk-backend-smart.c
+++ b/backends/smart/pk-backend-smart.c
@@ -40,7 +40,7 @@ PK_BACKEND_OPTIONS (
 	NULL,						/* get_update_detail */
 	pk_backend_python_get_updates,			/* get_updates */
 	pk_backend_python_install_package,		/* install_package */
-	NULL,						/* install_file */
+	pk_backend_python_install_file,			/* install_file */
 	pk_backend_python_refresh_cache,		/* refresh_cache */
 	pk_backend_python_remove_package,		/* remove_package */
 	pk_backend_python_resolve,			/* resolve */
diff --git a/html/pk-faq.html b/html/pk-faq.html
index 14de232..d232d5d 100644
--- a/html/pk-faq.html
+++ b/html/pk-faq.html
@@ -34,7 +34,7 @@ search-details    |        |  X  |  X  |  X  |      |       |      |
 search-file       |        |  X  |     |  X  |      |       |      |
 search-group      |        |  X  |     |     |      |       |      |
 install-package   |   X    |  X  |     |  X  |  X   |   X   |   X  |
-install-file      |        |  X  |     |  X  |      |       |   X  |
+install-file      |        |  X  |     |  X  |      |   X   |   X  |
 remove-package    |   X    |  X  |     |  X  |  X   |   X   |   X  |
 update-package    |        |  X  |     |  X  |      |   X   |   X  |
 get-depends       |        |  X  |     |  X  |      |   X   |   X  |
commit 291c04d5fb02c84cd19f6751899a02f22c17cd50
Author: James Bowes <jbowes at dangerouslyinc.com>
Date:   Thu Nov 1 16:55:11 2007 -0400

    smart: Extract a search_packageid method.

diff --git a/backends/smart/helpers/smartBackend.py b/backends/smart/helpers/smartBackend.py
index fde7f45..77c81b4 100644
--- a/backends/smart/helpers/smartBackend.py
+++ b/backends/smart/helpers/smartBackend.py
@@ -48,9 +48,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
 
     @needs_cache
     def install(self, packageid):
-        idparts = packageid.split(';')
-        packagestring = "%s-%s@%s" % (idparts[0], idparts[1], idparts[2])
-        ratio, results, suggestions = self.ctrl.search(packagestring)
+        ratio, results, suggestions = self._search_packageid(packageid)
 
         packages = self._process_search_results(results)
 
@@ -66,9 +64,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
 
     @needs_cache
     def remove(self, allowdeps, packageid):
-        idparts = packageid.split(';')
-        packagestring = "%s-%s@%s" % (idparts[0], idparts[1], idparts[2])
-        ratio, results, suggestions = self.ctrl.search(packagestring)
+        ratio, results, suggestions = self._search_packageid(packageid)
 
         packages = self._process_search_results(results)
 
@@ -84,9 +80,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
 
     @needs_cache
     def update(self, packageid):
-        idparts = packageid.split(';')
-        packagestring = "%s-%s@%s" % (idparts[0], idparts[1], idparts[2])
-        ratio, results, suggestions = self.ctrl.search(packagestring)
+        ratio, results, suggestions = self._search_packageid(packageid)
 
         packages = self._process_search_results(results)
         installed = [package for package in packages if package.installed]
@@ -157,9 +151,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
 
     @needs_cache
     def get_description(self, packageid):
-        idparts = packageid.split(';')
-        packagestring = "%s-%s@%s" % (idparts[0], idparts[1], idparts[2])
-        ratio, results, suggestions = self.ctrl.search(packagestring)
+        ratio, results, suggestions = self._search_packageid(packageid)
 
         packages = self._process_search_results(results)
 
@@ -204,9 +196,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
 
     @needs_cache
     def get_files(self, packageid):
-        idparts = packageid.split(';')
-        packagestring = "%s-%s@%s" % (idparts[0], idparts[1], idparts[2])
-        ratio, results, suggestions = self.ctrl.search(packagestring)
+        ratio, results, suggestions = self._search_packageid(packageid)
 
         packages = self._process_search_results(results)
 
@@ -226,9 +216,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
 
     @needs_cache
     def get_depends(self, packageid):
-        idparts = packageid.split(';')
-        packagestring = "%s-%s@%s" % (idparts[0], idparts[1], idparts[2])
-        ratio, results, suggestions = self.ctrl.search(packagestring)
+        ratio, results, suggestions = self._search_packageid(packageid)
 
         packages = self._process_search_results(results)
 
@@ -267,6 +255,13 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
         else:
             self.error(ERROR_REPO_NOT_FOUND, "repo %s was not found" % repoid)
 
+    def _search_packageid(self, packageid):
+        idparts = packageid.split(';')
+        packagestring = "%s-%s@%s" % (idparts[0], idparts[1], idparts[2])
+        ratio, results, suggestions = self.ctrl.search(packagestring)
+
+        return (ratio, results, suggestions)
+
     def _show_package(self, package, status=None):
         if not status:
             if package.installed:



More information about the PackageKit mailing list