[PackageKit-commit] packagekit: Branch 'master' - 17 commits

Richard Hughes hughsient at kemper.freedesktop.org
Thu Apr 24 01:26:17 PDT 2008


 backends/alpm/pk-backend-alpm.c   |  108 +++++-----
 backends/zypp/pk-backend-zypp.cpp |    8 
 backends/zypp/zypp-utils.cpp      |    8 
 configure.ac                      |    2 
 docs/html/pk-faq.html             |    2 
 libpackagekit/pk-common.c         |  100 +++++++++
 libpackagekit/pk-enum.c           |    4 
 po/LINGUAS                        |    2 
 po/pt_BR.po                       |  407 ++++++++++++++++++++++++++++++++++++++
 src/pk-thread-list.c              |   31 --
 10 files changed, 578 insertions(+), 94 deletions(-)

New commits:
commit 8a50ddb57985eea48bb224e8805878379c02d393
Merge: 4475c50... 86cd0a6...
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Apr 24 09:24:35 2008 +0100

    Merge branch 'master' of git+ssh://hughsie@git.packagekit.org/srv/git/PackageKit

commit 86cd0a6e8f7877eadcd05c813e27e2eaa5c9fc76
Author: Stefan Haas <shaas at suse.de>
Date:   Thu Apr 24 09:30:58 2008 +0200

    changes for zypp 4.14.0 (needed for reboot-flag)

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index a82868b..943e9a2 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -969,9 +969,9 @@ backend_get_update_detail_thread (PkBackendThread *thread, gpointer data)
 
 	if (zypp::isKind<zypp::Patch>(solvable)) {
 		zypp::Patch::constPtr patch = zypp::asKind<zypp::Patch>(item);
-		if (patch->reboot_needed ()) {
+		if (patch->rebootSuggested ()) {
 			restart = PK_RESTART_ENUM_SYSTEM;
-		}else if (patch->affects_pkg_manager ()) {
+		}else if (patch->restartSuggested ()) {
 			restart = PK_RESTART_ENUM_SESSION;
 		}
 
diff --git a/configure.ac b/configure.ac
index b084ac4..f38eec2 100755
--- a/configure.ac
+++ b/configure.ac
@@ -556,7 +556,7 @@ if test x$enable_poldek = xyes; then
 fi
 
 if test x$enable_zypp = xyes; then
-	PKG_CHECK_MODULES(ZYPP, libzypp >= 4.10.0)
+	PKG_CHECK_MODULES(ZYPP, libzypp >= 4.14.0)
 	AC_SUBST(ZYPP_CFLAGS)
 	AC_SUBST(ZYPP_LIBS)
 fi
commit 05e5de9847e56329fbde3b9b2483232a862c2d6d
Author: Stefan Haas <shaas at suse.de>
Date:   Thu Apr 24 09:18:25 2008 +0200

    Added arch filter to backend

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 07c5b84..a82868b 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -364,7 +364,9 @@ backend_get_filters (PkBackend *backend)
 {
 	g_return_val_if_fail (backend != NULL, PK_FILTER_ENUM_UNKNOWN);
 	return (PkFilterEnum) (PK_FILTER_ENUM_INSTALLED |
-			PK_FILTER_ENUM_NOT_INSTALLED);
+			PK_FILTER_ENUM_NOT_INSTALLED |
+			PK_FILTER_ENUM_ARCH |
+			PK_FILTER_ENUM_NOT_ARCH);
 }
 
 static gboolean
diff --git a/backends/zypp/zypp-utils.cpp b/backends/zypp/zypp-utils.cpp
index 9b05207..17a610d 100644
--- a/backends/zypp/zypp-utils.cpp
+++ b/backends/zypp/zypp-utils.cpp
@@ -412,6 +412,14 @@ zypp_emit_packages_in_list (PkBackend *backend, std::vector<zypp::sat::Solvable>
 			continue;
 		if (filters == PK_FILTER_ENUM_NOT_INSTALLED && it->isSystem ())
 			continue;
+		if (filters == PK_FILTER_ENUM_ARCH) {
+			if (it->arch () != zypp::ZConfig::defaultSystemArchitecture () && it->arch () != zypp::Arch_noarch)
+				continue;
+		}
+		if (filters == PK_FILTER_ENUM_NOT_ARCH) {
+			if (it->arch () == zypp::ZConfig::defaultSystemArchitecture ())
+				continue;
+		}
 		pk_backend_package (backend,
 			    it->isSystem() == true ?
 				PK_INFO_ENUM_INSTALLED :
commit 4a33df969c1a8a2510ae0fec83971593e6b0eb90
Merge: b7d8b64... 6180a63...
Author: Stefan Haas <shaas at suse.de>
Date:   Thu Apr 24 09:14:23 2008 +0200

    Merge branch 'master' of git+ssh://shaas@git.packagekit.org/srv/git/PackageKit

commit 6180a638bd2a2c37365c53b4cc638b7e98f26535
Merge: 7639ccc... 147ce64...
Author: Valeriy Lyasotskiy <onestep at ukr.net>
Date:   Thu Apr 24 08:18:09 2008 +0300

    Merge branch 'master' of git+ssh://onestep_ua@git.packagekit.org/srv/git/PackageKit

commit 7639ccc586f5e76ea5184aaf3f7ebef4e768b39d
Author: Valeriy Lyasotskiy <onestep at ukr.net>
Date:   Thu Apr 24 08:17:54 2008 +0300

    main part of search function moved to get_packages_by_name, some fixes in backend_refresh_cache

diff --git a/backends/alpm/pk-backend-alpm.c b/backends/alpm/pk-backend-alpm.c
index cc54ad7..cc543e0 100644
--- a/backends/alpm/pk-backend-alpm.c
+++ b/backends/alpm/pk-backend-alpm.c
@@ -65,19 +65,19 @@ package_source_free (PackageSource *source)
 }
 
 void
-trans_event_cb (pmtransevt_t event, void *data1, void *data2)
+cb_trans_evt (pmtransevt_t event, void *data1, void *data2)
 {
     // TODO: Add code here
 }
 
 void
-trans_conv_cb (pmtransconv_t conv, void *data1, void *data2, void *data3, int *response)
+cb_trans_conv (pmtransconv_t conv, void *data1, void *data2, void *data3, int *response)
 {
     // TODO: Add code here
 }
 
 void
-trans_prog_cb (pmtransprog_t prog, const char *pkgname, int percent, int n, int remain)
+cb_trans_progress (pmtransprog_t prog, const char *pkgname, int percent, int n, int remain)
 {
     pk_debug ("Percentage is %i", percent);
     subprogress_percentage = percent;
@@ -204,24 +204,23 @@ find_packages_by_desc (const gchar *name, pmdb_t *db)
     if (db == NULL || name == NULL)
 	return NULL;
 
-    alpm_list_t *needle = NULL;
     alpm_list_t *result = NULL;
-    alpm_list_t *query_result = NULL;
 
     // determine if repository is local
     gboolean repo_is_local = (db == alpm_option_get_localdb ());
     // determine repository name
     const gchar *repo = alpm_db_get_name (db);
     // set search term
+    alpm_list_t *needle = NULL;
     needle = alpm_list_add (needle, (gchar *) name);
     // execute query
-    query_result = alpm_db_search (db, needle);
+    alpm_list_t *query_result = alpm_db_search (db, needle);
 
     alpm_list_t *iterator;
     for (iterator = query_result; iterator; iterator = alpm_list_next (iterator)) {
 	PackageSource *source = g_malloc (sizeof (PackageSource));
 
-	source->pkg = (pmpkg_t *) alpm_list_getdata(iterator);
+	source->pkg = (pmpkg_t *) alpm_list_getdata (iterator);
 	source->repo = (gchar *) repo;
 	source->installed = repo_is_local;
 
@@ -233,6 +232,39 @@ find_packages_by_desc (const gchar *name, pmdb_t *db)
     return result;
 }
 
+alpm_list_t *
+find_packages_by_name (const gchar *name, pmdb_t *db)
+{
+    if (db == NULL || name == NULL)
+	return NULL;
+
+    alpm_list_t *result = NULL;
+
+    // determine if repository is local
+    gboolean repo_is_local = (db == alpm_option_get_localdb ());
+    // determine repository name
+    const gchar *repo = alpm_db_get_name (db);
+    // get list of packages in repository
+    alpm_list_t *cache = alpm_db_getpkgcache (db);
+
+    alpm_list_t *iterator;
+    for (iterator = cache; iterator; iterator = alpm_list_next (iterator)) {
+	pmpkg_t *pkg = alpm_list_getdata (iterator);
+
+	if (strstr (alpm_pkg_get_name (pkg), name)) {
+	    PackageSource *source = g_malloc (sizeof (PackageSource));
+
+	    source->pkg = (pmpkg_t *) pkg;
+	    source->repo = (gchar *) repo;
+	    source->installed = repo_is_local;
+
+	    result = alpm_list_add (result, (PackageSource *) source);
+	}
+    }
+
+    return result;
+}
+
 gboolean
 pkg_is_installed (const gchar *name, const gchar *version)
 {
@@ -271,9 +303,7 @@ backend_destroy (PkBackend *backend)
     g_return_if_fail (backend != NULL);
 
     if (alpm_release () == -1)
-	pk_backend_error_code (backend,
-		PK_ERROR_ENUM_FAILED_FINALISE,
-		"Failed to release control");
+	pk_backend_error_code (backend, PK_ERROR_ENUM_FAILED_FINALISE, "Failed to release control");
 }
 
 /**
@@ -635,7 +665,7 @@ backend_install_package (PkBackend *backend, const gchar *package_id)
     }
 */
 
-    if (alpm_trans_init (PM_TRANS_TYPE_SYNC, flags, trans_event_cb, trans_conv_cb, trans_prog_cb) == -1) {
+    if (alpm_trans_init (PM_TRANS_TYPE_SYNC, flags, cb_trans_evt, cb_trans_conv, cb_trans_progress) == -1) {
 	pk_backend_error_code (backend,
 		PK_ERROR_ENUM_TRANSACTION_ERROR,
 		alpm_strerror (pm_errno));
@@ -711,7 +741,7 @@ backend_refresh_cache (PkBackend *backend, gboolean force)
     alpm_list_t *problems = NULL;
 */
 
-    if (alpm_trans_init (PM_TRANS_TYPE_SYNC, 0, trans_event_cb, trans_conv_cb, trans_prog_cb) != 0) {
+    if (alpm_trans_init (PM_TRANS_TYPE_SYNC, 0, cb_trans_evt, cb_trans_conv, cb_trans_progress) != 0) {
 	pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerror (pm_errno));
 	pk_backend_finished (backend);
 	return;
@@ -727,21 +757,18 @@ backend_refresh_cache (PkBackend *backend, gboolean force)
     }
 */
 
-    alpm_list_t *i = NULL;
     pk_backend_set_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
-    g_timeout_add (ALPM_PROGRESS_UPDATE_INTERVAL, update_subprogress, backend);
 
-    for (i = dbs; i; i = alpm_list_next (i)) {
-	if (alpm_db_update (force, (pmdb_t *) i->data)) {
+    alpm_list_t *iterator;
+    for (iterator = dbs; iterator; iterator = alpm_list_next (iterator)) {
+	if (alpm_db_update (force, (pmdb_t *) alpm_list_getdata (iterator))) {
 	    pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerror (pm_errno));
-	    alpm_list_free (dbs);
 	    pk_backend_finished (backend);
-	    subprogress_percentage = -1;
 	    return;
 	}
-	subprogress_percentage = -1;
     }
 
+    alpm_trans_release ();
     pk_backend_finished (backend);
 }
 
@@ -800,7 +827,7 @@ backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean al
     if (allow_deps)
 	flags |= PM_TRANS_FLAG_CASCADE;
 
-    if (alpm_trans_init (PM_TRANS_TYPE_REMOVE, flags, trans_event_cb, trans_conv_cb, trans_prog_cb) == -1) {
+    if (alpm_trans_init (PM_TRANS_TYPE_REMOVE, flags, cb_trans_evt, cb_trans_conv, cb_trans_progress) == -1) {
 	pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, alpm_strerror (pm_errno));
 	pk_backend_finished (backend);
 	pk_package_id_free (id);
@@ -849,7 +876,7 @@ backend_search_details (PkBackend *backend, PkFilterEnum filters, const gchar *s
     if (!ninstalled)
 	repos = alpm_list_add (repos, alpm_option_get_localdb ());
     if (!installed)
-	repos = alpm_list_join (repos, alpm_list_copy(alpm_option_get_syncdbs ()));
+	repos = alpm_list_join (repos, alpm_list_copy (alpm_option_get_syncdbs ()));
 
     alpm_list_t *iterator;
     for (iterator = repos; iterator; iterator = alpm_list_next (iterator))
@@ -868,7 +895,8 @@ backend_search_details (PkBackend *backend, PkFilterEnum filters, const gchar *s
  * backend_search_name:
  */
 static void
-backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *search) {
+backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *search)
+{
     g_return_if_fail (backend != NULL);
 
     alpm_list_t *repos = NULL;
@@ -882,33 +910,11 @@ backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *sear
     if (!ninstalled)
 	repos = alpm_list_add (repos, alpm_option_get_localdb ());
     if (!installed)
-	repos = alpm_list_join (repos, alpm_list_copy(alpm_option_get_syncdbs ()));
+	repos = alpm_list_join (repos, alpm_list_copy (alpm_option_get_syncdbs ()));
 
     alpm_list_t *iterator;
-    for (iterator = repos; iterator; iterator = alpm_list_next (iterator)) {
-	pmdb_t *db = alpm_list_getdata (iterator);
-	alpm_list_t *cache = alpm_db_getpkgcache (db);
-
-	// determine if repository is local
-	gboolean db_is_local = (db == alpm_option_get_localdb ());
-	// determine repository name
-	const gchar *repo = alpm_db_get_name (db);
-
-	alpm_list_t *pkg_iterator;
-	for (pkg_iterator = cache; pkg_iterator; pkg_iterator = alpm_list_next (pkg_iterator)) {
-	    pmpkg_t *pkg = alpm_list_getdata(pkg_iterator);
-
-	    if (strstr (alpm_pkg_get_name (pkg), search)) {
-		PackageSource *source = g_malloc (sizeof (PackageSource));
-
-		source->pkg = (pmpkg_t *) pkg;
-		source->repo = (gchar *) repo;
-		source->installed = db_is_local;
-
-		result = alpm_list_add (result, (PackageSource *) source);
-	    }
-	}
-    }
+    for (iterator = repos; iterator; iterator = alpm_list_next (iterator))
+	result = alpm_list_join (result, find_packages_by_name (search, (pmdb_t *) alpm_list_getdata(iterator)));
 
     add_packages_from_list (backend, alpm_list_first (result));
 
@@ -948,7 +954,7 @@ backend_install_file (PkBackend *backend, gboolean trusted, const gchar *path)
     g_return_if_fail (backend != NULL);
 
     alpm_list_t *problems = NULL;
-    if (alpm_trans_init (PM_TRANS_TYPE_ADD, 0, trans_event_cb, trans_conv_cb, trans_prog_cb) == -1) {
+    if (alpm_trans_init (PM_TRANS_TYPE_ADD, 0, cb_trans_evt, cb_trans_conv, cb_trans_progress) == -1) {
 	pk_backend_error_code (backend,
 		PK_ERROR_ENUM_TRANSACTION_ERROR,
 		alpm_strerror (pm_errno));
@@ -991,19 +997,17 @@ backend_get_repo_list (PkBackend *backend, PkFilterEnum filters)
     pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
 
     alpm_list_t *repos = alpm_option_get_syncdbs ();
-
     if (repos == NULL)
 	pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, alpm_strerror (pm_errno));
 
     // Iterate on repository list
-    repos = alpm_list_first (repos);
-    while (repos != NULL) {
+    alpm_list_t *iterator;
+    for (iterator = repos; iterator; iterator = alpm_list_next(iterator)) {
 	pmdb_t *db = alpm_list_getdata (repos);
 	pk_backend_repo_detail (backend, alpm_db_get_name (db), alpm_db_get_url (db), TRUE);
 	repos = alpm_list_next (repos);
     }
 
-    alpm_list_free (repos);
     pk_backend_finished (backend);
 }
   
commit 147ce644b2abf0ff06aacee7560aa92999b89d7c
Author: Igor Pires Soares <igorsoares at gmail.com>
Date:   Thu Apr 24 03:09:07 2008 +0000

    2008-04-24  Igor Pires Soares <igorsoares at gmail.com> (via
    igor at fedoraproject.org)
    
      * po/LINGUAS: pt_BR added to LINGUAS

diff --git a/po/LINGUAS b/po/LINGUAS
index 210c56a..ca3453c 100644
--- a/po/LINGUAS
+++ b/po/LINGUAS
@@ -12,4 +12,4 @@ pl
 cs
 fi
 ru
-
+pt_BR
commit 5fc139c8c8ee1405dc98b0ed1380f28d1cd9efc1
Merge: d184e7a... 2712232...
Author: Igor Pires Soares <igorsoares at gmail.com>
Date:   Thu Apr 24 03:05:25 2008 +0000

    Merge branch 'master' of git+ssh://transif@git.packagekit.org/srv/git/PackageKit

commit d184e7abf9156afd68605b52d2638fd0f40ef8b1
Author: Igor Pires Soares <igorsoares at gmail.com>
Date:   Thu Apr 24 03:05:21 2008 +0000

    2008-04-24  Igor Pires Soares <igorsoares at gmail.com> (via
    igor at fedoraproject.org)
    
      * po/pt_BR.po: Initial Brazilian Portuguese translation

diff --git a/po/pt_BR.po b/po/pt_BR.po
new file mode 100644
index 0000000..e261ac3
--- /dev/null
+++ b/po/pt_BR.po
@@ -0,0 +1,407 @@
+# Brazilian Portuguese translation of PackageKit.
+# Copyright (C) 2008 Free Software Foundation, Inc.
+# This file is distributed under the same license as the packagekit package.
+#
+# Igor Pires Soares <igor at projetofedora.org>, 2008
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PackageKit\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2008-04-18 21:33+0300\n"
+"PO-Revision-Date: 2008-04-23 23:58-0300\n"
+"Last-Translator: Igor Pires Soares <igor at projetofedora.org>\n"
+"Language-Team: Brazilian Portuguese <fedora-trans-pt_br at redhat.com>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+"X-Poedit-Language: Portuguese\n"
+"X-Poedit-Country: BRAZIL\n"
+
+#: ../policy/org.freedesktop.packagekit.policy.in.h:1
+msgid "Accept EULA"
+msgstr "Aceitar a licença EULA"
+
+#: ../policy/org.freedesktop.packagekit.policy.in.h:2
+msgid "Authentication is required to accept a EULA"
+msgstr "É necessário autenticar para aceitar uma licença EULA"
+
+#: ../policy/org.freedesktop.packagekit.policy.in.h:3
+msgid "Authentication is required to change software source parameters"
+msgstr "É necessário autenticar para alterar os parâmetros das fontes de programas"
+
+#: ../policy/org.freedesktop.packagekit.policy.in.h:4
+msgid "Authentication is required to install a local file"
+msgstr "É necessário autenticar para instalar um arquivo local"
+
+#: ../policy/org.freedesktop.packagekit.policy.in.h:5
+msgid "Authentication is required to install a package"
+msgstr "É necessário autenticar para instalar um pacote"
+
+#: ../policy/org.freedesktop.packagekit.policy.in.h:6
+msgid "Authentication is required to install a security signature"
+msgstr "É necessário autenticar para instalar uma assinatura de segurança"
+
+#: ../policy/org.freedesktop.packagekit.policy.in.h:7
+msgid "Authentication is required to refresh the package lists"
+msgstr "É necessário autenticar para recarregar a lista de pacotes"
+
+#: ../policy/org.freedesktop.packagekit.policy.in.h:8
+msgid "Authentication is required to remove packages"
+msgstr "É necessário autenticar para remover pacotes"
+
+#: ../policy/org.freedesktop.packagekit.policy.in.h:9
+msgid "Authentication is required to rollback a transaction"
+msgstr "É necessário autenticar para retroceder uma transação"
+
+#: ../policy/org.freedesktop.packagekit.policy.in.h:10
+msgid "Authentication is required to update all packages"
+msgstr "É necessário autenticar para atualizar todos os pacotes"
+
+#: ../policy/org.freedesktop.packagekit.policy.in.h:11
+msgid "Authentication is required to update packages"
+msgstr "É necessário autenticar para atualizar os pacotes"
+
+#: ../policy/org.freedesktop.packagekit.policy.in.h:12
+msgid "Change software source parameters"
+msgstr "Altere parâmetros das fontes de programas"
+
+#: ../policy/org.freedesktop.packagekit.policy.in.h:13
+msgid "Install local file"
+msgstr "Instalar um arquivo local"
+
+#: ../policy/org.freedesktop.packagekit.policy.in.h:14
+msgid "Install package"
+msgstr "Instalar um pacote"
+
+#: ../policy/org.freedesktop.packagekit.policy.in.h:15
+msgid "Install security signature"
+msgstr "Instalar uma assinatura de segurança"
+
+#: ../policy/org.freedesktop.packagekit.policy.in.h:16
+msgid "Refresh package lists"
+msgstr "Recarregar listas de pacotes"
+
+#: ../policy/org.freedesktop.packagekit.policy.in.h:17
+msgid "Remove package"
+msgstr "Remover pacote"
+
+#: ../policy/org.freedesktop.packagekit.policy.in.h:18
+msgid "Rollback to a previous transaction"
+msgstr "Retroceder para uma transação anterior"
+
+#: ../policy/org.freedesktop.packagekit.policy.in.h:19
+msgid "Update all packages"
+msgstr "Atualizar todos os pacotes"
+
+#: ../policy/org.freedesktop.packagekit.policy.in.h:20
+msgid "Update package"
+msgstr "Atualizar pacote"
+
+#: ../client/pk-console.c:208
+msgid "Update detail"
+msgstr "Detalhe da atualização"
+
+#: ../client/pk-console.c:400
+msgid "A system restart is required"
+msgstr "É necessário reiniciar o sistema"
+
+#: ../client/pk-console.c:402
+msgid "A logout and login is required"
+msgstr "É necessário sair da sessão e autenticar novamente"
+
+#: ../client/pk-console.c:404
+msgid "An application restart is required"
+msgstr "É necessário reiniciar a aplicação"
+
+#: ../client/pk-console.c:443
+#, c-format
+msgid "Please enter a number from 1 to %i: "
+msgstr "Por favor, insira um número entre 1 e %i: "
+
+#: ../client/pk-console.c:493
+msgid "Could not find a package match"
+msgstr "Não foi possível encontrar um pacote correspondente"
+
+#: ../client/pk-console.c:507
+msgid "There are multiple package matches"
+msgstr "Há múltiplos pacotes correspondentes"
+
+#. find out what package the user wants to use
+#: ../client/pk-console.c:514
+msgid "Please enter the package number: "
+msgstr "Por favor, insira o número do pacote: "
+
+#: ../client/pk-console.c:530
+msgid "Could not find a package with that name to install, or package already installed"
+msgstr "Não foi possível encontrar um pacote com esse nome para instalar ou o pacote já está instalado"
+
+#: ../client/pk-console.c:612
+msgid "Could not find a package with that name to remove"
+msgstr "Não foi possível encontrar um pacote com esse nome para remover"
+
+#: ../client/pk-console.c:652
+msgid "The following packages have to be removed"
+msgstr "Os seguintes pacotes têm que ser removidos"
+
+#. get user input
+#: ../client/pk-console.c:661
+msgid "Okay to remove additional packages?"
+msgstr "Os pacotes adicionais podem ser removidos?"
+
+#: ../client/pk-console.c:665
+msgid "Cancelled!"
+msgstr "Cancelado!"
+
+#: ../client/pk-console.c:687
+msgid "Could not find a package with that name to update"
+msgstr "Não foi possível encontrar um pacote com esse nome para ser atualizado"
+
+#: ../client/pk-console.c:705
+msgid "Could not find what packages require this package"
+msgstr "Não foi possível encontrar quais pacotes necessitam desse pacote"
+
+#: ../client/pk-console.c:723
+msgid "Could not get dependencies for this package"
+msgstr "Não foi possível obter as dependências desse pacote"
+
+#: ../client/pk-console.c:741
+msgid "Could not find a description for this package"
+msgstr "Não foi possível encontrar uma descrição para esse pacote"
+
+#: ../client/pk-console.c:759
+#, c-format
+msgid "Could not find the files for this package"
+msgstr "Não foi possível encontrar os arquivos para este pacote"
+
+#: ../client/pk-console.c:819
+msgid "Package description"
+msgstr "Descrição do pacote"
+
+#: ../client/pk-console.c:842
+msgid "Package files"
+msgstr "Arquivos do pacote"
+
+#: ../client/pk-console.c:850
+msgid "No files"
+msgstr "Nenhum arquivo"
+
+#. get user input
+#: ../client/pk-console.c:882
+msgid "Okay to import key?"
+msgstr "A chave pode ser importada?"
+
+#: ../client/pk-console.c:885
+msgid "Did not import key"
+msgstr "Não importar a chave"
+
+#. get user input
+#: ../client/pk-console.c:925
+msgid "Do you agree?"
+msgstr "Você concorda?"
+
+#: ../client/pk-console.c:928
+msgid "Did not agree to licence, task will fail"
+msgstr "Se você não concordar com a licença a tarefa irá falhar"
+
+#: ../client/pk-console.c:957
+msgid "The daemon crashed mid-transaction!"
+msgstr "O daemon travou no meio da transação!"
+
+#. header
+#: ../client/pk-console.c:1010
+msgid "PackageKit Console Interface"
+msgstr "Interface em Console do PackageKit"
+
+#: ../client/pk-console.c:1010
+msgid "Subcommands:"
+msgstr "Subcomandos:"
+
+#: ../client/pk-console.c:1114
+#: ../client/pk-monitor.c:100
+#: ../src/pk-main.c:189
+msgid "Show extra debugging information"
+msgstr "Mostrar informações extras de depuração"
+
+#: ../client/pk-console.c:1116
+#: ../client/pk-monitor.c:102
+msgid "Show the program version and exit"
+msgstr "Mostrar a versão do programa e sair"
+
+#: ../client/pk-console.c:1118
+msgid "Set the filter, e.g. installed"
+msgstr "Definir o filtro, p. ex.: instalados"
+
+#: ../client/pk-console.c:1120
+msgid "Exit without waiting for actions to complete"
+msgstr "Sair sem esperar pelo término das ações"
+
+#: ../client/pk-console.c:1143
+msgid "Could not connect to system DBUS."
+msgstr "Não foi possível conectar ao DBUS do sistema."
+
+#: ../client/pk-console.c:1231
+#, c-format
+msgid "You need to specify a search type"
+msgstr "Você precisa especificar um tipo de pesquisa"
+
+#: ../client/pk-console.c:1236
+#: ../client/pk-console.c:1243
+#: ../client/pk-console.c:1250
+#: ../client/pk-console.c:1257
+#: ../client/pk-console.c:1361
+#: ../client/pk-console.c:1368
+#: ../client/pk-console.c:1375
+#: ../client/pk-console.c:1382
+#, c-format
+msgid "You need to specify a search term"
+msgstr "Você precisa especificar um termo de pesquisa"
+
+#: ../client/pk-console.c:1262
+#, c-format
+msgid "Invalid search type"
+msgstr "Tipo de pesquisa inválido"
+
+#: ../client/pk-console.c:1267
+#, c-format
+msgid "You need to specify a package or file to install"
+msgstr "Você precisa especificar um pacote ou programa a ser instalado"
+
+#: ../client/pk-console.c:1280
+#, c-format
+msgid "You need to specify a type, key_id and package_id"
+msgstr "Você precisa especificar um tipo, key_id e package_id"
+
+#: ../client/pk-console.c:1287
+#, c-format
+msgid "You need to specify a package to remove"
+msgstr "Você precisa especificar um pacote a ser removido"
+
+#: ../client/pk-console.c:1294
+#, c-format
+msgid "You need to specify a eula-id"
+msgstr "Você precisa especificar um eula-id"
+
+#: ../client/pk-console.c:1309
+#, c-format
+msgid "You need to specify a package name to resolve"
+msgstr "Você precisa especificar um nome de pacote a ser analisado"
+
+#: ../client/pk-console.c:1316
+#: ../client/pk-console.c:1323
+#, c-format
+msgid "You need to specify a repo name"
+msgstr "Você precisa especificar um nome de repositório"
+
+#: ../client/pk-console.c:1330
+#, c-format
+msgid "You need to specify a repo name/parameter and value"
+msgstr "Você precisa especificar um nome/parâmetro de repositório e um valor"
+
+#: ../client/pk-console.c:1343
+#, c-format
+msgid "You need to specify a time term"
+msgstr "Você precisa especificar um termo de horário"
+
+#: ../client/pk-console.c:1348
+#, c-format
+msgid "You need to specify a correct role"
+msgstr "Você precisa especificar um papel correto"
+
+#: ../client/pk-console.c:1353
+#, c-format
+msgid "Failed to get last time"
+msgstr "Falha ao obter o último horário"
+
+#: ../client/pk-console.c:1389
+#, c-format
+msgid "You need to specify a package to find the description for"
+msgstr "Você precisa especificar o pacote para o qual você deseja localizar a descrição"
+
+#: ../client/pk-console.c:1396
+#, c-format
+msgid "You need to specify a package to find the files for"
+msgstr "Você precisa especificar o pacote para o qual você quer localizar os arquivos"
+
+#: ../client/pk-console.c:1441
+#, c-format
+msgid "Option '%s' not supported"
+msgstr "A opção \"%s\" não é suportada"
+
+#: ../client/pk-console.c:1452
+msgid "Command failed"
+msgstr "O comando falhou"
+
+#: ../client/pk-console.c:1456
+msgid "You don't have the necessary privileges for this operation"
+msgstr "Você não tem os privilégios necessários para esta operação"
+
+#: ../client/pk-monitor.c:113
+msgid "PackageKit Monitor"
+msgstr "Monitor do PackageKit"
+
+#: ../client/pk-import-desktop.c:283
+#: ../client/pk-import-specspo.c:169
+#, c-format
+msgid "Could not open database: %s"
+msgstr "Não foi possível abrir o banco de dados: %s"
+
+#: ../client/pk-import-desktop.c:284
+#: ../client/pk-import-specspo.c:170
+msgid "You probably need to run this program as the root user"
+msgstr "Você provavelmente precisa executar este programa como usuário root"
+
+#: ../src/pk-main.c:83
+msgid "Startup failed due to security policies on this machine."
+msgstr "A inicialização falhou devido à políticas de segurança desta máquina"
+
+#: ../src/pk-main.c:84
+msgid "This can happen for two reasons:"
+msgstr "Isso pode acontecer por duas razões:"
+
+#: ../src/pk-main.c:85
+msgid "The correct user is not launching the executable (usually root)"
+msgstr "O usuário correto não está iniciando o executável (normalmente o root)"
+
+#: ../src/pk-main.c:86
+msgid "The org.freedesktop.PackageKit.conf file is not installed in the system /etc/dbus-1/system.d directory"
+msgstr "O arquivo org.freedesktop.PackageKit.conf não está instalado no diretório  /etc/dbus-1/system.d do sistema"
+
+#: ../src/pk-main.c:185
+msgid "Packaging backend to use, e.g. dummy"
+msgstr "O backend de empacotamento a ser utilizado, p. ex.: dummy"
+
+#: ../src/pk-main.c:187
+msgid "Daemonize and detach from the terminal"
+msgstr "Tornar um daemon e separar do terminal"
+
+#: ../src/pk-main.c:191
+msgid "Disable the idle timer"
+msgstr "Desabilitar o tempo de ociosidade"
+
+#: ../src/pk-main.c:193
+msgid "Show version and exit"
+msgstr "Mostrar a versão e sair"
+
+#: ../src/pk-main.c:195
+msgid "Exit after a small delay"
+msgstr "Sair após um pequeno atraso"
+
+#: ../src/pk-main.c:197
+msgid "Exit after the engine has loaded"
+msgstr "Sair após o carregamento do mecanismo"
+
+#: ../src/pk-main.c:207
+msgid "PackageKit service"
+msgstr "Serviço do PackageKit"
+
+#: ../src/pk-main.c:233
+msgid "Cannot connect to the system bus"
+msgstr "Não foi possível conectar ao barramento do sistema"
+
+#: ../src/pk-main.c:273
+#, c-format
+msgid "Error trying to start: %s\n"
+msgstr "Erro ao tentar iniciar: %s\n"
+
commit 4475c50775d3a2fdf483b6b4597ece7476c275cc
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Apr 24 01:02:27 2008 +0100

    correct a typo in the self check code

diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index 35201cd..526c0ee 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -1118,7 +1118,7 @@ libst_enum (LibSelfTest *test)
 	/************************************************************/
 	libst_title (test, "find role_value");
 	role_value = pk_enum_find_value (enum_role, "search-file");
-	if (PK_ROLE_ENUM_SEARCH_FILE) {
+	if (role_value == PK_ROLE_ENUM_SEARCH_FILE) {
 		libst_success (test, NULL);
 	} else {
 		libst_failed (test, NULL);
@@ -1136,7 +1136,7 @@ libst_enum (LibSelfTest *test)
 	/************************************************************/
 	libst_title (test, "find value");
 	role_value = pk_role_enum_from_text ("search-file");
-	if (PK_ROLE_ENUM_SEARCH_FILE) {
+	if (role_value == PK_ROLE_ENUM_SEARCH_FILE) {
 		libst_success (test, NULL);
 	} else {
 		libst_failed (test, NULL);
commit 4845ebfedab7dd598f8910fda9aacdb0d613aa57
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Apr 24 00:09:28 2008 +0100

    remove some dead code

diff --git a/src/pk-thread-list.c b/src/pk-thread-list.c
index 5796b80..e53a512 100644
--- a/src/pk-thread-list.c
+++ b/src/pk-thread-list.c
@@ -135,30 +135,6 @@ pk_thread_list_wait (PkThreadList *tlist)
 }
 
 /**
- * pk_thread_list_number_running:
- **/
-guint
-pk_thread_list_number_running (PkThreadList *tlist)
-{
-	guint i;
-	guint length;
-	PkThreadListItem *item;
-	guint number = 0;
-
-	g_return_val_if_fail (PK_IS_THREAD_LIST (tlist), FALSE);
-
-	/* find all the running threads */
-	length = tlist->priv->thread_list->len;
-	for (i=0; i<length; i++) {
-		item = (PkThreadListItem *) g_ptr_array_index (tlist->priv->thread_list, i);
-		if (item->running) {
-			number++;
-		}
-	}
-	return number;
-}
-
-/**
  * pk_thread_list_class_init:
  * @klass: The PkThreadListClass
  **/
@@ -209,7 +185,6 @@ pk_thread_free_data (PkThreadList *tlist)
 static void
 pk_thread_list_finalize (GObject *object)
 {
-	guint running;
 	PkThreadList *tlist;
 
 	g_return_if_fail (object != NULL);
@@ -221,12 +196,6 @@ pk_thread_list_finalize (GObject *object)
 	/* wait for existing threads to finish */
 	pk_thread_list_wait (tlist);
 
-	/* be paranoid */
-	running = pk_thread_list_number_running (tlist);
-	if (running > 0) {
-		pk_warning ("running=%i", running);
-	}
-
 	pk_thread_free_data (tlist);
 	g_ptr_array_free (tlist->priv->thread_list, TRUE);
 	G_OBJECT_CLASS (pk_thread_list_parent_class)->finalize (object);
commit 27122323797c3a6417c59d65ba65b67718a4aad5
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Apr 23 21:46:24 2008 +0100

    fix pk_va_list_to_argv so that it splits lines with spaces as seporate entries.
    This fixes the recent regression where the yum backend could not select updates because
    the packageid's were being treated as a single entry in the GStrv.

diff --git a/libpackagekit/pk-common.c b/libpackagekit/pk-common.c
index 547f731..7d7aa4c 100644
--- a/libpackagekit/pk-common.c
+++ b/libpackagekit/pk-common.c
@@ -670,11 +670,34 @@ pk_ptr_array_to_argv (GPtrArray *array)
 }
 
 /**
+ * pk_va_list_to_argv_string:
+ **/
+static void
+pk_va_list_to_argv_string (GPtrArray *ptr_array, const gchar *string)
+{
+	gchar **array;
+	guint length;
+	guint i;
+
+	/* split the string up by spaces */
+	array = g_strsplit (string, " ", 0);
+
+	/* for each */
+	length = g_strv_length (array);
+	for (i=0; i<length; i++) {
+		g_ptr_array_add (ptr_array, g_strdup (array[i]));
+	}
+	g_strfreev (array);
+}
+
+/**
  * pk_va_list_to_argv:
  * @string_first: the first string
  * @args: any subsequant string's
  *
- * Form a composite string array of string
+ * Form a composite string array of string, with a special twist;
+ * if the entry contains a space, then it is split as seporate parts
+ * of the array.
  *
  * Return value: the string array, or %NULL if invalid
  **/
@@ -691,11 +714,16 @@ pk_va_list_to_argv (const gchar *string_first, va_list *args)
 
 	/* find how many elements we have in a temp array */
 	ptr_array = g_ptr_array_new ();
-	g_ptr_array_add (ptr_array, g_strdup (string_first));
+	pk_va_list_to_argv_string (ptr_array, string_first);
+
+	/* process all the va_list entries */
 	for (i=0;; i++) {
 		value_temp = va_arg (*args, gchar *);
+		/* end of array */
 		if (value_temp == NULL) break;
-		g_ptr_array_add (ptr_array, g_strdup (value_temp));
+
+		/* split the string up by spaces */
+		pk_va_list_to_argv_string (ptr_array, value_temp);
 	}
 	pk_debug ("number of strings=%i", i+1);
 
@@ -776,6 +804,20 @@ pk_strbuild_test (const gchar *first_element, ...)
 	return text;
 }
 
+static gchar **
+pk_va_list_to_argv_test (const gchar *first_element, ...)
+{
+	va_list args;
+	gchar **array;
+
+	/* get the argument list */
+	va_start (args, first_element);
+	array = pk_va_list_to_argv (first_element, &args);
+	va_end (args);
+
+	return array;
+}
+
 void
 libst_common (LibSelfTest *test)
 {
@@ -869,6 +911,58 @@ libst_common (LibSelfTest *test)
 	g_free (text_safe);
 
 	/************************************************************
+	 ****************      splitting va_list       **************
+	 ************************************************************/
+	libst_title (test, "va_list_to_argv single");
+	array = pk_va_list_to_argv_test ("richard", NULL);
+	if (pk_strequal (array[0], "richard") &&
+	    array[1] == NULL) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "incorrect array '%s'", array[0]);
+	}
+	g_strfreev (array);
+
+	/************************************************************/
+	libst_title (test, "va_list_to_argv triple");
+	array = pk_va_list_to_argv_test ("richard", "phillip", "hughes", NULL);
+	if (pk_strequal (array[0], "richard") &&
+	    pk_strequal (array[1], "phillip") &&
+	    pk_strequal (array[2], "hughes") &&
+	    array[3] == NULL) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "incorrect array '%s','%s','%s'", array[0], array[1], array[2]);
+	}
+	g_strfreev (array);
+
+	/************************************************************/
+	libst_title (test, "va_list_to_argv triple with space first");
+	array = pk_va_list_to_argv_test ("richard phillip", "hughes", NULL);
+	if (pk_strequal (array[0], "richard") &&
+	    pk_strequal (array[1], "phillip") &&
+	    pk_strequal (array[2], "hughes") &&
+	    array[3] == NULL) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "incorrect array '%s','%s','%s'", array[0], array[1], array[2]);
+	}
+	g_strfreev (array);
+
+	/************************************************************/
+	libst_title (test, "va_list_to_argv triple with space second");
+	array = pk_va_list_to_argv_test ("richard", "phillip hughes", NULL);
+	if (pk_strequal (array[0], "richard") &&
+	    pk_strequal (array[1], "phillip") &&
+	    pk_strequal (array[2], "hughes") &&
+	    array[3] == NULL) {
+		libst_success (test, NULL);
+	} else {
+		libst_failed (test, "incorrect array '%s','%s','%s'", array[0], array[1], array[2]);
+	}
+	g_strfreev (array);
+
+	/************************************************************
 	 ****************        validate text         **************
 	 ************************************************************/
 	libst_title (test, "validate correct char 1");
commit b7d8b64fc5faabd0d6f63a0ba2de503d493421a4
Merge: e8a8cee... d6120e0...
Author: Stefan Haas <shaas at suse.de>
Date:   Tue Apr 22 12:53:25 2008 +0200

    Merge branch 'master' of git+ssh://shaas@git.packagekit.org/srv/git/PackageKit

commit e8a8cee95687fab2e65b674dbd76ae312132af3f
Merge: 9643229... ba43b9d...
Author: Stefan Haas <shaas at suse.de>
Date:   Tue Apr 22 10:42:51 2008 +0200

    Merge branch 'master' of git+ssh://shaas@git.packagekit.org/srv/git/PackageKit

commit 9643229eeb3fe6a68bb20d0d82c6937767070c24
Author: Stefan Haas <shaas at suse.de>
Date:   Mon Apr 21 17:42:15 2008 +0200

    fixed BNC# 381698 and maked it even faster

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 42598ba..821fd91 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -1222,21 +1222,18 @@ backend_remove_package_thread (PkBackendThread *thread, gpointer data)
 	try
 	{
 		// Iterate over the resolvables and mark the ones we want to remove
-		//zypp->start ();
-		for (zypp::ResPoolProxy::const_iterator it = zypp->poolProxy().byKindBegin <zypp::Package>();
-				it != zypp->poolProxy().byKindEnd <zypp::Package>(); it++) {
-			zypp::ui::Selectable::Ptr selectable = *it;
-			if (strcmp (selectable->name().c_str(), pi->name) == 0) {
-				if (selectable->status () == zypp::ui::S_KeepInstalled) {
-					selectable->setStatus (zypp::ui::S_Del);
-					break;
-				}
+		zypp::ResPool pool = zypp::ResPool::instance ();
+		for (zypp::ResPool::byIdent_iterator it = pool.byIdentBegin (zypp::ResKind::package, pi->name);
+				it != pool.byIdentEnd (zypp::ResKind::package, pi->name); it++) {
+			if ((*it)->isSystem ()) {
+				it->status ().setToBeUninstalled (zypp::ResStatus::USER);
+				break;
 			}
 		}
-
+		
 		pk_backend_set_percentage (backend, 40);
 
-                if (!zypp_perform_execution (backend, REMOVE, FALSE)){
+                if (!zypp_perform_execution (backend, REMOVE, TRUE)){
                         pk_backend_error_code (backend, PK_ERROR_ENUM_TRANSACTION_ERROR, "Couldn't remove the package");
                         g_free (d->package_id);
                         g_free (d);
@@ -1247,7 +1244,6 @@ backend_remove_package_thread (PkBackendThread *thread, gpointer data)
 
 		pk_backend_set_percentage (backend, 100);
 
-		// TODO: Check result for success
 	} catch (const zypp::repo::RepoNotFoundException &ex) {
 		// TODO: make sure this dumps out the right sring.
 		pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, ex.asUserString().c_str() );
commit a63fb4ae79f80ff1d7750fddcc438094a243381c
Author: Stefan Haas <shaas at suse.de>
Date:   Mon Apr 21 15:51:20 2008 +0200

    added install-file to zypp-backend

diff --git a/docs/html/pk-faq.html b/docs/html/pk-faq.html
index 857f0c3..80acf3f 100644
--- a/docs/html/pk-faq.html
+++ b/docs/html/pk-faq.html
@@ -208,7 +208,7 @@
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- smart -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum -->
 <td><img src="img/status-good.png" alt="[yes]"/></td><!-- yum2 -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- zypp -->
+<td><img src="img/status-good.png" alt="[yes]"/></td><!-- zypp -->
 </tr>
 <tr>
 <td><b>RemovePackage</b></td>
commit e37666dfdd3285e99d9640a8fdf407446a378592
Author: Stefan Haas <shaas at suse.de>
Date:   Mon Apr 21 15:49:36 2008 +0200

    added install-file to the backend

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 0575263..42598ba 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -49,6 +49,7 @@
 #include <zypp/target/rpm/RpmHeader.h>
 #include <zypp/target/rpm/RpmException.h>
 #include <zypp/base/LogControl.h>
+#include <zypp/TmpPath.h>
 
 #include <zypp/sat/Solvable.h>
 
@@ -97,6 +98,10 @@ typedef struct {
 } ThreadData;
 
 typedef struct {
+	gchar *full_path;
+} InstFileData;
+
+typedef struct {
         gchar *package_id;
         PkFilterEnum filters;
         gint type;
@@ -704,6 +709,86 @@ backend_get_updates_thread (PkBackendThread *thread, gpointer data)
 	return TRUE;
 }
 
+static gboolean
+backend_refresh_cache_thread (PkBackendThread *thread, gpointer data)
+{
+	PkBackend *backend;
+	RefreshData *d = (RefreshData*) data;
+
+	backend = pk_backend_thread_get_backend (thread);
+	gboolean force = d->force;
+	g_free (d);
+
+	pk_backend_set_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
+	pk_backend_set_percentage (backend, 0);
+
+	zypp::RepoManager manager;
+	std::list <zypp::RepoInfo> repos;
+	try
+	{
+		repos = manager.knownRepositories();
+	}
+	catch ( const zypp::Exception &e)
+	{
+		// FIXME: make sure this dumps out the right sring.
+		pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, e.asUserString().c_str() );
+		pk_backend_finished (backend);
+		return FALSE;
+	}
+
+	int i = 1;
+	int num_of_repos = repos.size ();
+	int percentage_increment = 100 / num_of_repos;
+
+	for (std::list <zypp::RepoInfo>::iterator it = repos.begin(); it != repos.end(); it++, i++) {
+		zypp::RepoInfo repo (*it);
+
+		// skip disabled repos
+		if (repo.enabled () == false)
+			continue;
+
+		// skip changeable meda (DVDs and CDs).  Without doing this,
+		// the disc would be required to be physically present.
+		if (zypp_is_changeable_media (*repo.baseUrlsBegin ()) == true)
+			continue;
+
+		try {
+                        // Refreshing metadata
+			manager.refreshMetadata (repo, force == TRUE ?
+				zypp::RepoManager::RefreshForced :
+				zypp::RepoManager::RefreshIfNeeded);
+		} catch (const zypp::Exception &ex) {
+			pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString ().c_str ());
+			pk_backend_finished (backend);
+			return FALSE;
+		}
+
+		try {
+                        // Building cache
+                        manager.buildCache (repo, force == TRUE ?
+				zypp::RepoManager::BuildForced :
+				zypp::RepoManager::BuildIfNeeded);
+		//} catch (const zypp::repo::RepoNoUrlException &ex) {
+		//} catch (const zypp::repo::RepoNoAliasException &ex) {
+		//} catch (const zypp::repo::RepoUnknownTypeException &ex) {
+		//} catch (const zypp::repo::RepoException &ex) {
+		} catch (const zypp::Exception &ex) {
+			// TODO: Handle the exceptions in manager.refreshMetadata
+			pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString().c_str() );
+			pk_backend_finished (backend);
+			return FALSE;
+		}
+
+		// Update the percentage completed
+		pk_backend_set_percentage (backend,
+					      i == num_of_repos ?
+						100 :
+						i * percentage_increment);
+	}
+
+	pk_backend_finished (backend);
+	return TRUE;
+}
 
 /**
  * backend_get_updates
@@ -716,6 +801,137 @@ backend_get_updates (PkBackend *backend, PkFilterEnum filters)
 }
 
 static gboolean
+backend_install_file_thread (PkBackendThread *thread, gpointer data)
+{
+	PkBackend *backend;
+	InstFileData *d = (InstFileData*) data;
+
+	backend = pk_backend_thread_get_backend (thread);
+
+	// check if file is really a rpm
+
+	zypp::Pathname rpmPath (d->full_path);
+	zypp::target::rpm::RpmHeader::constPtr rpmHeader = zypp::target::rpm::RpmHeader::readPackage (rpmPath, zypp::target::rpm::RpmHeader::NOSIGNATURE);
+
+	if (rpmHeader == NULL) {
+		pk_backend_error_code (backend, PK_ERROR_ENUM_LOCAL_INSTALL_FAILED, "%s is no valid rpm-File", d->full_path);
+		g_free (d->full_path);
+		g_free (d);
+		pk_backend_finished (backend);
+		return FALSE;
+	}
+
+	// create a temporary directory
+	zypp::filesystem::TmpDir tmpDir;
+	if (tmpDir == NULL) {
+		pk_backend_error_code (backend, PK_ERROR_ENUM_LOCAL_INSTALL_FAILED, "Could not create a temporary directory");
+		g_free (d->full_path);
+		g_free (d);
+		pk_backend_finished (backend);
+		return FALSE;
+	}
+
+	// copy the rpm into tmpdir
+
+	std::string tempDest = tmpDir.path ().asString () + "/" + rpmHeader->tag_name () + ".rpm";
+	if (zypp::filesystem::copy (d->full_path, tempDest) != 0) {
+		pk_backend_error_code (backend, PK_ERROR_ENUM_LOCAL_INSTALL_FAILED, "Could not copy the rpm-file into the temp-dir");
+		g_free (d->full_path);
+		g_free (d);
+		pk_backend_finished (backend);
+		return FALSE;
+	}
+
+	// create a plaindir-repo
+	zypp::RepoInfo tmpRepo;
+
+	try {
+
+		tmpRepo.setType(zypp::repo::RepoType::RPMPLAINDIR);
+		std::string url = "dir://" + tmpDir.path ().asString ();
+		tmpRepo.addBaseUrl(zypp::Url::parseUrl(url));
+		tmpRepo.setEnabled (true);
+		tmpRepo.setAutorefresh (true);
+		tmpRepo.setAlias ("PK_TMP_DIR");
+		tmpRepo.setName ("PK_TMP_DIR");
+
+		// add Repo to pool
+
+		zypp::RepoManager manager;
+		manager.addRepository (tmpRepo);
+
+		manager.refreshMetadata (tmpRepo);
+		manager.buildCache (tmpRepo);
+
+	} catch (const zypp::url::UrlException &ex) {
+		pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString ().c_str ());
+		g_free (d->full_path);
+		g_free (d);
+		pk_backend_finished (backend);
+		return FALSE;
+	} catch (const zypp::Exception &ex) {
+		pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString().c_str() );
+		g_free (d->full_path);
+		g_free (d);
+		pk_backend_finished (backend);
+		return FALSE;
+	}
+
+	// look for the package and try to install it
+	std::vector<zypp::sat::Solvable> *solvables = new std::vector<zypp::sat::Solvable>;	
+	solvables = zypp_get_packages_by_name (rpmHeader->tag_name ().c_str (), zypp::ResKind::package, FALSE);
+	zypp::PoolItem *item = NULL;
+	gboolean found = FALSE;
+
+	for (std::vector<zypp::sat::Solvable>::iterator it = solvables->begin (); it != solvables->end (); it ++) {
+	       if (it->repository ().name () == "PK_TMP_DIR") {
+		       item = new zypp::PoolItem(*it);
+		       found = TRUE;
+		       break;
+	       }
+	}
+
+	if (!found) {
+		pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Could not find the rpm-Package in Pool");
+	}else{
+		zypp::ResStatus status = item->status ().setToBeInstalled (zypp::ResStatus::USER);
+		if (!zypp_perform_execution (backend, INSTALL, FALSE)) {
+			pk_backend_error_code (backend, PK_ERROR_ENUM_LOCAL_INSTALL_FAILED, "Could not install the rpm-file.");
+                }
+
+                item->statusReset ();
+	}
+
+	//remove tmp-dir and the tmp-repo
+	try {
+		zypp::RepoManager manager;
+		manager.removeRepository (tmpRepo);
+	} catch (const zypp::repo::RepoNotFoundException &ex) {
+		pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, ex.asUserString().c_str() );
+	}
+
+	g_free (d->full_path);
+	g_free (d);
+	delete (solvables);
+	delete (item);
+	pk_backend_finished (backend);
+	return TRUE;
+}
+
+/**
+  * backend_install_file
+  */
+static void
+backend_install_file (PkBackend *backend, const gchar *full_path)
+{
+	g_return_if_fail (backend != NULL);
+	InstFileData *data = g_new0(InstFileData, 1);
+	data->full_path = g_strdup (full_path);
+
+	pk_backend_thread_create (thread, backend_install_file_thread, data);
+}
+
+static gboolean
 backend_get_update_detail_thread (PkBackendThread *thread, gpointer data)
 {
 	PkBackend *backend;
@@ -972,87 +1188,6 @@ backend_install_package (PkBackend *backend, const gchar *package_id)
 }
 
 static gboolean
-backend_refresh_cache_thread (PkBackendThread *thread, gpointer data)
-{
-	PkBackend *backend;
-	RefreshData *d = (RefreshData*) data;
-
-	backend = pk_backend_thread_get_backend (thread);
-	gboolean force = d->force;
-	g_free (d);
-
-	pk_backend_set_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
-	pk_backend_set_percentage (backend, 0);
-
-	zypp::RepoManager manager;
-	std::list <zypp::RepoInfo> repos;
-	try
-	{
-		repos = manager.knownRepositories();
-	}
-	catch ( const zypp::Exception &e)
-	{
-		// FIXME: make sure this dumps out the right sring.
-		pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, e.asUserString().c_str() );
-		pk_backend_finished (backend);
-		return FALSE;
-	}
-
-	int i = 1;
-	int num_of_repos = repos.size ();
-	int percentage_increment = 100 / num_of_repos;
-
-	for (std::list <zypp::RepoInfo>::iterator it = repos.begin(); it != repos.end(); it++, i++) {
-		zypp::RepoInfo repo (*it);
-
-		// skip disabled repos
-		if (repo.enabled () == false)
-			continue;
-
-		// skip changeable meda (DVDs and CDs).  Without doing this,
-		// the disc would be required to be physically present.
-		if (zypp_is_changeable_media (*repo.baseUrlsBegin ()) == true)
-			continue;
-
-		try {
-                        // Refreshing metadata
-			manager.refreshMetadata (repo, force == TRUE ?
-				zypp::RepoManager::RefreshForced :
-				zypp::RepoManager::RefreshIfNeeded);
-		} catch (const zypp::Exception &ex) {
-			pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString ().c_str ());
-			pk_backend_finished (backend);
-			return FALSE;
-		}
-
-		try {
-                        // Building cache
-                        manager.buildCache (repo, force == TRUE ?
-				zypp::RepoManager::BuildForced :
-				zypp::RepoManager::BuildIfNeeded);
-		//} catch (const zypp::repo::RepoNoUrlException &ex) {
-		//} catch (const zypp::repo::RepoNoAliasException &ex) {
-		//} catch (const zypp::repo::RepoUnknownTypeException &ex) {
-		//} catch (const zypp::repo::RepoException &ex) {
-		} catch (const zypp::Exception &ex) {
-			// TODO: Handle the exceptions in manager.refreshMetadata
-			pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString().c_str() );
-			pk_backend_finished (backend);
-			return FALSE;
-		}
-
-		// Update the percentage completed
-		pk_backend_set_percentage (backend,
-					      i == num_of_repos ?
-						100 :
-						i * percentage_increment);
-	}
-
-	pk_backend_finished (backend);
-	return TRUE;
-}
-
-static gboolean
 backend_remove_package_thread (PkBackendThread *thread, gpointer data)
 {
 	PkBackend *backend;
@@ -1816,7 +1951,7 @@ extern "C" PK_BACKEND_OPTIONS (
 	backend_get_requires,			/* get_requires */
 	backend_get_update_detail,		/* get_update_detail */
 	backend_get_updates,			/* get_updates */
-	NULL,					/* install_file */
+	backend_install_file,			/* install_file */
 	backend_install_package,		/* install_package */
 	NULL,					/* install_signature */
 	backend_refresh_cache,			/* refresh_cache */


More information about the PackageKit-commit mailing list