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

Richard Hughes hughsient at kemper.freedesktop.org
Mon Oct 22 13:50:13 PDT 2007


 backends/BACKENDS                         |    6 -
 backends/yum/helpers/get-repo-list.py     |   18 +++
 backends/yum/helpers/get-update-detail.py |   19 +++
 backends/yum/helpers/repo-enable.py       |   20 +++
 backends/yum/helpers/yumBackend.py        |   27 ++++
 backends/yum/pk-backend-yum.c             |   28 ++++-
 client/pk-console.c                       |    7 +
 configure.ac                              |   18 ++-
 contrib/pk-completion.bash                |  148 ++++++++++++++++++++++++++
 libpackagekit/.gitignore                  |    1 
 libpackagekit/Makefile.am                 |   11 +
 libpackagekit/pk-network-dummy.c          |  132 +++++++++++++++++++++++
 libpackagekit/pk-network-nm.c             |  168 ++++++++++++++++++++++++++++++
 libpackagekit/pk-network.c                |  168 ------------------------------
 python/packagekit/backend.py              |   23 +++-
 15 files changed, 610 insertions(+), 184 deletions(-)

New commits:
commit 28e3f037b983e59155a4d1a18d271b396c5ea777
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Oct 22 21:44:57 2007 +0100

    apply a modified patch from S.Çağlar Onur to remove the hard dep on NetworkManager

diff --git a/configure.ac b/configure.ac
index 6af5641..21824a7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,7 +56,7 @@ dnl ---------------------------------------------------------------------------
 GLIB_REQUIRED=2.14.0
 DBUS_REQUIRED=1.1.1
 DBUS_GLIB_REQUIRED=0.73
-LIBNM_REQUIRED=0.6.4
+LIBNM_GLIB_REQUIRED=0.6.4
 POLKIT_DBUS_REQUIRED=0.5
 POLKIT_GRANT_REQUIRED=0.5
 
