[CVS] RPM: rpm/tools/ Makefile.am txar.c

2007-11-11 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:  [EMAIL PROTECTED]
  Module: rpm  Date:   11-Nov-2007 19:49:45
  Branch: HEAD Handle: 200718494500

  Modified files:
rpm/tools   Makefile.am txar.c

  Log:
fix building txar with internal xar

  Summary:
RevisionChanges Path
2.102   +4  -2  rpm/tools/Makefile.am
2.9 +1  -1  rpm/tools/txar.c
  

  patch -p0 <<'@@ .'
  Index: rpm/tools/Makefile.am
  
  $ cvs diff -u -r2.101 -r2.102 Makefile.am
  --- rpm/tools/Makefile.am 18 Sep 2007 19:19:21 -  2.101
  +++ rpm/tools/Makefile.am 11 Nov 2007 18:49:45 -  2.102
  @@ -7,7 +7,8 @@
-I$(top_srcdir)/lib \
-I$(top_srcdir)/rpmdb \
-I$(top_srcdir)/rpmio \
  - -I$(top_srcdir)/misc
  + -I$(top_srcdir)/misc \
  + @WITH_XAR_CPPFLAGS@
   
   EXTRA_DIST = hashtab.h
   
  @@ -49,7 +50,8 @@
   ## XAR package format work-in-progress.
   ##
   txar_SOURCES =   txar.c
  -txar_LDADD = $(myLDADD) -lxar
  +txar_LDADD = $(myLDADD) @WITH_XAR_LDFLAGS@
  +txar_LIBS =  @WITH_XAR_LIBS@
   
   ##
   ##  provide Berkeley-DB tools
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/tools/txar.c
  
  $ cvs diff -u -r2.8 -r2.9 txar.c
  --- rpm/tools/txar.c  10 Nov 2007 20:09:25 -  2.8
  +++ rpm/tools/txar.c  11 Nov 2007 18:49:45 -  2.9
  @@ -2,7 +2,7 @@
   #define  RPM2XAR
   #include "system.h"
   #include 
  -#include 
  +#include "xar.h"
   #include 
   #include 
   
  @@ .
__
RPM Package Managerhttp://rpm5.org
CVS Sources Repositoryrpm-cvs@rpm5.org


[CVS] RPM: rpm/tools/ Makefile.am txar.c

2007-08-29 Thread Jeff Johnson
  RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  

  Server: rpm5.org Name:   Jeff Johnson
  Root:   /v/rpm/cvs   Email:  [EMAIL PROTECTED]
  Module: rpm  Date:   29-Aug-2007 14:50:24
  Branch: HEAD Handle: 2007082913502400

  Added files:
rpm/tools   txar.c
  Modified files:
rpm/tools   Makefile.am

  Log:
preliminaries for converting *.rpm <-> *.xar (of the Leopard-like
persuasion).

  Summary:
RevisionChanges Path
2.99+4  -1  rpm/tools/Makefile.am
2.1 +304 -0 rpm/tools/txar.c
  

  patch -p0 <<'@@ .'
  Index: rpm/tools/Makefile.am
  
  $ cvs diff -u -r2.98 -r2.99 Makefile.am
  --- rpm/tools/Makefile.am 18 Aug 2007 16:45:02 -  2.98
  +++ rpm/tools/Makefile.am 29 Aug 2007 12:50:24 -  2.99
  @@ -11,7 +11,7 @@
   
   EXTRA_DIST = hashtab.h
   
  -EXTRA_PROGRAMS = debugedit rpmkey
  +EXTRA_PROGRAMS = debugedit rpmkey txar
   
   myLDADD = \
