Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Jul 2013 06:20:17 GMT
From:      mattbw@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r254537 - in soc2013/mattbw/backend: . actions bin bin/catregex bin/getcat query
Message-ID:  <201307100620.r6A6KHfj026674@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mattbw
Date: Wed Jul 10 06:20:16 2013
New Revision: 254537
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254537

Log:
  gratituous amounts of group-matcher changing in prep for SearchGroups; group mappings are for now specified in a text file and awked into a C array

Added:
  soc2013/mattbw/backend/bin/Makefile
  soc2013/mattbw/backend/bin/catregex/
  soc2013/mattbw/backend/bin/catregex/.indent.pro
  soc2013/mattbw/backend/bin/catregex/Makefile
  soc2013/mattbw/backend/bin/catregex/pkgpk-catregex.1
  soc2013/mattbw/backend/bin/catregex/pkgpk-catregex.c
  soc2013/mattbw/backend/bin/getcat/.indent.pro
  soc2013/mattbw/backend/group.c
     - copied, changed from r254454, soc2013/mattbw/backend/groups.c
  soc2013/mattbw/backend/group.h
     - copied, changed from r254454, soc2013/mattbw/backend/groups.h
  soc2013/mattbw/backend/group_map.awk   (contents, props changed)
  soc2013/mattbw/backend/group_map.h
  soc2013/mattbw/backend/groups
  soc2013/mattbw/backend/query/.indent.pro
Deleted:
  soc2013/mattbw/backend/groups.c
  soc2013/mattbw/backend/groups.h
Modified:
  soc2013/mattbw/backend/Makefile
  soc2013/mattbw/backend/actions/get_details.c
  soc2013/mattbw/backend/actions/get_files.c
  soc2013/mattbw/backend/actions/resolve.c
  soc2013/mattbw/backend/bin/getcat/Makefile
  soc2013/mattbw/backend/bin/getcat/pkgpk-getcat.c
  soc2013/mattbw/backend/pk-backend-pkgng.c

Modified: soc2013/mattbw/backend/Makefile
==============================================================================
--- soc2013/mattbw/backend/Makefile	Wed Jul 10 04:59:10 2013	(r254536)
+++ soc2013/mattbw/backend/Makefile	Wed Jul 10 06:20:16 2013	(r254537)
@@ -5,7 +5,8 @@
 SRCS=		pk-backend-pkgng.c
 SRCS+= 						\
 		db.c				\
-		groups.c			\
+		group_map.c			\
+		group.c				\
 		licenses.c			\
 		pkgutils.c			\
 		utils.c
@@ -42,10 +43,7 @@
 LDFLAGS+=	`pkg-config --libs ${PKGS}`
 CSTD?=		c11
 
-# NOTE: remove this before finishing
-CFLAGS+=	--pedantic -Weverything -Werror -Wno-system-headers	\
-		-isystem /usr/local/include/glib-2.0			\
-		-isystem /usr/local/include				\
-		-isystem /usr/include
+group_map.c: groups group_map.awk
+	sort groups | awk -f group_map.awk > group_map.c
 
 .include <bsd.lib.mk>

Modified: soc2013/mattbw/backend/actions/get_details.c
==============================================================================
--- soc2013/mattbw/backend/actions/get_details.c	Wed Jul 10 04:59:10 2013	(r254536)
+++ soc2013/mattbw/backend/actions/get_details.c	Wed Jul 10 06:20:16 2013	(r254537)
@@ -24,7 +24,7 @@
 #include "../pk-backend.h"
 #include "pkg.h"
 
-#include "../groups.h"		/* group_from_origin */
+#include "../group.h"		/* group_from_origin */
 #include "../licenses.h"	/* license_from_pkg */
 #include "../query.h"		/* query_... */
 #include "../actions.h"		/* get_details_thread prototype */

Modified: soc2013/mattbw/backend/actions/get_files.c
==============================================================================
--- soc2013/mattbw/backend/actions/get_files.c	Wed Jul 10 04:59:10 2013	(r254536)
+++ soc2013/mattbw/backend/actions/get_files.c	Wed Jul 10 06:20:16 2013	(r254537)
@@ -25,8 +25,6 @@
 #include "../pk-backend.h"
 #include "pkg.h"
 
