[packagekit] packagekit: Branch 'master' - 17 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Sun Oct 28 09:11:02 PDT 2007
backends/pisi/helpers/Makefile.am | 4 -
backends/pisi/helpers/pisiBackend.py | 35 ++++++++++
backends/pisi/helpers/repo-set-data.py | 19 +++++
backends/pisi/helpers/search-name.py | 19 +++++
backends/pisi/pk-backend-pisi.c | 4 -
backends/smart/helpers/get-description.py | 20 ++++++
backends/smart/helpers/get-repo-list.py | 18 +++++
backends/smart/helpers/repo-enable.py | 21 ++++++
backends/smart/helpers/smartBackend.py | 100 ++++++++++++++++++++++++++++--
backends/smart/pk-backend-smart.c | 6 -
client/pk-console.c | 64 ++++++++++++++++---
html/pk-download.html | 15 ----
html/pk-faq.html | 10 +--
python/packagekit/backend.py | 8 ++
src/pk-backend-python.c | 11 +++
src/pk-backend-python.h | 5 +
16 files changed, 322 insertions(+), 37 deletions(-)
New commits:
commit eef79dda37bf2094bb956d33600a9cd77ee619ed
Author: S.ÃaÄlar Onur <caglar at pardus.org.tr>
Date: Sat Oct 27 13:40:28 2007 +0300
Update pk-download.html for following;
* Add 0.1.1 to Release Versions section,
* Add optional keyword to libnm dependency,
* Remove backends status percentages and redirect to FAQ
diff --git a/html/pk-download.html b/html/pk-download.html
index f5f0beb..748c799 100644
--- a/html/pk-download.html
+++ b/html/pk-download.html
@@ -36,6 +36,7 @@ Released versions are found on
<table>
<tr><td><b>Version</b></td><td> </td><td><b>Date</b></td></tr>
<tr><td>0.1.0</td><td></td><td>2007-10-16</td></tr>
+<tr><td>0.1.1</td><td></td><td>2007-10-23</td></tr>
</table>
<h2>Dependencies</h2>
@@ -46,7 +47,7 @@ The actual PackageKit daemon needs:
<li><code>glib</code> 2.14.0</li>
<li><code>dbus</code> newer than 1.1.3 (20070819 or later)</li>
<li><code>dbus-glib</code> 0.74</li>
-<li><code>libnm</code> 0.6.4</li>
+<li><code>libnm</code> 0.6.4 (optional)</li>
<li><code>polkit-dbus</code> 0.5</li>
<li><code>polkit-grant</code> 0.5</li>
</ul>
@@ -87,18 +88,8 @@ information.
<p>
Backends do not have to be complete; often they just contain basic
functionality to install and remove but do not provide dependency or file
-lists for example.
-For instance:
+lists for example. See the FAQ <a href="pk-faq.html">here</a> for backends status.
</p>
-<ul>
-<li>yum (95% complete)</li>
-<li>conary (70% complete)</li>
-<li>box (50% complete)</li>
-<li>apt (40% complete)</li>
-<li>pacman/alpm (10% complete)</li>
-<li>smart (25% complete)</li>
-<li>pisi (25% complete)</li>
-</ul>
<p>
We need people to create backends, and then package (pardon the pun)
commit a07a35b07ff9b9541fe0cbcec4ef7d4254414d0d
Author: S.ÃaÄlar Onur <caglar at pardus.org.tr>
Date: Sat Oct 27 13:27:16 2007 +0300
Update backend status
diff --git a/html/pk-faq.html b/html/pk-faq.html
index da5372d..8d9da3e 100644
--- a/html/pk-faq.html
+++ b/html/pk-faq.html
@@ -43,7 +43,7 @@ get-description | X | X | X | X | | X | X |
get-update-detail | | | | | | | |
get-repo-list | | X | | X | X | X | X |
repo-enable | | X | | X | | X | |
-repo-set-data | | | | | | | |
+repo-set-data | | | | | | | X |
cancel-transaction| | | | | | | X |
</pre>
commit 88770dacb0624b1b551612c2c79d9ca1f83b4f13
Author: S.ÃaÄlar Onur <caglar at pardus.org.tr>
Date: Sat Oct 27 13:26:30 2007 +0300
PiSi: Add repo-set-data to backend
diff --git a/backends/pisi/helpers/Makefile.am b/backends/pisi/helpers/Makefile.am
index a2df63b..6087a38 100644
--- a/backends/pisi/helpers/Makefile.am
+++ b/backends/pisi/helpers/Makefile.am
@@ -14,6 +14,7 @@ dist_helper_DATA = \
refresh-cache.py \
remove.py \
resolve.py \
+ repo-set-data.py \
search-name.py \
update.py \
update-system.py \
diff --git a/backends/pisi/helpers/pisiBackend.py b/backends/pisi/helpers/pisiBackend.py
index c236798..5e3c755 100644
--- a/backends/pisi/helpers/pisiBackend.py
+++ b/backends/pisi/helpers/pisiBackend.py
@@ -58,6 +58,8 @@ class PackageKitPisiBackend(PackageKitBaseBackend):
def resolve(self, filter, package):
""" Turns a single package name into a package_id suitable for the other methods """
+
+ #FIXME: Use filter
self.allow_interrupt(True);
self.percentage(None)
self.__get_package(package)
@@ -225,8 +227,34 @@ class PackageKitPisiBackend(PackageKitBaseBackend):
self.__get_package(pkg.package)
def search_name(self, filters, package):
+ """ Prints a list of packages contains search term """
+
+ # FIXME: Use filter
self.allow_interrupt(True)
self.percentage(None)
for pkg in pisi.api.search_package([package]):
self.__get_package(pkg)
+
+ def repo_set_data(self, repo_id, parameter, value):
+ self.allow_interrupt(False)
+ self.percentage(None)
+
+ if parameter == "add-repo":
+ try:
+ pisi.api.add_repo(repo_id, value, parameter)
+ except pisi.Error, e:
+ self.error(ERROR_INTERNAL_ERROR, e)
+
+ try:
+ pisi.api.update_repo(repo_id)
+ except pisi.fetcher.FetchError:
+ pisi.api.remove_repo(repo_id)
+ self.error(ERROR_REPO_NOT_FOUND, "Could not be reached to repository, removing from system")
+ elif parameter == "remove-repo":
+ try:
+ pisi.api.remove_repo(repo_id)
+ except pisi.Error:
+ self.error(ERROR_REPO_NOT_FOUND, "Repository is not exists")
+ else:
+ self.error(ERROR_INTERNAL_ERROR, "Parameter not supported")
diff --git a/backends/pisi/helpers/repo-set-data.py b/backends/pisi/helpers/repo-set-data.py
new file mode 100644
index 0000000..05dbeb5
--- /dev/null
+++ b/backends/pisi/helpers/repo-set-data.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.repo_set_data(sys.argv[1], sys.argv[2], sys.argv[3])
+
+sys.exit()
diff --git a/backends/pisi/pk-backend-pisi.c b/backends/pisi/pk-backend-pisi.c
index 8fd7bbf..ede2ace 100644
--- a/backends/pisi/pk-backend-pisi.c
+++ b/backends/pisi/pk-backend-pisi.c
@@ -51,5 +51,5 @@ PK_BACKEND_OPTIONS (
pk_backend_python_update_system, /* update_system */
pk_backend_python_get_repo_list, /* get_repo_list */
NULL, /* repo_enable */
- NULL /* repo_set_data */
+ pk_backend_python_repo_set_data /* repo_set_data */
);
commit bcdcc58e28cb925b16d1ab8471c4b925ecce0f61
Author: S.ÃaÄlar Onur <caglar at pardus.org.tr>
Date: Sat Oct 27 13:25:04 2007 +0300
Add set-repo-data action to pkcon
diff --git a/client/pk-console.c b/client/pk-console.c
index f023c70..b9a9e51 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -357,6 +357,7 @@ const gchar *summary =
" get repos\n"
" enable-repo <repo_id>\n"
" disable-repo <repo_id>\n"
+ " set-repo-data <repo_id> <parameter> <value>\n"
"\n"
" package_id is typically gimp;2:2.4.0-0.rc1.1.fc8;i386;development";
@@ -593,6 +594,7 @@ pk_console_process_commands (PkClient *client, int argc, char *argv[], gboolean
const gchar *mode;
const gchar *value = NULL;
const gchar *details = NULL;
+ const gchar *parameter = NULL;
gboolean wait = FALSE;
PkEnumList *elist;
@@ -603,6 +605,9 @@ pk_console_process_commands (PkClient *client, int argc, char *argv[], gboolean
if (argc > 3) {
details = argv[3];
}
+ if (argc > 4) {
+ parameter = argv[4];
+ }
if (strcmp (mode, "search") == 0) {
if (value == NULL) {
@@ -688,6 +693,13 @@ pk_console_process_commands (PkClient *client, int argc, char *argv[], gboolean
} else {
wait = pk_client_repo_enable (client, value, FALSE);
}
+ } else if (strcmp (mode, "set-repo-data") == 0) {
+ if (value == NULL || details == NULL || parameter == NULL) {
+ g_set_error (error, 0, 0, "you need to specify a repo name/parameter and value");
+ return FALSE;
+ } else {
+ wait = pk_client_repo_set_data (client, value, details, parameter);
+ }
} else if (strcmp (mode, "get") == 0) {
if (value == NULL) {
g_set_error (error, 0, 0, "you need to specify a get type");
commit ebd2aabfbf25188e9ca6b5e277ebcb306612bdd6
Author: S.ÃaÄlar Onur <caglar at pardus.org.tr>
Date: Sat Oct 27 13:24:23 2007 +0300
Add repo-set-data to Python Backend
diff --git a/python/packagekit/backend.py b/python/packagekit/backend.py
index a288a84..773e83d 100644
--- a/python/packagekit/backend.py
+++ b/python/packagekit/backend.py
@@ -344,6 +344,14 @@ class PackageKitBaseBackend:
'''
self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+ def repo_set_data(self, repoid, parameter, value):
+ '''
+ Implement the {backend}-repo-set-data functionality
+ Needed to be implemented in a sub class
+ '''
+ self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+
+
def get_repo_list(self):
'''
Implement the {backend}-get-repo-list functionality
diff --git a/src/pk-backend-python.c b/src/pk-backend-python.c
index da53c5d..3a37104 100644
--- a/src/pk-backend-python.c
+++ b/src/pk-backend-python.c
@@ -229,3 +229,14 @@ pk_backend_python_repo_enable (PkBackend *backend, const gchar *rid, gboolean en
pk_backend_spawn_helper (backend, "repo-enable.py", rid, "false", NULL);
}
}
+
+/**
+ * pk_backend_python_repo_set_data:
+ */
+void
+pk_backend_python_repo_set_data (PkBackend *backend, const gchar *rid,
+ const gchar *parameter, const gchar *value)
+{
+ g_return_if_fail (backend != NULL);
+ pk_backend_spawn_helper (backend, "repo-set-data.py", rid, parameter, value, NULL);
+}
diff --git a/src/pk-backend-python.h b/src/pk-backend-python.h
index a9901f9..46e0343 100644
--- a/src/pk-backend-python.h
+++ b/src/pk-backend-python.h
@@ -83,6 +83,11 @@ void pk_backend_python_repo_enable (PkBackend *backend,
const gchar *rid,
gboolean enabled);
+void pk_backend_python_repo_set_data (PkBackend *backend,
+ const gchar *rid,
+ const gchar *parameter,
+ const gchar *value);
+
G_END_DECLS
#endif /* __PK_BACKEND_PYTHON_H */
commit c9a94d886294f6537d744498adaeacaab5c0d5c0
Merge: 5d802f5... e433b5c...
Author: James Bowes <jbowes at dangerouslyinc.com>
Date: Fri Oct 26 19:53:05 2007 -0400
Merge branch 'smart'
Conflicts:
html/pk-faq.html
diff --cc html/pk-faq.html
index 9b818ff,3ac4f54..da5372d
--- a/html/pk-faq.html
+++ b/html/pk-faq.html
@@@ -39,10 -39,10 +39,10 @@@ remove-package | X | X |
update-package | | X | | X | | X | X |
get-depends | | X | | X | | | X |
get-requires | X | | | X | | | X |
- get-description | X | X | X | X | | | X |
+ get-description | X | X | X | X | | X | X |
get-update-detail | | | | | | | |
- get-repo-list | | X | | X | X | | X |
- repo-enable | | X | | X | | | |
+ get-repo-list | | X | | X | X | X | X |
-repo-enable | | X | | | | X | |
++repo-enable | | X | | X | | X | |
repo-set-data | | | | | | | |
cancel-transaction| | | | | | | X |
</pre>
commit 5d802f5e9c251adb0a125bcacb16cc3580898442
Merge: 23377af... c82bf88...
Author: James Bowes <jbowes at dangerouslyinc.com>
Date: Fri Oct 26 19:48:33 2007 -0400
Merge branch 'time-estimates'
diff --cc client/pk-console.c
index 0c0f226,78502be..f023c70
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@@ -35,8 -34,7 +35,8 @@@
#include <pk-package-id.h>
#include <pk-enum-list.h>
- #define PROGRESS_BAR_PADDING 30
-#define PROGRESS_BAR_SIZE 60
++#define PROGRESS_BAR_PADDING 22
+#define MINIMUM_COLUMNS (PROGRESS_BAR_PADDING + 5)
static GMainLoop *loop = NULL;
static gboolean is_console = FALSE;
commit 23377af423564fb05a416806488512487a3bed12
Author: James Bowes <jbowes at dangerouslyinc.com>
Date: Wed Oct 24 21:49:36 2007 -0400
pkcon: Calculate progress bar length based on terminal columns.
diff --git a/client/pk-console.c b/client/pk-console.c
index 3b223be..0c0f226 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -25,6 +25,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
+#include <sys/ioctl.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <dbus/dbus-glib.h>
@@ -34,7 +35,8 @@
#include <pk-package-id.h>
#include <pk-enum-list.h>
-#define PROGRESS_BAR_SIZE 60
+#define PROGRESS_BAR_PADDING 30
+#define MINIMUM_COLUMNS (PROGRESS_BAR_PADDING + 5)
static GMainLoop *loop = NULL;
static gboolean is_console = FALSE;
@@ -176,14 +178,31 @@ pk_console_repo_detail_cb (PkClient *client, const gchar *repo_id,
}
/**
+ * pk_console_get_terminal_columns:
+ **/
+static guint
+pk_console_get_terminal_columns (void)
+{
+ struct winsize ws;
+
+ ioctl (1, TIOCGWINSZ, &ws);
+ if (ws.ws_col < MINIMUM_COLUMNS) {
+ return MINIMUM_COLUMNS;
+ }
+
+ return ws.ws_col;
+}
+
+/**
* pk_console_draw_progress_bar:
**/
static void
pk_console_draw_progress_bar (guint percentage, guint remaining_time)
{
guint i;
- guint progress = (gint) (PROGRESS_BAR_SIZE * (gfloat) (percentage) / 100);
- guint remaining = PROGRESS_BAR_SIZE - progress;
+ guint progress_bar_size = pk_console_get_terminal_columns () - PROGRESS_BAR_PADDING;
+ guint progress = (gint) (progress_bar_size * (gfloat) (percentage) / 100);
+ guint remaining = progress_bar_size - progress;
/* have we already been spinning? */
if (timer_id != 0) {
@@ -219,6 +238,8 @@ static gboolean
pk_console_pulse_bar (PulseState *pulse_state)
{
guint i;
+ guint progress_bar_size = pk_console_get_terminal_columns () - PROGRESS_BAR_PADDING;
+ gchar *padding;
/* don't spin if we have had output */
if (has_output == TRUE) {
@@ -234,13 +255,13 @@ pk_console_pulse_bar (PulseState *pulse_state)
g_print (".");
}
printf("===");
- for (i = pulse_state->position; i < PROGRESS_BAR_SIZE - 1; i++) {
+ for (i = pulse_state->position; i < progress_bar_size - 2; i++) {
g_print (".");
}
g_print ("]");
if (pulse_state->move_forward == TRUE) {
- if (pulse_state->position == PROGRESS_BAR_SIZE - 1) {
+ if (pulse_state->position == progress_bar_size - 2) {
pulse_state->move_forward = FALSE;
pulse_state->position--;
} else {
@@ -255,6 +276,11 @@ pk_console_pulse_bar (PulseState *pulse_state)
}
}
+ /* Move the cursor off the screen. */
+ padding = g_strnfill (PROGRESS_BAR_PADDING - 6, ' ');
+ g_print ("%s", padding);
+ g_free (padding);
+
return TRUE;
}
@@ -354,7 +380,7 @@ pk_console_finished_cb (PkClient *client, PkStatusEnum status, guint runtime, gp
/* if on console, clear the progress bar line */
if (is_console == TRUE && printed_bar == TRUE && has_output == FALSE) {
g_print ("\r");
- blanking = g_strnfill (PROGRESS_BAR_SIZE + 7, ' ');
+ blanking = g_strnfill (pk_console_get_terminal_columns (), ' ');
g_print ("%s", blanking);
g_free (blanking);
g_print ("\r");
commit e433b5c5d228f85ba3eb0d7221cf3d1502442150
Author: James Bowes <jbowes at dangerouslyinc.com>
Date: Fri Oct 26 19:32:05 2007 -0400
smart: Use a decorator for loading and saving the smart cache
diff --git a/backends/smart/helpers/smartBackend.py b/backends/smart/helpers/smartBackend.py
index ade0f60..255bbf3 100644
--- a/backends/smart/helpers/smartBackend.py
+++ b/backends/smart/helpers/smartBackend.py
@@ -21,6 +21,17 @@ from packagekit.backend import PackageKitBaseBackend, INFO_INSTALLED, \
INFO_AVAILABLE, INFO_NORMAL, FILTER_NON_INSTALLED, FILTER_INSTALLED, \
ERROR_REPO_NOT_FOUND
+
+def needs_cache(func):
+ """ Load smart's channels, and save the cache when done. """
+ def cache_wrap(obj, *args, **kwargs):
+ obj.ctrl.reloadChannels()
+ result = func(obj, *args, **kwargs)
+ obj.ctrl.saveSysConf()
+ return result
+ return cache_wrap
+
+
class PackageKitSmartBackend(PackageKitBaseBackend):
def __init__(self, args):
@@ -33,9 +44,8 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
smart.initPlugins()
smart.initPsyco()
+ @needs_cache
def install(self, packageid):
- self.ctrl.reloadChannels()
-
idparts = packageid.split(';')
packagestring = "%s-%s@%s" % (idparts[0], idparts[1], idparts[2])
ratio, results, suggestions = self.ctrl.search(packagestring)
@@ -52,9 +62,8 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
trans.run()
self.ctrl.commitTransaction(trans, confirm=False)
+ @needs_cache
def remove(self, allowdeps, packageid):
- self.ctrl.reloadChannels()
-
idparts = packageid.split(';')
packagestring = "%s-%s@%s" % (idparts[0], idparts[1], idparts[2])
ratio, results, suggestions = self.ctrl.search(packagestring)
@@ -71,9 +80,8 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
trans.run()
self.ctrl.commitTransaction(trans, confirm=False)
+ @needs_cache
def update(self, packageid):
- self.ctrl.reloadChannels()
-
idparts = packageid.split(';')
packagestring = "%s-%s@%s" % (idparts[0], idparts[1], idparts[2])
ratio, results, suggestions = self.ctrl.search(packagestring)
@@ -89,9 +97,8 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
trans.run()
self.ctrl.commitTransaction(trans, confirm=False)
+ @needs_cache
def update_system(self):
- self.ctrl.reloadChannels()
-
cache = self.ctrl.getCache()
trans = smart.transaction.Transaction(cache,
@@ -104,9 +111,8 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
trans.run()
self.ctrl.commitTransaction(trans, confirm=False)
+ @needs_cache
def get_updates(self):
- self.ctrl.reloadChannels()
-
cache = self.ctrl.getCache()
trans = smart.transaction.Transaction(cache,
@@ -121,9 +127,8 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
if op == smart.transaction.INSTALL:
self._show_package(package, status=INFO_NORMAL)
+ @needs_cache
def resolve(self, filters, packagename):
- self.ctrl.reloadChannels()
-
filterlist = filters.split(';')
ratio, results, suggestions = self.ctrl.search(packagename)
@@ -133,9 +138,8 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
if FILTER_INSTALLED not in filterlist and not result.installed:
self._show_package(result)
+ @needs_cache
def search_name(self, filters, packagename):
- self.ctrl.reloadChannels()
-
globbed = "*%s*" % packagename
ratio, results, suggestions = self.ctrl.search(globbed)
@@ -147,10 +151,10 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
def refresh_cache(self):
self.ctrl.rebuildSysConfChannels()
self.ctrl.reloadChannels(None, caching=smart.const.NEVER)
+ self.ctrl.saveSysConf()
+ @needs_cache
def get_description(self, packageid):
- self.ctrl.reloadChannels()
-
idparts = packageid.split(';')
packagestring = "%s-%s@%s" % (idparts[0], idparts[1], idparts[2])
ratio, results, suggestions = self.ctrl.search(packagestring)
commit 1ba5e4ffe789f38095a8d33201ef0f40635b9951
Author: James Bowes <jbowes at dangerouslyinc.com>
Date: Fri Oct 26 18:32:15 2007 -0400
smart: Only reload the channels when needed
diff --git a/backends/smart/helpers/smartBackend.py b/backends/smart/helpers/smartBackend.py
index ecc38e5..ade0f60 100644
--- a/backends/smart/helpers/smartBackend.py
+++ b/backends/smart/helpers/smartBackend.py
@@ -33,10 +33,9 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
smart.initPlugins()
smart.initPsyco()
+ def install(self, packageid):
self.ctrl.reloadChannels()
- self.ctrl.getCache()
- def install(self, packageid):
idparts = packageid.split(';')
packagestring = "%s-%s@%s" % (idparts[0], idparts[1], idparts[2])
ratio, results, suggestions = self.ctrl.search(packagestring)
@@ -54,6 +53,7 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self.ctrl.commitTransaction(trans, confirm=False)
def remove(self, allowdeps, packageid):
+ self.ctrl.reloadChannels()
idparts = packageid.split(';')
packagestring = "%s-%s@%s" % (idparts[0], idparts[1], idparts[2])
@@ -72,6 +72,8 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self.ctrl.commitTransaction(trans, confirm=False)
def update(self, packageid):
+ self.ctrl.reloadChannels()
+
idparts = packageid.split(';')
packagestring = "%s-%s@%s" % (idparts[0], idparts[1], idparts[2])
ratio, results, suggestions = self.ctrl.search(packagestring)
@@ -88,8 +90,11 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self.ctrl.commitTransaction(trans, confirm=False)
def update_system(self):
+ self.ctrl.reloadChannels()
+
cache = self.ctrl.getCache()
- trans = smart.transaction.Transaction(self.ctrl.getCache(),
+
+ trans = smart.transaction.Transaction(cache,
smart.transaction.PolicyUpgrade)
for package in cache.getPackages():
@@ -100,8 +105,11 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self.ctrl.commitTransaction(trans, confirm=False)
def get_updates(self):
+ self.ctrl.reloadChannels()
+
cache = self.ctrl.getCache()
- trans = smart.transaction.Transaction(self.ctrl.getCache(),
+
+ trans = smart.transaction.Transaction(cache,
smart.transaction.PolicyUpgrade)
for package in cache.getPackages():
@@ -114,6 +122,8 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self._show_package(package, status=INFO_NORMAL)
def resolve(self, filters, packagename):
+ self.ctrl.reloadChannels()
+
filterlist = filters.split(';')
ratio, results, suggestions = self.ctrl.search(packagename)
@@ -124,6 +134,8 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self._show_package(result)
def search_name(self, filters, packagename):
+ self.ctrl.reloadChannels()
+
globbed = "*%s*" % packagename
ratio, results, suggestions = self.ctrl.search(globbed)
@@ -137,6 +149,8 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self.ctrl.reloadChannels(None, caching=smart.const.NEVER)
def get_description(self, packageid):
+ self.ctrl.reloadChannels()
+
idparts = packageid.split(';')
packagestring = "%s-%s@%s" % (idparts[0], idparts[1], idparts[2])
ratio, results, suggestions = self.ctrl.search(packagestring)
commit 56bad2ed73e00728a2aaff940b415c90cb3c982f
Author: James Bowes <jbowes at dangerouslyinc.com>
Date: Fri Oct 26 17:49:37 2007 -0400
smart: Initialize plugins and psyco.
diff --git a/backends/smart/helpers/smartBackend.py b/backends/smart/helpers/smartBackend.py
index be30cf4..ecc38e5 100644
--- a/backends/smart/helpers/smartBackend.py
+++ b/backends/smart/helpers/smartBackend.py
@@ -30,6 +30,9 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self.percentage(None)
self.ctrl = smart.init()
+ smart.initPlugins()
+ smart.initPsyco()
+
self.ctrl.reloadChannels()
self.ctrl.getCache()
commit 94b9ef4a00813ac77682d66e5f47051fcf2dc87e
Author: S.ÃaÄlar Onur <caglar at pardus.org.tr>
Date: Sat Oct 27 00:40:14 2007 +0300
PiSi: add search-name support to backend
diff --git a/backends/pisi/helpers/Makefile.am b/backends/pisi/helpers/Makefile.am
index 45fc045..a2df63b 100644
--- a/backends/pisi/helpers/Makefile.am
+++ b/backends/pisi/helpers/Makefile.am
@@ -9,11 +9,12 @@ dist_helper_DATA = \
get-repo-list.py \
get-requires.py \
get-updates.py \
- install.py \
install-file.py \
+ install.py \
refresh-cache.py \
remove.py \
resolve.py \
+ search-name.py \
update.py \
update-system.py \
pisiBackend.py \
diff --git a/backends/pisi/helpers/pisiBackend.py b/backends/pisi/helpers/pisiBackend.py
index 70114fb..c236798 100644
--- a/backends/pisi/helpers/pisiBackend.py
+++ b/backends/pisi/helpers/pisiBackend.py
@@ -223,3 +223,10 @@ class PackageKitPisiBackend(PackageKitBaseBackend):
for pkg in self.packagedb.get_package(package).runtimeDependencies():
# Internal FIXME: PiSi API has really inconsistent for return types and arguments!
self.__get_package(pkg.package)
+
+ def search_name(self, filters, package):
+ self.allow_interrupt(True)
+ self.percentage(None)
+
+ for pkg in pisi.api.search_package([package]):
+ self.__get_package(pkg)
diff --git a/backends/pisi/helpers/search-name.py b/backends/pisi/helpers/search-name.py
new file mode 100644
index 0000000..1b4e3aa
--- /dev/null
+++ b/backends/pisi/helpers/search-name.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_name(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 74ac955..8fd7bbf 100644
--- a/backends/pisi/pk-backend-pisi.c
+++ b/backends/pisi/pk-backend-pisi.c
@@ -46,7 +46,7 @@ PK_BACKEND_OPTIONS (
NULL, /* search_details */
NULL, /* search_file */
NULL, /* search_group */
- NULL, /* search_name */
+ pk_backend_python_search_name, /* search_name */
pk_backend_python_update_package, /* update_package */
pk_backend_python_update_system, /* update_system */
pk_backend_python_get_repo_list, /* get_repo_list */
diff --git a/html/pk-faq.html b/html/pk-faq.html
index 138b51c..9b818ff 100644
--- a/html/pk-faq.html
+++ b/html/pk-faq.html
@@ -29,7 +29,7 @@ resolve | | X | | X | | X | X |
refresh-cache | X | X | X | X | | X | X |
get-updates | X | X | | X | | X | X |
update-system | X | X | | X | | X | X |
-search-name | X | 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 | | | | | | | |
commit 29c549f58a0b23a9cd6e31eb3fb7c544900a280a
Merge: 8c94676... 87b2c6e...
Author: James Bowes <jbowes at dangerouslyinc.com>
Date: Thu Oct 25 22:47:54 2007 -0400
Merge branch 'master' into smart
Conflicts:
backends/BACKENDS
html/pk-faq.html
diff --cc html/pk-faq.html
index fac24ee,83b48f9..3ac4f54
--- a/html/pk-faq.html
+++ b/html/pk-faq.html
@@@ -39,12 -39,12 +39,12 @@@ remove-package | X | X |
update-package | | X | | X | | X | X |
get-depends | | X | | X | | | X |
get-requires | X | | | X | | | X |
-get-description | X | X | X | X | | | X |
+get-description | X | X | X | X | | X | X |
get-update-detail | | | | | | | |
- get-repo-list | | X | | | X | X | X |
-get-repo-list | | X | | X | X | | X |
-repo-enable | | X | | | | | |
++get-repo-list | | X | | X | X | X | X |
+repo-enable | | X | | | | X | |
repo-set-data | | | | | | | |
- cancel-transaction| | | | | | | |
+ cancel-transaction| | | | | | | X |
</pre>
<h3>What if the backend package manager doesn't support percentage updates?</h3>
commit 8c94676a26afdf2993cbb5afe43177a7c0922f2e
Author: James Bowes <jbowes at dangerouslyinc.com>
Date: Thu Oct 25 22:05:07 2007 -0400
smart: Implement repo-enable.
diff --git a/backends/BACKENDS b/backends/BACKENDS
index 2233dd0..ad52a52 100644
--- a/backends/BACKENDS
+++ b/backends/BACKENDS
@@ -19,7 +19,7 @@ get-requires | X | | | X | | | X |
get-description | X | X | X | X | | X | X |
get-update-detail | | | | | | | |
get-repo-list | | X | | | X | X | X |
-repo-enable | | X | | | | | |
+repo-enable | | X | | | | X | |
repo-set-data | | | | | | | |
cancel-transaction| | | | | | | |
diff --git a/backends/smart/helpers/repo-enable.py b/backends/smart/helpers/repo-enable.py
new file mode 100755
index 0000000..b283422
--- /dev/null
+++ b/backends/smart/helpers/repo-enable.py
@@ -0,0 +1,21 @@
+#!/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]
+state=sys.argv[2]
+backend = PackageKitSmartBackend(sys.argv[2:])
+backend.repo_enable(repoid,state)
+sys.exit(0)
diff --git a/backends/smart/helpers/smartBackend.py b/backends/smart/helpers/smartBackend.py
index 9734fae..be30cf4 100644
--- a/backends/smart/helpers/smartBackend.py
+++ b/backends/smart/helpers/smartBackend.py
@@ -18,7 +18,8 @@
import smart
from packagekit.backend import PackageKitBaseBackend, INFO_INSTALLED, \
- INFO_AVAILABLE, INFO_NORMAL, FILTER_NON_INSTALLED, FILTER_INSTALLED
+ INFO_AVAILABLE, INFO_NORMAL, FILTER_NON_INSTALLED, FILTER_INSTALLED, \
+ ERROR_REPO_NOT_FOUND
class PackageKitSmartBackend(PackageKitBaseBackend):
@@ -188,6 +189,16 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
enabled = 'false'
self.repo_detail(alias, channel['name'], enabled)
+ def repo_enable(self, repoid, enable):
+ if smart.sysconf.has(("channels", repoid)):
+ if enable == "true":
+ smart.sysconf.remove(("channels", repoid, "disabled"))
+ else:
+ smart.sysconf.set(("channels", repoid, "disabled"), "yes")
+ self.ctrl.saveSysConf()
+ else:
+ self.error(ERROR_REPO_NOT_FOUND, "repo %s was not found" % repoid)
+
def _show_package(self, package, status=None):
if not status:
if package.installed:
diff --git a/backends/smart/pk-backend-smart.c b/backends/smart/pk-backend-smart.c
index 79433ab..dfbb720 100644
--- a/backends/smart/pk-backend-smart.c
+++ b/backends/smart/pk-backend-smart.c
@@ -51,6 +51,6 @@ PK_BACKEND_OPTIONS (
pk_backend_python_update_package, /* update_package */
pk_backend_python_update_system, /* update_system */
pk_backend_python_get_repo_list, /* get_repo_list */
- NULL, /* repo_enable */
+ pk_backend_python_repo_enable, /* repo_enable */
NULL /* repo_set_data */
);
diff --git a/html/pk-faq.html b/html/pk-faq.html
index 15e3f59..fac24ee 100644
--- a/html/pk-faq.html
+++ b/html/pk-faq.html
@@ -42,7 +42,7 @@ get-requires | X | | | X | | | X |
get-description | X | X | X | X | | X | X |
get-update-detail | | | | | | | |
get-repo-list | | X | | | X | X | X |
-repo-enable | | X | | | | | |
+repo-enable | | X | | | | X | |
repo-set-data | | | | | | | |
cancel-transaction| | | | | | | |
</pre>
commit 48623b83c33216c3c4b7e750792317b6201d76ef
Author: James Bowes <jbowes at dangerouslyinc.com>
Date: Thu Oct 25 17:12:46 2007 -0400
smart: Implement get-repo-list.
diff --git a/backends/BACKENDS b/backends/BACKENDS
index f11c5da..2233dd0 100644
--- a/backends/BACKENDS
+++ b/backends/BACKENDS
@@ -18,7 +18,7 @@ get-depends | | X | | X | | | X |
get-requires | X | | | X | | | X |
get-description | X | X | X | X | | X | X |
get-update-detail | | | | | | | |
-get-repo-list | | X | | | X | | X |
+get-repo-list | | X | | | X | X | X |
repo-enable | | X | | | | | |
repo-set-data | | | | | | | |
cancel-transaction| | | | | | | |
diff --git a/backends/smart/helpers/get-repo-list.py b/backends/smart/helpers/get-repo-list.py
new file mode 100755
index 0000000..c372f1e
--- /dev/null
+++ b/backends/smart/helpers/get-repo-list.py
@@ -0,0 +1,18 @@
+#!/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
+backend = PackageKitSmartBackend(sys.argv[2:])
+backend.get_repo_list()
+sys.exit(0)
diff --git a/backends/smart/helpers/smartBackend.py b/backends/smart/helpers/smartBackend.py
index 1fa5a4a..9734fae 100644
--- a/backends/smart/helpers/smartBackend.py
+++ b/backends/smart/helpers/smartBackend.py
@@ -178,6 +178,16 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self.description(packageid, "unknown", "unknown", description, url,
pkgsize, ";".join(info.getPathList()))
+ def get_repo_list(self):
+ channels = smart.sysconf.get("channels", ())
+ for alias in channels:
+ channel = smart.sysconf.get(("channels", alias))
+ parsed = smart.channel.parseChannelData(channel)
+ enabled = 'true'
+ if channel.has_key('disabled') and channel['disabled'] == 'yes':
+ enabled = 'false'
+ self.repo_detail(alias, channel['name'], enabled)
+
def _show_package(self, package, status=None):
if not status:
if package.installed:
diff --git a/backends/smart/pk-backend-smart.c b/backends/smart/pk-backend-smart.c
index 3a61778..79433ab 100644
--- a/backends/smart/pk-backend-smart.c
+++ b/backends/smart/pk-backend-smart.c
@@ -50,7 +50,7 @@ PK_BACKEND_OPTIONS (
pk_backend_python_search_name, /* search_name */
pk_backend_python_update_package, /* update_package */
pk_backend_python_update_system, /* update_system */
- NULL, /* get_repo_list */
+ pk_backend_python_get_repo_list, /* get_repo_list */
NULL, /* repo_enable */
NULL /* repo_set_data */
);
diff --git a/html/pk-faq.html b/html/pk-faq.html
index 25d66df..15e3f59 100644
--- a/html/pk-faq.html
+++ b/html/pk-faq.html
@@ -41,7 +41,7 @@ get-depends | | X | | X | | | X |
get-requires | X | | | X | | | X |
get-description | X | X | X | X | | X | X |
get-update-detail | | | | | | | |
-get-repo-list | | X | | | X | | X |
+get-repo-list | | X | | | X | X | X |
repo-enable | | X | | | | | |
repo-set-data | | | | | | | |
cancel-transaction| | | | | | | |
commit 0a42538a9ffc077535df3dd144641f7613a7509b
Author: James Bowes <jbowes at dangerouslyinc.com>
Date: Thu Oct 25 07:45:29 2007 -0400
smart: Implement get-description.
diff --git a/backends/BACKENDS b/backends/BACKENDS
index 954a8ac..f11c5da 100644
--- a/backends/BACKENDS
+++ b/backends/BACKENDS
@@ -16,7 +16,7 @@ remove-package | X | X | | X | X | X | X |
update-package | | X | | X | | X | X |
get-depends | | X | | X | | | X |
get-requires | X | | | X | | | X |
-get-description | X | X | X | X | | | X |
+get-description | X | X | X | X | | X | X |
get-update-detail | | | | | | | |
get-repo-list | | X | | | X | | X |
repo-enable | | X | | | | | |
diff --git a/backends/smart/helpers/get-description.py b/backends/smart/helpers/get-description.py
new file mode 100755
index 0000000..8a2babf
--- /dev/null
+++ b/backends/smart/helpers/get-description.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
+
+package = sys.argv[1]
+backend = PackageKitSmartBackend(sys.argv[1:])
+backend.get_description(package)
+sys.exit(0)
diff --git a/backends/smart/helpers/smartBackend.py b/backends/smart/helpers/smartBackend.py
index 8bcc1ce..1fa5a4a 100644
--- a/backends/smart/helpers/smartBackend.py
+++ b/backends/smart/helpers/smartBackend.py
@@ -132,6 +132,52 @@ class PackageKitSmartBackend(PackageKitBaseBackend):
self.ctrl.rebuildSysConfChannels()
self.ctrl.reloadChannels(None, caching=smart.const.NEVER)
+ 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)
+
+ packages = self._process_search_results(results)
+
+ if len(packages) != 1:
+ return
+
+ package = packages[0]
+ infos = []
+ for loader in package.loaders:
+ info = loader.getInfo(package)
+ infos.append(info)
+
+ infos.sort()
+ info = infos[0]
+
+ version, arch = package.version.split('@')
+ description = info.getDescription()
+ description = description.replace("\n\n", ";")
+ description = description.replace("\n", " ")
+ urls = info.getReferenceURLs()
+ if urls:
+ url = urls[0]
+ else:
+ url = "unknown"
+
+ pkgsize = None
+ seen = {}
+ for loader in package.loaders:
+ info = loader.getInfo(package)
+ for pkgurl in info.getURLs():
+ size = info.getSize(pkgurl)
+ if size:
+ pkgsize = size
+ break
+ if pkgsize:
+ break
+ if not pkgsize:
+ pkgsize = "unknown"
+
+ self.description(packageid, "unknown", "unknown", description, url,
+ pkgsize, ";".join(info.getPathList()))
+
def _show_package(self, package, status=None):
if not status:
if package.installed:
diff --git a/backends/smart/pk-backend-smart.c b/backends/smart/pk-backend-smart.c
index 1c3a4b8..3a61778 100644
--- a/backends/smart/pk-backend-smart.c
+++ b/backends/smart/pk-backend-smart.c
@@ -34,7 +34,7 @@ PK_BACKEND_OPTIONS (
NULL, /* get_filters */
NULL, /* cancel */
NULL, /* get_depends */
- NULL, /* get_description */
+ pk_backend_python_get_description, /* get_description */
NULL, /* get_requires */
NULL, /* get_update_detail */
pk_backend_python_get_updates, /* get_updates */
diff --git a/html/pk-faq.html b/html/pk-faq.html
index ac637f1..25d66df 100644
--- a/html/pk-faq.html
+++ b/html/pk-faq.html
@@ -39,7 +39,7 @@ remove-package | X | X | | X | X | X | X |
update-package | | X | | X | | X | X |
get-depends | | X | | X | | | X |
get-requires | X | | | X | | | X |
-get-description | X | X | X | X | | | X |
+get-description | X | X | X | X | | X | X |
get-update-detail | | | | | | | |
get-repo-list | | X | | | X | | X |
repo-enable | | X | | | | | |
commit c82bf88233ed8c9b4cd954336a4ec4eb7a917c2f
Author: James Bowes <jbowes at dangerouslyinc.com>
Date: Tue Oct 23 17:39:51 2007 -0400
pkcon: display eta in hours, minutes or seconds depending on what is left.
diff --git a/client/pk-console.c b/client/pk-console.c
index 53b1db9..78502be 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -203,9 +203,19 @@ pk_console_draw_progress_bar (guint percentage, guint remaining_time)
}
g_print ("] %3i%%", percentage);
if (remaining_time != 0) {
- g_print (" (%i seconds)", remaining_time);
+ if (remaining_time > 60) {
+ guint remaining_minutes = remaining_time / 60;
+ if (remaining_minutes > 60) {
+ guint remaining_hours = remaining_time / 3600;
+ g_print (" (%2ih eta)", remaining_hours);
+ } else {
+ g_print (" (%2im eta)", remaining_minutes);
+ }
+ } else {
+ g_print (" (%2is eta)", remaining_time);
+ }
} else {
- g_print (" ");
+ g_print (" ");
}
if (percentage == 100) {
g_print ("\n");
More information about the PackageKit
mailing list