$(top_builddir)/build/librpmbuild.la \
  @@ -45,6 +45,9 @@
   rpmkey_SOURCES =rpmkey.c
   rpmkey_LDADD =  $(myLDADD) -lkeyutils
   
  +txar_SOURCES =   txar.c
  +txar_LDADD = $(myLDADD) -lxar
  +
   ##
   ##  provide Berkeley-DB tools
   ##
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/tools/txar.c
  
  $ cvs diff -u -r0 -r2.1 txar.c
  --- /dev/null 2007-08-29 14:48:57 +0200
  +++ txar.c2007-08-29 14:50:24 +0200
  @@ -0,0 +1,304 @@
  +
  +#define  RPM2XAR
  +#include "system.h"
  +#include 
  +#include 
  +#include 
  +#include "debug.h"
  +
  +static int _debug = 0;
  +
  +typedef struct rpmmap_s {
  +const char * fn;
  +FD_t fd;
  +void * b;
  +size_t nb;
  +char * l;
  +size_t nl;
  +char * s;
  +size_t ns;
  +char * h;
  +size_t nh;
  +char * p;
  +size_t np;
  +xar_t x;
  +xar_file_t f;
  +xar_iter_t i;
  +} * rpmmap;
  +
  +static rpmmap rpmmapFree(rpmmap map)
  +{
  +if (map) {
  + int xx;
  +
  + if (map->b) {
  + xx = munmap(map->b, map->nb);
  + map->b = NULL;
  + map->nb = 0;
  + } else {
  + map->l = _free(map->l);
  + map->s = _free(map->s);
  + map->h = _free(map->h);
  + map->p = _free(map->p);
  + }
  + if (map->fd) {
  + (void) Fclose(map->fd);
  + map->fd = NULL;
  + }
  + map->fn = _free(map->fn);
  + map = _free(map);
  +}
  +return NULL;
  +}
  +
  +static rpmmap rpmmapNew(const char * fn)
  +{
  +rpmmap map = xcalloc(1, sizeof(*map));
  +struct stat sb, *st = &sb;
  +int xx;
  +
  +map->fn = xstrdup(fn);
  +xx = Stat(map->fn, st);
  +map->nb = st->st_size;
  +
  +return map;
  +}
  +
  +static size_t hSize(uint_32 *p)
  +{
  +return (8 + 8 + 16 * ntohl(p[2]) + ntohl(p[3]));
  +}
  +
  +static rpmmap rdRPM(const char * rpmfn)
  +{
  +rpmmap map = rpmmapNew(rpmfn);
  +
  +map->fd = Fopen(map->fn, "r");
  +
  +map->b = mmap(NULL, map->nb, PROT_READ, MAP_SHARED, Fileno(map->fd), 0);
  +
  +map->l = map->b;
  +map->nl = 96;
  +
  +map->s = map->l + map->nl;
  +map->ns = hSize((void *)map->s);
  +map->ns += (8 - (map->ns % 8));  /* padding */
  +
  +map->h = map->s + map->ns;
  +map->nh = hSize((void *)map->h);
  +
  +map->p = map->h + map->nh;
  +map->np = map->nb;
  +map->np -= map->nl + map->ns + map->nh;
  +
  +return map;
  +}
  +
  +static rpmmap rdXAR(const char * xarfn)
  +{
  +rpmmap map = rpmmapNew(xarfn);
  +
  +map->x = xar_open(map->fn, READ);
  +
  +map->i = xar_iter_new();
  +for (map->f = xar_file_first(map->x, map->i);
  +  map->f != NULL;
  +  map->f = xar_file_next(map->i))
  +{
  +#if 0
  + const char * key;
  + xar_iter_t p;
  +
  + p = xar_iter_new();
  + for (key = xar_prop_first(map->f, p);
  +  key != NULL;
  +  key = xar_prop_next(p))
  + {
  + const char * val = NULL;
  + xar_prop_get(map->f, key, &val);
  + fprintf(stderr, "key: %s, value: %s\n", key, val);
  + }
  + xar_iter_free(p);
  +#else
  + const char * type;
  + const char * name;
  + char * b;
  + size_t nb;
  + int xx;
  +
  + b = NULL;
  + nb = 0;
  + xx = xar_extract_tobuffersz(map->x, map->f, &b, &nb);
  +if (_debug)
  +fprintf(stderr, "*** xx %d %p[%lu]\n", xx, b, (unsigned long)nb);
  + if (xx || b == NULL || nb == 0)
  + continue;
  +
  + type = NULL;
  + xx = xar_prop_get(map->f, "type", &type);