-#include "../groups.h"		/* group_from_origin */
-#include "../licenses.h"	/* license_from_pkg */
 #include "../query.h"		/* query_... */
 
 #include "../actions.h"		/* get_files_thread prototype */

Modified: soc2013/mattbw/backend/actions/resolve.c
==============================================================================
--- soc2013/mattbw/backend/actions/resolve.c	Wed Jul 10 04:59:10 2013	(r254536)
+++ soc2013/mattbw/backend/actions/resolve.c	Wed Jul 10 06:20:16 2013	(r254537)
@@ -42,8 +42,8 @@
 
 	s.type = QUERY_BACKEND_MIXED;
 	t.type = QUERY_EMIT;
-	t.data.emit.load_flags = PKG_LOAD_BASIC;
-	t.data.emit.f = emit;
+	t.emit.load_flags = PKG_LOAD_BASIC;
+	t.emit.f = emit;
 
 	success = query_do(backend, &s, &t);
 

Added: soc2013/mattbw/backend/bin/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2013/mattbw/backend/bin/Makefile	Wed Jul 10 06:20:16 2013	(r254537)
@@ -0,0 +1,7 @@
+# $FreeBSD$
+
+SUBDIR=			\
+	getcat		\
+	catregex
+
+.include <bsd.subdir.mk>

Added: soc2013/mattbw/backend/bin/catregex/.indent.pro
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2013/mattbw/backend/bin/catregex/.indent.pro	Wed Jul 10 06:20:16 2013	(r254537)
@@ -0,0 +1,9 @@
+-TPkBitfield
+-TPkGroupEnum
+-TPkBackend
+-Tgchar
+-Tgboolean
+-Tbool
+-sob
+-nlp
+-ci4

Added: soc2013/mattbw/backend/bin/catregex/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2013/mattbw/backend/bin/catregex/Makefile	Wed Jul 10 06:20:16 2013	(r254537)
@@ -0,0 +1,16 @@
+# $FreeBSD$
+
+PROG=		pkgpk-catregex
+SRCS=		pkgpk-catregex.c ../../group.c ../../group_map.c
+
+DESTDIR?=	/usr/local
+BINDIR?=	/bin
+MANDIR?=	/man/man
+
+CFLAGS+=	`pkgconf --cflags pkg glib-2.0`
+CFLAGS+=        -I/usr/local/include/PackageKit -I/usr/local/include/PackageKit/backend
+CFLAGS+=        -I../../
+CFLAGS+=        -DPK_COMPILATION
+LDFLAGS+=	`pkgconf --libs pkg glib-2.0` -lpackagekit-glib2
+
+.include <bsd.prog.mk>

Added: soc2013/mattbw/backend/bin/catregex/pkgpk-catregex.1
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2013/mattbw/backend/bin/catregex/pkgpk-catregex.1	Wed Jul 10 06:20:16 2013	(r254537)
@@ -0,0 +1,49 @@
+.\" Copyright (C) 2013 Matt Windsor <mattbw@FreeBSD.org>
+.\"
+.\" Licensed under the GNU General Public License Version 2
+.\"
+.\" This program is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+.\" GNU General Public License for more files.
+.\"
+.\" You should have received a copy of the GNU General Public License
+.\" along with this program; if not, write to the Free Software
+.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+.\"-----------------------------------------------------------------------------
+.Dd July 10, 2013
+.Dt pkgpk-catregex 1
+.Os
+.\"-----------------------------------------------------------------------------
+.Sh NAME
+.Nm pkgpk-catregex
+.Nd create origin matching regular expression for given PackageKit groups 
+.\"-----------------------------------------------------------------------------
+.Sh SYNOPSIS
+.Nm
+.Ar group ...
+.\"-----------------------------------------------------------------------------
+.Sh DESCRIPTION
+.Nm
+is a debug utility for investigating the mapping between ports directories and 
+PackageKit groups as part of the PackageKit pkgng backend.
+It returns an Extended Regular Expression that will match any port origins that
+are inside any of the categories specified on the command line.
+.Pp
+Each
+.Ar group
+is expected to be the local name of a PackageKit group; the groups available
+can be investigated by utilities such as pkcon.
+.Pp
+The result is always written on one line to standard output.
+.\"-----------------------------------------------------------------------------
+.Sh AUTHORS
+.An Matt Windsor Aq mattbw@FreeBSD.org
+.\"-----------------------------------------------------------------------------
+.Sh BUGS
+Probably.

