+++ /dev/null
-diff -urN poldek-0.18.8.org/pkgfl.c poldek-0.18.8/pkgfl.c
---- poldek-0.18.8.org/pkgfl.c 2004-12-30 13:05:22.000000000 +0100
-+++ poldek-0.18.8/pkgfl.c 2005-04-21 22:06:58.126819592 +0200
-@@ -530,7 +530,7 @@
- tn_buf *nbuf;
- tn_buf_it nbufi;
- uint32_t size;
-- char *buf;
-+ char *buf, dummy;
-
- if (fread(&size, sizeof(size), 1, stream) != 1)
- return NULL;
-@@ -548,7 +548,7 @@
- fl = pkgfl_restore(&nbufi, dirs, include);
- n_buf_free(nbuf);
-
-- fseek(stream, 1, SEEK_CUR); /* skip final '\n' */
-+ fread(&dummy, 1, 1, stream); /* skip final '\n' */
-
- return fl;
- }
-@@ -557,12 +557,18 @@
- int pkgfl_skip_f(FILE *stream)
- {
- uint32_t size;
-+ char *buf;
-
- if (fread(&size, sizeof(size), 1, stream) != 1)
- return 0;
-
- size = ntoh32(size);
-- fseek(stream, size + 1, SEEK_CUR);
-+ buf = malloc(size + 1);
-+ if (buf)
-+ fread(buf, 1, size + 1, stream);
-+ else
-+ fseek(stream, size + 1, SEEK_CUR);
-+ free(buf);
- return 1;
- }
-
-diff -urN poldek-0.18.8.org/pkgu.c poldek-0.18.8/pkgu.c
---- poldek-0.18.8.org/pkgu.c 2002-05-15 17:42:48.000000000 +0200
-+++ poldek-0.18.8/pkgu.c 2005-04-21 22:47:36.188177928 +0200
-@@ -180,11 +180,36 @@
- void *rawhdr;
- Header hdr;
-
-- if (offset > 0)
-- if (fseek(stream, offset, SEEK_SET) != 0) {
-- logn(LOGERR, "pkguinf_restore: fseek %ld: %m", offset);
-- return NULL;
-- }
-+ if (offset > 0) {
-+ long currseek = ftell(stream);
-+ char *buf = NULL;
-+ if (currseek == -1) {
-+ logn(LOGERR, "pkguinf_restore: ftell %ld: %m", currseek);
-+ return NULL;
-+ }
-+ if (offset >= currseek) {
-+ currseek = offset - currseek;
-+ if (currseek) {
-+ buf = malloc(currseek);
-+ if (!buf) {
-+ logn(LOGERR, "pkguinf_restore: malloc: %m");
-+ return NULL;
-+ }
-+ if (fread(buf, 1, currseek, stream) != currseek) {
-+ logn(LOGERR, "pkguinf_restore: fread error currseek: at %ld %p",
-+ ftell(stream), stream);
-+ return NULL;
-+ }
-+ free(buf);
-+ }
-+ } else {
-+
-+ if (fseek(stream, offset, SEEK_SET) != 0) {
-+ logn(LOGERR, "pkguinf_restore: fseek %ld: %m", offset);
-+ return NULL;
-+ }
-+ }
-+ }
-
- if (fread(&nlangs, sizeof(nlangs), 1, stream) != 1) {
- logn(LOGERR, "pkguinf_restore: read error nlangs (%m) at %ld %p",
-@@ -239,8 +264,8 @@
- {
- uint16_t nsize, nlangs;
-
-- fseek(stream, sizeof(nlangs), SEEK_CUR);
-- if (fread(&nsize, sizeof(nsize), 1, stream) != 1) {
-+ if ((fread(&nlangs, sizeof(nlangs), 1, stream) != 1) ||
-+ (fread(&nsize, sizeof(nsize), 1, stream) != 1)) {
- nsize = 0;
- } else {
- nsize = ntoh16(nsize);
-diff -urN poldek-0.18.8.org/trurlib/nstream.c poldek-0.18.8/trurlib/nstream.c
---- poldek-0.18.8.org/trurlib/nstream.c 2004-05-06 09:57:45.000000000 +0200
-+++ poldek-0.18.8/trurlib/nstream.c 2005-04-21 22:04:22.622459848 +0200
-@@ -57,8 +57,10 @@
- z_off_t rc, off = *offset;
-
- rc = gzseek(stream, off, whence);
-- if (rc >= 0)
-+ if (rc >= 0) {
-+ *offset = rc;
- rc = 0;
-+ }
- #if ZLIB_TRACE
- printf("zfseek (%p, %ld, %lld, %d) = %d\n", stream, off, *offset, whence, rc);
- #endif
-@@ -281,7 +283,7 @@
-
- } else {
- st->stream = stream;
-- fseek(st->stream, 0, SEEK_SET); /* glibc BUG (?) */
-+ fseek(st->stream, 0, SEEK_SET); /* XXX glibc BUG (?) */
- st->type = type;
- };
- break;
-diff -urN poldek-0.18.8.org/vfile/vfile.c poldek-0.18.8/vfile/vfile.c
---- poldek-0.18.8.org/vfile/vfile.c 2004-02-26 19:22:28.000000000 +0100
-+++ poldek-0.18.8/vfile/vfile.c 2005-04-21 22:04:22.630458632 +0200
-@@ -129,8 +129,10 @@
- z_off_t rc, off = *offset;
-
- rc = gzseek(stream, off, whence);
-- if (rc >= 0)
-+ if (rc >= 0) {
-+ *offset = rc;
- rc = 0;
-+ }
- #if ZLIB_TRACE
- printf("zfseek (%p, %ld, %lld, %d) = %d\n", stream, off, *offset, whence, rc);
- #endif
-@@ -344,7 +346,16 @@
- vf->vf_stream = fopencookie(gzstream, mode, gzio_cookie);
- if (vf->vf_stream != NULL) {
- rc = 1;
-- fseek(vf->vf_stream, 0, SEEK_SET); /* glibc BUG (?) */
-+ vf->vf_buf = malloc(128); /* use small buffer to avoid reverse gzseeks on small forward fseeks */
-+ if(vf->vf_buf == NULL)
-+ vfile_err_fn("buffer malloc failed for %s\n", CL_URL(path));
-+ else
-+ if(setvbuf(vf->vf_stream, vf->vf_buf, _IOFBF, 128) != 0) {
-+ vfile_err_fn("setvbuf failed for %s\n", CL_URL(path));
-+ free(vf->vf_buf);
-+ vf->vf_buf = NULL;
-+ }
-+ fseek(vf->vf_stream, 0, SEEK_SET); /* XXX glibc BUG (?) */
- } else
- vfile_err_fn("fopencookie %s: hgw error\n", CL_URL(path));
-
-@@ -484,6 +495,7 @@
- vf.vf_type = vftype;
- vf.vf_mode = vfmode;
- vf.vf_flags = 0;
-+ vf.vf_buf = NULL;
-
- urltype = vf_url_type(path);
- opened = 0;
-@@ -681,6 +693,8 @@
- free(vf->vf_tmpath);
- vf->vf_tmpath = NULL;
- }
-+ if (vf->vf_buf)
-+ free(vf->vf_buf);
- memset(vf, 0, sizeof(*vf));
- free(vf);
- }
-diff -urN poldek-0.18.8.org/vfile/vfile.h poldek-0.18.8/vfile/vfile.h
---- poldek-0.18.8.org/vfile/vfile.h 2004-06-08 15:57:03.000000000 +0200
-+++ poldek-0.18.8/vfile/vfile.h 2005-04-21 22:04:22.634458024 +0200
-@@ -81,6 +81,7 @@
-
- char *vf_path;
- char *vf_tmpath;
-+ char *vf_buf;
- int16_t _refcnt;
- };
-
+++ /dev/null
-Index: pkgdir.c
-===================================================================
-RCS file: /cvsroot/installer/poldek/Attic/pkgdir.c,v
-retrieving revision 1.39.4.7
-retrieving revision 1.39.4.8
-diff -u -r1.39.4.7 -r1.39.4.8
---- pkgdir.c 6 May 2004 07:03:58 -0000 1.39.4.7
-+++ pkgdir.c 15 May 2005 17:04:58 -0000 1.39.4.8
-@@ -11,7 +11,7 @@
- */
-
- /*
-- $Id$
-+ $Id$
- */
-
- #ifdef HAVE_CONFIG_H
-@@ -80,6 +80,7 @@
- uint32_t size;
- uint32_t fsize;
- uint32_t btime;
-+ uint32_t fmtime;
- uint32_t groupid;
- tn_array *caps;
- tn_array *reqs;
-@@ -1093,6 +1094,7 @@
- case 'A':
- case 'O':
- case 'n':
-+ case 't':
- if (!add2pkgtags(&pkgt, *line, val, pkgdir->path, offs)) {
- nerr++;
- goto l_end;
-@@ -1320,6 +1322,10 @@
- }
- break;
-
-+ case 't':
-+ if (sscanf(value, "%u", &pkgt->fmtime) != 1)
-+ pkgt->fmtime = 0;
-+ break;
-
- case 'S':
- if (pkgt->flags & PKGT_HAS_SIZE) {
-@@ -1407,7 +1413,7 @@
-
- if (pkgt->flags & PKGT_HAS_FN)
- fn = pkgt->fn;
--
-+
- if (*pkgt->name == '\0' || *pkgt->evr == '\0' || *pkgt->arch == '\0')
- return NULL;
-
-@@ -1422,6 +1428,7 @@
- pkg = pkg_new(pkgt->name, epoch, version, release, arch, os, fn,
- pkgt->size, pkgt->fsize, pkgt->btime);
- pkg->groupid = pkgt->groupid;
-+ pkg->fmtime = pkgt->fmtime;
-
- if (pkg == NULL) {
- logn(LOGERR, _("error reading %s's data"), pkgt->name);
-Index: pkgdir_save.c
-===================================================================
-RCS file: /cvsroot/installer/poldek/Attic/pkgdir_save.c,v
-retrieving revision 1.8.6.2
-retrieving revision 1.8.6.3
-diff -u -r1.8.6.2 -r1.8.6.3
---- pkgdir_save.c 5 May 2004 16:56:43 -0000 1.8.6.2
-+++ pkgdir_save.c 15 May 2005 17:04:58 -0000 1.8.6.3
-@@ -7,7 +7,7 @@
- */
-
- /*
-- $Id$
-+ $Id$
- */
-
- #ifdef HAVE_CONFIG_H
-@@ -170,6 +170,9 @@
-
- if (pkg->fn)
- fprintf(stream, "n: %s\n", pkg->fn);
-+
-+ if (pkg->fmtime)
-+ fprintf(stream, "t: %u\n", pkg->fmtime);
-
- fprintf(stream, "F:\n");
- store_pkg_fields(stream, pkg->size, pkg->fsize, pkg->btime, pkg->groupid);
-Index: pkg.h
-===================================================================
-RCS file: /cvsroot/installer/poldek/pkg.h,v
-retrieving revision 1.37.4.3
-retrieving revision 1.37.4.4
-diff -u -r1.37.4.3 -r1.37.4.4
---- pkg.h 22 Mar 2004 17:31:51 -0000 1.37.4.3
-+++ pkg.h 15 May 2005 17:04:58 -0000 1.37.4.4
-@@ -1,4 +1,4 @@
--/* $Id$ */
-+/* $Id$ */
- #ifndef POLDEK_PKG_H
- #define POLDEK_PKG_H
-
-@@ -100,6 +100,7 @@
- uint32_t size; /* installed size */
- uint32_t fsize; /* package file size */
- uint32_t btime; /* build time */
-+ uint32_t fmtime;
- int32_t epoch;
- char *name;
- char *ver;