From owner-svn-soc-all@FreeBSD.ORG Sun Jul 7 23:59:19 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 8C7199DC for ; Sun, 7 Jul 2013 23:59:19 +0000 (UTC) (envelope-from mattbw@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) by mx1.freebsd.org (Postfix) with ESMTP id 7D45C1C36 for ; Sun, 7 Jul 2013 23:59:19 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r67NxJMp011792 for ; Sun, 7 Jul 2013 23:59:19 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r67NxJOv011788 for svn-soc-all@FreeBSD.org; Sun, 7 Jul 2013 23:59:19 GMT (envelope-from mattbw@FreeBSD.org) Date: Sun, 7 Jul 2013 23:59:19 GMT Message-Id: <201307072359.r67NxJOv011788@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to mattbw@FreeBSD.org using -f From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r254387 - in soc2013/mattbw/backend/bin: . getcat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Jul 2013 23:59:19 -0000 Author: mattbw Date: Sun Jul 7 23:59:19 2013 New Revision: 254387 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254387 Log: move getcat out of tests, make the test Warning: Object directory not changed from original /usr/home/mattbw/GSoC/backend it if necessary Added: soc2013/mattbw/backend/bin/ soc2013/mattbw/backend/bin/getcat/ soc2013/mattbw/backend/bin/getcat/Makefile soc2013/mattbw/backend/bin/getcat/pkgpk-getcat.1 soc2013/mattbw/backend/bin/getcat/pkgpk-getcat.c Added: soc2013/mattbw/backend/bin/getcat/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/bin/getcat/Makefile Sun Jul 7 23:59:19 2013 (r254387) @@ -0,0 +1,16 @@ +# $FreeBSD$ + +PROG= pkgpk-getcat +SRCS= pkgpk-getcat.c ../../groups.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 Added: soc2013/mattbw/backend/bin/getcat/pkgpk-getcat.1 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/bin/getcat/pkgpk-getcat.1 Sun Jul 7 23:59:19 2013 (r254387) @@ -0,0 +1,53 @@ +.\" Copyright (C) 2013 Matt Windsor +.\" +.\" 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 7, 2013 +.Dt pkgpk-getcat 1 +.Os +.\"----------------------------------------------------------------------------- +.Sh NAME +.Nm pkgpk-getcat +.Nd return PackageKit category for a pkgng port origin +.\"----------------------------------------------------------------------------- +.Sh SYNOPSIS +.Nm +.Ar origin +.\"----------------------------------------------------------------------------- +.Sh DESCRIPTION +.Nm +is a debug utility for investigating the mapping between ports directories and +PackageKit categories as part of the PackageKit pkgng backend. +It returns the descriptive name of the category that matches the directory of +the port origin given on the command line. +.Pp +.Ar origin +is expected to be a package origin, that is a port category directory followed +by a slash and then a port name. For the purposes of +.Nm +the actual port/package name may be empty, but the slash must always exist. +.Pp +The result is always written on one line to standard output. +.\"----------------------------------------------------------------------------- +.Sh AUTHORS +.An Matt Windsor Aq mattbw@FreeBSD.org +.\"----------------------------------------------------------------------------- +.Sh BUGS +If the backend cannot find a match for a port directory, it will return +.Ql unknown +instead. This includes the case in which a directory has been supplied without +a trailing slash. Added: soc2013/mattbw/backend/bin/getcat/pkgpk-getcat.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ soc2013/mattbw/backend/bin/getcat/pkgpk-getcat.c Sun Jul 7 23:59:19 2013 (r254387) @@ -0,0 +1,51 @@ +/*- + * + * Copyright (C) 2013 Matt Windsor + * + * 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. + */ + +/* + * Gets the group name of a pkgng origin, eg 'ports-mgmt/pkg' -> 'admin-tools'. + */ +const char *USAGE = "usage: %s origin\n"; + +#include + +#include +#include "pkg.h" +#include "pk-backend.h" + +#include "groups.h" + + +int +main(int argc, char **argv) +{ + int ret; + + ret = 0; + if (argc != 2) { + ret = 1; + fprintf(stderr, USAGE, argv[0]); + } else { + printf("%s\n", + pk_group_enum_to_string(group_from_origin(argv[1]))); + } + + return ret; +}