Added: soc2013/mattbw/backend/bin/catregex/pkgpk-catregex.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2013/mattbw/backend/bin/catregex/pkgpk-catregex.c	Wed Jul 10 06:20:16 2013	(r254537)
@@ -0,0 +1,76 @@
+/*-
+ * Copyright (C) 2013 Matt Windsor <mattbw@FreeBSD.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+/*
+ * Given the names of PackageKit groups, this programme prints out an
+ * Extended Regular Expression matching all dir/name style package origins in
+ * those groups.
+ */
+#define	USAGE "usage: %s group ...\n"
+
+#include <stdlib.h>		/* calloc, free */
+#include <stdio.h>		/* printf, fprintf */
+#include "pk-backend.h"		/* PkGroupEnum, pk_group_enum_to_string */
+#include "group.h"		/* group_list_to_origin_regex */
+
+int
+main(int argc, char **argv)
+{
+	int i;
+	int ret;
+	unsigned int groupc;
+	char *regex;
+	PkGroupEnum *groupv;
+
+	ret = 0;
+
+	/* Did we get any groups? */
+	if (argc == 1) {
+		ret = 1;
+		fprintf(stderr, USAGE, argv[0]);
+		goto cleanup;
+	}
+
+	groupc = (unsigned int)(argc - 1);
+	groupv = calloc(groupc, sizeof(PkGroupEnum));
+	if (groupv == NULL) {
+		ret = 1;
+		fprintf(stderr, "out of mem!\n");
+		goto cleanup;
+	}
+
+	/* Find the group enums from their names */
+	for (i = 1; i < argc; i++)
+		groupv[i - 1] = pk_group_enum_from_string(argv[i]);
+
+	/* Now build the regex */
+	regex = group_list_to_origin_regex(groupc, groupv);
+	if (regex == NULL) {
+		ret = 1;
+		fprintf (stderr, "passed null pointer to regex!\n");
+		goto cleanup;
+	}
+
+	printf("%s\n", regex);
+	free(regex);
+
+cleanup:
+	return ret;
+}

Added: soc2013/mattbw/backend/bin/getcat/.indent.pro
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2013/mattbw/backend/bin/getcat/.indent.pro	Wed Jul 10 06:20:16 2013	(r254537)
@@ -0,0 +1,9 @@
+-TPkBitfield
+-TPkGroupEnum
+-TPkBackend
+-Tgchar
+-Tgboolean
+-Tbool
+-sob
+-nlp
+-ci4

Modified: soc2013/mattbw/backend/bin/getcat/Makefile
==============================================================================
--- soc2013/mattbw/backend/bin/getcat/Makefile	Wed Jul 10 04:59:10 2013	(r254536)
+++ soc2013/mattbw/backend/bin/getcat/Makefile	Wed Jul 10 06:20:16 2013	(r254537)
@@ -1,7 +1,7 @@
 # $FreeBSD$
 
 PROG=		pkgpk-getcat
-SRCS=		pkgpk-getcat.c ../../groups.c
+SRCS=		pkgpk-getcat.c ../../group.c ../../group_map.c
 
 DESTDIR?=	/usr/local
 BINDIR?=	/bin

