Suggestion on how to add search order to multiple reponsitories

Patrick Powell papowell at astart.com
Wed Sep 24 03:20:33 UTC 2014


Currently there does not appear to be simple way to specify the
order that repositories searched for packages,  or at least there
is none documented as such that I can find.

Suppose we add a 'repo_order' field to the repository specification, i.e. -

FreeBSDMyStuff: {
   URL: http://myserver/${ABI}/latest
   ENABLED: yes
   MIRROR_TYPE: SRV
   repo_order:  1
  }

FreeBSD: {
   URL: http://pkg.freebsd.org/${ABI}/latest
   ENABLED: yes
   MIRROR_TYPE: SRV
   repo_order:  2
  }

When doing a search for packages,  the found/discovered packages
would be sorted by the value of the order field.  By default,  if
there is no value for the order field then this entry would come
last.  If there are two entries with no or the same order value
then they would be sorted on the repo name,  as is currently done.

Also,  when displaying repositories,  i.e. - pkg -v -v,  you would
sort the display entries by the repo_order field as well.

Just to jumpstart this effort I am attaching a set of patches for
pkg-1.4.0.pre-alpha15.  This implements the basic functionality to
add repo_order to the repository definitions and adds support to
display the repo_order when doing 'pkg search'.

I would happy to add this ordering functionality to other parts of
the pkg support,  but I need a bit of help with the current code.

 From my understanding/reading/crystal ball gazing/looking at the
code entrails, it appears that when doing a 'pkg install X' the X
is first used to determine the set of packages in question.  Once
these have been determined there is a rather intimidating (recursive
as well?) procedure which is used to determine any dependencies.

Somewhere in this process there is a place where the listed/named
repositories are searched for candidates for dependencies.  It
appears at a casual reading that the repositories are searched in
the reverse order they were put in the reponsitory list and candidates
found during the search are then added to the dependency list as
they are found.  This has the effect of having entries found in
earlier listed repositories overwrite those found in later listed
respositories (I thought this was VERY clever!).

Rather than modify this code,  I would suggest adding a 'repository
ordering' step or routine.  Just after the repositories are
found/listed,  the repository list should be sorted (stably) using
the name and the repo_order field.  That is,  all of the repositories
with a lower repo_order value would be moved ahead of those with
lower repo_order values, while preserving the order for those with
the same repo_order value.

If this is done and the algorithm for searching the repositories
is as I have outlined it,  then you should get the desired repository
priority effect.  And perhaps no other code changes would be required.

I hope.  Perhaps.  Maybe.

-------------- next part --------------
*** pkg-1.4.0.pre-alpha15/docs/pkg_printf.3	Mon Sep 15 13:18:26 2014
--- pkg-1.4.0.pre-alpha15.orig/docs/pkg_printf.3	Sun Jun  8 12:59:52 2014
***************
*** 644,655 ****
  Valid only during operations when one version of a package is being
  replaced by another.
  .Vt struct pkg *
- .It Cm %Z
- Repository Order (repo_order) [integer] value.
- Value is set in the repository information and is limited to 0-100 (default 100).
- When selecting packages for installation, repositories with lower order numbers
- are searched before packages with higher order numbers.
- .Vt struct pkg *
  .It Cm %a
  Autoremove flag [boolean]
  .Vt struct pkg *
--- 644,649 ----
*** pkg-1.4.0.pre-alpha15/docs/pkg.conf.5	Mon Sep 15 13:33:02 2014
--- pkg-1.4.0.pre-alpha15.orig/docs/pkg.conf.5	Sun Sep 14 15:11:40 2014
***************
*** 271,279 ****
  .Va hw.ncpu
  is used.
  Default: 0.
- .It Cm REPO_ORDER: integer [1-100, default 100]
- Repositories with lower repo_order values are examined before reponsitories with
- larger repo_order values.
  .El
  .Sh REPOSITORY CONFIGURATION
  To use a repository you will need at least one repository
--- 271,276 ----
***************
*** 422,438 ****
  .Sy REPOS_DIR
  search path, with individual repository configuration files in the
  same directory processed in alphabetical order.
! This search order is modified by the
! .Sy repo_order
! value; repositories with smaller
! .Sy repo_order
! values are searched befor repositories with larger
! .Sy repo_order
! values.
! Packages found earlier in the search order take precedence,
! meaning that 
! if the same package is available from several repositories
! the first one found in the search order will be used.
  This behaviour may be overridden per-package by adding a 
  .Sy repository
  annotation to the installed package.
--- 419,427 ----
  .Sy REPOS_DIR
  search path, with individual repository configuration files in the
  same directory processed in alphabetical order.
! Earlier files take precedence, meaning that packages will be downloaded
! from them preferentially where the same package is available from several
! repositories.
  This behaviour may be overridden per-package by adding a 
  .Sy repository
  annotation to the installed package.
***************
*** 455,478 ****
      fingerprints: "/usr/share/keys/pkg",
      mirror_type: "srv"
  }
- 
- # can be in the same or separate file
- FreeBSD_my_mods: {
-     url: "pkg+http://my.server.private/${ABI}/latest",
-     enabled: true,
-     signature_type: "fingerprints",
-     fingerprints: "/usr/share/keys/pkg",
-     mirror_type: "srv"
-     repo_order: 20
- }
  .Ed
- .Pp
- The 
- .Sy FreeBSD_my_mods
- repository (repo_order 20) will be searched before the
- .Sy FreeBSD
- repository (repo_order default 100).
- .Pp
  Example for pkg.conf
  .Bd -literal -offset indent
  pkg_dbdir: "/var/db/pkg"
--- 444,450 ----
*** pkg-1.4.0.pre-alpha15/libpkg/pkg.c	Mon Sep 15 13:58:21 2014
--- pkg-1.4.0.pre-alpha15.orig/libpkg/pkg.c	Fri Sep 12 16:55:14 2014
***************
*** 41,111 ****
  
  static ucl_object_t *manifest_schema = NULL;
  
! static struct pkg_key_x pkg_keys_x[] = {
! 	{ PKG_ORIGIN, "origin", UCL_STRING },
! 	{ PKG_NAME, "name", UCL_STRING },
! 	{ PKG_VERSION, "version", UCL_STRING },
! 	{ PKG_COMMENT, "comment", UCL_STRING },
! 	{ PKG_DESC, "desc", UCL_STRING },
! 	{ PKG_MTREE, "mtree", UCL_STRING },
! 	{ PKG_MESSAGE, "message", UCL_STRING },
! 	{ PKG_ARCH, "arch", UCL_STRING },
! 	{ PKG_MAINTAINER, "maintainer", UCL_STRING },
! 	{ PKG_WWW, "www", UCL_STRING },
! 	{ PKG_PREFIX, "prefix", UCL_STRING },
! 	{ PKG_REPOPATH, "repopath", UCL_STRING },
! 	{ PKG_CKSUM, "sum", UCL_STRING },
! 	{ PKG_OLD_VERSION, "oldversion", UCL_STRING },
! 	{ PKG_REPONAME, "reponame", UCL_STRING },
! 	{ PKG_REPOURL, "repourl", UCL_STRING },
! 	{ PKG_DIGEST, "digest", UCL_STRING },
! 	{ PKG_REASON, "reason", UCL_STRING },
! 	{ PKG_FLATSIZE, "flatsize", UCL_INT },
! 	{ PKG_OLD_FLATSIZE, "oldflatsize", UCL_INT },
! 	{ PKG_PKGSIZE, "pkgsize", UCL_INT },
! 	{ PKG_LICENSE_LOGIC, "licenselogic", UCL_INT },
! 	{ PKG_AUTOMATIC, "automatic", UCL_BOOLEAN },
! 	{ PKG_LOCKED, "locked", UCL_BOOLEAN },
! 	{ PKG_ROWID, "rowid", UCL_INT },
! 	{ PKG_TIME, "time", UCL_INT },
! 	{ PKG_ANNOTATIONS, "annotations", UCL_OBJECT },
! 	{ PKG_LICENSES, "licenses", UCL_ARRAY },
! 	{ PKG_CATEGORIES, "categories", UCL_ARRAY },
! 	{ PKG_UNIQUEID, "uniqueid", UCL_STRING },
! 	{ PKG_OLD_DIGEST, "olddigest", UCL_STRING },
! 	{ PKG_REPO_ORDER, "repo_order", UCL_INT }
  };
  