@@ -89,8 +89,19 @@ PKG_CHECK_MODULES(DBUS, \
 AC_SUBST(DBUS_CFLAGS)
 AC_SUBST(DBUS_LIBS)
 
-PKG_CHECK_MODULES(LIBNM, \
- libnm_glib >= $LIBNM_REQUIRED)
+dnl ---------------------------------------------------------------------------
+dnl - Is NetworkManager available?
+dnl ---------------------------------------------------------------------------
+PKG_CHECK_MODULES(LIBNM, libnm_glib >= $LIBNM_GLIB_REQUIRED, HAVE_NETWORKMANAGER="yes", HAVE_NETWORKMANAGER="no")
+if test "x$HAVE_NETWORKMANAGER" = "xyes"; then
+	with_networking_stack="NetworkManager"
+	AC_DEFINE(HAVE_NETWORKMANAGER, 1, [define if NetworkManager is installed])
+else
+	with_networking_stack="dummy"
+	HAVE_NETWORKMANAGER=no
+fi
+
+AM_CONDITIONAL(HAVE_NETWORKMANAGER, test x$HAVE_NETWORKMANAGER = xyes)
 AC_SUBST(LIBNM_CFLAGS)
 AC_SUBST(LIBNM_LIBS)
 
@@ -437,6 +448,7 @@ echo "
         cflags:                    ${CFLAGS}
         Default backend:           ${with_default_backend}
         Security Framework:        ${with_security_framework}
+        Networking stack:          ${with_networking_stack}
 "
 
 # warn that dummy is basically broken
diff --git a/libpackagekit/.gitignore b/libpackagekit/.gitignore
index f9799a9..be29c71 100644
--- a/libpackagekit/.gitignore
+++ b/libpackagekit/.gitignore
@@ -6,4 +6,5 @@
 *-marshal.c
 *-marshal.h
 pk-self-test
+*.loT
 
diff --git a/libpackagekit/Makefile.am b/libpackagekit/Makefile.am
index b73aed3..31f346c 100644
--- a/libpackagekit/Makefile.am
+++ b/libpackagekit/Makefile.am
@@ -47,7 +47,6 @@ libpackagekit_la_SOURCES =					\
 	pk-marshal.h						\
 	pk-connection.c						\
 	pk-connection.h						\
-	pk-network.c						\
 	pk-network.h						\
 	pk-package-id.c						\
 	pk-package-id.h						\
@@ -69,6 +68,16 @@ libpackagekit_la_SOURCES =					\
 	pk-polkit-client.h					\
 	$(NULL)
 
+if HAVE_NETWORKMANAGER
+libpackagekit_la_SOURCES +=					\
+	pk-network-nm.c						\
+	$(NULL)
+else
+libpackagekit_la_SOURCES +=					\
+	pk-network-dummy.c					\
+	$(NULL)
+endif
+
 libpackagekit_la_LIBADD =					\
 	$(GLIB_LIBS)						\
 	$(DBUS_LIBS)						\
diff --git a/libpackagekit/pk-network-dummy.c b/libpackagekit/pk-network-dummy.c
new file mode 100644
index 0000000..8567070
--- /dev/null
+++ b/libpackagekit/pk-network-dummy.c
@@ -0,0 +1,132 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+#include <errno.h>
+
+#include <string.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#include <glib/gi18n.h>
+
+#include "pk-debug.h"
+#include "pk-network.h"
+#include "pk-marshal.h"
+
+static void     pk_network_class_init	(PkNetworkClass *klass);
+static void     pk_network_init		(PkNetwork      *network);
+static void     pk_network_finalize	(GObject        *object);
+
+#define PK_NETWORK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_NETWORK, PkNetworkPrivate))
+
+struct PkNetworkPrivate
+{
+	gpointer		 data;
+};
+
+enum {
+	PK_NETWORK_ONLINE,
+	PK_NETWORK_LAST_SIGNAL
+};
+
+static guint signals [PK_NETWORK_LAST_SIGNAL] = { 0, };
+static gpointer pk_network_object = NULL;
+
+G_DEFINE_TYPE (PkNetwork, pk_network, G_TYPE_OBJECT)
+
+/**
+ * pk_network_is_online:
+ **/
+gboolean
+pk_network_is_online (PkNetwork *network)
+{
+	/* don't do any checks */
+	return TRUE;
+}
+
+/**
+ * pk_network_class_init:
+ * @klass: The PkNetworkClass
+ **/
+static void
+pk_network_class_init (PkNetworkClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize = pk_network_finalize;
+	signals [PK_NETWORK_ONLINE] =
+		g_signal_new ("online",
+			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+			      0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
+			      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+	g_type_class_add_private (klass, sizeof (PkNetworkPrivate));
+}
+
+/**
+ * pk_network_init:
+ * @network: This class instance
+ **/
+static void
+pk_network_init (PkNetwork *network)
+{
+	network->priv = PK_NETWORK_GET_PRIVATE (network);
+}
+
+/**
+ * pk_network_finalize:
+ * @object: The object to finalize
+ **/
+static void
+pk_network_finalize (GObject *object)
+{
+	PkNetwork *network;
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (PK_IS_NETWORK (object));
+	network = PK_NETWORK (object);
+
+	g_return_if_fail (network->priv != NULL);
+	G_OBJECT_CLASS (pk_network_parent_class)->finalize (object);
+}
+
+/**
+ * pk_network_new:
+ *
+ * Return value: a new PkNetwork object.
+ **/
+PkNetwork *
+pk_network_new (void)
+{
+	if (pk_network_object != NULL) {
+		g_object_ref (pk_network_object);
+	} else {
+		pk_network_object = g_object_new (PK_TYPE_NETWORK, NULL);
+		g_object_add_weak_pointer (pk_network_object, &pk_network_object);
+	}
+	return PK_NETWORK (pk_network_object);
+}
+
diff --git a/libpackagekit/pk-network-nm.c b/libpackagekit/pk-network-nm.c
new file mode 100644
index 0000000..cb12231
--- /dev/null
+++ b/libpackagekit/pk-network-nm.c
@@ -0,0 +1,168 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+#include <errno.h>
+
+#include <string.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#include <sys/wait.h>
+#include <fcntl.h>
+
+#include <glib/gi18n.h>
+#include <libnm_glib.h>
+
+#include "pk-debug.h"
+#include "pk-network.h"
+#include "pk-marshal.h"
+
+static void     pk_network_class_init	(PkNetworkClass *klass);
+static void     pk_network_init		(PkNetwork      *network);
+static void     pk_network_finalize	(GObject        *object);
+
+#define PK_NETWORK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_NETWORK, PkNetworkPrivate))
+
+struct PkNetworkPrivate
+{
+	libnm_glib_ctx		*ctx;
+	guint			 callbackid;
+};
+
+enum {
+	PK_NETWORK_ONLINE,
+	PK_NETWORK_LAST_SIGNAL
+};
+
+static guint signals [PK_NETWORK_LAST_SIGNAL] = { 0, };
+static gpointer pk_network_object = NULL;
+
+G_DEFINE_TYPE (PkNetwork, pk_network, G_TYPE_OBJECT)
+
+/**
+ * pk_network_is_online:
+ **/
+gboolean
+pk_network_is_online (PkNetwork *network)
+{
+	libnm_glib_state state;
+	gboolean ret;
+	state = libnm_glib_get_network_state (network->priv->ctx);
+	switch (state) {
+	case LIBNM_NO_NETWORK_CONNECTION:
+		ret = FALSE;
+		break;
+	default:
+		ret = TRUE;
+	}
+	return ret;
+}
+
+/**
+ * pk_network_nm_changed_cb:
+ **/
+static void
+pk_network_nm_changed_cb (libnm_glib_ctx *libnm_ctx, gpointer data)
+{
+	gboolean ret;
+	PkNetwork *network = (PkNetwork *) data;
+	ret = pk_network_is_online (network);
+	g_signal_emit (network, signals [PK_NETWORK_ONLINE], 0, ret);
+}
+
+/**
+ * pk_network_class_init:
+ * @klass: The PkNetworkClass
+ **/
+static void
+pk_network_class_init (PkNetworkClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+	object_class->finalize = pk_network_finalize;
+	signals [PK_NETWORK_ONLINE] =
+		g_signal_new ("online",
+			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+			      0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
+			      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+	g_type_class_add_private (klass, sizeof (PkNetworkPrivate));
+}
+
+/**
+ * pk_network_init:
+ * @network: This class instance
+ **/
+static void
+pk_network_init (PkNetwork *network)
+{
+	GMainContext *context;
+
+	network->priv = PK_NETWORK_GET_PRIVATE (network);
+	context = g_main_context_default ();
+	network->priv->ctx = libnm_glib_init ();
+	network->priv->callbackid =
+		libnm_glib_register_callback (network->priv->ctx,
+					      pk_network_nm_changed_cb,
+					      network, context);
+}
+
+/**
+ * pk_network_finalize:
+ * @object: The object to finalize
+ **/
+static void
+pk_network_finalize (GObject *object)
+{
+	PkNetwork *network;
+	g_return_if_fail (object != NULL);
+	g_return_if_fail (PK_IS_NETWORK (object));
+	network = PK_NETWORK (object);
+
+	g_return_if_fail (network->priv != NULL);
+	libnm_glib_unregister_callback (network->priv->ctx, network->priv->callbackid);
+	libnm_glib_shutdown (network->priv->ctx);
+
+	G_OBJECT_CLASS (pk_network_parent_class)->finalize (object);
+}
+
+/**
+ * pk_network_new:
+ *
+ * Return value: a new PkNetwork object.
+ **/
+PkNetwork *
+pk_network_new (void)
+{
+	if (pk_network_object != NULL) {
+		g_object_ref (pk_network_object);
+	} else {
+		pk_network_object = g_object_new (PK_TYPE_NETWORK, NULL);
+		g_object_add_weak_pointer (pk_network_object, &pk_network_object);
+	}
+	return PK_NETWORK (pk_network_object);
+}
diff --git a/libpackagekit/pk-network.c b/libpackagekit/pk-network.c
deleted file mode 100644
index cb12231..0000000
--- a/libpackagekit/pk-network.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2007 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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include "config.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <time.h>
-#include <errno.h>
-
-#include <string.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif /* HAVE_UNISTD_H */
-
-#include <sys/wait.h>
-#include <fcntl.h>
-
-#include <glib/gi18n.h>
-#include <libnm_glib.h>
-
-#include "pk-debug.h"
-#include "pk-network.h"
-#include "pk-marshal.h"
-
-static void     pk_network_class_init	(PkNetworkClass *klass);
-static void     pk_network_init		(PkNetwork      *network);
-static void     pk_network_finalize	(GObject        *object);
-
-#define PK_NETWORK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_NETWORK, PkNetworkPrivate))
-
-struct PkNetworkPrivate
-{
-	libnm_glib_ctx		*ctx;
-	guint			 callbackid;
-};
-
-enum {
-	PK_NETWORK_ONLINE,
-	PK_NETWORK_LAST_SIGNAL
-};
-
-static guint signals [PK_NETWORK_LAST_SIGNAL] = { 0, };
-static gpointer pk_network_object = NULL;
-
-G_DEFINE_TYPE (PkNetwork, pk_network, G_TYPE_OBJECT)
-
-/**
- * pk_network_is_online:
- **/
-gboolean
-pk_network_is_online (PkNetwork *network)
-{
-	libnm_glib_state state;
-	gboolean ret;
-	state = libnm_glib_get_network_state (network->priv->ctx);
-	switch (state) {
-	case LIBNM_NO_NETWORK_CONNECTION:
-		ret = FALSE;
-		break;
-	default:
-		ret = TRUE;
-	}
-	return ret;
-}
-
-/**
- * pk_network_nm_changed_cb:
- **/
-static void
-pk_network_nm_changed_cb (libnm_glib_ctx *libnm_ctx, gpointer data)
-{
-	gboolean ret;
-	PkNetwork *network = (PkNetwork *) data;
-	ret = pk_network_is_online (network);
-	g_signal_emit (network, signals [PK_NETWORK_ONLINE], 0, ret);
-}
-
-/**
- * pk_network_class_init:
- * @klass: The PkNetworkClass
- **/
-static void
-pk_network_class_init (PkNetworkClass *klass)
-{
-	GObjectClass *object_class = G_OBJECT_CLASS (klass);
-	object_class->finalize = pk_network_finalize;
-	signals [PK_NETWORK_ONLINE] =
-		g_signal_new ("online",
-			      G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
-			      0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
-			      G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
-	g_type_class_add_private (klass, sizeof (PkNetworkPrivate));
-}
-
-/**
- * pk_network_init:
- * @network: This class instance
- **/
-static void
-pk_network_init (PkNetwork *network)
-{
-	GMainContext *context;
-
-	network->priv = PK_NETWORK_GET_PRIVATE (network);
-	context = g_main_context_default ();
-	network->priv->ctx = libnm_glib_init ();
-	network->priv->callbackid =
-		libnm_glib_register_callback (network->priv->ctx,
-					      pk_network_nm_changed_cb,
-					      network, context);
-}
-
-/**
- * pk_network_finalize:
- * @object: The object to finalize
- **/
-static void
-pk_network_finalize (GObject *object)
-{
-	PkNetwork *network;
-	g_return_if_fail (object != NULL);
-	g_return_if_fail (PK_IS_NETWORK (object));
-	network = PK_NETWORK (object);
-
-	g_return_if_fail (network->priv != NULL);
-	libnm_glib_unregister_callback (network->priv->ctx, network->priv->callbackid);
-	libnm_glib_shutdown (network->priv->ctx);
-
-	G_OBJECT_CLASS (pk_network_parent_class)->finalize (object);
-}
-
-/**
- * pk_network_new:
- *
- * Return value: a new PkNetwork object.
- **/
-PkNetwork *
-pk_network_new (void)
-{
-	if (pk_network_object != NULL) {
-		g_object_ref (pk_network_object);
-	} else {
-		pk_network_object = g_object_new (PK_TYPE_NETWORK, NULL);
-		g_object_add_weak_pointer (pk_network_object, &pk_network_object);
-	}
-	return PK_NETWORK (pk_network_object);
-}
commit f90b3b76174c32729c4f722491a43adaa38c953d
Author: Richard Hughes <richard at hughsie.com>
Date:   Mon Oct 22 21:05:08 2007 +0100

    connect up get-repo-list.py & repo-enable.py to the yum backend

diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index 695e762..cf7e016 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -239,6 +239,30 @@ backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package_i
 	pk_backend_spawn_helper (backend, "resolve.py", filter, package_id, NULL);
 }
 
+/**
+ * backend_get_repo_list:
+ */
+static void
+backend_get_repo_list (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_spawn_helper (backend, "get-repo-list.py", NULL);
+}
+
+/**
+ * backend_repo_enable:
+ */
+static void
+backend_repo_enable (PkBackend *backend, const gchar *rid, gboolean enabled)
+{
+	g_return_if_fail (backend != NULL);
+	if (enabled == TRUE) {
+		pk_backend_spawn_helper (backend, "repo-enable.py", rid, "true", NULL);
+	} else {
+		pk_backend_spawn_helper (backend, "repo-enable.py", rid, "false", NULL);
+	}
+}
+
 PK_BACKEND_OPTIONS (
 	"YUM",					/* description */
 	"0.0.1",				/* version */
@@ -265,8 +289,8 @@ PK_BACKEND_OPTIONS (
 	backend_search_name,			/* search_name */
 	backend_update_package,			/* update_package */
 	backend_update_system,			/* update_system */
-	NULL,					/* get_repo_list */
-	NULL,					/* repo_enable */
+	backend_get_repo_list,			/* get_repo_list */
+	backend_repo_enable,			/* repo_enable */
 	NULL					/* repo_set_data */
 );
 
commit 9b35c113ee7d81968ac7c6bc707e600f5b85a066
Author: James Bowes <jbowes at dangerouslyinc.com>
Date:   Mon Oct 22 10:25:02 2007 -0400

    Add bash completion script for pkcon.

diff --git a/contrib/pk-completion.bash b/contrib/pk-completion.bash
new file mode 100755
index 0000000..b2f4b53
--- /dev/null
+++ b/contrib/pk-completion.bash
@@ -0,0 +1,148 @@
+#
+# bash completion support for PackageKit's console commands.
+#
+# 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.
+#
+# To use the completion:
+#   1. Copy this file somewhere (e.g. ~/.pk-completion.sh).
+#   2. Add the following line to your .bashrc:
+#        source ~/.git-completion.sh
+
+
+__pkcon_commandlist="
+    search
+    install
+    remove
+    update
+    refresh
+    resolve
+    force-refresh
+    update-system
+    get
+    enable-repo
+    disable-repo
+    "
+
+__pkconcomp ()
+{
+	local all c s=$'\n' IFS=' '$'\t'$'\n'
+	local cur="${COMP_WORDS[COMP_CWORD]}"
+	if [ $# -gt 2 ]; then
+		cur="$3"
+	fi
+	for c in $1; do
+		case "$c$4" in
+		*.)    all="$all$c$4$s" ;;
+		*)     all="$all$c$4 $s" ;;
+		esac
+	done
+	IFS=$s
+	COMPREPLY=($(compgen -P "$2" -W "$all" -- "$cur"))
+	return
+}
+
+_pkcon_search ()
+{
+	local i c=1 command
+	while [ $c -lt $COMP_CWORD ]; do
+		i="${COMP_WORDS[c]}"
+		case "$i" in
+            name|details|group|file)
+			command="$i"
+			break
+			;;
+		esac
+		c=$((++c))
+	done
+
+	if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
+        __pkconcomp "name details group file"
+    fi
+    return
+}
+
+_pkcon_get ()
+{
+	local i c=1 command
+	while [ $c -lt $COMP_CWORD ]; do
+		i="${COMP_WORDS[c]}"
+		case "$i" in
+            updates|depends|requires|description|updatedetail|actions|groups|filters|transactions|repos)
+			command="$i"
+			break
+			;;
+		esac
+		c=$((++c))
+	done
+
+	if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
+        __pkconcomp "
+            updates
+            depends
+            requires
+            description
+            updatedetail
+            actions
+            groups
+            filters
+            transactions
+            repos
+            "
+    fi
+    return
+}
+
+_pkcon ()
+{
+	local i c=1 command
+
+	while [ $c -lt $COMP_CWORD ]; do
+		i="${COMP_WORDS[c]}"
+		case "$i" in
+		--version|--help|--verbose|--nowait|-v|-n|-h|-?) ;;
+		*) command="$i"; break ;;
+		esac
+		c=$((++c))
+	done
+
+    if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
+		case "${COMP_WORDS[COMP_CWORD]}" in
+		--*=*) COMPREPLY=() ;;
+		--*)   __pkconcomp "
+			--version
+			--verbose
+            --help
+            --nowait
+			"
+			;;
+        -*) __pkconcomp "
+            -v
+            -n
+            -h
+            -?
+			--version
+			--verbose
+            --help
+            --nowait
+            "
+            ;;
+		*)     __pkconcomp "$__pkcon_commandlist" ;;
+		esac
+		return
+	fi
+
+	case "$command" in
+	search)      _pkcon_search ;;
+	get)         _pkcon_get ;;
+	*)           COMPREPLY=() ;;
+	esac
+}
+
+complete -o default -o nospace -F _pkcon pkcon
commit e93bc3e84ec3a879d750c6da19c2e73cdf71370b
Author: Tim Lauridsen <tla at rasmil.dk>
Date:   Mon Oct 22 12:50:15 2007 +0200

    yum: added stubs etc for get-updates-detail

