diff options
author | Richard Hughes <richard@hughsie.com> | 2007-09-02 22:55:36 +0100 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2007-09-02 22:55:36 +0100 |
commit | 9747b54cd549e6b7c0d495f37ddf5d2fceab1a3f (patch) | |
tree | 6866613903f65419a78d79f0dbad818a6b29b1b2 | |
parent | a1415982a9e6b698a3fc6deb3f85a73b00409188 (diff) |
Add the method GetRequires as discussed on the mailing list
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | client/pk-console.c | 15 | ||||
-rw-r--r-- | helpers/conary/Makefile.am | 1 | ||||
-rw-r--r-- | helpers/conary/conaryBackend.py | 3 | ||||
-rwxr-xr-x | helpers/conary/get-requires.py | 14 | ||||
-rw-r--r-- | helpers/yum/Makefile.am | 1 | ||||
-rwxr-xr-x | helpers/yum/get-requires.py | 18 | ||||
-rw-r--r-- | helpers/yum/packagekit.py | 7 | ||||
-rw-r--r-- | helpers/yum/yumBackend.py | 7 | ||||
-rw-r--r-- | libpackagekit/pk-task-client.c | 43 | ||||
-rw-r--r-- | libpackagekit/pk-task-client.h | 2 | ||||
-rw-r--r-- | libpackagekit/pk-task-utils.c | 1 | ||||
-rw-r--r-- | libpackagekit/pk-task-utils.h | 1 | ||||
-rw-r--r-- | src/pk-engine.c | 36 | ||||
-rw-r--r-- | src/pk-engine.h | 4 | ||||
-rw-r--r-- | src/pk-interface.xml | 4 | ||||
-rw-r--r-- | src/pk-task-apt.cpp | 16 | ||||
-rw-r--r-- | src/pk-task-box.c | 19 | ||||
-rw-r--r-- | src/pk-task-conary.c | 19 | ||||
-rw-r--r-- | src/pk-task-dummy.c | 24 | ||||
-rw-r--r-- | src/pk-task-yum.c | 22 | ||||
-rw-r--r-- | src/pk-task.h | 2 |
22 files changed, 256 insertions, 4 deletions
@@ -13,7 +13,6 @@ Core: * Add logging so we can see what was installed/removed and when * Add "when installed" data into description * Add "installed by 'Richard Hughes'" data into description -* Add GetRequires * Add GetUpdateDetail(s=package_id) UpdateDetail( string url diff --git a/client/pk-console.c b/client/pk-console.c index a8413c0d..23d4856d 100644 --- a/client/pk-console.c +++ b/client/pk-console.c @@ -121,7 +121,8 @@ pk_console_usage (const gchar *error) g_print (" pkcon [sync] [verbose] force-refresh\n"); g_print (" pkcon [sync] [verbose] update-system\n"); g_print (" pkcon [sync] [verbose] get updates\n"); - g_print (" pkcon [sync] [verbose] get deps <package_id>\n"); + g_print (" pkcon [sync] [verbose] get depends <package_id>\n"); + g_print (" pkcon [sync] [verbose] get requires <package_id>\n"); g_print (" pkcon [sync] [verbose] get description <package_id>\n"); g_print ("\n"); g_print (" package_id is typically gimp;2:2.4.0-0.rc1.1.fc8;i386;development\n"); @@ -218,7 +219,7 @@ pk_console_parse_multiple_commands (PkTaskClient *tclient, GPtrArray *array) pk_console_usage ("you need to specify a get type"); remove = 1; goto out; - } else if (strcmp (value, "deps") == 0) { + } else if (strcmp (value, "depends") == 0) { if (details == NULL) { pk_console_usage ("you need to specify a search term"); remove = 2; @@ -228,6 +229,16 @@ pk_console_parse_multiple_commands (PkTaskClient *tclient, GPtrArray *array) pk_task_client_get_depends (tclient, details); remove = 3; } + } else if (strcmp (value, "requires") == 0) { + if (details == NULL) { + pk_console_usage ("you need to specify a search term"); + remove = 2; + goto out; + } else { + pk_task_client_set_sync (tclient, TRUE); + pk_task_client_get_requires (tclient, details); + remove = 3; + } } else if (strcmp (value, "description") == 0) { if (details == NULL) { pk_console_usage ("you need to specify a package to find the description for"); diff --git a/helpers/conary/Makefile.am b/helpers/conary/Makefile.am index 6a8c40bc..afd3f658 100644 --- a/helpers/conary/Makefile.am +++ b/helpers/conary/Makefile.am @@ -7,6 +7,7 @@ dist_helper_DATA = \ search-name.py \ search-details.py \ get-depends.py \ + get-requires.py \ get-updates.py \ install.py \ refresh-cache.py \ diff --git a/helpers/conary/conaryBackend.py b/helpers/conary/conaryBackend.py index 3d1471f7..a26c21f3 100644 --- a/helpers/conary/conaryBackend.py +++ b/helpers/conary/conaryBackend.py @@ -155,6 +155,9 @@ class PackageKitConaryBackend(PackageKitBaseBackend): def get_depends(self, package_id): pass + def get_requires(self, package_id): + pass + def update_system(self): pass diff --git a/helpers/conary/get-requires.py b/helpers/conary/get-requires.py new file mode 100755 index 00000000..339fca99 --- /dev/null +++ b/helpers/conary/get-requires.py @@ -0,0 +1,14 @@ +#!/usr/bin/python +# +# Copyright (C) 2007 Ken VanDine <ken@vandine.org> +# +# 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 + +sys.exit(0) diff --git a/helpers/yum/Makefile.am b/helpers/yum/Makefile.am index 9cbbb476..84d1185e 100644 --- a/helpers/yum/Makefile.am +++ b/helpers/yum/Makefile.am @@ -9,6 +9,7 @@ dist_helper_DATA = \ search-group.py \ search-file.py \ get-depends.py \ + get-requires.py \ get-updates.py \ get-description.py \ install.py \ diff --git a/helpers/yum/get-requires.py b/helpers/yum/get-requires.py new file mode 100755 index 00000000..443a841e --- /dev/null +++ b/helpers/yum/get-requires.py @@ -0,0 +1,18 @@ +#!/usr/bin/python +# +# Copyright (C) 2007 Richard Hughes <richard@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[1:]) +backend.get_requires(package) +sys.exit(0) diff --git a/helpers/yum/packagekit.py b/helpers/yum/packagekit.py index a1592d1a..710bdd20 100644 --- a/helpers/yum/packagekit.py +++ b/helpers/yum/packagekit.py @@ -177,6 +177,13 @@ class PackageKitBaseBackend: ''' self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend") + def get_requires(self,package): + ''' + Implement the {backend}-get-requires functionality + Needed to be implemented in a sub class + ''' + self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend") + def update_system(self): ''' Implement the {backend}-update-system functionality diff --git a/helpers/yum/yumBackend.py b/helpers/yum/yumBackend.py index 11f8c30b..17507062 100644 --- a/helpers/yum/yumBackend.py +++ b/helpers/yum/yumBackend.py @@ -197,9 +197,14 @@ class PackageKitYumBackend(PackageKitBaseBackend): return None,False + def get_requires(self,package): + ''' + Print a list of requires for a given package + ''' + def get_depends(self,package): ''' - Print a list of dependencies for a given package + Print a list of depends for a given package ''' self._setup_yum() name = package.split(';')[0] diff --git a/libpackagekit/pk-task-client.c b/libpackagekit/pk-task-client.c index af9c619c..77f8f4d0 100644 --- a/libpackagekit/pk-task-client.c +++ b/libpackagekit/pk-task-client.c @@ -557,6 +557,49 @@ pk_task_client_get_depends (PkTaskClient *tclient, const gchar *package) } /** + * pk_task_client_get_requires: + **/ +gboolean +pk_task_client_get_requires (PkTaskClient *tclient, const gchar *package) +{ + gboolean ret; + GError *error; + + g_return_val_if_fail (tclient != NULL, FALSE); + g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE); + + /* check to see if we already have an action */ + if (tclient->priv->assigned == TRUE) { + pk_warning ("Already assigned"); + return FALSE; + } + + error = NULL; + ret = dbus_g_proxy_call (tclient->priv->proxy, "GetRequires", &error, + G_TYPE_STRING, package, + G_TYPE_INVALID, + G_TYPE_UINT, &tclient->priv->job, + G_TYPE_INVALID); + if (error) { + const gchar *error_name; + error_name = pk_task_client_get_error_name (error); + pk_debug ("ERROR: %s: %s", error_name, error->message); + g_error_free (error); + } + if (ret == FALSE) { + /* abort as the DBUS method failed */ + pk_warning ("GetRequires failed!"); + return FALSE; + } + /* only assign on success */ + tclient->priv->assigned = TRUE; + pk_task_monitor_set_job (tclient->priv->tmonitor, tclient->priv->job); + pk_task_client_wait_if_sync (tclient); + + return TRUE; +} + +/** * pk_task_client_get_description: **/ gboolean diff --git a/libpackagekit/pk-task-client.h b/libpackagekit/pk-task-client.h index ca242f8d..39bec5ec 100644 --- a/libpackagekit/pk-task-client.h +++ b/libpackagekit/pk-task-client.h @@ -84,6 +84,8 @@ gboolean pk_task_client_search_file (PkTaskClient *tclient, const gchar *search); gboolean pk_task_client_get_depends (PkTaskClient *tclient, const gchar *package_id); +gboolean pk_task_client_get_requires (PkTaskClient *tclient, + const gchar *package_id); gboolean pk_task_client_get_description (PkTaskClient *tclient, const gchar *package_id); gboolean pk_task_client_remove_package (PkTaskClient *tclient, diff --git a/libpackagekit/pk-task-utils.c b/libpackagekit/pk-task-utils.c index ac00be6e..e7e53397 100644 --- a/libpackagekit/pk-task-utils.c +++ b/libpackagekit/pk-task-utils.c @@ -116,6 +116,7 @@ static PkTaskEnumMatch task_action[] = { {PK_TASK_ACTION_SEARCH_GROUP, "search-group"}, {PK_TASK_ACTION_SEARCH_FILE, "search-file"}, {PK_TASK_ACTION_GET_DEPENDS, "get-depends"}, + {PK_TASK_ACTION_GET_REQUIRES, "get-requires"}, {PK_TASK_ACTION_GET_DESCRIPTION, "get-description"}, {0, NULL}, }; diff --git a/libpackagekit/pk-task-utils.h b/libpackagekit/pk-task-utils.h index 39aecc0b..19614458 100644 --- a/libpackagekit/pk-task-utils.h +++ b/libpackagekit/pk-task-utils.h @@ -104,6 +104,7 @@ typedef enum { PK_TASK_ACTION_SEARCH_GROUP, PK_TASK_ACTION_SEARCH_FILE, PK_TASK_ACTION_GET_DEPENDS, + PK_TASK_ACTION_GET_REQUIRES, PK_TASK_ACTION_GET_DESCRIPTION, PK_TASK_ACTION_UNKNOWN } PkTaskAction; diff --git a/src/pk-engine.c b/src/pk-engine.c index 09c46f70..3415e782 100644 --- a/src/pk-engine.c +++ b/src/pk-engine.c @@ -869,6 +869,42 @@ pk_engine_get_depends (PkEngine *engine, const gchar *package_id, } /** + * pk_engine_get_requires: + **/ +gboolean +pk_engine_get_requires (PkEngine *engine, const gchar *package_id, + guint *job, GError **error) +{ + gboolean ret; + PkTask *task; + + g_return_val_if_fail (engine != NULL, FALSE); + g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE); + + /* check package_id */ + ret = pk_package_id_check (package_id); + if (ret == FALSE) { + *error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_PACKAGE_ID_INVALID, + "The package id '%s' is not valid", package_id); + return FALSE; + } + + /* create a new task and start it */ + task = pk_engine_new_task (engine); + ret = pk_task_get_requires (task, package_id); + if (ret == FALSE) { + g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED, + "operation not yet supported by backend"); + g_object_unref (task); + return FALSE; + } + pk_engine_add_task (engine, task); + *job = pk_task_get_job (task); + + return TRUE; +} + +/** * pk_engine_get_description: **/ gboolean diff --git a/src/pk-engine.h b/src/pk-engine.h index 330fe637..52f72a15 100644 --- a/src/pk-engine.h +++ b/src/pk-engine.h @@ -97,6 +97,10 @@ gboolean pk_engine_get_depends (PkEngine *engine, const gchar *package_id, guint *job, GError **error); +gboolean pk_engine_get_requires (PkEngine *engine, + const gchar *package_id, + guint *job, + GError **error); gboolean pk_engine_get_description (PkEngine *engine, const gchar *package_id, guint *job, diff --git a/src/pk-interface.xml b/src/pk-interface.xml index efaf0798..f35db84e 100644 --- a/src/pk-interface.xml +++ b/src/pk-interface.xml @@ -38,6 +38,10 @@ <arg type="s" name="package_id" direction="in"/> <arg type="u" name="job" direction="out"/> </method> + <method name="GetRequires"> + <arg type="s" name="package_id" direction="in"/> + <arg type="u" name="job" direction="out"/> + </method> <method name="GetDescription"> <!-- orders Description signals for the package --> <arg type="s" name="package_id" direction="in"/> <arg type="u" name="job" direction="out"/> diff --git a/src/pk-task-apt.cpp b/src/pk-task-apt.cpp index 30f141ca..fc6777e9 100644 --- a/src/pk-task-apt.cpp +++ b/src/pk-task-apt.cpp @@ -618,6 +618,22 @@ gboolean pk_task_get_depends(PkTask * task, const gchar * package) pk_task_not_implemented_yet (task, "GetDepends"); return FALSE; } +/** + * pk_task_get_requires: + **/ +gboolean pk_task_get_requires(PkTask * task, const gchar * package) +{ + g_return_val_if_fail(task != NULL, FALSE); + g_return_val_if_fail(PK_IS_TASK(task), FALSE); + + if (pk_task_assign(task) == FALSE) + { + return FALSE; + } + + pk_task_not_implemented_yet (task, "GetRequires"); + return FALSE; +} struct desc_task { diff --git a/src/pk-task-box.c b/src/pk-task-box.c index 58568210..459cb759 100644 --- a/src/pk-task-box.c +++ b/src/pk-task-box.c @@ -133,6 +133,7 @@ pk_task_get_actions (void) /*PK_TASK_ACTION_SEARCH_GROUP,*/ PK_TASK_ACTION_SEARCH_FILE, /*PK_TASK_ACTION_GET_DEPENDS,*/ + /*PK_TASK_ACTION_GET_REQUIRES,*/ /*PK_TASK_ACTION_GET_DESCRIPTION,*/ 0); return actions; @@ -369,6 +370,24 @@ pk_task_get_depends (PkTask *task, const gchar *package_id) } /** + * pk_task_get_requires: + **/ +gboolean +pk_task_get_requires (PkTask *task, const gchar *package_id) +{ + g_return_val_if_fail (task != NULL, FALSE); + g_return_val_if_fail (PK_IS_TASK (task), FALSE); + + if (pk_task_assign (task) == FALSE) { + return FALSE; + } + + pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, package_id); + pk_task_not_implemented_yet (task, "GetRequires"); + return TRUE; +} + +/** * pk_task_get_description: **/ gboolean diff --git a/src/pk-task-conary.c b/src/pk-task-conary.c index a3aa77f1..deafa582 100644 --- a/src/pk-task-conary.c +++ b/src/pk-task-conary.c @@ -76,6 +76,7 @@ pk_task_get_actions (void) /* PK_TASK_ACTION_SEARCH_GROUP,*/ /* PK_TASK_ACTION_SEARCH_FILE,*/ /* PK_TASK_ACTION_GET_DEPENDS,*/ +/* PK_TASK_ACTION_GET_REQUIRES,*/ /* PK_TASK_ACTION_GET_DESCRIPTION,*/ 0); return actions; @@ -234,6 +235,24 @@ pk_task_get_depends (PkTask *task, const gchar *package_id) } /** + * pk_task_get_requires: + **/ +gboolean +pk_task_get_requires (PkTask *task, const gchar *package_id) +{ + g_return_val_if_fail (task != NULL, FALSE); + g_return_val_if_fail (PK_IS_TASK (task), FALSE); + + if (pk_task_assign (task) == FALSE) { + return FALSE; + } + + pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, package_id); + pk_task_not_implemented_yet (task, "GetRequires"); + return TRUE; +} + +/** * pk_task_get_description: **/ gboolean diff --git a/src/pk-task-dummy.c b/src/pk-task-dummy.c index f15ca0c4..3d5fd503 100644 --- a/src/pk-task-dummy.c +++ b/src/pk-task-dummy.c @@ -71,6 +71,7 @@ pk_task_get_actions (void) PK_TASK_ACTION_SEARCH_GROUP, PK_TASK_ACTION_SEARCH_FILE, PK_TASK_ACTION_GET_DEPENDS, + PK_TASK_ACTION_GET_REQUIRES, PK_TASK_ACTION_GET_DESCRIPTION, 0); return actions; @@ -256,6 +257,29 @@ pk_task_get_depends (PkTask *task, const gchar *package_id) } /** + * pk_task_get_requires: + **/ +gboolean +pk_task_get_requires (PkTask *task, const gchar *package_id) +{ + g_return_val_if_fail (task != NULL, FALSE); + g_return_val_if_fail (PK_IS_TASK (task), FALSE); + + if (pk_task_assign (task) == FALSE) { + return FALSE; + } + + pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, package_id); + pk_task_package (task, 1, "glib2;2.14.0;i386;fedora", + "The GLib library"); + pk_task_package (task, 1, "gtk2;gtk2-2.11.6-6.fc8;i386;fedora", + "GTK+ Libraries for GIMP"); + pk_task_finished (task, PK_TASK_EXIT_SUCCESS); + + return TRUE; +} + +/** * pk_task_get_description: **/ gboolean diff --git a/src/pk-task-yum.c b/src/pk-task-yum.c index 737228f2..33b3f91e 100644 --- a/src/pk-task-yum.c +++ b/src/pk-task-yum.c @@ -75,6 +75,7 @@ pk_task_get_actions (void) PK_TASK_ACTION_SEARCH_GROUP, PK_TASK_ACTION_SEARCH_FILE, PK_TASK_ACTION_GET_DEPENDS, + PK_TASK_ACTION_GET_REQUIRES, PK_TASK_ACTION_GET_DESCRIPTION, 0); return actions; @@ -268,6 +269,27 @@ pk_task_get_depends (PkTask *task, const gchar *package_id) } /** + * pk_task_get_requires: + **/ +gboolean +pk_task_get_requires (PkTask *task, const gchar *package_id) +{ + g_return_val_if_fail (task != NULL, FALSE); + g_return_val_if_fail (PK_IS_TASK (task), FALSE); + + if (pk_task_assign (task) == FALSE) { + return FALSE; + } + + /* only copy this code if you can kill the process with no ill effect */ + pk_task_allow_interrupt (task, TRUE); + + pk_task_set_job_role (task, PK_TASK_ROLE_QUERY, package_id); + pk_task_spawn_helper (task, "get-requires.py", package_id, NULL); + return TRUE; +} + +/** * pk_task_get_description: **/ gboolean diff --git a/src/pk-task.h b/src/pk-task.h index 6ed13d99..a1f1c19f 100644 --- a/src/pk-task.h +++ b/src/pk-task.h @@ -92,6 +92,8 @@ gboolean pk_task_search_file (PkTask *task, const gchar *search); gboolean pk_task_get_depends (PkTask *task, const gchar *package); +gboolean pk_task_get_requires (PkTask *task, + const gchar *package); gboolean pk_task_remove_package (PkTask *task, const gchar *package, gboolean allow_deps); |