socsvn commit: r254592 - in soc2013/mattbw/backend: . actions
mattbw at FreeBSD.org
mattbw at FreeBSD.org
Thu Jul 11 03:59:03 UTC 2013
Author: mattbw
Date: Thu Jul 11 03:59:02 2013
New Revision: 254592
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254592
Log:
attempt to use first category instead of port directory for package groups
Modified:
soc2013/mattbw/backend/actions/get_details.c
soc2013/mattbw/backend/group.c
soc2013/mattbw/backend/group.h
Modified: soc2013/mattbw/backend/actions/get_details.c
==============================================================================
--- soc2013/mattbw/backend/actions/get_details.c Thu Jul 11 02:10:23 2013 (r254591)
+++ soc2013/mattbw/backend/actions/get_details.c Thu Jul 11 03:59:02 2013 (r254592)
@@ -55,7 +55,6 @@
{
bool success;
const char *description;
- const char *origin;
const char *www;
int64_t flatsize;
guint flatsize_u;
@@ -63,12 +62,11 @@
query_set_percentage(q, 0);
/* Information not already part of the PackageID */
- description = origin = www = NULL;
+ description = www = NULL;
flatsize = 0;
pkg_get(pkg,
PKG_DESC, &description,
PKG_FLATSIZE, &flatsize,
- PKG_ORIGIN, &origin,
PKG_WWW, &www);
flatsize_u = (guint)CLAMP(flatsize, 0, G_MAXUINT);
@@ -76,7 +74,7 @@
success = pk_backend_details(query_backend(q),
id,
license_name_from_pkg(pkg),
- group_from_origin(origin),
+ group_of_pkg(pkg),
description,
www,
flatsize_u) == TRUE;
Modified: soc2013/mattbw/backend/group.c
==============================================================================
--- soc2013/mattbw/backend/group.c Thu Jul 11 02:10:23 2013 (r254591)
+++ soc2013/mattbw/backend/group.c Thu Jul 11 03:59:02 2013 (r254592)
@@ -21,11 +21,11 @@
#include <assert.h> /* assert */
#include <stdbool.h> /* bool, true, false */
#include <stdlib.h> /* NULL */
-#include <string.h> /* strchr, strdup */
+#include <string.h> /* strchr, strcmp, strdup */
#include <sys/sbuf.h> /* struct sbuf, sbuf_... */
-#include "glib.h" /* g_strcmp0 */
#include "pk-backend.h" /* PkGroupEnum, PK_... */
+#include "pkg.h" /* pkg_... */
#include "group_map.h" /* group_mappings */
#include "group.h" /* group_... */
@@ -66,7 +66,7 @@
/*
* Is this a valid origin (did it have a separator)? If not, we want
- * the default group. If so, then the number of chars between the
+ * the default group. If so, then the number of chars between the
* origin start and the separator mark the port directory name we
* want to use.
*/
@@ -79,6 +79,42 @@
}
/*
+ * Maps from packages to PackageKit groups. PKG_LOAD_CATEGORIES must have been
+ * set whilst loading the package for this to work properly.
+ */
+PkGroupEnum
+group_of_pkg(struct pkg *pkg)
+{
+ PkGroupEnum group;
+ struct pkg_category *category;
+
+ assert(pkg != NULL);
+
+ /* Default failure state group. */
+ group = PK_GROUP_ENUM_UNKNOWN;
+
+ /* Take the first category only. */
+ category = NULL;
+ if (pkg_categories(pkg, &category) == EPKG_OK) {
+ assert(category != NULL);
+
+ group = group_from_port_dir(pkg_category_name(category));
+ } else {
+ const char *origin;
+
+ /* Fallback to checking the origin. */
+ origin = NULL;
+ if (pkg_get(pkg, PKG_ORIGIN, &origin) == EPKG_OK) {
+ assert(origin != NULL);
+
+ group = group_from_origin(origin);
+ }
+ }
+
+ return group;
+}
+
+/*
* Constructs an Extended Regular Expression matching any package origins
* that lie within the given group. The regex should be freed using free(3).
*/
Modified: soc2013/mattbw/backend/group.h
==============================================================================
--- soc2013/mattbw/backend/group.h Thu Jul 11 02:10:23 2013 (r254591)
+++ soc2013/mattbw/backend/group.h Thu Jul 11 03:59:02 2013 (r254592)
@@ -22,9 +22,11 @@
#define _PKGNG_BACKEND_GROUPS_H_
#include "pk-backend.h"
+#include "pkg.h"
PkBitfield group_bitfield(void);
PkGroupEnum group_from_origin(const char *origin);
+PkGroupEnum group_of_pkg(struct pkg *pkg);
char * group_list_to_origin_regex(unsigned int groupc, PkGroupEnum *groupv);
#endif /* _PKGNG_BACKEND_GROUPS_H_ */
More information about the svn-soc-all
mailing list