diff --git a/backends/yum/helpers/get-update-detail.py b/backends/yum/helpers/get-update-detail.py
new file mode 100755
index 0000000..8ab1f93
--- /dev/null
+++ b/backends/yum/helpers/get-update-detail.py
@@ -0,0 +1,19 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2007 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
+package=sys.argv[1]
+backend = PackageKitYumBackend(sys.argv[2:])
+backend.get_update_detail(package)
+backend.unLock()
+sys.exit(0)
commit 072f7bedc6024b2617f3b82769baecd36bf1da95
Author: Tim Lauridsen <tla at rasmil.dk>
Date:   Mon Oct 22 12:48:01 2007 +0200

    yum: added get-repo-list.py & repo-enable.py to git

diff --git a/backends/BACKENDS b/backends/BACKENDS
index 43aba80..bd149e7 100644
--- a/backends/BACKENDS
+++ b/backends/BACKENDS
@@ -11,15 +11,15 @@ search-details    |        |  X  |  X  |  X  |      |
 search-file       |        |  X  |     |  X  |      |
 search-group      |        |     |     |     |      |
 install-package   |   X    |  X  |     |  X  |  X   |
-install-file      |        |     |     |  X  |      |
+install-file      |        |  X  |     |  X  |      |
 remove-package    |   X    |  X  |     |  X  |  X   |   X
 update-package    |        |     |     |  X  |      |
 get-depends       |        |  X  |     |  X  |      |
 get-requires      |   X    |     |     |  X  |      |
 get-description   |   X    |  X  |  X  |  X  |      |
 get-update-detail |        |     |     |     |      |
