/** * backend_get_requires: */ static void backend_get_requires (PkBackend *backend, PkBitfield filters, gchar **package_ids, gboolean recursive) { guint i; guint len; const gchar *package_id; PkPackageId *pi; slapt_pkg_info_t *pkg; slapt_pkg_list_t *installed; slapt_pkg_list_t *available; slapt_pkg_list_t *requires; PkInfoEnum state; const char *summary; installed = slapt_get_installed_pkgs(); available = slapt_get_available_pkgs(); pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); len = g_strv_length (package_ids); for (i=0; i<len; i++) { package_id = package_ids[i]; pi = pk_package_id_new_from_string (package_id); if (pi == NULL) { pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id"); pk_backend_finished (backend); return; } pkg = _get_pkg_from_id(pi, available, installed); pk_package_id_free (pi); if (pkg == NULL) { pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "package not found"); continue; } requires = slapt_is_required_by(_config, available, pkg); for (i = 0; i < requires->pkg_count; i++) { pkg = requires->pkgs[i]; state = pkg->installed ? PK_INFO_ENUM_INSTALLED : PK_INFO_ENUM_AVAILABLE; package_id = _get_string_from_pkg(pkg); summary = _get_pkg_summary(pkg); pk_backend_package (backend, state, package_id, summary); g_free((gpointer) summary); g_free((gpointer) package_id); } slapt_free_pkg_list(requires); } slapt_free_pkg_list(available); slapt_free_pkg_list(installed); pk_backend_finished (backend); }
/** * backend_remove_packages: */ static void backend_remove_packages (PkBackend *backend, gchar **package_ids, gboolean allow_deps, gboolean autoremove) { guint i; guint len; gchar *pi; int ret; slapt_pkg_list_t *installed; slapt_pkg_list_t *available; slapt_transaction_t *transaction; slapt_pkg_info_t *pkg; /* FIXME: support only_trusted */ pk_backend_set_status (backend, PK_STATUS_ENUM_REMOVE); pk_backend_set_percentage (backend, 0); installed = slapt_get_installed_pkgs(); available = slapt_get_available_pkgs(); transaction = slapt_init_transaction(); len = g_strv_length (package_ids); for (i=0; i<len; i++) { pi = package_ids[i]; if (pi == NULL) { pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id"); pk_backend_finished (backend); return; } pkg = _get_pkg_from_id(pi, installed, NULL); if (pkg == NULL) { pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "package not found"); continue; } if (!pkg->installed) { char *pkgname = slapt_stringify_pkg(pkg); pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_INSTALLED, "package %s not installed", pkgname); free(pkgname); continue; } slapt_add_remove_to_transaction(transaction, pkg); } ret = slapt_handle_transaction(_config, transaction); if (ret != 0) { pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, "remove failed"); } slapt_free_transaction(transaction); slapt_free_pkg_list(available); slapt_free_pkg_list(installed); pk_backend_set_percentage (backend, 100); pk_backend_finished (backend); }
/** * backend_update_packages: */ static void backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids) { guint i; guint len; const gchar *package_id; int ret; slapt_pkg_list_t *installed; slapt_pkg_list_t *available; const gchar *search; slapt_pkg_list_t *results = NULL; slapt_transaction_t *transaction; slapt_pkg_info_t *pkg; slapt_pkg_info_t *oldpkg; /* FIXME: support only_trusted */ pk_backend_set_status (backend, PK_STATUS_ENUM_UPDATE); pk_backend_set_percentage (backend, 0); installed = slapt_get_installed_pkgs(); available = slapt_get_available_pkgs(); transaction = slapt_init_transaction(); len = g_strv_length (package_ids); for (i=0; i<len; i++) { package_id = package_ids[i]; pkg = _get_pkg_from_string(package_id, available, installed); if (pkg == NULL) { pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "package not found"); continue; } oldpkg = NULL; search = g_strdup_printf("^%s$", pkg->name); results = slapt_search_pkg_list(installed, search); g_free((gpointer) search); if (results->pkg_count > 0) { oldpkg = results->pkgs[0]; } else { continue; } slapt_add_upgrade_to_transaction(transaction, oldpkg, pkg); } ret = slapt_handle_transaction(_config, transaction); if (ret != 0) { pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, "install failed"); } slapt_free_transaction(transaction); slapt_free_pkg_list(available); slapt_free_pkg_list(installed); pk_backend_set_percentage (backend, 100); pk_backend_finished (backend); }
/** * pk_backend_spawn_exit_cb: **/ static void pk_backend_spawn_exit_cb (PkSpawn *spawn, PkSpawnExitType exit_enum, PkBackendSpawn *backend_spawn) { gboolean ret; g_return_if_fail (PK_IS_BACKEND_SPAWN (backend_spawn)); /* if we force killed the process, set an error */ if (exit_enum == PK_SPAWN_EXIT_TYPE_SIGKILL) { /* we just call this failed, and set an error */ pk_backend_error_code (backend_spawn->priv->backend, PK_ERROR_ENUM_PROCESS_KILL, "Process had to be killed to be cancelled"); } if (exit_enum == PK_SPAWN_EXIT_TYPE_DISPATCHER_EXIT || exit_enum == PK_SPAWN_EXIT_TYPE_DISPATCHER_CHANGED) { g_debug ("dispatcher exited, nothing to see here"); return; } /* only emit if not finished */ if (!backend_spawn->priv->finished) { g_debug ("script exited without doing finished, tidying up"); ret = pk_backend_has_set_error_code (backend_spawn->priv->backend); if (!ret) { pk_backend_error_code (backend_spawn->priv->backend, PK_ERROR_ENUM_INTERNAL_ERROR, "The backend exited unexpectedly. " "This is a serious error as the spawned backend did not complete the pending transaction."); } pk_backend_finished (backend_spawn->priv->backend); } }
gboolean zypp_signature_required (PkBackend *backend, const std::string &file) { gboolean ok = FALSE; if (std::find (_signatures[backend]->begin (), _signatures[backend]->end (), file) == _signatures[backend]->end ()) { zypp::RepoInfo info = zypp_get_Repository (backend, _repoName); if (info.type () == zypp::repo::RepoType::NONE) { pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Repository unknown"); return FALSE; } pk_backend_repo_signature_required (backend, "dummy;0.0.1;i386;data", _repoName, info.baseUrlsBegin ()->asString ().c_str (), "UNKNOWN", file.c_str (), "UNKNOWN", "UNKNOWN", PK_SIGTYPE_ENUM_GPG); pk_backend_error_code (backend, PK_ERROR_ENUM_GPG_FAILURE, "Signature verification for Repository %s failed", _repoName); }else{ ok = TRUE; } return ok; }
/** * pk_backend_search_files: */ void pk_backend_search_files (PkBackend *backend, PkBitfield filters, gchar **values) { pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Error number 1"); pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Duplicate error"); pk_backend_finished (backend); }
/** * backend_download_packages: */ static void backend_download_packages (PkBackend *backend, gchar **package_ids, const gchar *directory) { guint i; guint len; const gchar *package_id; const gchar *files; const char *error; slapt_pkg_list_t *installed; slapt_pkg_list_t *available; slapt_pkg_info_t *pkg; const char *summary; const char *note = NULL; char *filename; pk_backend_set_status (backend, PK_STATUS_ENUM_LOADING_CACHE); installed = slapt_get_installed_pkgs(); available = slapt_get_available_pkgs(); pk_backend_set_status (backend, PK_STATUS_ENUM_DOWNLOAD); pk_backend_set_percentage (backend, 0); len = g_strv_length (package_ids); for (i=0; i<len; i++) { package_id = package_ids[i]; pkg = _get_pkg_from_string(package_id, available, installed); if (pkg == NULL) { pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "package not found"); continue; } summary = _get_pkg_summary(pkg); pk_backend_package (backend, PK_INFO_ENUM_DOWNLOADING, package_id, summary); g_free((gpointer) summary); error = slapt_download_pkg(_config, pkg, note); if (error == NULL) { filename = slapt_gen_pkg_file_name(_config, pkg); files = g_strdup(filename); pk_backend_files (backend, package_id, files); g_free((gpointer) files); free(filename); } else { pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_DOWNLOAD_FAILED, error); } } slapt_free_pkg_list(available); slapt_free_pkg_list(installed); pk_backend_set_percentage (backend, 100); pk_backend_finished (backend); }
/** * backend_search_file: */ static void backend_search_file (PkBackend *backend, PkBitfield filters, const gchar *search) { pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Error number 1"); pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Duplicate error"); pk_backend_finished (backend); }
/** * backend_get_details: */ static void backend_get_details (PkBackend *backend, gchar **package_ids) { guint i; guint len; const gchar *package_id; gchar *pi; const gchar *license = ""; const gchar *homepage = ""; const gchar *description; PkGroupEnum group; slapt_pkg_list_t *installed; slapt_pkg_list_t *available; slapt_pkg_info_t *pkg; const char *category; pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); pk_backend_set_percentage (backend, 0); installed = slapt_get_installed_pkgs(); available = slapt_get_available_pkgs(); len = g_strv_length (package_ids); for (i=0; i<len; i++) { pi = package_ids[i]; if (pi == NULL) { pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id"); pk_backend_finished (backend); return; } pkg = _get_pkg_from_id(pi, available, installed); if (pkg == NULL) { pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "package not found"); continue; } category = _get_pkg_category(pkg); group = _get_pkg_group(category); package_id = _get_string_from_pkg(pkg); description = g_strstrip((gchar*) _get_pkg_description(pkg)); pk_backend_details (backend, package_id, license, group, description, homepage, pkg->size_c * 1024); g_free((gpointer) description); g_free((gpointer) package_id); } slapt_free_pkg_list(available); slapt_free_pkg_list(installed); pk_backend_set_percentage (backend, 100); pk_backend_finished (backend); }
static gboolean backend_repo_enable_thread (PkBackend *backend) { GError *error = NULL; const gchar *repo; gboolean enabled; g_return_val_if_fail (pacman != NULL, FALSE); g_return_val_if_fail (disabled_repos != NULL, FALSE); g_return_val_if_fail (backend != NULL, FALSE); repo = pk_backend_get_string (backend, "repo_id"); enabled = pk_backend_get_bool (backend, "enabled"); g_return_val_if_fail (repo != NULL, FALSE); if (enabled) { /* check that repo is indeed disabled */ if (g_hash_table_remove (disabled_repos, repo)) { /* reload configuration to preserve the correct order */ if (disabled_repos_configure (disabled_repos, &error)) { pk_backend_repo_list_changed (backend); } else { backend_error (backend, error); pk_backend_thread_finished (backend); return FALSE; } } else { pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, "Could not find repo [%s]", repo); pk_backend_thread_finished (backend); return FALSE; } } else { PacmanDatabase *database = pacman_manager_find_sync_database (pacman, repo); if (database != NULL) { if (pacman_manager_unregister_database (pacman, database, &error)) { g_hash_table_insert (disabled_repos, g_strdup (repo), GINT_TO_POINTER (1)); } else { backend_error (backend, error); pk_backend_thread_finished (backend); return FALSE; } } else { pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, "Could not find repo [%s]", repo); pk_backend_thread_finished (backend); return FALSE; } } pk_backend_thread_finished (backend); return TRUE; }
static gboolean backend_get_files_thread (PkBackend *backend) { gchar **package_ids; gchar *pi; package_ids = pk_backend_get_strv (backend, "package_ids"); if (package_ids == NULL) { pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "Invalid package id"); pk_backend_finished (backend); return false; } aptcc *m_apt = new aptcc(backend, _cancel); pk_backend_set_pointer(backend, "aptcc_obj", m_apt); if (m_apt->init()) { egg_debug ("Failed to create apt cache"); delete m_apt; pk_backend_finished (backend); return false; } pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); for (uint i = 0; i < g_strv_length(package_ids); i++) { pi = package_ids[i]; if (pk_package_id_check(pi) == false) { pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, pi); delete m_apt; pk_backend_finished (backend); return false; } pair<pkgCache::PkgIterator, pkgCache::VerIterator> pkg_ver; pkg_ver = m_apt->find_package_id(pi); if (pkg_ver.second.end() == true) { pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "Couldn't find package"); delete m_apt; pk_backend_finished (backend); return false; } emit_files (backend, pi); } delete m_apt; pk_backend_finished (backend); return true; }
static gboolean backend_get_details_thread (PkBackend *backend) { PackageSearch *ps; GList *list; sqlite3 *db; gchar **package_ids; gchar **package_id_data; package_ids = pk_backend_get_strv (backend, "package_ids"); /* FIXME: support multiple packages */ package_id_data = pk_package_id_split (package_ids[0]); db = db_open (); pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); /* only one element is returned */ list = box_db_repos_packages_search_by_data (db, package_id_data[PK_PACKAGE_ID_NAME], package_id_data[PK_PACKAGE_ID_VERSION]); if (list == NULL) { pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "cannot find package by id"); db_close (db); return FALSE; } ps = (PackageSearch*) list->data; pk_backend_details (backend, package_ids[0], "unknown", PK_GROUP_ENUM_OTHER, ps->description, "", 0); box_db_repos_package_list_free (list); db_close (db); pk_backend_finished (backend); return TRUE; }
/** * backend_update_package: */ static gboolean backend_update_package_thread (PkBackend *backend) { gchar **parts; gint err = 0; const gchar *package_id; /* FIXME: support only_trusted */ package_id = pk_backend_get_string (backend, "pkgid"); parts = pk_package_id_split (package_id); if (!parts) { pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "Package not found"); pk_backend_finished (backend); return FALSE; } err = opkg_upgrade_package (parts[PK_PACKAGE_ID_NAME], pk_opkg_progress_cb, backend); if (err) handle_install_error (backend, err); g_strfreev (parts); pk_backend_finished (backend); return (err != 0); }
/** * backend_get_details: */ static gboolean backend_get_details_thread (PkBackend *backend) { gchar **package_ids; gchar **parts; int group_index; PkGroupEnum group = 0; pkg_t *pkg; gchar *newid; package_ids = pk_backend_get_strv(backend, "package_ids"); parts = pk_package_id_split (package_ids[0]); if (!parts) { pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id"); pk_backend_finished (backend); return FALSE; } pkg = opkg_find_package (parts[PK_PACKAGE_ID_NAME], parts[PK_PACKAGE_ID_VERSION], parts[PK_PACKAGE_ID_ARCH], parts[PK_PACKAGE_ID_DATA]); g_strfreev (parts); if (!pkg) { pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, NULL); pk_backend_finished (backend); return FALSE; } newid = g_strdup_printf ("%s;%s;%s;%s", pkg->name, pkg->version, pkg->architecture, pkg->src->name); if (pkg->tags) { for (group_index = 0; group < PK_GROUP_ENUM_LAST; group_index++) { group = 1 << group_index; if (!(group & backend_get_groups(backend))) continue; if (opkg_check_tag(pkg, (const gchar *)pk_group_enum_to_string(group))) break; } } pk_backend_details (backend, newid, NULL, group, pkg->description, NULL, pkg->size); g_free (newid); pk_backend_finished (backend); return TRUE; }
/** * backend_refresh_cache_thread: */ static gboolean backend_refresh_cache_thread (PkBackend *backend) { pk_backend_set_allow_cancel (backend, true); aptcc *m_apt = new aptcc(backend, _cancel); pk_backend_set_pointer(backend, "aptcc_obj", m_apt); if (m_apt->init()) { egg_debug ("Failed to create apt cache"); delete m_apt; pk_backend_finished (backend); return false; } pk_backend_set_status (backend, PK_STATUS_ENUM_REFRESH_CACHE); // Lock the list directory FileFd Lock; if (_config->FindB("Debug::NoLocking", false) == false) { Lock.Fd(GetLock(_config->FindDir("Dir::State::Lists") + "lock")); if (_error->PendingError() == true) { pk_backend_error_code (backend, PK_ERROR_ENUM_CANNOT_GET_LOCK, "Unable to lock the list directory"); delete m_apt; pk_backend_finished (backend); return false; // return _error->Error(_("Unable to lock the list directory")); } } // Create the progress AcqPackageKitStatus Stat(m_apt, backend, _cancel); // do the work if (_config->FindB("APT::Get::Download",true) == true) { ListUpdate(Stat, *m_apt->packageSourceList); } // Rebuild the cache. pkgCacheFile Cache; OpTextProgress Prog(*_config); if (Cache.BuildCaches(Prog, true) == false) { if (_error->PendingError() == true) { show_errors(backend, PK_ERROR_ENUM_CANNOT_GET_LOCK); } delete m_apt; pk_backend_finished (backend); return false; } // missing gpg signature would appear here // TODO we need a better enum if (_error->PendingError() == false && _error->empty() == false) { show_warnings(backend, PK_MESSAGE_ENUM_UNTRUSTED_PACKAGE); } pk_backend_finished (backend); delete m_apt; return true; }
static void opkg_unknown_error (PkBackend *backend, gint error_code, const gchar *failed_cmd) { gchar *msg; msg = g_strdup_printf ("%s failed with error code %d", failed_cmd, error_code); pk_backend_error_code (backend, PK_ERROR_ENUM_UNKNOWN, msg); g_free (msg); }
/** * backend_resolve: */ static void backend_resolve (PkBackend *backend, PkBitfield filters, gchar **packages) { guint i; guint len; const gchar *package_id; slapt_pkg_list_t *pkglist; slapt_pkg_info_t *pkg = NULL; slapt_pkg_list_t *results = NULL; PkInfoEnum state; const gchar *search; const char *summary; pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); pk_backend_set_percentage (backend, 0); if (pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED)) { pkglist = slapt_get_installed_pkgs(); state = PK_INFO_ENUM_INSTALLED; } else { pkglist = slapt_get_available_pkgs(); state = PK_INFO_ENUM_AVAILABLE; } len = g_strv_length (packages); for (i=0; i<len; i++) { search = g_strdup_printf("^%s$", packages[i]); /* regexp */ results = slapt_search_pkg_list(pkglist, search); g_free((gpointer) search); if (results == NULL) { pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "package not found"); continue; } for (i = 0; i < results->pkg_count; i++) { pkg = results->pkgs[i]; package_id = _get_string_from_pkg(pkg); summary = _get_pkg_summary(pkg); pk_backend_package (backend, state, package_id, summary); g_free((gpointer) summary); g_free((gpointer) package_id); } slapt_free_pkg_list(results); } slapt_free_pkg_list(pkglist); pk_backend_set_percentage (backend, 100); pk_backend_finished (backend); }
/** * backend_search_names: */ static void backend_search_names (PkBackend *backend, PkBitfield filters, gchar **values) { unsigned int i; gchar *search; const gchar *package_id; slapt_pkg_list_t *pkglist; slapt_pkg_info_t *pkg = NULL; slapt_pkg_list_t *results = NULL; PkInfoEnum state; const char *summary; pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); pk_backend_set_percentage (backend, 0); search = g_strjoinv ("&", values); if (pk_bitfield_contain (filters, PK_FILTER_ENUM_INSTALLED)) { pkglist = slapt_get_installed_pkgs(); state = PK_INFO_ENUM_INSTALLED; } else { pkglist = slapt_get_available_pkgs(); state = PK_INFO_ENUM_AVAILABLE; } results = slapt_search_pkg_list(pkglist, search); g_free((gpointer) search); if (results == NULL) { pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_FOUND, "package not found"); goto out; } for (i = 0; i < results->pkg_count; i++) { pkg = results->pkgs[i]; package_id = _get_string_from_pkg(pkg); summary = _get_pkg_summary(pkg); pk_backend_package (backend, state, package_id, summary); g_free((gpointer) summary); g_free((gpointer) package_id); } slapt_free_pkg_list(results); out: slapt_free_pkg_list(pkglist); g_free (search); pk_backend_set_percentage (backend, 100); pk_backend_finished (backend); }
/** * backend_update_packages: */ static void backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids) { /* check network state */ if (!pk_backend_is_online (backend)) { pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot update when offline"); pk_backend_finished (backend); return; } pk_backend_thread_create (backend, backend_update_packages_thread); }
/** * pk_backend_spawn_kill: * * A forceful exit, useful for aborting scripts **/ gboolean pk_backend_spawn_kill (PkBackendSpawn *backend_spawn) { g_return_val_if_fail (PK_IS_BACKEND_SPAWN (backend_spawn), FALSE); /* set an error as the script will just exit without doing finished */ pk_backend_error_code (backend_spawn->priv->backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "the script was killed as the action was cancelled"); pk_spawn_kill (backend_spawn->priv->spawn); return TRUE; }
/** * backend_refresh_cache: */ static void backend_refresh_cache (PkBackend *backend, gboolean force) { /* check network state */ if (!pk_backend_is_online (backend)) { pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot refresh cache whilst offline"); pk_backend_finished (backend); return; } /* FIXME: support force */ pk_backend_thread_create (backend, backend_refresh_cache_thread); }
/** * pk_backend_refresh_cache: */ void pk_backend_refresh_cache (PkBackend *backend, gboolean force) { /* check network state */ if (!pk_backend_is_online (backend)) { pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot refresh cache whilst offline"); pk_backend_finished (backend); return; } pk_backend_spawn_helper (spawn, BACKEND_FILE, "refresh-cache", pk_backend_bool_to_string (force), NULL); }
zypp::RepoInfo zypp_get_Repository (PkBackend *backend, const gchar *alias) { zypp::RepoInfo info; try { zypp::RepoManager manager; info = manager.getRepositoryInfo (alias); } catch (const zypp::repo::RepoNotFoundException &ex) { pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, ex.asUserString().c_str() ); return zypp::RepoInfo (); } return info; }
/** * pk_backend_update_packages: */ void pk_backend_update_packages (PkBackend *backend, gboolean only_trusted, gchar **package_ids) { gchar *package_ids_temp; /* check network state */ if (!pk_backend_is_online (backend)) { pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot install when offline"); pk_backend_finished (backend); return; } /* send the complete list as stdin */ package_ids_temp = pk_package_ids_to_string (package_ids); pk_backend_spawn_helper (spawn, BACKEND_FILE, "update-packages", pk_backend_bool_to_string (only_trusted), package_ids_temp, NULL); g_free (package_ids_temp); }
/** * backend_initialize: */ static void backend_initialize (PkBackend *backend) { int opkg = opkg_new (); if (!opkg) { pk_backend_error_code (backend, PK_ERROR_ENUM_FAILED_INITIALIZATION, "Could not start Opkg"); return; } #ifdef OPKG_OFFLINE_ROOT opkg_set_option ((char *) "offline_root", OPKG_OFFLINE_ROOT); opkg_re_read_config_files (); #endif }
static gboolean backend_remove_packages_thread (PkBackend *backend) { gchar **package_ids; gchar **package_id_data; package_ids = pk_backend_get_strv (backend, "package_ids"); /* FIXME: support multiple packages */ package_id_data = pk_package_id_split (package_ids[0]); pk_backend_set_status (backend, PK_STATUS_ENUM_REMOVE); if (!box_package_uninstall (package_id_data[PK_PACKAGE_ID_NAME], ROOT_DIRECTORY, common_progress, backend, FALSE)) { pk_backend_error_code (backend, PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, "Cannot uninstall"); } pk_backend_finished (backend); return TRUE; }
/** * backend_search_name_thread: */ static gboolean backend_search_name_thread (PkBackend *backend) { GTimer *timer; guint percentage; PkBitfield filters; gchar *filters_text; const gchar *search; filters = pk_backend_get_uint (backend, "filters"); search = pk_backend_get_string (backend, "search"); filters_text = pk_filter_bitfield_to_text (filters); egg_debug ("started task (%p) search=%s filters=%s", backend, search, filters_text); g_free (filters_text); pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY); timer = g_timer_new (); percentage = 0; do { /* now is a good time to see if we should cancel the thread */ if (is_cancelled) { pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_CANCELLED, "The thread was stopped successfully"); pk_backend_finished (backend); return TRUE; } pk_backend_set_percentage (backend, percentage); percentage += 10; g_usleep (1000*100); } while (percentage < 100); g_timer_destroy (timer); pk_backend_set_percentage (backend, 100); egg_debug ("exited task (%p)", backend); pk_backend_package (backend, PK_INFO_ENUM_INSTALLED, "glib2;2.14.0;i386;fedora", "The GLib library"); pk_backend_package (backend, PK_INFO_ENUM_INSTALLED, "gtk2;gtk2-2.11.6-6.fc8;i386;fedora", "GTK+ Libraries for GIMP"); pk_backend_finished (backend); return TRUE; }
/* Prompt for a media swap */ bool AcqPackageKitStatus::MediaChange(string Media, string Drive) { pk_backend_media_change_required(m_backend, PK_MEDIA_TYPE_ENUM_DISC, Media.c_str(), Media.c_str()); char errorMsg[400]; sprintf(errorMsg, "Media change: please insert the disc labeled" " '%s' " "in the drive '%s' and try again.", Media.c_str(), Drive.c_str()); pk_backend_error_code(m_backend, PK_ERROR_ENUM_MEDIA_CHANGE_REQUIRED, errorMsg); // Set this so we can fail the transaction Update = true; return false; }
/** * backend_destroy: */ static void backend_destroy (PkBackend *backend) { pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Failed to release control"); }
/** * backend_initialize: */ static void backend_initialize (PkBackend *backend) { pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Failed to initialize package manager"); }