socsvn commit: r256768 - in soc2013/mattbw/backend: . query

mattbw at FreeBSD.org mattbw at FreeBSD.org
Sat Aug 31 10:31:39 UTC 2013


Author: mattbw
Date: Sat Aug 31 10:31:39 2013
New Revision: 256768
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=256768

Log:
  Use pkgutils_pk_repo_of when making a PackageID from a package.
  
  This means that installed and local-file packages will have a repo of
  "installed" and "local" respectively.
  
  This function now returns remote repo NAMES (repo-XYZ) instead of idents
  (XYZ).  This change is mainly for simplicity.
  

Modified:
  soc2013/mattbw/backend/pkgutils.c
  soc2013/mattbw/backend/query/check_test.c

Modified: soc2013/mattbw/backend/pkgutils.c
==============================================================================
--- soc2013/mattbw/backend/pkgutils.c	Sat Aug 31 09:40:01 2013	(r256767)
+++ soc2013/mattbw/backend/pkgutils.c	Sat Aug 31 10:31:39 2013	(r256768)
@@ -165,18 +165,21 @@
 gchar          *
 pkgutils_pkg_to_id(struct pkg *pkg)
 {
-	gchar	       *strv[4];
+	const char     *name;
+	const char     *version;
+	const char     *arch;
+	const char     *repo;
+
+	assert(pkg != NULL);
 
 	pkg_get(pkg,
-	    PKG_NAME, strv + PK_PACKAGE_ID_NAME,
-	    PKG_VERSION, strv + PK_PACKAGE_ID_VERSION,
-	    PKG_ARCH, strv + PK_PACKAGE_ID_ARCH,
-	    PKG_REPONAME, strv + PK_PACKAGE_ID_DATA);
-
-	return pk_package_id_build(strv[PK_PACKAGE_ID_NAME],
-	    strv[PK_PACKAGE_ID_VERSION],
-	    strv[PK_PACKAGE_ID_ARCH],
-	    strv[PK_PACKAGE_ID_DATA]);
+	    PKG_NAME, &name,
+	    PKG_VERSION, &version,
+	    PKG_ARCH, &arch);
+
+	repo = pkgutils_pk_repo_of(pkg);
+
+	return pk_package_id_build(name, version, arch, repo);
 }
 
 /*
@@ -243,34 +246,20 @@
 /*
  * Gets the PackageKit repository name for the (remote) package.
  *
- * Currently this is actually the pkgng repository ident.  This might change.
+ * Currently this is the pkgng repository name (not the ident as was previously
+ * the case).
  *
  * This does not need to be freed (possibly, TODO: check).
  */
 static const char *
 repo_of_remote(struct pkg *pkg)
 {
-	const char     *repo;
 	const char     *repo_name;
-	struct pkg_repo *repo_struct;
 
 	assert(pkg != NULL);
 	assert(pkg_type(pkg) == PKG_REMOTE);
 
-	repo = repo_name = NULL;
-	repo_struct = 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.
-	 */
+	repo_name = NULL;
 	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;
+	return repo_name;
 }

Modified: soc2013/mattbw/backend/query/check_test.c
==============================================================================
--- soc2013/mattbw/backend/query/check_test.c	Sat Aug 31 09:40:01 2013	(r256767)
+++ soc2013/mattbw/backend/query/check_test.c	Sat Aug 31 10:31:39 2013	(r256768)
@@ -17,6 +17,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
+
 #include <atf-c.h>
 #include <stdlib.h>		/* free */
 #include <string.h>		/* strcmp */


More information about the svn-soc-all mailing list