[CVS] RPM: rpm/ CHANGES rpm/rpmio/ libsqlio.c rpmsql.c rpmsql.h

2010-04-20 Thread Jeff Johnson
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  

  Server: rpm5.org Name:   Jeff Johnson
  Root:   /v/rpm/cvs   Email:  j...@rpm5.org
  Module: rpm  Date:   21-Apr-2010 00:35:56
  Branch: HEAD Handle: 2010042022355501

  Modified files:
rpm CHANGES
rpm/rpmio   libsqlio.c rpmsql.c rpmsql.h

  Log:
- rpmvt: resurrect Nixdb against db.sqlite ValidPaths(path).

  Summary:
RevisionChanges Path
1.3332  +1  -0  rpm/CHANGES
2.2 +47 -1  rpm/rpmio/libsqlio.c
2.51+18 -0  rpm/rpmio/rpmsql.c
2.25+1  -0  rpm/rpmio/rpmsql.h
  

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  
  $ cvs diff -u -r1.3331 -r1.3332 CHANGES
  --- rpm/CHANGES   19 Apr 2010 16:35:00 -  1.3331
  +++ rpm/CHANGES   20 Apr 2010 22:35:55 -  1.3332
  @@ -1,5 +1,6 @@
   
   5.2b1 -> 5.3a1
  +- jbj: rpmvt: resurrect Nixdb against db.sqlite ValidPaths(path).
   - jbj: rpmvt: stub-in a loadable libsqldb.so module.
   - jbj: rpmvt: stub-in a loadable libsql.so module.
   - jbj: rpmvt: stub-in a loadable libsqlio.so module.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/libsqlio.c
  
  $ cvs diff -u -r2.1 -r2.2 libsqlio.c
  --- rpm/rpmio/libsqlio.c  19 Apr 2010 15:32:20 -  2.1
  +++ rpm/rpmio/libsqlio.c  20 Apr 2010 22:35:55 -  2.2
  @@ -10,10 +10,56 @@
   #include "debug.h"
   
   /*==*/
  +#ifdef   REFERENCE
  +create table if not exists ValidPaths (
  +id   integer primary key autoincrement not null,
  +path text unique not null,
  +hash text not null,
  +registrationTime integer not null,
  +deriver  text
  +);
  +
  +create table if not exists Refs (
  +referrer  integer not null,
  +reference integer not null,
  +primary key (referrer, reference),
  +foreign key (referrer) references ValidPaths(id) on delete cascade,
  +foreign key (reference) references ValidPaths(id) on delete restrict
  +);
  +
  +create index if not exists IndexReferrer on Refs(referrer);
  +create index if not exists IndexReference on Refs(reference);
  +
  +-- Paths can refer to themselves, causing a tuple (N, N) in the Refs
  +-- table.  This causes a deletion of the corresponding row in
  +-- ValidPaths to cause a foreign key constraint violation (due to `on
  +-- delete restrict' on the `reference' column).  Therefore, explicitly
  +-- get rid of self-references.
  +create trigger if not exists DeleteSelfRefs before delete on ValidPaths
  +  begin
  +delete from Refs where referrer = old.id and reference = old.id;
  +  end;
  +
  +create table if not exists DerivationOutputs (
  +drv  integer not null,
  +id   text not null, -- symbolic output id, usually "out"
  +path text not null,
  +primary key (drv, id),
  +foreign key (drv) references ValidPaths(id) on delete cascade
  +);
  +
  +create index if not exists IndexDerivationOutputs on DerivationOutputs(path);
  +
  +create table if not exists FailedPaths (
  +path text primary key not null,
  +time integer not null
  +);
  +#endif
   
   static struct rpmvd_s _nixdbVD = {
  +.dbpath = "/nix/var/nix/db/db.sqlite",
/* XXX glob needs adjustment for base32 and possibly length. */
  - .prefix = "%{?_nixdb}%{!?_nixdb:/nix/store}/[a-z0-9]*-",
  + .prefix = "/nix/store/[a-z0-9]*-",
.split  = "/-",
.parse  = "dir/instance-name",
.regex  = "^(.+/)([^-]+)-(.*)$",
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmsql.c
  
  $ cvs diff -u -r2.50 -r2.51 rpmsql.c
  --- rpm/rpmio/rpmsql.c20 Apr 2010 10:54:18 -  2.50
  +++ rpm/rpmio/rpmsql.c20 Apr 2010 22:35:55 -  2.51
  @@ -219,6 +219,24 @@
   
   (void) urlPath(uri, (const char **) &fn);
   
  +if (!strcasecmp(vt->argv[0], "nixdb")) {
  + static const char _cmd[] = "select path from ValidPaths;";
  + const char * out =
  + rpmExpand("%{sql ", vd->dbpath, ":", _cmd, "}", NULL);
  + const char ** oav = NULL;
  + int yy = argvSplit(&oav, out, "\n");
  + int oac = argvCount(oav);
  + miRE mire = mireNew(RPMMIRE_GLOB, 0);
  + yy = mireRegcomp(mire, uri);
  + for (i = 0; i < oac; i++) {
  + if (mireRegexec(mire, oav[i], strlen(oav[i])))
  + continue;
  + yy = argvAdd(&vt->av, oav[i]);
  + }
  +

[CVS] RPM: rpm/rpmio/ macro.c

2010-04-20 Thread Anders F. Bj�rklund
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  

  Server: rpm5.org Name:   Anders F. Björklund
  Root:   /v/rpm/cvs   Email:  a...@rpm5.org
  Module: rpm  Date:   20-Apr-2010 15:22:28
  Branch: HEAD Handle: 2010042013222700

  Modified files:
rpm/rpmio   macro.c

  Log:
fix conditionals, minor typo on WITH_SQLITE

  Summary:
RevisionChanges Path
2.248   +2  -2  rpm/rpmio/macro.c
  

  patch -p0 <<'@@ .'
  Index: rpm/rpmio/macro.c
  
  $ cvs diff -u -r2.247 -r2.248 macro.c
  --- rpm/rpmio/macro.c 4 Apr 2010 14:35:44 -   2.247
  +++ rpm/rpmio/macro.c 20 Apr 2010 13:22:27 -  2.248
  @@ -99,7 +99,7 @@
   #include "debug.h"
   
   /*...@unchecked@*/
  -#if defined(WITH_AUGEAS) || defined(WITH_FICL) || defined(WITH_JS) || 
defined(WITH_NIX) || defined(WITH_PERLEMBED) || defined(WITH_PYTHONEMBED) || 
defined(WITH_RUBYEMBED) || defined(WITH_SQL) || defined(WITH_SQUIRREL) || 
defined(WITH_TCL)
  +#if defined(WITH_AUGEAS) || defined(WITH_FICL) || defined(WITH_JS) || 
defined(WITH_NIX) || defined(WITH_PERLEMBED) || defined(WITH_PYTHONEMBED) || 
defined(WITH_RUBYEMBED) || defined(WITH_SQLITE) || defined(WITH_SQUIRREL) || 
defined(WITH_TCL)
   static int _globalI = 0x8000;
   #endif
   
  @@ -1587,7 +1587,7 @@
* @retval *avp  invocation args
* @return   script string
*/
  -#if defined(WITH_AUGEAS) || defined(WITH_FICL) || defined(WITH_JS) || 
defined(WITH_PERLEMBED) || defined(WITH_PYTHONEMBED) || defined(WITH_RUBYEMBED) 
|| defined(WITH_SQUIRREL) || defined(WITH_TCL)
  +#if defined(WITH_AUGEAS) || defined(WITH_FICL) || defined(WITH_JS) || 
defined(WITH_PERLEMBED) || defined(WITH_PYTHONEMBED) || defined(WITH_RUBYEMBED) 
|| defined(WITH_SQLITE) || defined(WITH_SQUIRREL) || defined(WITH_TCL)
   static char * parseEmbedded(const char * s, size_t nb, char *** avp)
/*...@*/
   {
  @@ .
__
RPM Package Managerhttp://rpm5.org
CVS Sources Repositoryrpm-cvs@rpm5.org


[CVS] RPM: rpm/ configure.ac

2010-04-20 Thread Anders F. Bj�rklund
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  

  Server: rpm5.org Name:   Anders F. Björklund
  Root:   /v/rpm/cvs   Email:  a...@rpm5.org
  Module: rpm  Date:   20-Apr-2010 15:18:46
  Branch: HEAD Handle: 2010042013184600

  Modified files:
rpm configure.ac

  Log:
add missing sys/time.h detection, for use in system.h

  Summary:
RevisionChanges Path
2.434   +1  -1  rpm/configure.ac
  

  patch -p0 <<'@@ .'
  Index: rpm/configure.ac
  
  $ cvs diff -u -r2.433 -r2.434 configure.ac
  --- rpm/configure.ac  3 Apr 2010 15:55:58 -   2.433
  +++ rpm/configure.ac  20 Apr 2010 13:18:46 -  2.434
  @@ -575,7 +575,7 @@
   dnl # standard headers (generic)
   AC_CHECK_HEADERS([dnl
   fcntl.h getopt.h grp.h memory.h netdb.h pwd.h utime.h dnl
  -signal.h sys/ipc.h sys/socket.h sys/select.h dnl
  +signal.h sys/ipc.h sys/socket.h sys/select.h sys/time.h dnl
   sys/types.h sys/stdtypes.h sys/mman.h sys/resource.h dnl
   sys/utsname.h sys/prctl.h sys/wait.h netinet/in_systm.h dnl
   machine/types.h mntent.h sys/mnttab.h sys/systemcfg.h dnl
  @@ .
__
RPM Package Managerhttp://rpm5.org
CVS Sources Repositoryrpm-cvs@rpm5.org


[CVS] RPM: rpm/rpmio/ rpmsql.c rpmsql.h

2010-04-20 Thread Jeff Johnson
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  

  Server: rpm5.org Name:   Jeff Johnson
  Root:   /v/rpm/cvs   Email:  j...@rpm5.org
  Module: rpm  Date:   20-Apr-2010 12:54:19
  Branch: HEAD Handle: 2010042010541800

  Modified files:
rpm/rpmio   rpmsql.c rpmsql.h

  Log:
- rpmsql: simplify vtab column sql spewage.

  Summary:
RevisionChanges Path
2.50+75 -102rpm/rpmio/rpmsql.c
2.24+4  -0  rpm/rpmio/rpmsql.h
  

  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmsql.c
  
  $ cvs diff -u -r2.49 -r2.50 rpmsql.c
  --- rpm/rpmio/rpmsql.c19 Apr 2010 15:32:20 -  2.49
  +++ rpm/rpmio/rpmsql.c20 Apr 2010 10:54:18 -  2.50
  @@ -37,7 +37,7 @@
   #include "debug.h"
   
   /*...@unchecked@*/
  -int _rpmsql_debug = -1;
  +int _rpmsql_debug = 0;
   
   /*...@unchecked@*/
   int _rpmvt_debug = -1;
  @@ -132,117 +132,93 @@
   
   /*==*/
   
  +static char * _rpmvtJoin(const char * a, const char ** argv, const char * z)
  +{
  +const char ** av;
  +size_t na = strlen(a);
  +size_t nb = 0;
  +size_t nz = strlen(z);
  +char *t, *te;
  +
  +for (av = argv; *av != NULL; av++)
  + nb += na + strlen(*av) + nz;
  +
  +te = t = xmalloc(nb + 1);
  +for (av = argv; *av != NULL; av++)
  + te = stpcpy(stpcpy(stpcpy(te, a), *av), z);
  +*te = '\0';
  +
  +return t;
  +}
  +
  +static char * _rpmvtAppendCols(rpmvt vt, const char ** av)
  +{
  +char * h = _rpmvtJoin("\t'", av, "' HIDDEN TEXT,\n");
  +int xx = argvAppend(&vt->cols, av);
  +char * u;
  +char * hu;
  +
  +av = (const char **) (vt->argc > 4 ? &vt->argv[4] : vt->fields);
  +assert(av);
  +u = _rpmvtJoin("\t'", av, "' TEXT,\n");
  +u[strlen(u)-2] = ' ';/* XXX nuke the final comma */
  +xx = argvAppend(&vt->cols, av);
  +
  +#define  dbN vt->argv[1]
  +#define  tblNvt->argv[2]
  +hu = rpmExpand("CREATE TABLE ", dbN, ".", tblN, " (\n", h, u, ");", 
NULL);
  +#undef   dbN
  +#undef   tblN
  +
  +u = _free(u);
  +h = _free(h);
  +
  +fprintf(stderr, "%s\n", hu);
  +return hu;
  +}
  +
   int rpmvtLoadArgv(rpmvt vt, rpmvt * vtp)
   {
  -static const char _type[] = "TEXT";
  -rpmsql sql = _rpmsqlI;
   sqlite3 * db = (sqlite3 *) vt->db;
  -#define  modName vt->argv[0]
  -#define  dbName  vt->argv[1]
  -#define  tblName vt->argv[2]
  -
   rpmvd vd = vt->vd;
  -const char * uprefix;
  -const char * prefix;
  +
  +static const char * hidden[] = { "path", "id", NULL };
  +const char * hu;
   
   char * uri = NULL;
  -size_t nuri;
   struct stat sb;
   
  -char * fn;
  -size_t nfn;
  -char * t, * te;
  +const char * fn = NULL;
   
  -size_t nb;
   int rc = SQLITE_OK;
   int xx;
   int i;
   
  -static const char _hidden[] = "\
  -\t'path' HIDDEN TEXT,\n\
  -\t'id' HIDDEN TEXT,\n\
  -";
  -
   fprintf(stderr, "--> %s(%p,%p)\n", __FUNCTION__, vt, vtp);
   argvPrint("vt->argv", (ARGV_t)vt->argv, NULL);
   
  -prefix = (vd->prefix ? vd->prefix : "");
  +/* Set the columns in the schema. */
  +hu = _rpmvtAppendCols(vt, hidden);
  +rc = rpmsqlCmd(NULL, "declare_vtab", db,
  + sqlite3_declare_vtab(db, hu));
  +hu = _free(hu);
  +
   if (vt->argv[3]) {
/* XXX slice out the quotes that sqlite passes through ...  */
static char _quotes[] = "'\"";
int quoted = (strchr(_quotes, *vt->argv[3]) != NULL);
  - uri = rpmExpand(vt->argv[3] + quoted, NULL);
  - nuri = strlen(uri);
  - if (quoted) uri[--nuri] = '\0';
  - /* XXX Strip file:/// et al (if present). */
  - (void) urlPath(uri, &uprefix);
  + const char * prefix;
  + const char * path = NULL;
/* XXX Prefer user override to global prefix (if absolute path). */
  - if (*uprefix == '/')
  - prefix = "";
  + (void) urlPath(vt->argv[3]+quoted, &path);
  + prefix = (*path != '/' && vd->prefix ? vd->prefix : "");
  + uri = rpmGetPath(prefix, path, NULL);
  + uri[strlen(uri)-quoted] = '\0';
   } else
  - uprefix = NULL;
  -
  -fn = rpmGetPath(prefix, uprefix, NULL);
  -nfn = strlen(fn);
  -
  -nb = 0;
  -nb += sizeof("CREATE TABLE ") - 1;
  -nb += strlen(dbName) + (sizeof(".")-1) + strlen(tblName);
  -nb += (sizeof(" (\n")-1);
  + uri = rpmGetPath(vd->prefix, fn, NULL);
   
  -nb += strlen(_hidden);
  +(void) urlPath(uri, (const char **) &fn);
   
  -if (vt->argc <= 4) {
  -assert(vt->fi