[PackageKit-commit] packagekit: Branch 'master' - 15 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Tue Sep 2 06:58:15 PDT 2008
backends/apt/aptDBUSBackend.py | 2
backends/smart/helpers/smartBackend.py | 186 +++++++++++++++++++---------
backends/smart/pk-backend-smart.c | 4
backends/yum/helpers/Makefile.am | 1
backends/yum/helpers/get-distro-upgrades.py | 20 +++
backends/yum/helpers/yumBackend.py | 66 +++++++++
backends/yum/pk-backend-yum.c | 13 +
docs/html/pk-matrix.html | 14 +-
libpackagekit/pk-enum.c | 2
python/packagekit/backend.py | 17 ++
src/pk-backend-spawn.c | 19 ++
11 files changed, 278 insertions(+), 66 deletions(-)
New commits:
commit f51e5af8ec5868c917d8b5507f91d9ef334a6af5
Merge: 3a62698... db8f35e...
Author: Anders F Bjorklund <afb at users.sourceforge.net>
Date: Tue Sep 2 15:17:55 2008 +0200
Merge branch 'master' of git+ssh://afb@git.packagekit.org/srv/git/PackageKit
commit 3a626985ff14e358b033a9696f06a3da6cc23933
Author: Anders F Bjorklund <afb at users.sourceforge.net>
Date: Tue Sep 2 15:17:31 2008 +0200
Update feature matrix for smart.
diff --git a/docs/html/pk-matrix.html b/docs/html/pk-matrix.html
index c1453cf..4aa2fa1 100644
--- a/docs/html/pk-matrix.html
+++ b/docs/html/pk-matrix.html
@@ -587,7 +587,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-bad.png" alt="[no]"/></td><!-- yum -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- yum2 -->
commit e16a1e68f9e4dc94325909b98bb55d7dec2d83b9
Author: Anders F Bjorklund <afb at users.sourceforge.net>
Date: Tue Sep 2 15:16:38 2008 +0200
smart: add arch_filtering
diff --git a/backends/smart/helpers/smartBackend.py b/backends/smart/helpers/smartBackend.py
index 50fb3e2..52e8b38 100644
--- a/backends/smart/helpers/smartBackend.py
+++ b/backends/smart/helpers/smartBackend.py
@@ -566,6 +566,23 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
systemchannel = None # unfortunately package strings depend on system
+ def _machine(self):
+ import os
+ machine = os.uname()[-1]
+ if machine == "Power Macintosh": #<sigh>
+ machine = "ppc"
+ return machine
+
+ def _samearch(self, arch1, arch2):
+ if arch1 == arch2:
+ return True
+ if arch1 == 'noarch' or arch2 == 'noarch':
+ return True
+ x86 = re.compile(r'i[3456]86')
+ if x86.search(arch1) and x86.search(arch2):
+ return True
+ return False
+
def _splitpackage(self, package):
from smart.backends.rpm.base import RPMPackage
from smart.backends.deb.base import DebPackage
@@ -578,11 +595,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
ver, arch, rel = package.version.rsplit('-')
version = "%s-%s" % (ver, rel)
else:
- import os
- machine = os.uname()[-1]
- if machine == "Power Macintosh": #<sigh>
- machine = "ppc"
- version, arch = package.version, machine
+ version, arch = package.version, self._machine()
return package.name, version, arch
def _joinpackage(self, name, version, arch):
@@ -715,6 +728,13 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
loader = package.loaders.keys()[0]
info = loader.getInfo(package)
for filter in filterlist:
+ if filter in (FILTER_ARCH, FILTER_NOT_ARCH):
+ name, version, arch = self._splitpackage(package)
+ same = self._samearch(arch, self._machine())
+ if filter == FILTER_ARCH and not same:
+ return False
+ if filter == FILTER_NOT_ARCH and same:
+ return False
if filter in (FILTER_GUI, FILTER_NOT_GUI):
graphical = self._package_is_graphical(package)
if graphical is None: # tristate boolean
diff --git a/backends/smart/pk-backend-smart.c b/backends/smart/pk-backend-smart.c
index 994ccf4..9b79d4d 100644
--- a/backends/smart/pk-backend-smart.c
+++ b/backends/smart/pk-backend-smart.c
@@ -90,6 +90,7 @@ backend_get_filters (PkBackend *backend)
return pk_bitfield_from_enums (
PK_FILTER_ENUM_INSTALLED,
PK_FILTER_ENUM_NEWEST,
+ PK_FILTER_ENUM_ARCH,
PK_FILTER_ENUM_GUI,
PK_FILTER_ENUM_DEVELOPMENT,
/* FIXME: These depend on a newer Smart API: */
commit db8f35e4285f09c517721aec316ab53abfffc784
Merge: f057bf5... c7b95fb...
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Sep 2 14:13:31 2008 +0100
Merge branch 'master' of git+ssh://hughsie@git.packagekit.org/srv/git/PackageKit
commit f057bf5875b42f990afdd140a0377ed8c070c609
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Sep 2 14:09:37 2008 +0100
apt: use the correct variable names if we fail to get the changelog. fixes fd#17406
diff --git a/backends/apt/aptDBUSBackend.py b/backends/apt/aptDBUSBackend.py
index 6974740..dd58d39 100755
--- a/backends/apt/aptDBUSBackend.py
+++ b/backends/apt/aptDBUSBackend.py
@@ -1828,7 +1828,7 @@ class PackageKitAptBackend(PackageKitBaseBackend):
"Please use http://launchpad.net/ubuntu/+source/%s/%s/" \
"+changelog\n" \
"until the changes become available or try again " \
- "later." % (srcpkg, srcver),
+ "later." % (src_pkg, src_ver),
except IOError, httplib.BadStatusLine:
return "Failed to download the list of changes.\nPlease " \
"check your Internet connection."
commit c7b95fbf36a0e2741dd89484b79ee4bf3c7d1884
Author: Anders F Bjorklund <afb at users.sourceforge.net>
Date: Tue Sep 2 14:47:38 2008 +0200
Update feature matrix for smart.
diff --git a/docs/html/pk-matrix.html b/docs/html/pk-matrix.html
index 1649788..c1453cf 100644
--- a/docs/html/pk-matrix.html
+++ b/docs/html/pk-matrix.html
@@ -542,8 +542,8 @@
<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><!-- urpmi -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- smart -->
+<td><img src="img/status-bad.png" alt="[no]"/></td><!-- urpmi -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- yum -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- yum2 -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- zypp -->
@@ -557,8 +557,8 @@
<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><!-- urpmi -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- smart -->
+<td><img src="img/status-bad.png" alt="[no]"/></td><!-- urpmi -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- yum -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- yum2 -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- zypp -->
@@ -572,8 +572,8 @@
<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-good.png" alt="[yes]"/></td><!-- smart -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- urpmi -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- smart -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum2 -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- zypp -->
@@ -587,8 +587,8 @@
<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><!-- urpmi -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- smart -->
+<td><img src="img/status-bad.png" alt="[no]"/></td><!-- urpmi -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- yum -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- yum2 -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- zypp -->
commit 965dbb5fbb7f2e4d0b15b0835b6ff1a4ba7d342c
Merge: 1dd6c88... 260b13c...
Author: Anders F Bjorklund <afb at users.sourceforge.net>
Date: Tue Sep 2 14:42:21 2008 +0200
Merge branch 'master' of git+ssh://afb@git.packagekit.org/srv/git/PackageKit
commit 1dd6c8866b7408b7c6deebbfb08684de06be3ffe
Author: Anders F Bjorklund <afb at users.sourceforge.net>
Date: Tue Sep 2 14:41:55 2008 +0200
smart: add newest_filtering
diff --git a/backends/smart/helpers/smartBackend.py b/backends/smart/helpers/smartBackend.py
index 3ac151b..50fb3e2 100644
--- a/backends/smart/helpers/smartBackend.py
+++ b/backends/smart/helpers/smartBackend.py
@@ -95,6 +95,8 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
smart.initPlugins()
smart.initPsyco()
+ self._package_list = []
+
def status(self, state):
PackageKitBaseBackend.status(self, state)
self._status = state
@@ -206,7 +208,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self.ctrl.commitTransaction(trans, confirm=False)
@needs_cache
- def get_updates(self, filter):
+ def get_updates(self, filters):
cache = self.ctrl.getCache()
trans = smart.transaction.Transaction(cache,
@@ -222,7 +224,9 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
for (package, op) in trans.getChangeSet().items():
if op == smart.transaction.INSTALL:
status = self._get_status(package)
- self._show_package(package, status)
+ self._add_package(package, status)
+ self._post_process_package_list(filters)
+ self._show_package_list()
@needs_cache
def resolve(self, filters, packagename):
@@ -230,7 +234,9 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
ratio, results, suggestions = self.ctrl.search(packagename)
for result in results:
if self._package_passes_filters(result, filters):
- self._show_package(result)
+ self._add_package(result)
+ self._post_process_package_list(filters)
+ self._show_package_list()
@needs_cache
def search_name(self, filters, packagename):
@@ -242,7 +248,9 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
for package in packages:
if self._package_passes_filters(package, filters):
- self._show_package(package)
+ self._add_package(package)
+ self._post_process_package_list(filters)
+ self._show_package_list()
@needs_cache
def search_file(self, filters, searchstring):
@@ -258,7 +266,9 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
if len(paths) > 0:
break
if searchstring in paths:
- self._show_package(package)
+ self._add_package(package)
+ self._post_process_package_list(filters)
+ self._show_package_list()
@needs_cache
def search_group(self, filters, searchstring):
@@ -271,7 +281,9 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
if group in self.GROUPS:
group = self.GROUPS[group]
if searchstring in group:
- self._show_package(package)
+ self._add_package(package)
+ self._post_process_package_list(filters)
+ self._show_package_list()
@needs_cache
def search_details(self, filters, searchstring):
@@ -281,7 +293,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
if self._package_passes_filters(package, filters):
info = package.loaders.keys()[0].getInfo(package)
if searchstring in info.getDescription():
- self._show_package(package)
+ self._add_package(package)
@needs_cache
def get_packages(self, filters):
@@ -290,6 +302,8 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
for package in packages:
if self._package_passes_filters(package, filters):
self._show_package(package)
+ self._post_process_package_list(filters)
+ self._show_package_list()
@needs_cache
def what_provides(self, filters, provides_type, search):
@@ -299,7 +313,9 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
for provider in providers:
for package in provider.packages:
if self._package_passes_filters(package, filters):
- self._show_package(package)
+ self._add_package(package)
+ self._post_process_package_list(filters)
+ self._show_package_list()
def refresh_cache(self):
self.status(STATUS_REFRESH_CACHE)
@@ -598,20 +614,24 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
return (ratio, results, suggestions)
- def _show_package(self, package, status=None):
+ def _add_package(self, package, status=None):
if not status:
if package.installed:
status = INFO_INSTALLED
else:
status = INFO_AVAILABLE
- name, version, arch = self._splitpackage(package)
- for loader in package.loaders:
- channel = loader.getChannel()
- if package.installed and not channel.getType().endswith('-sys'):
- continue
- info = loader.getInfo(package)
- self.package(pkpackage.get_package_id(name, version, arch,
- channel.getAlias()), status, info.getSummary())
+ self._package_list.append((package, status))
+
+ def _show_package_list(self, filters=None):
+ for package,status in self._package_list:
+ name, version, arch = self._splitpackage(package)
+ for loader in package.loaders:
+ channel = loader.getChannel()
+ if package.installed and not channel.getType().endswith('-sys'):
+ continue
+ info = loader.getInfo(package)
+ self.package(pkpackage.get_package_id(name, version, arch,
+ channel.getAlias()), status, info.getSummary())
def _get_status(self, package):
flags = smart.pkgconf.testAllFlags(package)
@@ -726,3 +746,19 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
"filter %s not supported" % filter)
return False
return True
+
+ def _do_newest_filtering(self, package_list):
+ newest = {}
+ for package,status in package_list:
+ name, version, arch = self._splitpackage(package)
+ key = (name, arch)
+ if key in newest and package <= newest[key]:
+ continue
+ newest[key] = (package,status)
+ return newest.values()
+
+ def _post_process_package_list(self, filters):
+ filterlist = filters.split(';')
+ if FILTER_NEWEST in filterlist:
+ self._package_list = self._do_newest_filtering(self._package_list)
+
diff --git a/backends/smart/pk-backend-smart.c b/backends/smart/pk-backend-smart.c
index 0290b18..994ccf4 100644
--- a/backends/smart/pk-backend-smart.c
+++ b/backends/smart/pk-backend-smart.c
@@ -89,9 +89,10 @@ backend_get_filters (PkBackend *backend)
{
return pk_bitfield_from_enums (
PK_FILTER_ENUM_INSTALLED,
- /* FIXME: These depend on a newer Smart API: */
+ PK_FILTER_ENUM_NEWEST,
PK_FILTER_ENUM_GUI,
PK_FILTER_ENUM_DEVELOPMENT,
+ /* FIXME: These depend on a newer Smart API: */
PK_FILTER_ENUM_FREE,
-1);
}
commit 260b13c276656267fe4cb88f4a3a79e79169fd44
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Sep 2 13:15:14 2008 +0100
yum: add GetDistroUpgrades support using the preupgrade package and data
diff --git a/backends/yum/helpers/Makefile.am b/backends/yum/helpers/Makefile.am
index e17664d..4cf5c44 100644
--- a/backends/yum/helpers/Makefile.am
+++ b/backends/yum/helpers/Makefile.am
@@ -15,6 +15,7 @@ dist_helper_DATA = \
get-details.py \
get-repo-list.py \
get-packages.py \
+ get-distro-upgrades.py \
repo-enable.py \
repo-set-data.py \
get-update-detail.py \
diff --git a/backends/yum/helpers/get-distro-upgrades.py b/backends/yum/helpers/get-distro-upgrades.py
new file mode 100755
index 0000000..cb9aa07
--- /dev/null
+++ b/backends/yum/helpers/get-distro-upgrades.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2008 Richard Hughes <richard at hughsie.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 yumBackend import PackageKitYumBackend
+
+backend = PackageKitYumBackend(sys.argv[1:])
+backend.get_distro_upgrades()
+backend.unLock()
+sys.exit(0)
+
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 7485864..c7c922a 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -48,6 +48,7 @@ import os.path
import tarfile
import tempfile
import shutil
+import ConfigParser
from yumDirect import *
from yumFilter import *
@@ -1214,6 +1215,71 @@ class PackageKitYumBackend(PackageKitBaseBackend):
else:
return INFO_UNKNOWN
+ def get_distro_upgrades(self):
+ '''
+ Implement the {backend}-get-distro-upgrades functionality
+ '''
+ self._check_init()
+ self.allow_cancel(True)
+ self.percentage(None)
+ self.status(STATUS_QUERY)
+
+ # is preupgrade installed?
+ pkgs = self.yumbase.rpmdb.searchNevra(name='preupgrade')
+ if len(pkgs) == 0:
+ #install preupgrade
+ pkgs = self.yumbase.pkgSack.searchNevra(name='preupgrade')
+ if len(pkgs) == 0:
+ self.error(ERROR_PACKAGE_NOT_FOUND,"Could not find upgrade preupgrade package in any enabled repos")
+ elif len(pkgs) == 1:
+ txmbr = self.yumbase.install(po=pkgs[0])
+ if txmbr:
+ self._runYumTransaction()
+ else:
+ self.error(ERROR_INTERNAL_ERROR,"not one update possibility")
+ elif len(pkgs) == 1:
+ # check if there are any updates to the preupgrade package
+ po = pkgs[0]
+ pkgs = self.yumbase.pkgSack.returnNewestByName(name='kernel')
+ if pkgs:
+ newest = pkgs[0]
+ if newest.EVR > po.EVR:
+ # need to update preupgrade package
+ txmbr = self.yumbase.update(po=pkgs[0])
+ if txmbr:
+ self._runYumTransaction()
+ else:
+ self.error(ERROR_INTERNAL_ERROR,"more than one preupgrade package installed")
+
+ # parse the releases file
+ config = ConfigParser.ConfigParser()
+ config.read('/usr/share/preupgrade/releases.list')
+
+ # find the newest release
+ newest = None
+ last_version = 0;
+ for section in config.sections():
+ # we only care about stable versions
+ if config.has_option(section,'stable') and config.getboolean(section,'stable'):
+ version = config.getfloat(section,'version')
+ if (version > last_version):
+ newest = section
+ last_version = version
+
+ # got no valid data
+ if not newest:
+ self.error(ERROR_FAILED_CONFIG_PARSING,"could not get latest distro data")
+
+ # are we already on the latest version
+ present_version = self.yumbase.conf.yumvar['releasever']
+ if (present_version >= last_version):
+ return
+
+ # if we have an upgrade candidate then pass back data to daemon
+ tok = newest.split(" ")
+ name = "%s-%s" % (tok[0].lower(),tok[1])
+ self.distro_upgrade(DISTRO_UPGRADE_STABLE, name, newest)
+
def get_updates(self,filters):
'''
Implement the {backend}-get-updates functionality
diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index 1c37a44..62f859b 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -158,6 +158,15 @@ backend_get_details (PkBackend *backend, gchar **package_ids)
}
/**
+ * backend_get_distro_upgrades:
+ */
+static void
+backend_get_distro_upgrades (PkBackend *backend)
+{
+ pk_backend_spawn_helper (spawn, "get-distro-upgrades.py", NULL);
+}
+
+/**
* backend_get_files:
*/
static void
@@ -441,7 +450,7 @@ backend_what_provides (PkBackend *backend, PkBitfield filters, PkProvidesEnum pr
PK_BACKEND_OPTIONS (
"YUM", /* description */
- "Tim Lauridsen <timlau at fedoraproject.org>", /* author */
+ "Tim Lauridsen <timlau at fedoraproject.org>, Richard Hughes <richard at hughsie.com>", /* author */
backend_initialize, /* initalize */
backend_destroy, /* destroy */
backend_get_groups, /* get_groups */
@@ -450,7 +459,7 @@ PK_BACKEND_OPTIONS (
backend_download_packages, /* download_packages */
backend_get_depends, /* get_depends */
backend_get_details, /* get_details */
- NULL, /* get_distro_upgrades */
+ backend_get_distro_upgrades, /* get_distro_upgrades */
backend_get_files, /* get_files */
backend_get_packages, /* get_packages */
backend_get_repo_list, /* get_repo_list */
diff --git a/docs/html/pk-matrix.html b/docs/html/pk-matrix.html
index 75d16df..1649788 100644
--- a/docs/html/pk-matrix.html
+++ b/docs/html/pk-matrix.html
@@ -105,7 +105,7 @@
<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-bad.png" alt="[no]"/></td><!-- urpmi -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- yum -->
+<td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- yum2 -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- zypp -->
</tr>
commit 7e2094fa41d9ae5757a6ccfc91714d0808ab4ba6
Merge: ef25a17... 881c050...
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Sep 2 12:25:10 2008 +0100
Merge branch 'master' of git+ssh://hughsie@git.packagekit.org/srv/git/PackageKit
commit 881c05051fee5f0ae4ba44af5735025cd71880df
Author: Anders F Bjorklund <afb at users.sourceforge.net>
Date: Tue Sep 2 13:18:23 2008 +0200
smart: do graphical/development filtering, was rejected upstream
diff --git a/backends/smart/helpers/smartBackend.py b/backends/smart/helpers/smartBackend.py
index a2dcba7..3ac151b 100644
--- a/backends/smart/helpers/smartBackend.py
+++ b/backends/smart/helpers/smartBackend.py
@@ -28,6 +28,7 @@ from packagekit.backend import PackageKitBaseBackend, INFO_INSTALLED, \
ERROR_PACKAGE_DOWNLOAD_FAILED
from packagekit.package import PackagekitPackage
from packagekit.enums import *
+import re
# Global vars
pkpackage = PackagekitPackage()
@@ -228,7 +229,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self.status(STATUS_QUERY)
ratio, results, suggestions = self.ctrl.search(packagename)
for result in results:
- if self._passes_filters(result, filters):
+ if self._package_passes_filters(result, filters):
self._show_package(result)
@needs_cache
@@ -240,7 +241,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
packages = self._process_search_results(results)
for package in packages:
- if self._passes_filters(package, filters):
+ if self._package_passes_filters(package, filters):
self._show_package(package)
@needs_cache
@@ -248,7 +249,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self.status(STATUS_QUERY)
packages = self.ctrl.getCache().getPackages()
for package in packages:
- if self._passes_filters(package, filters):
+ if self._package_passes_filters(package, filters):
# FIXME: Only installed packages have path lists.
paths = []
for loader in package.loaders:
@@ -264,7 +265,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self.status(STATUS_QUERY)
packages = self.ctrl.getCache().getPackages()
for package in packages:
- if self._passes_filters(package, filters):
+ if self._package_passes_filters(package, filters):
info = package.loaders.keys()[0].getInfo(package)
group = info.getGroup()
if group in self.GROUPS:
@@ -277,7 +278,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self.status(STATUS_QUERY)
packages = self.ctrl.getCache().getPackages()
for package in packages:
- if self._passes_filters(package, filters):
+ if self._package_passes_filters(package, filters):
info = package.loaders.keys()[0].getInfo(package)
if searchstring in info.getDescription():
self._show_package(package)
@@ -287,7 +288,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self.status(STATUS_QUERY)
packages = self.ctrl.getCache().getPackages()
for package in packages:
- if self._passes_filters(package, filters):
+ if self._package_passes_filters(package, filters):
self._show_package(package)
@needs_cache
@@ -297,7 +298,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
providers = self.ctrl.getCache().getProvides(search)
for provider in providers:
for package in provider.packages:
- if self._passes_filters(package, filters):
+ if self._package_passes_filters(package, filters):
self._show_package(package)
def refresh_cache(self):
@@ -486,7 +487,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
providers[package] = True
for package in providers.keys():
- if self._passes_filters(package, filters):
+ if self._package_passes_filters(package, filters):
self._show_package(package)
@needs_cache
@@ -511,7 +512,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
requirers[package] = True
for package in requirers.keys():
- if self._passes_filters(package, filters):
+ if self._package_passes_filters(package, filters):
self._show_package(package)
def get_repo_list(self, filters):
@@ -653,7 +654,38 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
return False
return True
- def _passes_filters(self, package, filters):
+ def _package_is_graphical(self, package):
+ from smart.backends.rpm.base import RPMPackage
+ from smart.backends.deb.base import DebPackage
+ if isinstance(package, RPMPackage):
+ regex = re.compile(r'(qt)|(gtk)')
+ for required in package.requires:
+ for provider in required.providedby:
+ for package in provider.packages:
+ if regex.search(package.name):
+ return True
+ return False
+ elif isinstance(package, DebPackage):
+ group = package.getGroup().split('/')[-1].lower()
+ return group in ['x11', 'gnome', 'kde']
+ else:
+ return None
+
+ def _package_is_development(self, package):
+ from smart.backends.rpm.base import RPMPackage
+ from smart.backends.deb.base import DebPackage
+ if isinstance(package, RPMPackage):
+ regex = re.compile(r'(-devel)|(-dgb)|(-static)')
+ return bool(regex.search(package.name))
+ elif isinstance(package, DebPackage):
+ group = package.getGroup().split('/')[-1].lower()
+ return package.name.endswith("-dev") or \
+ package.name.endswith("-dbg") or \
+ group in ['devel', 'libdevel']
+ else:
+ return None
+
+ def _package_passes_filters(self, package, filters):
filterlist = filters.split(';')
if FILTER_NOT_INSTALLED in filterlist and package.installed:
return False
@@ -664,30 +696,20 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
info = loader.getInfo(package)
for filter in filterlist:
if filter in (FILTER_GUI, FILTER_NOT_GUI):
- if hasattr(info, 'isGraphical'):
- graphical = info.isGraphical()
- if graphical is None: # tristate boolean
- return None
- if filter == FILTER_GUI and graphical:
- return False
- if filter == FILTER_NOT_GUI and graphical:
- return False
- else:
- self.error(ERROR_FILTER_INVALID, \
- "filter %s not supported" % filter)
+ graphical = self._package_is_graphical(package)
+ if graphical is None: # tristate boolean
+ return None
+ if filter == FILTER_GUI and not graphical:
+ return False
+ if filter == FILTER_NOT_GUI and graphical:
return False
if filter in (FILTER_DEVELOPMENT, FILTER_NOT_DEVELOPMENT):
- if hasattr(info, 'isDevelopment'):
- development = info.isDevelopment()
- if development is None: # tristate boolean
- return None
- if filter == FILTER_DEVELOPMENT and development:
- return False
- if filter == FILTER_NOT_DEVELOPMENT and development:
- return False
- else:
- self.error(ERROR_FILTER_INVALID, \
- "filter %s not supported" % filter)
+ development = self._package_is_development(package)
+ if development is None: # tristate boolean
+ return None
+ if filter == FILTER_DEVELOPMENT and not development:
+ return False
+ if filter == FILTER_NOT_DEVELOPMENT and development:
return False
if filter in (FILTER_FREE, FILTER_NOT_FREE):
if hasattr(info, 'getLicense'):
commit e0f3051ae336b91e287d0879a0f1cd63fca9e011
Author: Anders F Bjorklund <afb at users.sourceforge.net>
Date: Tue Sep 2 13:16:20 2008 +0200
Update feature matrix for smart.
diff --git a/docs/html/pk-matrix.html b/docs/html/pk-matrix.html
index ccf7074..75d16df 100644
--- a/docs/html/pk-matrix.html
+++ b/docs/html/pk-matrix.html
@@ -58,7 +58,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 ef25a1750bcad17678ff4c7420f6ad26b310aa75
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Sep 2 12:08:36 2008 +0100
bugfix: fix the formatting in the enum list, as COULD_NOT_FIND_PACKAGE was not being picked up by the enum converter
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index e588773..4628c53 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -184,7 +184,7 @@ static PkEnumMatch enum_message[] = {
{PK_MESSAGE_ENUM_CACHE_BEING_REBUILT, "cache-being-rebuilt"},
{PK_MESSAGE_ENUM_UNTRUSTED_PACKAGE, "untrusted-package"},
{PK_MESSAGE_ENUM_NEWER_PACKAGE_EXISTS, "newer-package-exists"},
- {PK_MESSAGE_ENUM_COULD_NOT_FIND_PACKAGE,"could-not-find-package"},
+ {PK_MESSAGE_ENUM_COULD_NOT_FIND_PACKAGE, "could-not-find-package"},
{PK_MESSAGE_ENUM_CONFIG_FILES_CHANGED, "config-files-changed"},
{PK_MESSAGE_ENUM_PACKAGE_ALREADY_INSTALLED, "package-already-installed"},
{0, NULL}
commit 0c5d43883c908a2e925a5a2a679ae4c0a86b9c1f
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Sep 2 12:03:18 2008 +0100
trivial: add the get-distro-upgrades and distro-upgrades functionality to the python backends
diff --git a/python/packagekit/backend.py b/python/packagekit/backend.py
index f025f31..2e7a266 100644
--- a/python/packagekit/backend.py
+++ b/python/packagekit/backend.py
@@ -102,6 +102,16 @@ class PackageKitBaseBackend:
print >> sys.stdout,"package\t%s\t%s\t%s" % (status,id,summary)
sys.stdout.flush()
+ def distro_upgrade(self,dtype,name,summary):
+ '''
+ send 'distro-upgrade' signal
+ @param dtype: the enumerated DISTRO_UPGRADE_* string
+ @param name: The distro name, e.g. "fedora-9"
+ @param summary: The localised distribution name and description
+ '''
+ print >> sys.stdout,"distro-upgrade\t%s\t%s\t%s" % (dtype,name,summary)
+ sys.stdout.flush()
+
def status(self,state):
'''
send 'status' signal
@@ -351,6 +361,13 @@ class PackageKitBaseBackend:
'''
self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+ def get_distro_upgrades(self):
+ '''
+ Implement the {backend}-get-distro-upgrades functionality
+ Needed to be implemented in a sub class
+ '''
+ self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+
def repo_enable(self,repoid,enable):
'''
Implement the {backend}-repo-enable functionality
diff --git a/src/pk-backend-spawn.c b/src/pk-backend-spawn.c
index 6a95402..e09c44d 100644
--- a/src/pk-backend-spawn.c
+++ b/src/pk-backend-spawn.c
@@ -95,6 +95,7 @@ pk_backend_spawn_parse_stdout (PkBackendSpawn *backend_spawn, const gchar *line)
PkRestartEnum restart_enum;
PkSigTypeEnum sig_type;
PkUpdateStateEnum update_state_enum;
+ PkDistroUpgradeEnum distro_upgrade_enum;
g_return_val_if_fail (PK_IS_BACKEND_SPAWN (backend_spawn), FALSE);
@@ -356,6 +357,24 @@ pk_backend_spawn_parse_stdout (PkBackendSpawn *backend_spawn, const gchar *line)
sections[2], sections[3], sections[4],
sections[5], sections[6], sections[7], sig_type);
goto out;
+ } else if (egg_strequal (command, "distro-upgrade")) {
+
+ if (size != 4) {
+ egg_warning ("invalid command '%s'", command);
+ ret = FALSE;
+ goto out;
+ }
+
+ distro_upgrade_enum = pk_distro_upgrade_enum_from_text (sections[1]);
+ if (distro_upgrade_enum == PK_DISTRO_UPGRADE_ENUM_UNKNOWN) {
+ pk_backend_message (backend_spawn->priv->backend, PK_MESSAGE_ENUM_BACKEND_ERROR,
+ "distro upgrade enum not recognised, and hence ignored: '%s'", sections[1]);
+ ret = FALSE;
+ goto out;
+ }
+
+ ret = pk_backend_distro_upgrade (backend_spawn->priv->backend, distro_upgrade_enum, sections[2], sections[3]);
+ goto out;
} else {
egg_warning ("invalid command '%s'", command);
}
commit afc7a1ba04913b58bcd11e80b125a4b025ecb170
Author: Stefan Haas <shaas at suse.de>
Date: Tue Sep 2 12:46:12 2008 +0200
zypp: updated pk-matrix
diff --git a/docs/html/pk-matrix.html b/docs/html/pk-matrix.html
index 5cffb7d..ccf7074 100644
--- a/docs/html/pk-matrix.html
+++ b/docs/html/pk-matrix.html
@@ -182,7 +182,7 @@
<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 -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- zypp -->
+<td><img src="img/status-good.png" alt="[yes]"/></td><!-- zypp -->
</tr>
<tr>
<td><b>GetUpdates</b></td>
More information about the PackageKit-commit
mailing list