Modified: soc2013/mattbw/backend/bin/getcat/pkgpk-getcat.c
==============================================================================
--- soc2013/mattbw/backend/bin/getcat/pkgpk-getcat.c	Wed Jul 10 04:59:10 2013	(r254536)
+++ soc2013/mattbw/backend/bin/getcat/pkgpk-getcat.c	Wed Jul 10 06:20:16 2013	(r254537)
@@ -1,5 +1,4 @@
 /*-
- *
  * Copyright (C) 2013 Matt Windsor <mattbw@FreeBSD.org>
  *
  * Licensed under the GNU General Public License Version 2
@@ -20,18 +19,17 @@
  */
 
 /*
- * Gets the group name of a pkgng origin, eg 'ports-mgmt/pkg' -> 'admin-tools'.
+ * Gets the group name of a pkgng origin, eg 'ports-mgmt/pkg' ->
+ * 'admin-tools'.
  */
-const char *USAGE = "usage: %s origin\n";
+#define	USAGE		"usage: %s origin\n"
 
 #include <stdio.h>
 
-#include <glib.h>
 #include "pkg.h"
 #include "pk-backend.h"
 
-#include "groups.h"
-
+#include "group.h"
 
 int
 main(int argc, char **argv)
@@ -42,10 +40,9 @@
 	if (argc != 2) {
 		ret = 1;
 		fprintf(stderr, USAGE, argv[0]);
-	} else {
+	} else
 		printf("%s\n",
-		       pk_group_enum_to_string(group_from_origin(argv[1])));
-	}
+		    pk_group_enum_to_string(group_from_origin(argv[1])));
 
 	return ret;
 }

Copied and modified: soc2013/mattbw/backend/group.c (from r254454, soc2013/mattbw/backend/groups.c)
==============================================================================
--- soc2013/mattbw/backend/groups.c	Tue Jul  9 07:29:25 2013	(r254454, copy source)
+++ soc2013/mattbw/backend/group.c	Wed Jul 10 06:20:16 2013	(r254537)
@@ -19,119 +19,38 @@
  */
 
 #include <assert.h>		/* assert */
+#include <stdbool.h>		/* bool, true, false */
 #include <stdlib.h>		/* NULL */
 #include <string.h>		/* strchr, strdup */
+#include <sys/sbuf.h>		/* struct sbuf, sbuf_... */
 
 #include "glib.h"		/* g_strcmp0 */
-#include "pk-backend.h"		/* PkGroupEnum, PK_* */
+#include "pk-backend.h"		/* PkGroupEnum, PK_... */
 
-#include "groups.h"		/* prototypes */
+#include "group_map.h"		/* group_mappings */
+#include "group.h"		/* group_... */
 
 static const char ORIGIN_SEPARATOR = '/';
 
