[PackageKit-commit] packagekit: Branch 'master' - 3 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Fri Apr 18 04:40:47 PDT 2008
backends/zypp/pk-backend-zypp.cpp | 8 ++--
backends/zypp/zypp-utils.cpp | 74 ++++++++++++++++++++------------------
backends/zypp/zypp-utils.h | 4 +-
3 files changed, 46 insertions(+), 40 deletions(-)
New commits:
commit a05fb4625a6722a7ee39b8aea06546f96161f29b
Merge: be643bd... abe08e7...
Author: Richard Hughes <richard at hughsie.com>
Date: Fri Apr 18 12:40:03 2008 +0100
Merge branch 'master' of git+ssh://hughsie@git.packagekit.org/srv/git/PackageKit
commit abe08e70ab22ae9855d247bf0bdab74c6184a69d
Author: Stefan Haas <shaas at suse.de>
Date: Fri Apr 18 13:10:38 2008 +0200
changed conversion from rpm-groups to pk-groups
diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 747decc..6cfc552 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -585,7 +585,7 @@ backend_get_description_thread (PkBackendThread *thread, gpointer data)
}
try {
- PkGroupEnum group = get_enum_group (package);
+ PkGroupEnum group = get_enum_group (zypp_get_group (package));
if (package.isSystem ()){
zypp::target::rpm::RpmHeader::constPtr rpmHeader = zypp_get_rpmHeader (package.name (), package.edition ());
@@ -1344,13 +1344,13 @@ backend_search_group_thread (PkBackendThread *thread, gpointer data)
pk_backend_set_percentage (backend, 30);
std::vector<zypp::sat::Solvable> *v = new std::vector<zypp::sat::Solvable> ();
+ PkGroupEnum pkGroup = pk_group_enum_from_text (d->pkGroup);
zypp::sat::LookupAttr look (zypp::sat::SolvAttr::group);
for (zypp::sat::LookupAttr::iterator it = look.begin (); it != look.end (); it++) {
- std::string group = it.asString ();
- std::transform (group.begin (), group.end (), group.begin (), tolower);
- if (g_strrstr (group.c_str (), d->pkGroup))
+ PkGroupEnum rpmGroup = get_enum_group (it.asString ());
+ if (pkGroup == rpmGroup)
v->push_back (it.inSolvable ());
}
diff --git a/backends/zypp/zypp-utils.cpp b/backends/zypp/zypp-utils.cpp
index f7fbd4e..baef946 100644
--- a/backends/zypp/zypp-utils.cpp
+++ b/backends/zypp/zypp-utils.cpp
@@ -178,7 +178,7 @@ zypp_get_rpmHeader (std::string name, zypp::Edition edition)
}
-gchar*
+std::string
zypp_get_group (zypp::sat::Solvable item)
{
std::string group;
@@ -192,63 +192,61 @@ zypp_get_group (zypp::sat::Solvable item)
group = item.lookupStrAttribute (zypp::sat::SolvAttr::group);
}
std::transform(group.begin(), group.end(), group.begin(), tolower);
- return (gchar*)group.c_str ();
+ return group;
}
PkGroupEnum
-get_enum_group (zypp::sat::Solvable item)
+get_enum_group (std::string group)
{
- std::string group (zypp_get_group (item));
-
- PkGroupEnum pkGroup = PK_GROUP_ENUM_UNKNOWN;
// TODO Look for a faster and nice way to do this conversion
+ std::transform(group.begin(), group.end(), group.begin(), tolower);
if (group.find ("amusements") != std::string::npos) {
- pkGroup = PK_GROUP_ENUM_GAMES;
+ return PK_GROUP_ENUM_GAMES;
} else if (group.find ("development") != std::string::npos) {
- pkGroup = PK_GROUP_ENUM_PROGRAMMING;
+ return PK_GROUP_ENUM_PROGRAMMING;
} else if (group.find ("hardware") != std::string::npos) {
- pkGroup = PK_GROUP_ENUM_SYSTEM;
+ return PK_GROUP_ENUM_SYSTEM;
} else if (group.find ("archiving") != std::string::npos
|| group.find("clustering") != std::string::npos
|| group.find("system/monitoring") != std::string::npos
|| group.find("databases") != std::string::npos
|| group.find("system/management") != std::string::npos) {
- pkGroup = PK_GROUP_ENUM_ADMIN_TOOLS;
+ return PK_GROUP_ENUM_ADMIN_TOOLS;
} else if (group.find ("graphics") != std::string::npos) {
- pkGroup = PK_GROUP_ENUM_GRAPHICS;
- } else if (group.find ("mulitmedia") != std::string::npos) {
- pkGroup = PK_GROUP_ENUM_MULTIMEDIA;
+ return PK_GROUP_ENUM_GRAPHICS;
+ } else if (group.find ("multimedia") != std::string::npos) {
+ return PK_GROUP_ENUM_MULTIMEDIA;
} else if (group.find ("network") != std::string::npos) {
- pkGroup = PK_GROUP_ENUM_NETWORK;
+ return PK_GROUP_ENUM_NETWORK;
} else if (group.find ("office") != std::string::npos
|| group.find("text") != std::string::npos
|| group.find("editors") != std::string::npos) {
- pkGroup = PK_GROUP_ENUM_OFFICE;
+ return PK_GROUP_ENUM_OFFICE;
} else if (group.find ("publishing") != std::string::npos) {
- pkGroup = PK_GROUP_ENUM_PUBLISHING;
+ return PK_GROUP_ENUM_PUBLISHING;
} else if (group.find ("security") != std::string::npos) {
- pkGroup = PK_GROUP_ENUM_SECURITY;
+ return PK_GROUP_ENUM_SECURITY;
} else if (group.find ("telephony") != std::string::npos) {
- pkGroup = PK_GROUP_ENUM_COMMUNICATION;
+ return PK_GROUP_ENUM_COMMUNICATION;
} else if (group.find ("gnome") != std::string::npos) {
- pkGroup = PK_GROUP_ENUM_DESKTOP_GNOME;
+ return PK_GROUP_ENUM_DESKTOP_GNOME;
} else if (group.find ("kde") != std::string::npos) {
- pkGroup = PK_GROUP_ENUM_DESKTOP_KDE;
+ return PK_GROUP_ENUM_DESKTOP_KDE;
} else if (group.find ("xfce") != std::string::npos) {
- pkGroup = PK_GROUP_ENUM_DESKTOP_XFCE;
+ return PK_GROUP_ENUM_DESKTOP_XFCE;
} else if (group.find ("gui/other") != std::string::npos) {
- pkGroup = PK_GROUP_ENUM_DESKTOP_OTHER;
+ return PK_GROUP_ENUM_DESKTOP_OTHER;
} else if (group.find ("localization") != std::string::npos) {
- pkGroup = PK_GROUP_ENUM_LOCALIZATION;
+ return PK_GROUP_ENUM_LOCALIZATION;
} else if (group.find ("system") != std::string::npos) {
- pkGroup = PK_GROUP_ENUM_SYSTEM;
+ return PK_GROUP_ENUM_SYSTEM;
} else if (group.find ("scientific") != std::string::npos) {
- pkGroup = PK_GROUP_ENUM_EDUCATION;
+ return PK_GROUP_ENUM_EDUCATION;
}
- return pkGroup;
+ return PK_GROUP_ENUM_UNKNOWN;
}
std::vector<zypp::sat::Solvable> *
diff --git a/backends/zypp/zypp-utils.h b/backends/zypp/zypp-utils.h
index c2b710d..9643e51 100644
--- a/backends/zypp/zypp-utils.h
+++ b/backends/zypp/zypp-utils.h
@@ -56,12 +56,12 @@ zypp::target::rpm::RpmHeader::constPtr zypp_get_rpmHeader (std::string name, zyp
/**
* Return the group of the given PoolItem.
*/
-gchar* zypp_get_group (zypp::sat::Solvable item);
+std::string zypp_get_group (zypp::sat::Solvable item);
/**
* Return the PkEnumGroup of the given PoolItem.
*/
-PkGroupEnum get_enum_group (zypp::sat::Solvable item);
+PkGroupEnum get_enum_group (std::string group);
/**
* Returns a list of packages that match the specified package_name.
commit 4da401fac8f714af695a346afad99c90d9ffb520
Author: Stefan Haas <shaas at suse.de>
Date: Fri Apr 18 11:13:39 2008 +0200
changed license-handling
diff --git a/backends/zypp/zypp-utils.cpp b/backends/zypp/zypp-utils.cpp
index 7e0916e..f7fbd4e 100644
--- a/backends/zypp/zypp-utils.cpp
+++ b/backends/zypp/zypp-utils.cpp
@@ -545,14 +545,22 @@ zypp_perform_execution (PkBackend *backend, PerformType type, gboolean force)
zypp::ResPool pool = zypp::ResPool::instance ();
for (zypp::ResPool::const_iterator it = pool.begin (); it != pool.end (); it++) {
if (it->status ().isToBeInstalled () && !(it->satSolvable ().lookupStrAttribute (zypp::sat::SolvAttr::eula).empty ())) {
- gchar *package_id = zypp_build_package_id_from_resolvable (it->satSolvable ());
- pk_backend_eula_required (backend,
- "", //eula_id
- package_id,
- (*it)->vendor ().c_str (),
- it->satSolvable ().lookupStrAttribute (zypp::sat::SolvAttr::eula).c_str ());
- pk_backend_error_code (backend, PK_ERROR_ENUM_NO_LICENSE_AGREEMENT, "You've to agree/decline a license");
- g_free (package_id);
+ gchar *eula_id = g_strdup ((*it)->name ().c_str ());
+ gboolean has_eula = pk_backend_is_eula_valid (backend, eula_id);
+ if (!has_eula) {
+ gchar *package_id = zypp_build_package_id_from_resolvable (it->satSolvable ());
+ pk_backend_eula_required (backend,
+ eula_id,
+ package_id,
+ (*it)->vendor ().c_str (),
+ it->satSolvable ().lookupStrAttribute (zypp::sat::SolvAttr::eula).c_str ());
+ pk_backend_error_code (backend, PK_ERROR_ENUM_NO_LICENSE_AGREEMENT, "You've to agree/decline a license");
+ g_free (package_id);
+ g_free (eula_id);
+ pk_backend_finished (backend);
+ return FALSE;
+ }
+ g_free (eula_id);
}
}
More information about the PackageKit-commit
mailing list