diff options
author | Richard Hughes <richard@hughsie.com> | 2010-03-08 16:28:07 +0000 |
---|---|---|
committer | Richard Hughes <richard@hughsie.com> | 2010-03-08 16:28:07 +0000 |
commit | 14b1dd1ef2cc3d00fa4a30062ea6271c600b3b0e (patch) | |
tree | 78d12f77cf00cbb20910b246026965d47f66649f /backends | |
parent | d33a3c9ab21fb6f1bf461c5851790a1144d61259 (diff) |
yum: use Zif to get the list of distro-upgrades
Diffstat (limited to 'backends')
-rw-r--r-- | backends/yum/Makefile.am | 74 | ||||
-rw-r--r-- | backends/yum/pk-backend-yum.c | 225 | ||||
-rwxr-xr-x | backends/yum/yumBackend.py | 50 |
3 files changed, 254 insertions, 95 deletions
diff --git a/backends/yum/Makefile.am b/backends/yum/Makefile.am index b5f61d1b0..242040fb6 100644 --- a/backends/yum/Makefile.am +++ b/backends/yum/Makefile.am @@ -6,6 +6,18 @@ dist_helper_DATA = \ yumMediaManager.py \ yumFilter.py +INCLUDES = \ + -DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE \ + -DZIF_COMPILATION \ + $(SQLITE_CFLAGS) \ + $(RPM_CFLAGS) \ + $(ZLIB_CFLAGS) \ + $(BZLIB_CFLAGS) \ + $(SOUP_CFLAGS) \ + $(ARCHIVE_CFLAGS) \ + -I$(top_srcdir)/backends/yum/libzif \ + -I$(top_builddir)/backends/yum/libzif + plugindir = $(PK_PLUGIN_DIR) plugin_LTLIBRARIES = libpk_backend_yum.la libpk_backend_yum_la_SOURCES = pk-backend-yum.c @@ -13,6 +25,68 @@ libpk_backend_yum_la_LIBADD = $(PK_PLUGIN_LIBS) libpk_backend_yum_la_LDFLAGS = -module -avoid-version libpk_backend_yum_la_CFLAGS = $(PK_PLUGIN_CFLAGS) $(WARNINGFLAGS_C) +libpk_backend_yum_la_SOURCES += \ + libzif/egg-debug.c \ + libzif/egg-debug.h \ + libzif/egg-string.c \ + libzif/egg-string.h \ + libzif/zif.h \ + libzif/zif-lock.c \ + libzif/zif-lock.h \ + libzif/zif-completion.c \ + libzif/zif-completion.h \ + libzif/zif-string.c \ + libzif/zif-string.h \ + libzif/zif-depend.c \ + libzif/zif-depend.h \ + libzif/zif-package.c \ + libzif/zif-package.h \ + libzif/zif-package-local.c \ + libzif/zif-package-local.h \ + libzif/zif-package-remote.c \ + libzif/zif-package-remote.h \ + libzif/zif-store.c \ + libzif/zif-store.h \ + libzif/zif-store-local.c \ + libzif/zif-store-local.h \ + libzif/zif-store-remote.c \ + libzif/zif-store-remote.h \ + libzif/zif-repo-md.c \ + libzif/zif-repo-md.h \ + libzif/zif-repo-md-filelists.c \ + libzif/zif-repo-md-filelists.h \ + libzif/zif-repo-md-primary.c \ + libzif/zif-repo-md-primary.h \ + libzif/zif-repo-md-metalink.c \ + libzif/zif-repo-md-metalink.h \ + libzif/zif-repo-md-mirrorlist.c \ + libzif/zif-repo-md-mirrorlist.h \ + libzif/zif-repo-md-comps.c \ + libzif/zif-repo-md-comps.h \ + libzif/zif-sack.c \ + libzif/zif-sack.h \ + libzif/zif-repos.c \ + libzif/zif-repos.h \ + libzif/zif-utils.c \ + libzif/zif-utils.h \ + libzif/zif-groups.c \ + libzif/zif-groups.h \ + libzif/zif-config.c \ + libzif/zif-config.h \ + libzif/zif-monitor.c \ + libzif/zif-monitor.h \ + libzif/zif-download.c \ + libzif/zif-download.h + +libpk_backend_yum_la_LIBADD += \ + $(SQLITE_LIBS) \ + $(ZLIB_LIBS) \ + $(BZLIB_LIBS) \ + $(RPM_LIBS) \ + $(SOUP_LIBS) \ + $(ARCHIVE_LIBS) \ + $(NULL) + install-data-hook: chmod a+rx $(DESTDIR)$(helperdir)/*.py diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c index cc8e17f4d..e82ebd824 100644 --- a/backends/yum/pk-backend-yum.c +++ b/backends/yum/pk-backend-yum.c @@ -23,12 +23,20 @@ #include <pk-backend.h> #include <pk-backend-spawn.h> #include <string.h> +#include <zif.h> #define PREUPGRADE_BINARY "/usr/bin/preupgrade" #define YUM_REPOS_DIRECTORY "/etc/yum.repos.d" -static PkBackendSpawn *spawn; -static GFileMonitor *monitor; +typedef struct { + PkBackendSpawn *spawn; + GFileMonitor *monitor; + ZifDownload *download; + ZifConfig *config; + ZifCompletion *completion; +} PkBackendYumPrivate; + +static PkBackendYumPrivate *priv; /** * backend_stderr_cb: @@ -64,6 +72,12 @@ backend_yum_repos_changed_cb (GFileMonitor *monitor_, GFile *file, GFile *other_ pk_backend_repo_list_changed (backend); } +static void +backend_completion_percentage_changed_cb (ZifCompletion *completion, guint percentage, PkBackend *backend) +{ + pk_backend_set_percentage (backend, percentage); +} + /** * backend_initialize: * This should only be run once per backend load, i.e. not every transaction @@ -71,26 +85,44 @@ backend_yum_repos_changed_cb (GFileMonitor *monitor_, GFile *file, GFile *other_ static void backend_initialize (PkBackend *backend) { + gboolean ret; GFile *file; GError *error = NULL; + /* create private area */ + priv = g_new0 (PkBackendYumPrivate, 1); + egg_debug ("backend: initialize"); - spawn = pk_backend_spawn_new (); - pk_backend_spawn_set_filter_stderr (spawn, backend_stderr_cb); - pk_backend_spawn_set_filter_stdout (spawn, backend_stdout_cb); - pk_backend_spawn_set_name (spawn, "yum"); - pk_backend_spawn_set_allow_sigkill (spawn, FALSE); + priv->spawn = pk_backend_spawn_new (); + pk_backend_spawn_set_filter_stderr (priv->spawn, backend_stderr_cb); + pk_backend_spawn_set_filter_stdout (priv->spawn, backend_stdout_cb); + pk_backend_spawn_set_name (priv->spawn, "yum"); + pk_backend_spawn_set_allow_sigkill (priv->spawn, FALSE); /* setup a file monitor on the repos directory */ file = g_file_new_for_path (YUM_REPOS_DIRECTORY); - monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, &error); - if (monitor != NULL) { - g_signal_connect (monitor, "changed", G_CALLBACK (backend_yum_repos_changed_cb), backend); + priv->monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, &error); + if (priv->monitor != NULL) { + g_signal_connect (priv->monitor, "changed", G_CALLBACK (backend_yum_repos_changed_cb), backend); } else { egg_warning ("failed to setup monitor: %s", error->message); g_error_free (error); } + /* init rpm */ + zif_init (); + + /* get zif objects */ + priv->config = zif_config_new (); + ret = zif_config_set_filename (priv->config, "/etc/yum.conf", &error); + if (!ret) { + pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, "load yum.conf: %s", error->message); + goto out; + } + priv->download = zif_download_new (); + priv->completion = zif_completion_new (); + g_signal_connect (priv->completion, "percentage-changed", G_CALLBACK (backend_completion_percentage_changed_cb), backend); +out: g_object_unref (file); } @@ -102,9 +134,16 @@ static void backend_destroy (PkBackend *backend) { egg_debug ("backend: destroy"); - g_object_unref (spawn); - if (monitor != NULL) - g_object_unref (monitor); + g_object_unref (priv->spawn); + if (priv->monitor != NULL) + g_object_unref (priv->monitor); + if (priv->config != NULL) + g_object_unref (priv->config); + if (priv->download != NULL) + g_object_unref (priv->download); + if (priv->completion != NULL) + g_object_unref (priv->completion); + g_free (priv); } /** @@ -219,7 +258,7 @@ static void backend_cancel (PkBackend *backend) { /* this feels bad... */ - pk_backend_spawn_kill (spawn); + pk_backend_spawn_kill (priv->spawn); } /** @@ -232,7 +271,7 @@ backend_download_packages (PkBackend *backend, gchar **package_ids, const gchar /* send the complete list as stdin */ package_ids_temp = pk_package_ids_to_string (package_ids); - pk_backend_spawn_helper (spawn, "yumBackend.py", "download-packages", directory, package_ids_temp, NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "download-packages", directory, package_ids_temp, NULL); g_free (package_ids_temp); } @@ -246,7 +285,7 @@ backend_get_depends (PkBackend *backend, PkBitfield filters, gchar **package_ids gchar *package_ids_temp; package_ids_temp = pk_package_ids_to_string (package_ids); filters_text = pk_filter_bitfield_to_string (filters); - pk_backend_spawn_helper (spawn, "yumBackend.py", "get-depends", filters_text, package_ids_temp, pk_backend_bool_to_string (recursive), NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "get-depends", filters_text, package_ids_temp, pk_backend_bool_to_string (recursive), NULL); g_free (filters_text); g_free (package_ids_temp); } @@ -259,7 +298,7 @@ backend_get_details (PkBackend *backend, gchar **package_ids) { gchar *package_ids_temp; package_ids_temp = pk_package_ids_to_string (package_ids); - pk_backend_spawn_helper (spawn, "yumBackend.py", "get-details", package_ids_temp, NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "get-details", package_ids_temp, NULL); g_free (package_ids_temp); } @@ -269,7 +308,103 @@ backend_get_details (PkBackend *backend, gchar **package_ids) static void backend_get_distro_upgrades (PkBackend *backend) { - pk_backend_spawn_helper (spawn, "yumBackend.py", "get-distro-upgrades", NULL); + gboolean ret; + gchar *distro_id = NULL; + gchar *filename = NULL; + gchar **groups = NULL; + gchar *name = NULL; + gchar *proxy = NULL; + gchar **split = NULL; + guint i; + guint last_version = 0; + guint newest = G_MAXUINT; + guint version; + GError *error = NULL; + GKeyFile *file = NULL; + ZifCompletion *child; + + /* download, then parse */ + zif_completion_reset (priv->completion); + zif_completion_set_number_steps (priv->completion, 2); + + /* set proxy */ + proxy = pk_backend_get_proxy_http (backend); + ret = zif_download_set_proxy (priv->download, proxy, &error); + if (!ret) { + pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, "failed to set proxy: %s", error->message); + g_error_free (error); + goto out; + } + + /* download new file */ + filename = g_build_filename ("/var/cache/PackageKit", "releases.txt", NULL); + child = zif_completion_get_child (priv->completion); + pk_backend_set_status (backend, PK_STATUS_ENUM_DOWNLOAD); + ret = zif_download_file (priv->download, "http://mirrors.fedoraproject.org/releases.txt", filename, NULL, child, &error); + if (!ret) { + pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, "failed to download %s: %s", filename, error->message); + g_error_free (error); + goto out; + } + zif_completion_done (priv->completion); + + file = g_key_file_new (); + ret = g_key_file_load_from_file (file, filename, G_KEY_FILE_NONE, &error); + if (!ret) { + pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, "failed to open %s: %s", filename, error->message); + g_error_free (error); + goto out; + } + + /* get all entries */ + groups = g_key_file_get_groups (file, NULL); + for (i=0; groups[i] != NULL; i++) { + /* we only care about stable versions */ + if (!g_key_file_get_boolean (file, groups[i], "stable", NULL)) + goto out; + version = g_key_file_get_integer (file, groups[i], "version", NULL); + egg_debug ("%s is update to version %i", groups[i], version); + if (version > last_version) { + newest = i; + last_version = version; + } + } + + /* nothing found */ + if (newest == G_MAXUINT) { + pk_backend_error_code (backend, PK_ERROR_ENUM_FAILED_CONFIG_PARSING, "could not get latest distro data"); + goto out; + } + + /* are we already on the latest version */ + version = zif_config_get_uint (priv->config, "releasever", &error); + if (version == G_MAXUINT) { + pk_backend_error_code (backend, PK_ERROR_ENUM_FAILED_CONFIG_PARSING, "could not get distro present version"); + goto out; + } + + /* all okay, nothing to show */ + if (version >= last_version) + goto out; + + /* if we have an upgrade candidate then pass back data to daemon */ + split = g_strsplit (groups[newest], " ", -1); + name = g_ascii_strdown (split[0], -1); + distro_id = g_strdup_printf ("%s-%s", name, split[1]); + pk_backend_distro_upgrade (backend, PK_DISTRO_UPGRADE_ENUM_STABLE, distro_id, groups[newest]); + + /* we're done */ + zif_completion_done (priv->completion); +out: + pk_backend_finished (backend); + g_free (distro_id); + g_free (filename); + g_free (name); + g_free (proxy); + if (file != NULL) + g_key_file_free (file); + g_strfreev (groups); + g_strfreev (split); } /** @@ -280,7 +415,7 @@ backend_get_files (PkBackend *backend, gchar **package_ids) { gchar *package_ids_temp; package_ids_temp = pk_package_ids_to_string (package_ids); - pk_backend_spawn_helper (spawn, "yumBackend.py", "get-files", package_ids_temp, NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "get-files", package_ids_temp, NULL); g_free (package_ids_temp); } @@ -294,7 +429,7 @@ backend_get_requires (PkBackend *backend, PkBitfield filters, gchar **package_id gchar *filters_text; package_ids_temp = pk_package_ids_to_string (package_ids); filters_text = pk_filter_bitfield_to_string (filters); - pk_backend_spawn_helper (spawn, "yumBackend.py", "get-requires", filters_text, package_ids_temp, pk_backend_bool_to_string (recursive), NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "get-requires", filters_text, package_ids_temp, pk_backend_bool_to_string (recursive), NULL); g_free (filters_text); g_free (package_ids_temp); } @@ -307,7 +442,7 @@ backend_get_updates (PkBackend *backend, PkBitfield filters) { gchar *filters_text; filters_text = pk_filter_bitfield_to_string (filters); - pk_backend_spawn_helper (spawn, "yumBackend.py", "get-updates", filters_text, NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "get-updates", filters_text, NULL); g_free (filters_text); } @@ -319,7 +454,7 @@ backend_get_packages (PkBackend *backend, PkBitfield filters) { gchar *filters_text; filters_text = pk_filter_bitfield_to_string (filters); - pk_backend_spawn_helper (spawn, "yumBackend.py", "get-packages", filters_text, NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "get-packages", filters_text, NULL); g_free (filters_text); } @@ -331,7 +466,7 @@ backend_get_update_detail (PkBackend *backend, gchar **package_ids) { gchar *package_ids_temp; package_ids_temp = pk_package_ids_to_string (package_ids); - pk_backend_spawn_helper (spawn, "yumBackend.py", "get-update-detail", package_ids_temp, NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "get-update-detail", package_ids_temp, NULL); g_free (package_ids_temp); } @@ -345,7 +480,7 @@ backend_install_packages (PkBackend *backend, gboolean only_trusted, gchar **pac /* send the complete list as stdin */ package_ids_temp = pk_package_ids_to_string (package_ids); - pk_backend_spawn_helper (spawn, "yumBackend.py", "install-packages", pk_backend_bool_to_string (only_trusted), package_ids_temp, NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "install-packages", pk_backend_bool_to_string (only_trusted), package_ids_temp, NULL); g_free (package_ids_temp); } @@ -359,7 +494,7 @@ backend_simulate_remove_packages (PkBackend *backend, gchar **package_ids, gbool /* send the complete list as stdin */ package_ids_temp = pk_package_ids_to_string (package_ids); - pk_backend_spawn_helper (spawn, "yumBackend.py", "simulate-remove-packages", package_ids_temp, NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "simulate-remove-packages", package_ids_temp, NULL); g_free (package_ids_temp); } @@ -373,7 +508,7 @@ backend_simulate_update_packages (PkBackend *backend, gchar **package_ids) /* send the complete list as stdin */ package_ids_temp = pk_package_ids_to_string (package_ids); - pk_backend_spawn_helper (spawn, "yumBackend.py", "simulate-update-packages", package_ids_temp, NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "simulate-update-packages", package_ids_temp, NULL); g_free (package_ids_temp); } @@ -387,7 +522,7 @@ backend_simulate_install_packages (PkBackend *backend, gchar **package_ids) /* send the complete list as stdin */ package_ids_temp = pk_package_ids_to_string (package_ids); - pk_backend_spawn_helper (spawn, "yumBackend.py", "simulate-install-packages", package_ids_temp, NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "simulate-install-packages", package_ids_temp, NULL); g_free (package_ids_temp); } @@ -401,7 +536,7 @@ backend_install_files (PkBackend *backend, gboolean only_trusted, gchar **full_p /* send the complete list as stdin */ package_ids_temp = g_strjoinv (PK_BACKEND_SPAWN_FILENAME_DELIM, full_paths); - pk_backend_spawn_helper (spawn, "yumBackend.py", "install-files", pk_backend_bool_to_string (only_trusted), package_ids_temp, NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "install-files", pk_backend_bool_to_string (only_trusted), package_ids_temp, NULL); g_free (package_ids_temp); } @@ -415,7 +550,7 @@ backend_install_signature (PkBackend *backend, PkSigTypeEnum type, const gchar *type_text; type_text = pk_sig_type_enum_to_string (type); - pk_backend_spawn_helper (spawn, "yumBackend.py", "install-signature", type_text, key_id, package_id, NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "install-signature", type_text, key_id, package_id, NULL); } /** @@ -431,7 +566,7 @@ backend_refresh_cache (PkBackend *backend, gboolean force) return; } - pk_backend_spawn_helper (spawn, "yumBackend.py", "refresh-cache", pk_backend_bool_to_string (force), NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "refresh-cache", pk_backend_bool_to_string (force), NULL); } /** @@ -444,7 +579,7 @@ backend_remove_packages (PkBackend *backend, gchar **package_ids, gboolean allow /* send the complete list as stdin */ package_ids_temp = pk_package_ids_to_string (package_ids); - pk_backend_spawn_helper (spawn, "yumBackend.py", "remove-packages", pk_backend_bool_to_string (allow_deps), pk_backend_bool_to_string (autoremove), package_ids_temp, NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "remove-packages", pk_backend_bool_to_string (allow_deps), pk_backend_bool_to_string (autoremove), package_ids_temp, NULL); g_free (package_ids_temp); } @@ -458,7 +593,7 @@ backend_search_details (PkBackend *backend, PkBitfield filters, gchar **values) gchar *search; filters_text = pk_filter_bitfield_to_string (filters); search = g_strjoinv ("&", values); - pk_backend_spawn_helper (spawn, "yumBackend.py", "search-details", filters_text, search, NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "search-details", filters_text, search, NULL); g_free (filters_text); g_free (search); } @@ -473,7 +608,7 @@ backend_search_files (PkBackend *backend, PkBitfield filters, gchar **values) gchar *search; filters_text = pk_filter_bitfield_to_string (filters); search = g_strjoinv ("&", values); - pk_backend_spawn_helper (spawn, "yumBackend.py", "search-file", filters_text, search, NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "search-file", filters_text, search, NULL); g_free (filters_text); g_free (search); } @@ -488,7 +623,7 @@ backend_search_groups (PkBackend *backend, PkBitfield filters, gchar **values) gchar *search; filters_text = pk_filter_bitfield_to_string (filters); search = g_strjoinv ("&", values); - pk_backend_spawn_helper (spawn, "yumBackend.py", "search-group", filters_text, search, NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "search-group", filters_text, search, NULL); g_free (filters_text); g_free (search); } @@ -503,7 +638,7 @@ backend_search_names (PkBackend *backend, PkBitfield filters, gchar **values) gchar *search; filters_text = pk_filter_bitfield_to_string (filters); search = g_strjoinv ("&", values); - pk_backend_spawn_helper (spawn, "yumBackend.py", "search-name", filters_text, search, NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "search-name", filters_text, search, NULL); g_free (filters_text); g_free (search); } @@ -518,7 +653,7 @@ backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **pack /* send the complete list as stdin */ package_ids_temp = pk_package_ids_to_string (package_ids); - pk_backend_spawn_helper (spawn, "yumBackend.py", "update-packages", pk_backend_bool_to_string (only_trusted), package_ids_temp, NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "update-packages", pk_backend_bool_to_string (only_trusted), package_ids_temp, NULL); g_free (package_ids_temp); } @@ -528,7 +663,7 @@ backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **pack static void backend_update_system (PkBackend *backend, gboolean only_trusted) { - pk_backend_spawn_helper (spawn, "yumBackend.py", "update-system", pk_backend_bool_to_string (only_trusted), NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "update-system", pk_backend_bool_to_string (only_trusted), NULL); } /** @@ -541,7 +676,7 @@ backend_resolve (PkBackend *backend, PkBitfield filters, gchar **package_ids) gchar *package_ids_temp; filters_text = pk_filter_bitfield_to_string (filters); package_ids_temp = pk_package_ids_to_string (package_ids); - pk_backend_spawn_helper (spawn, "yumBackend.py", "resolve", filters_text, package_ids_temp, NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "resolve", filters_text, package_ids_temp, NULL); g_free (filters_text); g_free (package_ids_temp); } @@ -554,7 +689,7 @@ backend_get_repo_list (PkBackend *backend, PkBitfield filters) { gchar *filters_text; filters_text = pk_filter_bitfield_to_string (filters); - pk_backend_spawn_helper (spawn, "yumBackend.py", "get-repo-list", filters_text, NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "get-repo-list", filters_text, NULL); g_free (filters_text); } @@ -565,9 +700,9 @@ static void backend_repo_enable (PkBackend *backend, const gchar *rid, gboolean enabled) { if (enabled == TRUE) { - pk_backend_spawn_helper (spawn, "yumBackend.py", "repo-enable", rid, "true", NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "repo-enable", rid, "true", NULL); } else { - pk_backend_spawn_helper (spawn, "yumBackend.py", "repo-enable", rid, "false", NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "repo-enable", rid, "false", NULL); } } @@ -577,7 +712,7 @@ backend_repo_enable (PkBackend *backend, const gchar *rid, gboolean enabled) static void backend_repo_set_data (PkBackend *backend, const gchar *rid, const gchar *parameter, const gchar *value) { - pk_backend_spawn_helper (spawn, "yumBackend.py", "repo-set-data", rid, parameter, value, NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "repo-set-data", rid, parameter, value, NULL); } /** @@ -592,7 +727,7 @@ backend_what_provides (PkBackend *backend, PkBitfield filters, PkProvidesEnum pr provides_text = pk_provides_enum_to_string (provides); filters_text = pk_filter_bitfield_to_string (filters); search = g_strjoinv ("&", values); - pk_backend_spawn_helper (spawn, "yumBackend.py", "what-provides", filters_text, provides_text, search, NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "what-provides", filters_text, provides_text, search, NULL); g_free (filters_text); g_free (search); } @@ -603,7 +738,7 @@ backend_what_provides (PkBackend *backend, PkBitfield filters, PkProvidesEnum pr static void backend_get_categories (PkBackend *backend) { - pk_backend_spawn_helper (spawn, "yumBackend.py", "get-categories", NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "get-categories", NULL); } /** @@ -616,7 +751,7 @@ backend_simulate_install_files (PkBackend *backend, gchar **full_paths) /* send the complete list as stdin */ package_ids_temp = g_strjoinv (PK_BACKEND_SPAWN_FILENAME_DELIM, full_paths); - pk_backend_spawn_helper (spawn, "yumBackend.py", "simulate-install-files", package_ids_temp, NULL); + pk_backend_spawn_helper (priv->spawn, "yumBackend.py", "simulate-install-files", package_ids_temp, NULL); g_free (package_ids_temp); } diff --git a/backends/yum/yumBackend.py b/backends/yum/yumBackend.py index 87ed876db..b82a8ac46 100755 --- a/backends/yum/yumBackend.py +++ b/backends/yum/yumBackend.py @@ -2319,56 +2319,6 @@ class PackageKitYumBackend(PackageKitBaseBackend, PackagekitPackage): package_id = self._pkg_to_id(pkg) self.package(package_id, status, pkg.summary) - def get_distro_upgrades(self): - ''' - Implement the get-distro-upgrades functionality - ''' - try: - self._check_init() - except PkError, e: - self.error(e.code, e.details, exit=False) - return - self.yumbase.conf.cache = 0 # Allow new files - self.allow_cancel(True) - self.percentage(None) - self.status(STATUS_QUERY) - - # if we're RHEL, then we don't have preupgrade - if not os.path.exists('/usr/share/preupgrade/releases.list'): - return - - # 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 - try: - present_version = float(self.yumbase.conf.yumvar['releasever']) - except Exception, e: - self.error(ERROR_INTERNAL_ERROR, _format_str(traceback.format_exc())) - 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_status(self, notice): ut = notice['type'] if ut == 'security': |