-struct group_mapping {
-	const char     *key;
-	PkGroupEnum	group;
-};
-
-/*
- * Mappings between ports directories (as in the first part of PKG_ORIGIN)
- * and PackageKit enums.
- * 
- * Some of these mappings are a bit iffy, peer review would be greatly
- * appreciated.
- * 
- * These should ALWAYS be in ASCIIbetical order of ports directories.  This is
- * in case anything relies on this property when searching this list (for
- * example binary searching)
- */
-static struct group_mapping group_mappings[] = {
-	{"accessibility", PK_GROUP_ENUM_ACCESSIBILITY},
-	{"arabic", PK_GROUP_ENUM_LOCALIZATION},
-	{"archivers", PK_GROUP_ENUM_ACCESSORIES},
-	{"astro", PK_GROUP_ENUM_SCIENCE},
-	{"audio", PK_GROUP_ENUM_MULTIMEDIA},
-	{"benchmarks", PK_GROUP_ENUM_PROGRAMMING},
-	{"biology", PK_GROUP_ENUM_SCIENCE},
-	{"cad", PK_GROUP_ENUM_SCIENCE},	/* dubious */
-	{"chinese", PK_GROUP_ENUM_LOCALIZATION},
-	{"comms", PK_GROUP_ENUM_COMMUNICATION},
-	{"converters", PK_GROUP_ENUM_ACCESSORIES},	/* dubious */
-	{"databases", PK_GROUP_ENUM_SERVERS},	/* dubious */
-	{"deskutils", PK_GROUP_ENUM_ACCESSORIES},
-	{"devel", PK_GROUP_ENUM_PROGRAMMING},
-	{"distfiles", PK_GROUP_ENUM_OTHER},	/* ?? */
-	{"dns", PK_GROUP_ENUM_NETWORK},
-	{"editors", PK_GROUP_ENUM_OFFICE},	/* dubious */
-	{"emulators", PK_GROUP_ENUM_OTHER},	/* ?? */
-	{"finance", PK_GROUP_ENUM_OFFICE},	/* dubious */
-	{"french", PK_GROUP_ENUM_LOCALIZATION},
-	{"ftp", PK_GROUP_ENUM_NETWORK},
-	{"games", PK_GROUP_ENUM_GAMES},
-	{"german", PK_GROUP_ENUM_LOCALIZATION},
-	{"graphics", PK_GROUP_ENUM_GRAPHICS},
-	{"hebrew", PK_GROUP_ENUM_LOCALIZATION},
-	{"hungarian", PK_GROUP_ENUM_LOCALIZATION},
-	{"irc", PK_GROUP_ENUM_COMMUNICATION},
-	{"japanese", PK_GROUP_ENUM_LOCALIZATION},
-	{"java", PK_GROUP_ENUM_PROGRAMMING},
-	{"korean", PK_GROUP_ENUM_LOCALIZATION},
-	{"lang", PK_GROUP_ENUM_PROGRAMMING},
-	{"mail", PK_GROUP_ENUM_COMMUNICATION},
-	{"math", PK_GROUP_ENUM_SCIENCE},
-	{"misc", PK_GROUP_ENUM_OTHER},
-	{"multimedia", PK_GROUP_ENUM_MULTIMEDIA},
-	{"net", PK_GROUP_ENUM_NETWORK},
-	{"net-im", PK_GROUP_ENUM_COMMUNICATION},
-	{"net-mgmt", PK_GROUP_ENUM_NETWORK},
-	{"net-p2p", PK_GROUP_ENUM_NETWORK},	/* possibly COMMUNICATION */
-	{"news", PK_GROUP_ENUM_COMMUNICATION},	/* ?? */
-	{"packages", PK_GROUP_ENUM_OTHER},	/* ?? */
-	{"palm", PK_GROUP_ENUM_OTHER},
-	{"polish", PK_GROUP_ENUM_LOCALIZATION},
-	{"ports-mgmt", PK_GROUP_ENUM_ADMIN_TOOLS},	/* dubious? */
-	{"portuguese", PK_GROUP_ENUM_LOCALIZATION},
-	{"print", PK_GROUP_ENUM_OFFICE},	/* dubious */
-	{"russian", PK_GROUP_ENUM_LOCALIZATION},
-	{"science", PK_GROUP_ENUM_SCIENCE},
-	{"security", PK_GROUP_ENUM_SECURITY},
-	{"shells", PK_GROUP_ENUM_ACCESSORIES},	/* dubious */
-	{"sysutils", PK_GROUP_ENUM_ADMIN_TOOLS},
-	{"textproc", PK_GROUP_ENUM_PUBLISHING},	/* dubious */
-	{"ukrainian", PK_GROUP_ENUM_LOCALIZATION},
-	{"vietnamese", PK_GROUP_ENUM_LOCALIZATION},
-	{"www", PK_GROUP_ENUM_NETWORK},	/* could be COMMUNICATION?  prob. not */
-	/* Some of the X directories could be better classified possibly */
-	{"x11", PK_GROUP_ENUM_DESKTOP_OTHER},
-	{"x11-clocks", PK_GROUP_ENUM_DESKTOP_OTHER},
-	{"x11-drivers", PK_GROUP_ENUM_DESKTOP_OTHER},
-	{"x11-fm", PK_GROUP_ENUM_DESKTOP_OTHER},
-	{"x11-fonts", PK_GROUP_ENUM_FONTS},
-	{"x11-servers", PK_GROUP_ENUM_DESKTOP_OTHER},
-	{"x11-themes", PK_GROUP_ENUM_DESKTOP_OTHER},
-	{"x11-toolkits", PK_GROUP_ENUM_DESKTOP_OTHER},
-	{"x11-wm", PK_GROUP_ENUM_DESKTOP_OTHER},
-	/* Default (for new/unspecified ports directories) */
-	{"", PK_GROUP_ENUM_UNKNOWN}
-};
-
 static PkGroupEnum group_from_port_dir(const char *port_dir);
 
 /* Reports the PackageKit groups available on this backend as a bitfield. */
 PkBitfield
