From owner-svn-soc-all@FreeBSD.ORG Thu Jun 27 00:35:59 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id C9A55455 for ; Thu, 27 Jun 2013 00:35:59 +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 AC2A01939 for ; Thu, 27 Jun 2013 00:35:59 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r5R0ZxLv010920 for ; Thu, 27 Jun 2013 00:35:59 GMT (envelope-from mattbw@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r5R0ZxhT010914 for svn-soc-all@FreeBSD.org; Thu, 27 Jun 2013 00:35:59 GMT (envelope-from mattbw@FreeBSD.org) Date: Thu, 27 Jun 2013 00:35:59 GMT Message-Id: <201306270035.r5R0ZxhT010914@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: r253582 - soc2013/mattbw/backend 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: Thu, 27 Jun 2013 00:35:59 -0000 Author: mattbw Date: Thu Jun 27 00:35:59 2013 New Revision: 253582 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=253582 Log: fixed up the repository name matching for pkg1.1, via query test Modified: soc2013/mattbw/backend/iterate.c Modified: soc2013/mattbw/backend/iterate.c ============================================================================== --- soc2013/mattbw/backend/iterate.c Thu Jun 27 00:09:03 2013 (r253581) +++ soc2013/mattbw/backend/iterate.c Thu Jun 27 00:35:59 2013 (r253582) @@ -29,6 +29,8 @@ #include "hash_traverse.h" /* HASH_FOR */ #include "utils.h" /* string_match */ +static const char *get_repo_of(struct pkg *pkg); +static const char *get_repo_of_remote(struct pkg *pkg); static gboolean try_id_match(struct pkg *pkg, const gchar *name, const gchar *version, const gchar *arch, const gchar *data, gchar **match_id); @@ -61,18 +63,18 @@ if ((fetch_flags & PKG_LOAD_FILES) && g_strcmp0(data, "installed") != 0) { pk_backend_error_code(backend, - PK_ERROR_ENUM_CANNOT_GET_FILELIST, + PK_ERROR_ENUM_CANNOT_GET_FILELIST, "Cannot get files for non-installed package." - ); + ); err = EPKG_FATAL; } else { for (HASH_FOR(err, pkgdb_it_next, iterator, &pkg, fetch_flags)) { if (try_id_match(pkg, - name, - version, - arch, - data, - &match_id) == TRUE) { + name, + version, + arch, + data, + &match_id) == TRUE) { found = TRUE; iterate_f(pkg, match_id, backend); } @@ -85,6 +87,61 @@ return found; } +/* Gets the PackageKit repository name for the package. */ +static const char * +get_repo_of(struct pkg *pkg) +{ + const char *repo; + + switch (pkg_type(pkg)) { + case PKG_FILE: + repo = "local"; + break; + case PKG_INSTALLED: + repo = "installed"; + break; + case PKG_REMOTE: + repo = get_repo_of_remote(pkg); + break; + default: + repo = "unknown"; + break; + } + + return repo; +} + +/* + * Gets the PackageKit repository name for the (remote) package. + * + * Currently this is actually the pkgng repository ident. This might change. + * + * This does not need to be freed (possibly, TODO: check). + */ +static const char * +get_repo_of_remote(struct pkg *pkg) +{ + const char *repo; + const char *repo_name; + struct pkg_repo *repo_struct; + + repo = NULL; + + /* + * We can get the repo NAME directly, but we need the repo IDENT. + * Short of chopping bits of the string off in the assumption that + * the name is repo-IDENT, we'll have to grab it from the repo + * structure itself. + */ + pkg_get(pkg, PKG_REPONAME, &repo_name); + + repo_struct = pkg_repo_find_name(repo_name); + if (repo_struct) + repo = pkg_repo_ident(repo_struct); + + return repo; +} + static gboolean try_id_match(struct pkg *pkg, const char *name, const char *version, const char *arch, const char *data, char **match_id) @@ -99,20 +156,7 @@ PKG_NAME, &p_name, PKG_VERSION, &p_version); - switch (pkg_type(pkg)) { - case PKG_FILE: - p_data = "local"; - break; - case PKG_INSTALLED: - p_data = "installed"; - break; - case PKG_REMOTE: - pkg_get(pkg, PKG_REPONAME, &p_data); - break; - default: - p_data = "unknown"; - break; - } + p_data = get_repo_of(pkg); if (*match_id != NULL) g_free(*match_id);