-get-repo-list     |        |     |     |     |  X   |
-repo-enable       |        |     |     |     |      |
+get-repo-list     |        |  X  |     |     |  X   |
+repo-enable       |        |  X  |     |     |      |
 repo-set-data     |        |     |     |     |      |
 cancel-transaction|        |     |     |     |      |
 
diff --git a/backends/yum/helpers/get-repo-list.py b/backends/yum/helpers/get-repo-list.py
new file mode 100755
index 0000000..96ff86a
--- /dev/null
+++ b/backends/yum/helpers/get-repo-list.py
@@ -0,0 +1,18 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2007 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[2:])
+backend.get_repo_list()
+backend.unLock()
+sys.exit(0)
diff --git a/backends/yum/helpers/repo-enable.py b/backends/yum/helpers/repo-enable.py
new file mode 100755
index 0000000..4e492d4
--- /dev/null
+++ b/backends/yum/helpers/repo-enable.py
@@ -0,0 +1,20 @@
+#!/usr/bin/python
+#
+# Copyright (C) 2007 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
+repoid = sys.argv[1]
+state=sys.argv[2]
+backend = PackageKitYumBackend(sys.argv[2:])
+backend.repo_enable(repoid,state)
+backend.unLock()
+sys.exit(0)
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index e7dbf3b..68129e5 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -757,6 +757,13 @@ class PackageKitYumBackend(PackageKitBaseBackend):
             else:
                 self.repo_detail(repo.id,repo.name,'false')
 