- struct pkg_key_x *get_pkg_key_by_enum_tag( int enum_tag )
- {
- 	struct pkg_key_x *found = 0;
- 	int i;
- 	for( i = 0; i < sizeof(pkg_keys_x)/sizeof(pkg_keys_x[0]); ++i ){
- 		struct pkg_key_x *test = &pkg_keys_x[i];
- 		if( test->enum_tag == enum_tag ){
- 			found = test;
- 			break;
- 		}
- 	}
- 	return( found );
- }
- 
- 
- struct pkg_key_x *get_pkg_key_by_name( const char * name )
- {
- 	struct pkg_key_x *found = 0;
- 	int i;
- 	for( i = 0; i < sizeof(pkg_keys_x)/sizeof(pkg_keys_x[0]); ++i ){
- 		struct pkg_key_x *test = &pkg_keys_x[i];
- 		if( ! strcmp( test->name , name ) ){
- 			found = test;
- 			break;
- 		}
- 	}
- 	return( found );
- }
- 
- 
  int
  pkg_new(struct pkg **pkg, pkg_t type)
  {
--- 41,80 ----
  
  static ucl_object_t *manifest_schema = NULL;
  
! struct pkg_key pkg_keys[PKG_NUM_FIELDS] = {
! 	[PKG_ORIGIN] = { "origin", UCL_STRING },
! 	[PKG_NAME] = { "name", UCL_STRING },
! 	[PKG_VERSION] = { "version", UCL_STRING },
! 	[PKG_COMMENT] = { "comment", UCL_STRING },
! 	[PKG_DESC] = { "desc", UCL_STRING },
! 	[PKG_MTREE] = { "mtree", UCL_STRING },
! 	[PKG_MESSAGE] = { "message", UCL_STRING },
! 	[PKG_ARCH] = { "arch", UCL_STRING },
! 	[PKG_MAINTAINER] = { "maintainer", UCL_STRING },
! 	[PKG_WWW] = { "www", UCL_STRING },
! 	[PKG_PREFIX] = { "prefix", UCL_STRING },
! 	[PKG_REPOPATH] = { "repopath", UCL_STRING },
! 	[PKG_CKSUM] = { "sum", UCL_STRING },
! 	[PKG_OLD_VERSION] = { "oldversion", UCL_STRING },
! 	[PKG_REPONAME] = { "reponame", UCL_STRING },
! 	[PKG_REPOURL] = { "repourl", UCL_STRING },
! 	[PKG_DIGEST] = { "digest", UCL_STRING },
! 	[PKG_REASON] = { "reason", UCL_STRING },
! 	[PKG_FLATSIZE] = { "flatsize", UCL_INT },
! 	[PKG_OLD_FLATSIZE] = { "oldflatsize", UCL_INT },
! 	[PKG_PKGSIZE] = { "pkgsize", UCL_INT },
! 	[PKG_LICENSE_LOGIC] = { "licenselogic", UCL_INT },
! 	[PKG_AUTOMATIC] = { "automatic", UCL_BOOLEAN },
! 	[PKG_LOCKED] = { "locked", UCL_BOOLEAN },
! 	[PKG_ROWID] = { "rowid", UCL_INT },
! 	[PKG_TIME] = { "time", UCL_INT },
! 	[PKG_ANNOTATIONS] = { "annotations", UCL_OBJECT },
! 	[PKG_LICENSES] = { "licenses", UCL_ARRAY },
! 	[PKG_CATEGORIES] = { "categories", UCL_ARRAY },
! 	[PKG_UNIQUEID] = { "uniqueid", UCL_STRING },
! 	[PKG_OLD_DIGEST] = { "olddigest", UCL_STRING },
  };
  
  int
  pkg_new(struct pkg **pkg, pkg_t type)
  {
***************
*** 289,302 ****
  
  	while ((attr = va_arg(ap, int)) > 0) {
  
! 		struct pkg_key_x *key = get_pkg_key_by_enum_tag( attr );
! 		if (!key) {
! 			pkg_emit_error("Bad enum value %d to pkg_vset", attr );
  			return (EPKG_FATAL);
  		}
! 		
! 		obj = ucl_object_find_key(pkg->fields, key->name);
! 		switch (key->type) {
  		case UCL_STRING:
  			if (obj == NULL) {
  				*va_arg(ap, const char **) = NULL;
--- 258,270 ----
  
  	while ((attr = va_arg(ap, int)) > 0) {
  
! 		if (attr >= PKG_NUM_FIELDS || attr <= 0) {
! 			pkg_emit_error("Bad argument on pkg_get");
  			return (EPKG_FATAL);
  		}
! 
! 		obj = ucl_object_find_key(pkg->fields, pkg_keys[attr].name);
! 		switch (pkg_keys[attr].type) {
  		case UCL_STRING:
  			if (obj == NULL) {
  				*va_arg(ap, const char **) = NULL;
***************
*** 356,368 ****
  	ucl_object_t *o;
  
  	while ((attr = va_arg(ap, int)) > 0) {
! 		struct pkg_key_x *key = get_pkg_key_by_enum_tag( attr );
! 		if (!key) {
! 			pkg_emit_error("Bad enum value %d to pkg_vset", attr );
  			return (EPKG_FATAL);
  		}
! 		
! 		switch (key->type) {
  		case UCL_STRING:
  			str = va_arg(ap, const char *);
  			data = str;
--- 324,335 ----
  	ucl_object_t *o;
  
  	while ((attr = va_arg(ap, int)) > 0) {
! 		if (attr >= PKG_NUM_FIELDS || attr <= 0) {
! 			pkg_emit_error("Bad argument on pkg_get");
  			return (EPKG_FATAL);
  		}
! 
! 		switch (pkg_keys[attr].type) {
  		case UCL_STRING:
  			str = va_arg(ap, const char *);
  			data = str;
***************
*** 373,401 ****
  			}
  
  			if (data == NULL)
! 				ucl_object_delete_key(pkg->fields, key->name);
  			else
  				ucl_object_replace_key(pkg->fields,
  				    ucl_object_fromstring_common(data, strlen(data), 0),
! 				    key->name, strlen(key->name), false);
  
  			free(buf);
  			break;
  		case UCL_BOOLEAN:
  			ucl_object_replace_key(pkg->fields,
  			    ucl_object_frombool((bool)va_arg(ap, int)),
! 			    key->name, strlen(key->name), false);
  			break;
  		case UCL_INT:
  			ucl_object_replace_key(pkg->fields,
  			    ucl_object_fromint(va_arg(ap, int64_t)),
! 			    key->name, strlen(key->name), false);
  			break;
  		case UCL_OBJECT:
  		case UCL_ARRAY:
  			o = va_arg(ap, ucl_object_t *);
  			ucl_object_replace_key(pkg->fields, o,
! 			    key->name, strlen(key->name), false);
  			break;
  		default:
  			(void) va_arg(ap, void *);
--- 340,368 ----
  			}
  
  			if (data == NULL)
! 				ucl_object_delete_key(pkg->fields, pkg_keys[attr].name);
  			else
  				ucl_object_replace_key(pkg->fields,
  				    ucl_object_fromstring_common(data, strlen(data), 0),
! 				    pkg_keys[attr].name, strlen(pkg_keys[attr].name), false);
  
  			free(buf);
  			break;
  		case UCL_BOOLEAN:
  			ucl_object_replace_key(pkg->fields,
  			    ucl_object_frombool((bool)va_arg(ap, int)),
! 			    pkg_keys[attr].name, strlen(pkg_keys[attr].name), false);
  			break;
  		case UCL_INT:
  			ucl_object_replace_key(pkg->fields,
  			    ucl_object_fromint(va_arg(ap, int64_t)),
! 			    pkg_keys[attr].name, strlen(pkg_keys[attr].name), false);
  			break;
  		case UCL_OBJECT:
  		case UCL_ARRAY:
  			o = va_arg(ap, ucl_object_t *);
  			ucl_object_replace_key(pkg->fields, o,
! 			    pkg_keys[attr].name, strlen(pkg_keys[attr].name), false);
  			break;
  		default:
  			(void) va_arg(ap, void *);
*** pkg-1.4.0.pre-alpha15/libpkg/pkg.h.in	Mon Sep 15 13:17:10 2014
--- pkg-1.4.0.pre-alpha15.orig/libpkg/pkg.h.in	Sun Sep 14 15:11:40 2014
***************
*** 266,272 ****
  	PKG_CATEGORIES,
  	PKG_UNIQUEID,
  	PKG_OLD_DIGEST,
! 	PKG_REPO_ORDER,
  } pkg_attr;
  
  typedef enum {
--- 266,272 ----
  	PKG_CATEGORIES,
  	PKG_UNIQUEID,
  	PKG_OLD_DIGEST,
! 	PKG_NUM_FIELDS, 	/* end of fields */
  } pkg_attr;
  
  typedef enum {
*** pkg-1.4.0.pre-alpha15/libpkg/pkg_checksum.c	Mon Sep 15 13:13:54 2014
--- pkg-1.4.0.pre-alpha15.orig/libpkg/pkg_checksum.c	Sat Sep  6 19:01:46 2014
***************
*** 127,132 ****
--- 127,133 ----
  pkg_checksum_generate(struct pkg *pkg, char *dest, size_t destlen,
  	pkg_checksum_type_t type)
  {
+ 	const char *key;
  	unsigned char *bdigest;
  	size_t blen;
  	struct pkg_checksum_entry *entries = NULL;
***************
*** 150,163 ****
  		return (EPKG_FATAL);
  
  	for (i = 0; recopies[i] != -1; i++) {
! 		struct pkg_key_x *key = get_pkg_key_by_enum_tag(recopies[i]);
! 		if( !key ){
! 			pkg_emit_error("pkg_checksum_generate: no key for enum value '%d'", recopies[i]);
! 		} else {
! 			if ((o = ucl_object_find_key(pkg->fields, key->name))){
! 				pkg_checksum_add_entry(key->name, ucl_object_tostring(o), &entries);
! 			}
! 		}
  	}
  
  	while (pkg_options(pkg, &option) == EPKG_OK) {
--- 151,159 ----
  		return (EPKG_FATAL);
  
  	for (i = 0; recopies[i] != -1; i++) {
! 		key = pkg_keys[recopies[i]].name;
! 		if ((o = ucl_object_find_key(pkg->fields, key)))
! 			pkg_checksum_add_entry(key, ucl_object_tostring(o), &entries);
  	}
  
  	while (pkg_options(pkg, &option) == EPKG_OK) {
*** pkg-1.4.0.pre-alpha15/libpkg/pkg_config.c	Mon Sep 15 13:09:57 2014
--- pkg-1.4.0.pre-alpha15.orig/libpkg/pkg_config.c	Sun Sep 14 15:11:40 2014
***************
*** 424,430 ****
  	const char *signature_type = NULL, *fingerprints = NULL;
  	const char *key;
  	const char *type = NULL;
- 	int repo_order = 100;
  	int use_ipvx;
  
  	pkg_debug(1, "PkgConfig: parsing repository object %s", rname);
--- 424,429 ----
***************
*** 513,529 ****
  			use_ipvx = ucl_object_toint(cur);
  			if (use_ipvx != 4 && use_ipvx != 6)
  				use_ipvx = 0;
- 		} else if (strcasecmp(key, "repo_order") == 0) {
- 		    pkg_debug(1, "repo %s has 'repo_order'", rname);
- 			if (cur->type != UCL_INT) {
- 				pkg_emit_error("Expecting an integer for the "
- 					"'%s' key of the '%s' repo",
- 					key, rname);
- 				return;
- 			}
- 			repo_order = ucl_object_toint(cur);
- 			if( repo_order >= 100 ){ repo_order = 100; }
- 			if( repo_order < 0 ){ repo_order = 0; }
  		}
  	}
  
--- 512,517 ----
***************
*** 558,564 ****
  	}
  
  	r->enable = enable;
- 	r->repo_order = repo_order;
  
  	if (mirror_type != NULL) {
  		if (strcasecmp(mirror_type, "srv") == 0)
--- 546,551 ----
*** pkg-1.4.0.pre-alpha15/libpkg/pkg_manifest.c	Mon Sep 15 13:03:46 2014
--- pkg-1.4.0.pre-alpha15.orig/libpkg/pkg_manifest.c	Sun Sep  7 23:23:24 2014
***************
*** 99,105 ****
  	{ "option_descriptions", PKG_OPTION_DESCRIPTIONS, UCL_OBJECT, pkg_obj},
  	{ "origin",              PKG_ORIGIN,              UCL_STRING, pkg_string},
  	{ "path",                PKG_REPOPATH,            UCL_STRING, pkg_string},
- 	{ "repo_order",          PKG_REPO_ORDER,          UCL_INT,    pkg_int},
  	{ "repopath",            PKG_REPOPATH,            UCL_STRING, pkg_string},
  	{ "pkgsize",             PKG_PKGSIZE,             UCL_INT,    pkg_int},
  	{ "prefix",              PKG_PREFIX,              UCL_STRING, pkg_string},
--- 99,104 ----
***************
*** 883,888 ****
--- 882,888 ----
  	ucl_object_t *map, *seq, *submap;
  	ucl_object_t *top = ucl_object_typed_new(UCL_OBJECT);
  	const ucl_object_t *o;
+ 	const char *key;
  	int recopies[] = {
  		PKG_NAME,
  		PKG_ORIGIN,
***************
*** 904,917 ****
  
  	pkg_debug(4, "Emitting basic metadata");
  	for (i = 0; recopies[i] != -1; i++) {
! 		struct pkg_key_x *key = get_pkg_key_by_enum_tag( recopies[i] );
! 		if( !key ){
! 			pkg_emit_error("pkg_emit_obj: bad enum value %d", recopies[i] );
! 			continue;
! 		}
! 		if ((o = ucl_object_find_key(pkg->fields, key->name)))
  			ucl_object_insert_key(top, ucl_object_ref(o),
! 			    key->name, strlen(key->name), false);
  	}
  	if (comment)
  		ucl_object_insert_key(top, ucl_object_fromstring_common(comment, 0,
--- 904,913 ----
  
  	pkg_debug(4, "Emitting basic metadata");
  	for (i = 0; recopies[i] != -1; i++) {
! 		key = pkg_keys[recopies[i]].name;
! 		if ((o = ucl_object_find_key(pkg->fields, key)))
  			ucl_object_insert_key(top, ucl_object_ref(o),
! 			    key, strlen(key), false);
  	}
  	if (comment)
  		ucl_object_insert_key(top, ucl_object_fromstring_common(comment, 0,
***************
*** 1054,1060 ****
  		map = ucl_object_typed_new(UCL_OBJECT);
  		/* Add annotations except for internal ones. */
  		while ((o = ucl_iterate_object(annotations, &it, true))) {
- 			const char *key;
  			if ((key = ucl_object_keyl(o, &key_len)) == NULL)
  				continue;
  			/* Internal annotations. */
--- 1050,1055 ----
*** pkg-1.4.0.pre-alpha15/libpkg/pkg_printf.c	Mon Sep 15 12:48:15 2014
--- pkg-1.4.0.pre-alpha15.orig/libpkg/pkg_printf.c	Fri Sep 12 16:32:43 2014
***************
*** 111,117 ****
   * W
   * X
   * Y
!  * Z  pkg          repo_order
   *
   * a  pkg          autoremove flag
   *
--- 111,117 ----
   * W
   * X
   * Y
!  * Z
   *
   * a  pkg          autoremove flag
   *
***************
*** 786,800 ****
  		PP_ALL,
  		&format_home_url,
  	},
- 	[PP_PKG_REPO_ORDER] =
- 	{
- 		'Z',
- 		'\0',
- 		false,
- 		true,
- 		PP_ALL,
- 		&format_repo_order,
- 	},
  	[PP_LITERAL_PERCENT] =
  	{
  		'%',
--- 786,791 ----
***************
*** 1884,1903 ****
  	return (string_val(sbuf, url, p));
  }
  
- 
- /*
-  * %Z -- Repo Order. integer
-  */
- struct sbuf *
- format_repo_order(struct sbuf *sbuf, const void *data, struct percent_esc *p)
- {
- 	const struct pkg	*pkg = data;
- 	int64_t			 repo_order;
- 
- 	pkg_get(pkg, PKG_REPO_ORDER, &repo_order);
- 	return (int_val(sbuf, repo_order, p));
- }
- 
  /*
   * %% -- Output a literal '%' character
   */
--- 1875,1880 ----
*** pkg-1.4.0.pre-alpha15/libpkg/pkgdb.c	Mon Sep 15 12:42:09 2014
--- pkg-1.4.0.pre-alpha15.orig/libpkg/pkgdb.c	Wed Sep 10 23:17:52 2014
***************
*** 1069,1075 ****
  		const char sql[] = "BEGIN IMMEDIATE TRANSACTION";
  		
  		psql = sql;
! 		pkg_debug(4, "Pkgdb: pkgdb_transaction_begin running '%s'", sql);
  		ret = sqlite3_prepare_v2(sqlite, sql, strlen(sql) + 1,
  					 &stmt, NULL);
  	} else {
--- 1069,1075 ----
  		const char sql[] = "BEGIN IMMEDIATE TRANSACTION";
  		
  		psql = sql;
! 		pkg_debug(4, "Pkgdb: running '%s'", sql);
  		ret = sqlite3_prepare_v2(sqlite, sql, strlen(sql) + 1,
  					 &stmt, NULL);
  	} else {
***************
*** 1078,1084 ****
  		strlcat(sql, savepoint, sizeof(sql));
  
  		psql = sql;
! 		pkg_debug(4, "Pkgdb: pkgdb_transaction_begin running '%s'", sql);
  		ret = sqlite3_prepare_v2(sqlite, sql, strlen(sql) + 1,
  					 &stmt, NULL);
  	}
--- 1078,1084 ----
  		strlcat(sql, savepoint, sizeof(sql));
  
  		psql = sql;
! 		pkg_debug(4, "Pkgdb: running '%s'", sql);
  		ret = sqlite3_prepare_v2(sqlite, sql, strlen(sql) + 1,
  					 &stmt, NULL);
  	}
***************
*** 1108,1114 ****
  		const char sql[] = "COMMIT TRANSACTION";
  		psql = sql;
  
! 		pkg_debug(4, "Pkgdb: pkgdb_transaction_commit running '%s'", sql);
  		ret = sqlite3_prepare_v2(sqlite, sql, strlen(sql) + 1,
  					 &stmt, NULL);
  	} else {
--- 1108,1114 ----
  		const char sql[] = "COMMIT TRANSACTION";
  		psql = sql;
  
! 		pkg_debug(4, "Pkgdb: running '%s'", sql);
  		ret = sqlite3_prepare_v2(sqlite, sql, strlen(sql) + 1,
  					 &stmt, NULL);
  	} else {
***************
*** 1118,1124 ****
  
  		psql = sql;
  
! 		pkg_debug(4, "Pkgdb: pkgdb_transaction_commit running '%s'", sql);
  		ret = sqlite3_prepare_v2(sqlite, sql, strlen(sql) + 1,
  					 &stmt, NULL);
  	}
--- 1118,1124 ----
  
  		psql = sql;
  
! 		pkg_debug(4, "Pkgdb: running '%s'", sql);
  		ret = sqlite3_prepare_v2(sqlite, sql, strlen(sql) + 1,
  					 &stmt, NULL);
  	}
***************
*** 1148,1154 ****
  		const char sql[] = "ROLLBACK TRANSACTION";
  
  		psql = sql;
! 		pkg_debug(4, "Pkgdb: pkgdb_transaction_rollback running '%s'", sql);
  		ret = sqlite3_prepare_v2(sqlite, sql, strlen(sql) + 1,
  					 &stmt, NULL);
  	} else {
--- 1148,1154 ----
  		const char sql[] = "ROLLBACK TRANSACTION";
  
  		psql = sql;
! 		pkg_debug(4, "Pkgdb: running '%s'", sql);
  		ret = sqlite3_prepare_v2(sqlite, sql, strlen(sql) + 1,
  					 &stmt, NULL);
  	} else {
***************
*** 1157,1163 ****
  		strlcat(sql, savepoint, sizeof(sql));
  
  		psql = sql;
! 		pkg_debug(4, "Pkgdb: pkgdb_transaction_rollback running '%s'", sql);
  		ret = sqlite3_prepare_v2(sqlite, sql, strlen(sql) + 1,
  					 &stmt, NULL);
  	}
--- 1157,1163 ----
  		strlcat(sql, savepoint, sizeof(sql));
  
  		psql = sql;
! 		pkg_debug(4, "Pkgdb: running '%s'", sql);
  		ret = sqlite3_prepare_v2(sqlite, sql, strlen(sql) + 1,
  					 &stmt, NULL);
  	}
***************
*** 1979,1985 ****
  
  		for (i = 0; i < 2; i++) {
  			/* Clean out old shlibs first */
! 			pkg_debug(4, "Pkgdb: pkgdb_reanalyse_shlibs running '%s'", sql[i]);
  			if (sqlite3_prepare_v2(db->sqlite, sql[i], -1,
  					       &stmt_del, NULL)
  			    != SQLITE_OK) {
--- 1979,1985 ----
  
  		for (i = 0; i < 2; i++) {
  			/* Clean out old shlibs first */
! 			pkg_debug(4, "Pkgdb: running '%s'", sql[i]);
  			if (sqlite3_prepare_v2(db->sqlite, sql[i], -1,
  					       &stmt_del, NULL)
  			    != SQLITE_OK) {
***************
*** 2201,2207 ****
  
  	assert(db != NULL);
  
! 	pkg_debug(4, "Pkgdb: pkgdb_unregister_pkg running '%s'", sql);
  	if (sqlite3_prepare_v2(db->sqlite, sql, -1, &stmt_del, NULL)
  	    != SQLITE_OK){
  		ERROR_SQLITE(db->sqlite, sql);
--- 2201,2207 ----
  
  	assert(db != NULL);
  
! 	pkg_debug(4, "Pkgdb: running '%s'", sql);
  	if (sqlite3_prepare_v2(db->sqlite, sql, -1, &stmt_del, NULL)
  	    != SQLITE_OK){
  		ERROR_SQLITE(db->sqlite, sql);
***************
*** 2247,2253 ****
  		sql_to_exec = sql;
  	}
  
! 	pkg_debug(4, "Pkgdb: sql_exec executing '%s'", sql_to_exec);
  	if (sqlite3_exec(s, sql_to_exec, NULL, NULL, &errmsg) != SQLITE_OK) {
  		ERROR_SQLITE(s, sql_to_exec);
  		sqlite3_free(errmsg);
--- 2247,2253 ----
  		sql_to_exec = sql;
  	}
  
! 	pkg_debug(4, "Pkgdb: executing '%s'", sql_to_exec);
  	if (sqlite3_exec(s, sql_to_exec, NULL, NULL, &errmsg) != SQLITE_OK) {
  		ERROR_SQLITE(s, sql_to_exec);
  		sqlite3_free(errmsg);
***************
*** 2271,2277 ****
  
  	assert(s != NULL && sql != NULL);
  
! 	pkg_debug(4, "Pkgdb: get_pragma running '%s'", sql);
  	if (sqlite3_prepare_v2(s, sql, -1, &stmt, NULL) != SQLITE_OK) {
  		if (!silence)
  			ERROR_SQLITE(s, sql);
--- 2271,2277 ----
  
  	assert(s != NULL && sql != NULL);
  
! 	pkg_debug(4, "Pkgdb: running '%s'", sql);
  	if (sqlite3_prepare_v2(s, sql, -1, &stmt, NULL) != SQLITE_OK) {
  		if (!silence)
  			ERROR_SQLITE(s, sql);
***************
*** 2303,2309 ****
  
  	assert(s != NULL && sql != NULL);
  
! 	pkg_debug(4, "Pkgdb: get_sql_string running '%s'", sql);
  	if (sqlite3_prepare_v2(s, sql, -1, &stmt, NULL) != SQLITE_OK) {
  		ERROR_SQLITE(s, sql);
  		return (EPKG_OK);
--- 2303,2309 ----
  
  	assert(s != NULL && sql != NULL);
  
! 	pkg_debug(4, "Pkgdb: running '%s'", sql);
  	if (sqlite3_prepare_v2(s, sql, -1, &stmt, NULL) != SQLITE_OK) {
  		ERROR_SQLITE(s, sql);
  		return (EPKG_OK);
***************
*** 2382,2388 ****
  			"path TEXT UNIQUE);"
  		);
  
! 	pkg_debug(4, "Pkgdb: pkgdb_integrity_append running '%s'", sql);
  	if (sqlite3_prepare_v2(db->sqlite, sql, -1, &stmt, NULL)
  	    != SQLITE_OK) {
  		ERROR_SQLITE(db->sqlite, sql);
--- 2382,2388 ----
  			"path TEXT UNIQUE);"
  		);
  
! 	pkg_debug(4, "Pkgdb: running '%s'", sql);
  	if (sqlite3_prepare_v2(db->sqlite, sql, -1, &stmt, NULL)
  	    != SQLITE_OK) {
  		ERROR_SQLITE(db->sqlite, sql);
***************
*** 2391,2397 ****
  
  	pkg_get(p, PKG_UNIQUEID, &puid);
  
! 	pkg_debug(4, "Pkgdb: pkgdb_integrity_append test conflicts for %s", puid);
  	while (pkg_files(p, &file) == EPKG_OK) {
  		const char	*uid;
  		const char	*pkg_path = pkg_file_path(file);
--- 2391,2397 ----
  
  	pkg_get(p, PKG_UNIQUEID, &puid);
  
! 	pkg_debug(4, "Pkgdb: test conflicts for %s", puid);
  	while (pkg_files(p, &file) == EPKG_OK) {
  		const char	*uid;
  		const char	*pkg_path = pkg_file_path(file);
***************
*** 2403,2409 ****
  
  		if (sqlite3_step(stmt) != SQLITE_DONE) {
  
! 			pkg_debug(4, "Pkgdb: pkgdb_integrity_append running '%s'", sql_conflicts);
  			if (sqlite3_prepare_v2(db->sqlite, sql_conflicts,
  			    -1, &stmt_conflicts, NULL) != SQLITE_OK) {
  				ERROR_SQLITE(db->sqlite, sql_conflicts);
--- 2403,2409 ----
  
  		if (sqlite3_step(stmt) != SQLITE_DONE) {
  
! 			pkg_debug(4, "Pkgdb: running '%s'", sql_conflicts);
  			if (sqlite3_prepare_v2(db->sqlite, sql_conflicts,
  			    -1, &stmt_conflicts, NULL) != SQLITE_OK) {
  				ERROR_SQLITE(db->sqlite, sql_conflicts);
***************
*** 2474,2480 ****
  	 * Select paths that are both in integritycheck and local table but their
  	 * UIDs are different
  	 */
! 	pkg_debug(4, "Pkgdb: pkgdb_integrity_append running '%s'", sql_integrity_prepare);
  	if (sqlite3_prepare_v2(db->sqlite,
  		sql_integrity_prepare,
  		-1, &stmt, NULL) != SQLITE_OK) {
--- 2474,2480 ----
  	 * Select paths that are both in integritycheck and local table but their
  	 * UIDs are different
  	 */
! 	pkg_debug(4, "Pkgdb: running '%s'", sql_integrity_prepare);
  	if (sqlite3_prepare_v2(db->sqlite,
  		sql_integrity_prepare,
  		-1, &stmt, NULL) != SQLITE_OK) {
***************
*** 2495,2501 ****
  		 * Conflict found on path, so find the corresponding local
  		 * package
  		 */
! 		pkg_debug(4, "Pkgdb: pkgdb_integrity_append running '%s'", sql_local_conflict);
  		ret = sqlite3_prepare_v2(db->sqlite, sql_local_conflict, -1,
  		    &stmt_conflicts, NULL);
  		if (ret != SQLITE_OK) {
--- 2495,2501 ----
  		 * Conflict found on path, so find the corresponding local
  		 * package
  		 */
! 		pkg_debug(4, "Pkgdb: running '%s'", sql_local_conflict);
  		ret = sqlite3_prepare_v2(db->sqlite, sql_local_conflict, -1,
  		    &stmt_conflicts, NULL);
  		if (ret != SQLITE_OK) {
***************
*** 2523,2529 ****
  		/*
  		 * Now match local and remote conflicting packages
  		 */
! 		pkg_debug(4, "Pkgdb: pkgdb_integrity_append running '%s'", sql_conflicts);
  		ret = sqlite3_prepare_v2(db->sqlite, sql_conflicts, -1,
  		    &stmt_conflicts, NULL);
  		if (ret != SQLITE_OK) {
--- 2523,2529 ----
  		/*
  		 * Now match local and remote conflicting packages
  		 */
! 		pkg_debug(4, "Pkgdb: running '%s'", sql_conflicts);
  		ret = sqlite3_prepare_v2(db->sqlite, sql_conflicts, -1,
  		    &stmt_conflicts, NULL);
  		if (ret != SQLITE_OK) {
***************
*** 2579,2585 ****
  		"AND i.uid = ?1 AND "
  		"i.uid != p.name || '~' || p.origin";
  
! 	pkg_debug(4, "Pkgdb: pkgdb_integrity_conflict_local running '%s'", sql_conflicts);
  	ret = sqlite3_prepare_v2(db->sqlite, sql_conflicts, -1, &stmt, NULL);
  	if (ret != SQLITE_OK) {
  		ERROR_SQLITE(db->sqlite, sql_conflicts);
--- 2579,2585 ----
  		"AND i.uid = ?1 AND "
  		"i.uid != p.name || '~' || p.origin";
  
! 	pkg_debug(4, "Pkgdb: running '%s'", sql_conflicts);
  	ret = sqlite3_prepare_v2(db->sqlite, sql_conflicts, -1, &stmt, NULL);
  	if (ret != SQLITE_OK) {
  		ERROR_SQLITE(db->sqlite, sql_conflicts);
***************
*** 2619,2625 ****
  	};
  
  	while ((attr = va_arg(ap, int)) > 0) {
! 		pkg_debug(4, "Pkgdb: pkgdb_vset running '%s'", sql[attr]);
  		if (sqlite3_prepare_v2(db->sqlite, sql[attr], -1, &stmt, NULL)
  		    != SQLITE_OK) {
  			ERROR_SQLITE(db->sqlite, sql[attr]);
--- 2619,2625 ----
  	};
  
  	while ((attr = va_arg(ap, int)) > 0) {
! 		pkg_debug(4, "Pkgdb: running '%s'", sql[attr]);
  		if (sqlite3_prepare_v2(db->sqlite, sql[attr], -1, &stmt, NULL)
  		    != SQLITE_OK) {
  			ERROR_SQLITE(db->sqlite, sql[attr]);
***************
*** 2700,2706 ****
  		"UPDATE files SET sha256 = ?1 WHERE path = ?2";
  	int		 ret;
  
! 	pkg_debug(4, "Pkgdb: pkgdb_file_set_cksum running '%s'", sql_file_update);
  	ret = sqlite3_prepare_v2(db->sqlite, sql_file_update, -1, &stmt, NULL);
  	if (ret != SQLITE_OK) {
  		ERROR_SQLITE(db->sqlite, sql_file_update);
--- 2700,2706 ----
  		"UPDATE files SET sha256 = ?1 WHERE path = ?2";
  	int		 ret;
  
! 	pkg_debug(4, "Pkgdb: running '%s'", sql_file_update);
  	ret = sqlite3_prepare_v2(db->sqlite, sql_file_update, -1, &stmt, NULL);
  	if (ret != SQLITE_OK) {
  		ERROR_SQLITE(db->sqlite, sql_file_update);
***************
*** 3102,3108 ****
  	}
  
  	sbuf_finish(sql);
! 	pkg_debug(4, "Pkgdb: pkgdb_stats running '%s'", sbuf_data(sql));
  	ret = sqlite3_prepare_v2(db->sqlite, sbuf_data(sql), -1, &stmt, NULL);
  	if (ret != SQLITE_OK) {
  		ERROR_SQLITE(db->sqlite, sbuf_data(sql));
--- 3102,3108 ----
  	}
  
  	sbuf_finish(sql);
! 	pkg_debug(4, "Pkgdb: running '%s'", sbuf_data(sql));
  	ret = sqlite3_prepare_v2(db->sqlite, sbuf_data(sql), -1, &stmt, NULL);
  	if (ret != SQLITE_OK) {
  		ERROR_SQLITE(db->sqlite, sbuf_data(sql));
*** pkg-1.4.0.pre-alpha15/libpkg/pkgdb_iterator.c	Mon Sep 15 12:40:03 2014
--- pkg-1.4.0.pre-alpha15.orig/libpkg/pkgdb_iterator.c	Wed Aug 27 15:03:11 2014
***************
*** 83,89 ****
  	{ "origin",	PKG_ORIGIN, PKG_SQLITE_STRING },
  	{ "pkgsize",	PKG_PKGSIZE, PKG_SQLITE_INT64 },
  	{ "prefix",	PKG_PREFIX, PKG_SQLITE_STRING },
- 	{ "repo_order",	PKG_REPO_ORDER, PKG_SQLITE_INT64 },
  	{ "repopath",	PKG_REPOPATH, PKG_SQLITE_STRING },
  	{ "repourl",	PKG_REPOURL, PKG_SQLITE_STRING },
  	{ "rowid",	PKG_ROWID, PKG_SQLITE_INT64 },
--- 83,88 ----
***************
*** 108,114 ****
  	if (pkg->flags & flags)
  		return (EPKG_OK);
  
! 	pkg_debug(4, "Pkgdb: load_val running '%s'", sql);
  	if (sqlite3_prepare_v2(db, sql, -1, &stmt, NULL) != SQLITE_OK) {
  		ERROR_SQLITE(db, sql);
  		return (EPKG_FATAL);
--- 107,113 ----
  	if (pkg->flags & flags)
  		return (EPKG_OK);
  
! 	pkg_debug(4, "Pkgdb: running '%s'", sql);
  	if (sqlite3_prepare_v2(db, sql, -1, &stmt, NULL) != SQLITE_OK) {
  		ERROR_SQLITE(db, sql);
  		return (EPKG_FATAL);
***************
*** 148,154 ****
  	if (pkg->flags & flags)
  		return (EPKG_OK);
  
! 	pkg_debug(4, "Pkgdb: load_tag_val running '%s'", sql);
  	if (sqlite3_prepare_v2(db, sql, -1, &stmt, NULL) != SQLITE_OK) {
  		ERROR_SQLITE(db, sql);
  		return (EPKG_FATAL);
--- 147,153 ----
  	if (pkg->flags & flags)
  		return (EPKG_OK);
  
! 	pkg_debug(4, "Pkgdb: running '%s'", sql);
  	if (sqlite3_prepare_v2(db, sql, -1, &stmt, NULL) != SQLITE_OK) {
  		ERROR_SQLITE(db, sql);
  		return (EPKG_FATAL);
***************
*** 204,210 ****
  		return (EPKG_OK);
  
  
! 	pkg_debug(4, "Pkgdb: pkgdb_load_deps running '%s'", mainsql);
  	ret = sqlite3_prepare_v2(sqlite, mainsql, -1, &stmt, NULL);
  
  	if (ret != SQLITE_OK) {
--- 203,209 ----
  		return (EPKG_OK);
  
  
! 	pkg_debug(4, "Pkgdb: running '%s'", mainsql);
  	ret = sqlite3_prepare_v2(sqlite, mainsql, -1, &stmt, NULL);
  
  	if (ret != SQLITE_OK) {
***************
*** 253,259 ****
  		return (EPKG_OK);
  
  
! 	pkg_debug(4, "Pkgdb: pkgdb_load_rdeps running '%s'", mainsql);
  	ret = sqlite3_prepare_v2(sqlite, mainsql, -1, &stmt, NULL);
  
  	if (ret != SQLITE_OK) {
--- 252,258 ----
  		return (EPKG_OK);
  
  
! 	pkg_debug(4, "Pkgdb: running '%s'", mainsql);
  	ret = sqlite3_prepare_v2(sqlite, mainsql, -1, &stmt, NULL);
  
  	if (ret != SQLITE_OK) {
***************
*** 301,307 ****
  	if (pkg->flags & PKG_LOAD_FILES)
  		return (EPKG_OK);
  
! 	pkg_debug(4, "Pkgdb: pkgdb_load_files running '%s'", sql);
  	if (sqlite3_prepare_v2(sqlite, sql, -1, &stmt, NULL) != SQLITE_OK) {
  		ERROR_SQLITE(sqlite, sql);
  		return (EPKG_FATAL);
--- 300,306 ----
  	if (pkg->flags & PKG_LOAD_FILES)
  		return (EPKG_OK);
  
! 	pkg_debug(4, "Pkgdb: running '%s'", sql);
  	if (sqlite3_prepare_v2(sqlite, sql, -1, &stmt, NULL) != SQLITE_OK) {
  		ERROR_SQLITE(sqlite, sql);
  		return (EPKG_FATAL);
***************
*** 345,351 ****
  	if (pkg->flags & PKG_LOAD_DIRS)
  		return (EPKG_OK);
  
! 	pkg_debug(4, "Pkgdb: pkgdb_load_dirs running '%s'", sql);
  	if (sqlite3_prepare_v2(sqlite, sql, -1, &stmt, NULL) != SQLITE_OK) {
  		ERROR_SQLITE(sqlite, sql);
  		return (EPKG_FATAL);
--- 344,350 ----
  	if (pkg->flags & PKG_LOAD_DIRS)
  		return (EPKG_OK);
  
! 	pkg_debug(4, "Pkgdb: running '%s'", sql);
  	if (sqlite3_prepare_v2(sqlite, sql, -1, &stmt, NULL) != SQLITE_OK) {
  		ERROR_SQLITE(sqlite, sql);
  		return (EPKG_FATAL);
***************
*** 543,549 ****
  	if (pkg->flags & PKG_LOAD_SCRIPTS)
  		return (EPKG_OK);
  
! 	pkg_debug(4, "Pkgdb: pkgdb_load_scripts running '%s'", sql);
  	if (sqlite3_prepare_v2(sqlite, sql, -1, &stmt, NULL) != SQLITE_OK) {
  		ERROR_SQLITE(sqlite, sql);
  		return (EPKG_FATAL);
--- 542,548 ----
  	if (pkg->flags & PKG_LOAD_SCRIPTS)
  		return (EPKG_OK);
  
! 	pkg_debug(4, "Pkgdb: running '%s'", sql);
  	if (sqlite3_prepare_v2(sqlite, sql, -1, &stmt, NULL) != SQLITE_OK) {
  		ERROR_SQLITE(sqlite, sql);
  		return (EPKG_FATAL);
*** pkg-1.4.0.pre-alpha15/libpkg/private/pkg.h	Mon Sep 15 12:33:26 2014
--- pkg-1.4.0.pre-alpha15.orig/libpkg/private/pkg.h	Sun Sep 14 15:11:40 2014
***************
*** 351,358 ****
  
  	pkg_repo_flags flags;
  
- 	/* order for repository */
-     int repo_order;
  	/* Opaque repository data */
  	void *priv;
  };
--- 351,356 ----
***************
*** 436,450 ****
  #define PKG_DELETE_NOSCRIPT (1<<2)
  #define PKG_DELETE_CONFLICT (1<<3)
  
! 
! struct pkg_key_x {
! 	int enum_tag;
  	const char *name;
  	int type;
! };
! 
! struct pkg_key_x *get_pkg_key_by_enum_tag( int enum_tag );
! struct pkg_key_x *get_pkg_key_by_name( const char *name );
  
  int pkg_fetch_file_to_fd(struct pkg_repo *repo, const char *url,
  		int dest, time_t *t);
--- 434,443 ----
  #define PKG_DELETE_NOSCRIPT (1<<2)
  #define PKG_DELETE_CONFLICT (1<<3)
  
! extern struct pkg_key {
  	const char *name;
  	int type;
! } pkg_keys[PKG_NUM_FIELDS];
  
  int pkg_fetch_file_to_fd(struct pkg_repo *repo, const char *url,
  		int dest, time_t *t);
*** pkg-1.4.0.pre-alpha15/libpkg/private/pkg_printf.h	Mon Sep 15 12:24:03 2014
--- pkg-1.4.0.pre-alpha15.orig/libpkg/private/pkg_printf.h	Sun Jun  8 12:59:53 2014
***************
*** 141,147 ****
  	PP_PKG_CHECKSUM,
  	PP_PKG_VERSION,
  	PP_PKG_HOME_PAGE,
- 	PP_PKG_REPO_ORDER,
  	PP_PKG_SHORT_CHECKSUM,
  	PP_LAST_FORMAT = PP_PKG_SHORT_CHECKSUM,
  	PP_LITERAL_PERCENT,
--- 141,146 ----
***************
*** 226,232 ****
  _static struct sbuf *format_short_checksum(struct sbuf *, const void *, struct percent_esc *);
  _static struct sbuf *format_version(struct sbuf *, const void *, struct percent_esc *);
  _static struct sbuf *format_home_url(struct sbuf *, const void *, struct percent_esc *);
- _static struct sbuf *format_repo_order(struct sbuf *, const void *, struct percent_esc *);
  _static struct sbuf *format_literal_percent(struct sbuf *, __unused const void *, __unused struct percent_esc *);
  _static struct sbuf *format_unknown(struct sbuf *, __unused const void *, __unused struct percent_esc *);
  
--- 225,230 ----
*** pkg-1.4.0.pre-alpha15/libpkg/repo/binary/init.c	Mon Sep 15 12:23:10 2014
--- pkg-1.4.0.pre-alpha15.orig/libpkg/repo/binary/init.c	Wed Aug 27 15:03:11 2014
***************
*** 137,143 ****
  
  	/* apply change */
  	if (ret == EPKG_OK) {
! 		pkg_debug(4, "Pkgdb: pkg_repo_binary_apply_change running '%s'", change->sql);
  		ret = sqlite3_exec(sqlite, change->sql, NULL, NULL, &errmsg);
  		if (ret != SQLITE_OK) {
  			pkg_emit_error("sqlite: %s", errmsg);
--- 137,143 ----
  
  	/* apply change */
  	if (ret == EPKG_OK) {
! 		pkg_debug(4, "Pkgdb: running '%s'", change->sql);
  		ret = sqlite3_exec(sqlite, change->sql, NULL, NULL, &errmsg);
  		if (ret != SQLITE_OK) {
  			pkg_emit_error("sqlite: %s", errmsg);
*** pkg-1.4.0.pre-alpha15/libpkg/repo/binary/query.c	Mon Sep 15 12:22:10 2014
--- pkg-1.4.0.pre-alpha15.orig/libpkg/repo/binary/query.c	Wed Aug 27 15:03:11 2014
***************
*** 128,134 ****
  	sbuf_cat(sql, " ORDER BY name;");
  	sbuf_finish(sql);
  
! 	pkg_debug(4, "Pkgdb: pkg_repo_binary_query running '%s' query for %s", sbuf_get(sql), pattern);
  	ret = sqlite3_prepare_v2(sqlite, sbuf_get(sql), sbuf_size(sql), &stmt, NULL);
  	if (ret != SQLITE_OK) {
  		ERROR_SQLITE(sqlite, sbuf_get(sql));
--- 128,134 ----
  	sbuf_cat(sql, " ORDER BY name;");
  	sbuf_finish(sql);
  
! 	pkg_debug(4, "Pkgdb: running '%s' query for %s", sbuf_get(sql), pattern);
  	ret = sqlite3_prepare_v2(sqlite, sbuf_get(sql), sbuf_size(sql), &stmt, NULL);
  	if (ret != SQLITE_OK) {
  		ERROR_SQLITE(sqlite, sbuf_get(sql));
***************
*** 167,173 ****
  
  	sbuf_finish(sql);
  
! 	pkg_debug(4, "Pkgdb: pkg_repo_binary_shlib_provide running '%s'", sbuf_get(sql));
  	ret = sqlite3_prepare_v2(sqlite, sbuf_get(sql), -1, &stmt, NULL);
  	if (ret != SQLITE_OK) {
  		ERROR_SQLITE(sqlite, sbuf_get(sql));
--- 167,173 ----
  
  	sbuf_finish(sql);
  
! 	pkg_debug(4, "Pkgdb: running '%s'", sbuf_get(sql));
  	ret = sqlite3_prepare_v2(sqlite, sbuf_get(sql), -1, &stmt, NULL);
  	if (ret != SQLITE_OK) {
  		ERROR_SQLITE(sqlite, sbuf_get(sql));
***************
*** 204,210 ****
  
  	sbuf_finish(sql);
  
! 	pkg_debug(4, "Pkgdb: pkg_repo_binary_shlib_require running '%s'", sbuf_get(sql));
  	ret = sqlite3_prepare_v2(sqlite, sbuf_get(sql), -1, &stmt, NULL);
  	if (ret != SQLITE_OK) {
  		ERROR_SQLITE(sqlite, sbuf_get(sql));
--- 204,210 ----
  
  	sbuf_finish(sql);
  
! 	pkg_debug(4, "Pkgdb: running '%s'", sbuf_get(sql));
  	ret = sqlite3_prepare_v2(sqlite, sbuf_get(sql), -1, &stmt, NULL);
  	if (ret != SQLITE_OK) {
  		ERROR_SQLITE(sqlite, sbuf_get(sql));
***************
*** 325,339 ****
  		"SELECT id, origin, name, version, comment, "
  		"prefix, desc, arch, maintainer, www, "
  		"licenselogic, flatsize, pkgsize, "
! 		"cksum, path AS repopath, '%1$s' AS dbname, '%2$s' AS repourl, "
!         "%3$d as repo_order "
  		"FROM packages ";
  
  	if (pattern == NULL || pattern[0] == '\0')
  		return (NULL);
  
  	sql = sbuf_new_auto();
! 	sbuf_printf(sql, multireposql, repo->name, repo->url, repo->repo_order );
  
  	/* close the UNIONs and build the search query */
  	sbuf_cat(sql, "WHERE ");
--- 325,338 ----
  		"SELECT id, origin, name, version, comment, "
  		"prefix, desc, arch, maintainer, www, "
  		"licenselogic, flatsize, pkgsize, "
! 		"cksum, path AS repopath, '%1$s' AS dbname, '%2$s' AS repourl "
  		"FROM packages ";
  
  	if (pattern == NULL || pattern[0] == '\0')
  		return (NULL);
  
  	sql = sbuf_new_auto();
! 	sbuf_printf(sql, multireposql, repo->name, repo->url);
  
  	/* close the UNIONs and build the search query */
  	sbuf_cat(sql, "WHERE ");
***************
*** 342,348 ****
  	sbuf_cat(sql, ";");
  	sbuf_finish(sql);
  
! 	pkg_debug(4, "Pkgdb: pkg_repo_binary_search running '%s'", sbuf_get(sql));
  	ret = sqlite3_prepare_v2(sqlite, sbuf_get(sql), -1, &stmt, NULL);
  	if (ret != SQLITE_OK) {
  		ERROR_SQLITE(sqlite, sbuf_get(sql));
--- 341,347 ----
  	sbuf_cat(sql, ";");
  	sbuf_finish(sql);
  
! 	pkg_debug(4, "Pkgdb: running '%s'", sbuf_get(sql));
  	ret = sqlite3_prepare_v2(sqlite, sbuf_get(sql), -1, &stmt, NULL);
  	if (ret != SQLITE_OK) {
  		ERROR_SQLITE(sqlite, sbuf_get(sql));
***************
*** 423,429 ****
  	}
  
  	sbuf_finish(sql);
! 	pkg_debug(4, "binary_repo: pkg_repo_binary_stat running '%s'", sbuf_data(sql));
  	ret = sqlite3_prepare_v2(sqlite, sbuf_data(sql), -1, &stmt, NULL);
  	if (ret != SQLITE_OK) {
  		ERROR_SQLITE(sqlite, sbuf_data(sql));
--- 422,428 ----
  	}
  
  	sbuf_finish(sql);
! 	pkg_debug(4, "binary_repo: running '%s'", sbuf_data(sql));
  	ret = sqlite3_prepare_v2(sqlite, sbuf_data(sql), -1, &stmt, NULL);
  	if (ret != SQLITE_OK) {
  		ERROR_SQLITE(sqlite, sbuf_data(sql));
*** pkg-1.4.0.pre-alpha15/src/check.c	Mon Sep 15 12:17:49 2014
--- pkg-1.4.0.pre-alpha15.orig/src/check.c	Thu Aug 28 11:58:05 2014
***************
*** 253,259 ****
  	bool reanalyse_shlibs = false;
  	bool noinstall = false;
  	int nbpkgs = 0;
! 	int i, processed = 0, total = 0;
  	int verbose = 0;
  
  	struct option longopts[] = {
--- 253,259 ----
  	bool reanalyse_shlibs = false;
  	bool noinstall = false;
  	int nbpkgs = 0;
! 	int i, processed, total;
  	int verbose = 0;
  
  	struct option longopts[] = {
*** pkg-1.4.0.pre-alpha15/src/event.c	Mon Sep 15 12:14:22 2014
--- pkg-1.4.0.pre-alpha15.orig/src/event.c	Thu Aug 28 11:58:05 2014
***************
*** 412,418 ****
  {
  	int percent;
  	int64_t transferred;
! 	time_t elapsed = 0, now = 0;
  	char buf[7];
  	int64_t bytes_left;
  	int cur_speed;
--- 412,418 ----
  {
  	int percent;
  	int64_t transferred;
! 	time_t elapsed, now;
  	char buf[7];
  	int64_t bytes_left;
  	int cur_speed;
*** pkg-1.4.0.pre-alpha15/src/pkgcli.h	Mon Sep 15 12:10:10 2014
--- pkg-1.4.0.pre-alpha15.orig/src/pkgcli.h	Wed Aug 27 15:03:11 2014
***************
*** 214,226 ****
  #define INFO_DIRS		(1LL<<23)
  #define INFO_USERS		(1LL<<24)
  #define INFO_GROUPS		(1LL<<25)
! #define INFO_REPOURL	(1LL<<26)
  #define INFO_LOCKED		(1LL<<27)
! #define INFO_REPO_ORDER	(1LL<<28)
! #define INFO_OPTION_DEFAULTS    (1LL<<29)
! #define INFO_OPTION_DESCRIPTIONS (1LL<<30)
  
! #define INFO_LASTFIELD	INFO_REPO_ORDER
  #define INFO_ALL	(((INFO_LASTFIELD) << 1) - 1)
  
  /* Identifying tags */
--- 214,225 ----
  #define INFO_DIRS		(1LL<<23)
  #define INFO_USERS		(1LL<<24)
  #define INFO_GROUPS		(1LL<<25)
! #define INFO_REPOURL		(1LL<<26)
  #define INFO_LOCKED		(1LL<<27)
! #define INFO_OPTION_DEFAULTS    (1LL<<28)
! #define INFO_OPTION_DESCRIPTIONS (1LL<<29)
  
! #define INFO_LASTFIELD	INFO_LOCKED
  #define INFO_ALL	(((INFO_LASTFIELD) << 1) - 1)
  
  /* Identifying tags */
*** pkg-1.4.0.pre-alpha15/src/search.c	Mon Sep 15 12:08:38 2014
--- pkg-1.4.0.pre-alpha15.orig/src/search.c	Mon Aug  4 14:59:40 2014
***************
*** 69,75 ****
  	{ "options",              'o'  },
  	{ "pkg-size",	          'P'  },
  	{ "prefix",               'p'  },
- 	{ "repo_order",           'Z'  },
  	{ "repository",           'R'  },
  	{ "required-by",          'r'  },
  	{ "shared-libs-required", 'B'  },
--- 69,74 ----
***************
*** 177,185 ****
  	case 'o':
  		opt = INFO_OPTIONS;
  		break;
- 	case 'Z':
- 		opt = INFO_REPO_ORDER;
- 		break;
  	case 'P':
  		opt = INFO_PKGSIZE;
  		break;
--- 176,181 ----
***************
*** 212,218 ****
  		break;
  	default:
  		usage_search();
! 		errx(EX_USAGE, "Unknown modifier option %s", optionarg);
  		/* NOTREACHED */
  	}
  	return opt;
--- 208,214 ----
  		break;
  	default:
  		usage_search();
! 		errx(EX_USAGE, "Unkown modifier option %s", optionarg);
  		/* NOTREACHED */
  	}
  	return opt;
*** pkg-1.4.0.pre-alpha15/src/utils.c	Mon Sep 15 12:03:42 2014
--- pkg-1.4.0.pre-alpha15.orig/src/utils.c	Wed Aug 27 15:03:11 2014
***************
*** 472,482 ****
  				printf("%-15s: ", "WWW");
  			pkg_printf("%w\n", pkg);
  			break;
- 		case INFO_REPO_ORDER:	
- 			if (print_tag)
- 				printf("%-15s: ", "Repo_order");
- 			pkg_printf("%Z\n", pkg);
- 			break;
  		case INFO_COMMENT:
  			if (print_tag)
  				printf("%-15s: ", "Comment");
--- 472,477 ----
*** pkg-1.4.0.pre-alpha15/src/which.c	Mon Sep 15 12:03:02 2014
--- pkg-1.4.0.pre-alpha15.orig/src/which.c	Wed Aug 27 15:03:11 2014
***************
*** 57,66 ****
  	struct pkgdb_it	*it = NULL;
  	struct pkg	*pkg = NULL;
  	char		 pathabs[MAXPATHLEN];
! 	char		*p, *path = 0, *match;
  	int		 ret = EPKG_OK, retcode = EX_SOFTWARE;
  	int		 ch;
! 	int		 res, pathlen = 0;
  	bool		 orig = false;
  	bool		 glob = false;
  	bool		 search = false;
--- 57,66 ----
  	struct pkgdb_it	*it = NULL;
  	struct pkg	*pkg = NULL;
  	char		 pathabs[MAXPATHLEN];
! 	char		*p, *path, *match;
  	int		 ret = EPKG_OK, retcode = EX_SOFTWARE;
  	int		 ch;
! 	int		 res, pathlen;
  	bool		 orig = false;
  	bool		 glob = false;
  	bool		 search = false;


More information about the freebsd-ports mailing list