[packagekit] [PATCH 4 of 4] Implement 'get-update-detail'

Ikey Doherty ikey at solusos.com
Sat Jun 8 05:56:02 PDT 2013


# HG changeset patch
# User Ikey Doherty <ikey at solusos.com>
# Date 1370695572 -3600
# Node ID e879418c1a584364fe9f035dd17633bef4eb4ac6
# Parent  6924c435d4774792912d965c8690597614805f03
Implement 'get-update-detail'

diff --git a/backends/pisi/pisiBackend.py b/backends/pisi/pisiBackend.py
--- a/backends/pisi/pisiBackend.py
+++ b/backends/pisi/pisiBackend.py
@@ -25,6 +25,7 @@
 from packagekit.package import PackagekitPackage
 from packagekit import enums
 import os.path
+import piksemel
 
 class SimplePisiHandler(pisi.ui.UI):
     
@@ -201,6 +202,50 @@
             else:
                 self.package(id, INFO_NORMAL, pkg.summary)
 
+    def _extract_update_details (self, pindex, package_name):
+		document = piksemel.parse (pindex)
+		packages = document.tags ("Package")
+		for pkg in packages:
+			if pkg.getTagData ("Name") == package_name:
+				history = pkg.getTag("History")
+				update = history.tags ("Update")
+				update_message = "Updated"
+				update_release = 0
+				update_data = ""
+				for update in update:
+					if int(update.getAttribute ("release")) > update_release:
+						update_release = int(update.getAttribute ("release"))
+						updater = update.getTagData ("Name")
+						update_message = update.getTagData ("Comment")
+						update_message = update_message.replace ("\n\n", ";").replace ("\n", " ")
+						update_date = update.getTagData ("Date")
+				return (update_message,update_date)
+			pkg = pkg.nextTag ("Package")
+		return "Great its an update."
+		
+    def get_update_detail(self, package_ids):
+        for package_id in package_ids:
+            package = self.get_package_from_id (package_id)[0]
+            the_package = self.installdb.get_package (package)
+            updates = [package_id]
+            obsoletes = ""
+            bugzilla_url = "" # TODO: Add regex matching for #FIXES:ID or something similar
+            cve_url = ""
+            package_url = the_package.source.homepage
+            vendor_url = package_url if package_url is not None else ""
+            issued = ""
+            repo = self.packagedb.get_package_repo (package, None)[1]
+            pindex = "/var/lib/pisi/index/%s/pisi-index.xml" % repo
+
+            changelog = ""  
+            issued = updated = "" # TODO: Set to security_issued if security update     
+            update_message,security_issued = self._extract_update_details (pindex, package)
+            state = UPDATE_STATE_STABLE # TODO: Add tagging to repo's, or a mapping file
+            
+            self.update_detail(package_id, updates, obsoletes, vendor_url,
+                bugzilla_url, cve_url, "none", update_message, changelog,
+                state, issued, updated)
+    
     def install_files(self, only_trusted, files):
         """ Installs given package into system"""
 
diff --git a/backends/pisi/pk-backend-pisi.c b/backends/pisi/pk-backend-pisi.c
--- a/backends/pisi/pk-backend-pisi.c
+++ b/backends/pisi/pk-backend-pisi.c
@@ -188,6 +188,18 @@
 }
 
 /**
+ * pk_backend_get_update_detail:
+ */
+void
+pk_backend_get_update_detail (PkBackend *backend, PkBackendJob *job, gchar **package_ids)
+{
+	gchar *package_ids_temp;
+	package_ids_temp = pk_package_ids_to_string (package_ids);
+	pk_backend_spawn_helper (spawn, job, "pisiBackend.py", "get-update-detail", package_ids_temp, NULL);
+	g_free (package_ids_temp);
+}
+
+/**
  * pk_backend_install_packages:
  */
 void


More information about the PackageKit mailing list