+    def get_update_detail(self,package):
+        '''
+        Implement the {backend}-get-update_detail functionality
+        '''
+        self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+                
+
     def _setup_yum(self):
         self.yumbase.doConfigSetup(errorlevel=0,debuglevel=0)     # Setup Yum Config
         self.yumbase.conf.throttle = "40%"                        # Set bandwidth throttle to 40%
diff --git a/python/packagekit/backend.py b/python/packagekit/backend.py
index c66030c..8dcce69 100644
--- a/python/packagekit/backend.py
+++ b/python/packagekit/backend.py
@@ -162,6 +162,18 @@ class PackageKitBaseBackend:
         '''
         print >> sys.stdout,"description\t%s\t%s\t%s\t%s\t%s\t%ld\t%s" % (id,licence,group,desc,url,bytes,file_list)
 
+    def update_detail(self,id,updates,obsoletes,url,restart,update_text):
+        '''
+        Send 'updatedetail' signal
+        @param id: The package ID name, e.g. openoffice-clipart;2.6.22;ppc64;fedora
+        @param updates: 
+        @param obsoletes: 
+        @param url: 
+        @param restart:
+        @param update_text:  
+        '''
+        print >> sys.stdout,"updatedetail\t%s\t%s\t%s\t%s\t%s\t%s" % (id,updates,obsoletes,url,restart,update_text)
+
     def require_restart(self,restart_type,details):
         '''
         Send 'requirerestart' signal