-available_groups(void)
+group_bitfield(void)
 {
-	int		i;
+	const struct group_mapping *map;
 	PkBitfield	bits;
 
 	bits = 0;
-	for (i = 0; group_mappings[i].key[0] != '\0'; i++)
-		pk_bitfield_add(bits, group_mappings[i].group);
+	for (map = group_mappings; map->key[0] != '\0'; map++)
+		pk_bitfield_add(bits, map->group);
 
 	return bits;
 }
 
-/* Maps from package origins to PackageKit groups. */
+/*
+ * Maps from package origins to PackageKit groups.
+ */
 PkGroupEnum
 group_from_origin(const char *origin)
 {
@@ -159,11 +78,65 @@
 	return group;
 }
 
-/* Maps from port/origin directories to PackageKit groups. */
+/*
+ * Constructs an Extended Regular Expression matching any package origins
+ * that lie within the given group.  The regex should be freed using free(3).
+ */
+char           *
+group_list_to_origin_regex(unsigned int groupc, PkGroupEnum *groupv)
+{
+	char           *regex;
+	struct sbuf    *sb;
+
+	regex = NULL;
+	sb = sbuf_new_auto();
+	if (sb != NULL) {
+		bool		at_least_one;
+		unsigned int	i;
+		const struct group_mapping *map;
+
+		at_least_one = false;
+
+		/* (group1|group2|group3|...)/.* */
+		(void)sbuf_putc(sb, '(');
+
+		/* Quadratic time, any improvements welcomed */
+		for (map = group_mappings; map->key[0] != '\0'; map++) {
+			for (i = 0; i < groupc; i++) {
+				if (map->group == groupv[i]) {
+					if (at_least_one)
+						(void)sbuf_putc(sb, '|');
+
+					(void)sbuf_cat(sb, map->key);
+
+					at_least_one = true;
+				}
+			}
+		}
+
+		(void)sbuf_cat(sb, ")/.*");
+
+		/*
+		 * Invalidate the regex if there were no matching groups.
+		 */
+		if (at_least_one == false)
+			(void)sbuf_clear(sb);
+
+		if (sbuf_finish(sb) == 0)
+			regex = strdup(sbuf_data(sb));
+
+		sbuf_delete(sb);
+	}
+	return regex;
+}
+
+/*
+ * Maps from port/origin directories to PackageKit groups.
+ */
 static PkGroupEnum
 group_from_port_dir(const char *port_dir)
 {
-	struct group_mapping *result;
+	const struct group_mapping *result;
 
 	assert(port_dir != NULL);
 

Copied and modified: soc2013/mattbw/backend/group.h (from r254454, soc2013/mattbw/backend/groups.h)
==============================================================================
--- soc2013/mattbw/backend/groups.h	Tue Jul  9 07:29:25 2013	(r254454, copy source)
+++ soc2013/mattbw/backend/group.h	Wed Jul 10 06:20:16 2013	(r254537)
@@ -23,7 +23,8 @@
 
 #include "pk-backend.h"
 
-PkBitfield	available_groups(void);
+PkBitfield	group_bitfield(void);
 PkGroupEnum	group_from_origin(const char *origin);
+char *		group_list_to_origin_regex(unsigned int groupc, PkGroupEnum *groupv);
 
 #endif				/* _PKGNG_BACKEND_GROUPS_H_ */

Added: soc2013/mattbw/backend/group_map.awk
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2013/mattbw/backend/group_map.awk	Wed Jul 10 06:20:16 2013	(r254537)
@@ -0,0 +1,17 @@
+#! /usr/bin/awk -f 
+BEGIN {
+	print "/* Auto-generated, do not edit directly.  Edit 'groups' instead */"
+	print "#include \"group_map.h\""
+	print "const struct group_mapping group_mappings[] = {"
+}
+{
+	sub("#.*$", "", $0);
+	if (length($0) > 0) {
+		print "\t{\"" $1 "\", " $2 "},";
+		MAP[tolower($1)] = toupper($2);
+	}
+}
+END {
+	print "\t{\"\", PK_GROUP_ENUM_UNKNOWN}";
+	print "};";
+}

Added: soc2013/mattbw/backend/group_map.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2013/mattbw/backend/group_map.h	Wed Jul 10 06:20:16 2013	(r254537)
@@ -0,0 +1,33 @@
+/*-
+ * Copyright (C) 2013 Matt Windsor <mattbw@FreeBSD.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef _PKGNG_BACKEND_GROUP_MAP_H_
+#define _PKGNG_BACKEND_GROUP_MAP_H_
+
+#include "pk-backend.h"
+
+struct group_mapping {
+	const char     *key;
+	PkGroupEnum	group;
+};
+
+extern const struct group_mapping group_mappings[];
+
+#endif				/* _PKGNG_BACKEND_GROUP_MAP_H_ */

Added: soc2013/mattbw/backend/groups
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2013/mattbw/backend/groups	Wed Jul 10 06:20:16 2013	(r254537)
@@ -0,0 +1,75 @@
+# $FreeBSD$
+# Mapping from ports directories to PackageKit group enums.
+# (See /usr/local/include/PackageKit/packagekit-glib2/pk-enum.h)
+#
+# This file does not have to be in alphabetical order, but it would help.
+# It will be processed into group-map.c during a make.
+#
+# '#' starts a line comment as usual; any form of whitespace can separate the
+# port directory from its group enum.
+
+# Port dir	Group enum			Comments
+accessibility	PK_GROUP_ENUM_ACCESSIBILITY
+arabic		PK_GROUP_ENUM_LOCALIZATION
+archivers	PK_GROUP_ENUM_ACCESSORIES
+astro		PK_GROUP_ENUM_SCIENCE
+audio		PK_GROUP_ENUM_MULTIMEDIA
+benchmarks	PK_GROUP_ENUM_PROGRAMMING
+biology		PK_GROUP_ENUM_SCIENCE
+cad		PK_GROUP_ENUM_SCIENCE		# dubious
+chinese		PK_GROUP_ENUM_LOCALIZATION
+comms		PK_GROUP_ENUM_COMMUNICATION
+converters	PK_GROUP_ENUM_ACCESSORIES	# dubious
+databases	PK_GROUP_ENUM_SERVERS		# dubious 
+deskutils	PK_GROUP_ENUM_ACCESSORIES
+devel		PK_GROUP_ENUM_PROGRAMMING
+distfiles	PK_GROUP_ENUM_OTHER		# ??
+dns		PK_GROUP_ENUM_NETWORK
+editors		PK_GROUP_ENUM_OFFICE		# dubious 
+emulators	PK_GROUP_ENUM_OTHER		# ?? 
+finance		PK_GROUP_ENUM_OFFICE		# dubious 
+french		PK_GROUP_ENUM_LOCALIZATION
+ftp		PK_GROUP_ENUM_NETWORK
+games		PK_GROUP_ENUM_GAMES
+german		PK_GROUP_ENUM_LOCALIZATION
+graphics	PK_GROUP_ENUM_GRAPHICS
+hebrew		PK_GROUP_ENUM_LOCALIZATION
+hungarian	PK_GROUP_ENUM_LOCALIZATION
+irc		PK_GROUP_ENUM_COMMUNICATION
+japanese	PK_GROUP_ENUM_LOCALIZATION
+java		PK_GROUP_ENUM_PROGRAMMING
+korean		PK_GROUP_ENUM_LOCALIZATION
+lang		PK_GROUP_ENUM_PROGRAMMING
+mail		PK_GROUP_ENUM_COMMUNICATION
+math		PK_GROUP_ENUM_SCIENCE
+misc		PK_GROUP_ENUM_OTHER
+multimedia	PK_GROUP_ENUM_MULTIMEDIA
+net		PK_GROUP_ENUM_NETWORK
+net-im		PK_GROUP_ENUM_COMMUNICATION
+net-mgmt	PK_GROUP_ENUM_NETWORK
+net-p2p		PK_GROUP_ENUM_NETWORK		# possibly COMMUNICATION
+news		PK_GROUP_ENUM_COMMUNICATION	# ??
+packages	PK_GROUP_ENUM_OTHER		# ??
+palm		PK_GROUP_ENUM_OTHER
+polish		PK_GROUP_ENUM_LOCALIZATION
+ports-mgmt	PK_GROUP_ENUM_ADMIN_TOOLS	# dubious?
+portuguese	PK_GROUP_ENUM_LOCALIZATION
+print		PK_GROUP_ENUM_OFFICE		# dubious
+russian		PK_GROUP_ENUM_LOCALIZATION
+science		PK_GROUP_ENUM_SCIENCE
+security	PK_GROUP_ENUM_SECURITY
+shells		PK_GROUP_ENUM_ACCESSORIES	# dubious
+sysutils	PK_GROUP_ENUM_ADMIN_TOOLS
+textproc	PK_GROUP_ENUM_PUBLISHING	# dubious
+ukrainian	PK_GROUP_ENUM_LOCALIZATION
+vietnamese	PK_GROUP_ENUM_LOCALIZATION
+www		PK_GROUP_ENUM_NETWORK		# could be COMMUNICATION
+x11		PK_GROUP_ENUM_DESKTOP_OTHER
+x11-clocks	PK_GROUP_ENUM_DESKTOP_OTHER
+x11-drivers	PK_GROUP_ENUM_DESKTOP_OTHER
+x11-fm		PK_GROUP_ENUM_DESKTOP_OTHER
+x11-fonts	PK_GROUP_ENUM_FONTS
+x11-servers	PK_GROUP_ENUM_DESKTOP_OTHER
+x11-themes	PK_GROUP_ENUM_DESKTOP_OTHER
+x11-toolkits	PK_GROUP_ENUM_DESKTOP_OTHER
+x11-wm		PK_GROUP_ENUM_DESKTOP_OTHER

Modified: soc2013/mattbw/backend/pk-backend-pkgng.c
==============================================================================
--- soc2013/mattbw/backend/pk-backend-pkgng.c	Wed Jul 10 04:59:10 2013	(r254536)
+++ soc2013/mattbw/backend/pk-backend-pkgng.c	Wed Jul 10 06:20:16 2013	(r254537)
@@ -28,12 +28,9 @@
 #include "pkg.h"
 
 #include "utils.h"		/* INTENTIONALLY_IGNORE */
-#include "groups.h"		/* available_groups */
+#include "group.h"		/* group_bitfield */
 #include "actions.h"		/* Actions threads */
 
-/**
- * pk_backend_initialize:
- */
 void
 pk_backend_initialize(PkBackend *backend)
 {
@@ -49,9 +46,6 @@
 		    "could not initialise pkg");
 }
 
-/**
- * pk_backend_destroy:
- */
 void
 pk_backend_destroy(PkBackend *backend)
 {
@@ -124,7 +118,7 @@
 {
 
 	INTENTIONALLY_IGNORE(backend);
-	return available_groups();
+	return group_bitfield();
 }
 
 gchar          *

Added: soc2013/mattbw/backend/query/.indent.pro
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ soc2013/mattbw/backend/query/.indent.pro	Wed Jul 10 06:20:16 2013	(r254537)
@@ -0,0 +1,7 @@
+-TPkBackend
+-Tgchar
+-Tgboolean
+-Tbool
+-sob
+-nlp
+-ci4



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201307100620.r6A6KHfj026674>