Date: Thu, 27 Jun 2013 00:35:59 GMT From: mattbw@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r253582 - soc2013/mattbw/backend Message-ID: <201306270035.r5R0ZxhT010914@socsvn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201306270035.r5R0ZxhT010914>