@@ -336,3 +348,10 @@ class PackageKitBaseBackend:
         Needed to be implemented in a sub class
         '''
         self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+
+    def get_update_detail(self,package):
+        '''
+        Implement the {backend}-get-update_detail functionality
+        Needed to be implemented in a sub class
+        '''
+        self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
commit 37e28b46e1f5da7a1238aab1fd1c6777646d9750
Author: Tim Lauridsen <tla at rasmil.dk>
Date:   Mon Oct 22 12:24:31 2007 +0200

    yum: implemented get-repo-list & repo-enable

diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index aadd483..e7dbf3b 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -733,17 +733,29 @@ class PackageKitYumBackend(PackageKitBaseBackend):
     def repo_enable(self, repoid, enable):
         '''
         Implement the {backend}-repo-enable functionality
-        Needed to be implemented in a sub class
         '''
-        self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+        try:
+            repo = self.yumbase.repos.getRepo(repoid)
+            if enable == 'false':
+                if repo.isEnabled():
+                    repo.disablePersistent()
+            else:
+                if not repo.isEnabled():
+                    repo.enablePersistent()
+                
+        except Errors.RepoError,e:
+            self.error(ERROR_INTERNAL_ERROR, "repo %s is not found" % repoid)
+        
 
     def get_repo_list(self):
         '''
         Implement the {backend}-get-repo-list functionality
-        Needed to be implemented in a sub class
         '''
-        self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
-
+        for repo in self.yumbase.repos.repos.values():
+            if repo.isEnabled():
+                self.repo_detail(repo.id,repo.name,'true')
+            else:
+                self.repo_detail(repo.id,repo.name,'false')
 
     def _setup_yum(self):
         self.yumbase.doConfigSetup(errorlevel=0,debuglevel=0)     # Setup Yum Config
diff --git a/python/packagekit/backend.py b/python/packagekit/backend.py
index 7303157..c66030c 100644
--- a/python/packagekit/backend.py
+++ b/python/packagekit/backend.py
@@ -134,13 +134,13 @@ class PackageKitBaseBackend:
         '''
         print >> sys.stderr,"status\t%s" % (state)
 
-    def repo_detail(self,repoid,state):
+    def repo_detail(self,repoid,name,state):
         '''
         send 'repo-detail' signal
         @param repoid: The repo id tag
         @param state: false is repo is disabled else true.
         '''
-        print >> sys.stderr,"repo-detail\t%s\t%s" % (repoid,state)
+        print >> sys.stderr,"repo-detail\t%s\t%s\t%s" % (repoid,name,state)
 
     def data(self,data):
         '''
commit 60a42980527d0e91cbfb8ef7c500484953834f9c
Author: Richard Hughes <richard at hughsie.com>
Date:   Sun Oct 21 23:35:58 2007 +0100

    blank out the progressbar when we go up

diff --git a/client/pk-console.c b/client/pk-console.c
index 7aa7924..0abe0e2 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -314,6 +314,7 @@ static void
 pk_console_finished_cb (PkClient *client, PkStatusEnum status, guint runtime, gpointer data)
 {
 	PkRoleEnum role;
+	gchar *blanking;
 	const gchar *role_text;
 
 	/* cancel the spinning */
@@ -323,7 +324,11 @@ 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\r");
+		g_print ("\r");
+		blanking = g_strnfill (PROGRESS_BAR_SIZE + 7, ' ');
+		g_print ("%s", blanking);
+		g_free (blanking);
+		g_print ("\r");
 	}
 
 	pk_client_get_role (client, &role, NULL);



More information about the PackageKit mailing list