+++ /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;
+++ /dev/null
-diff -ur poldek-0.18.8/main.c poldek-0.18.8-rpm/main.c
---- poldek-0.18.8/main.c 2004-12-30 13:37:30.000000000 +0100
-+++ poldek-0.18.8-rpm/main.c 2005-05-21 00:19:48.878118872 +0200
-@@ -247,6 +247,7 @@
- #define OPT_ASK 2006
- #define OPT_NOASK 2007
- #define OPT_RPMOPT 2008
-+#define OPT_RPMCMD 2009
- #define OPT_MERGE 2101
- #define OPT_SW_V016 (1 << 0)
- #define OPT_SW_NOASK (1 << 1)
-@@ -463,6 +464,7 @@
- {"version", OPT_BANNER, 0, 0, N_("Display program version information and exit"), 500 },
- {"log", OPT_LOG, "FILE", 0, N_("Log program messages to FILE"), 500 },
- {"v016", OPT_V016, 0, 0, N_("Read indexes created by versions < 0.17"), 500 },
-+{"pmcmd", OPT_RPMCMD, "FILE", 0, N_("Use FILE as rpm program"), 500 },
- {0, 'v', 0, 0, N_("Be verbose."), 500 },
- {0, 'q', 0, 0, N_("Do not produce any output."), 500 },
- { 0, 0, 0, 0, 0, 0 },
-@@ -917,6 +919,10 @@
- argsp->switches |= OPT_SW_NOCONF;
- break;
-
-+ case OPT_RPMCMD:
-+ argsp->inst.rpmcommand = prepare_path(arg);
-+ break;
-+
- case OPT_SPLITSIZE: {
- char *p, rc;
- check_mjrmode(argsp);
-diff -ur poldek-0.18.8/pkgfetch.c poldek-0.18.8-rpm/pkgfetch.c
---- poldek-0.18.8/pkgfetch.c 2004-05-20 23:47:59.000000000 +0200
-+++ poldek-0.18.8-rpm/pkgfetch.c 2005-05-21 00:19:48.879118720 +0200
-@@ -43,7 +43,7 @@
-
- #ifdef HAVE_RPM_4_0
-
--int package_verify_sign(const char *path, unsigned flags)
-+int package_verify_sign(const char *path, unsigned flags, const char *rpmcommand)
- {
- unsigned rpmflags = 0;
-
-@@ -67,7 +67,7 @@
-
- #else /* HAVE_RPMCHECKSIG */
-
--int package_verify_sign(const char *path, unsigned flags)
-+int package_verify_sign(const char *path, unsigned flags, const char *rpmcommand)
- {
- char **argv;
- char *cmd;
-@@ -80,8 +80,8 @@
- argv[n] = NULL;
- n = 0;
-
-- cmd = "/bin/rpm";
-- argv[n++] = "rpm";
-+ cmd = rpmcommand;
-+ argv[n++] = rpmcommand;
- argv[n++] = "-K";
-
- nopts = n;
-@@ -117,7 +117,7 @@
-
- #endif /* HAVE_RPMCHECKSIG */
-
--int package_verify_pgpg_sign(const struct pkg *pkg, const char *localpath)
-+int package_verify_pgpg_sign(const struct pkg *pkg, const char *localpath, const char *rpmcommand)
- {
- int rc = 1;
-
-@@ -133,7 +133,7 @@
- if (pkg->pkgdir->flags & PKGDIR_VRFY_PGP)
- verify_flags |= PKGVERIFY_PGP;
-
-- if (!package_verify_sign(localpath, verify_flags)) {
-+ if (!package_verify_sign(localpath, verify_flags, rpmcommand)) {
- logn(LOGERR, "%s: signature verification failed", pkg_snprintf_s(pkg));
- rc = 0;
- }
-@@ -145,7 +145,7 @@
- return rc;
- }
-
--int packages_fetch(tn_array *pkgs, const char *destdir, int nosubdirs)
-+int packages_fetch(tn_array *pkgs, const char *destdir, int nosubdirs, const char *rpmcommand)
- {
- int i, nerr, urltype, ncdroms;
- tn_array *urls = NULL;
-@@ -189,7 +189,7 @@
-
- } else {
- rpmlib_verbose = -2; /* be quiet */
-- if (!package_verify_sign(path, PKGVERIFY_MD)) {
-+ if (!package_verify_sign(path, PKGVERIFY_MD, rpmcommand)) {
- logn(LOGERR, _("%s: MD5 signature verification failed"),
- n_basenam(path));
- nerr++;
-@@ -216,7 +216,7 @@
- int pkg_ok, v = rpmlib_verbose;
-
- rpmlib_verbose = -2; /* be quiet */
-- pkg_ok = package_verify_sign(path, PKGVERIFY_MD);
-+ pkg_ok = package_verify_sign(path, PKGVERIFY_MD, rpmcommand);
- rpmlib_verbose = v;
-
- if (pkg_ok) /* already downloaded, */
-@@ -283,7 +283,7 @@
- char localpath[PATH_MAX];
- snprintf(localpath, sizeof(localpath), "%s/%s", real_destdir,
- n_basenam(n_array_nth(urls, j)));
-- if (!package_verify_sign(localpath, PKGVERIFY_MD)) {
-+ if (!package_verify_sign(localpath, PKGVERIFY_MD, rpmcommand)) {
- logn(LOGERR, _("%s: MD5 signature verification failed"),
- n_basenam(localpath));
- nerr++;
-diff -ur poldek-0.18.8/pkgset-install.c poldek-0.18.8-rpm/pkgset-install.c
---- poldek-0.18.8/pkgset-install.c 2004-12-30 13:03:52.000000000 +0100
-+++ poldek-0.18.8-rpm/pkgset-install.c 2005-05-21 00:19:48.883118112 +0200
-@@ -2115,7 +2115,7 @@
- if (destdir == NULL)
- destdir = inst->cachedir;
-
-- rc = packages_fetch(upg->install_pkgs, destdir, inst->fetchdir ? 1 : 0);
-+ rc = packages_fetch(upg->install_pkgs, destdir, inst->fetchdir ? 1 : 0, inst->rpmcommand);
-
- } else if ((inst->flags & INSTS_NOHOLD) || (rc = check_holds(ps, upg))) {
- int is_test = inst->flags & INSTS_RPMTEST;
-diff -ur poldek-0.18.8/pkgset.c poldek-0.18.8-rpm/pkgset.c
---- poldek-0.18.8/pkgset.c 2004-12-30 13:05:24.000000000 +0100
-+++ poldek-0.18.8-rpm/pkgset.c 2005-05-21 00:19:48.885117808 +0200
-@@ -144,6 +144,7 @@
- inst->dumpfile = NULL;
- inst->rpmopts = NULL;
- inst->rpmacros = NULL;
-+ inst->rpmcommand = "/bin/rpm";
- inst->askpkg_fn = ask_pkg;
- inst->ask_fn = ask_yn;
- inst->rpmacros = n_array_new(2, NULL, NULL);
-diff -ur poldek-0.18.8/pkgset.h poldek-0.18.8-rpm/pkgset.h
---- poldek-0.18.8/pkgset.h 2004-07-02 19:42:40.000000000 +0200
-+++ poldek-0.18.8-rpm/pkgset.h 2005-05-21 00:19:48.886117656 +0200
-@@ -83,6 +83,7 @@
- const char *fetchdir; /* dir to fetch files to */
- const char *cachedir; /* cache directory */
- const char *dumpfile; /* file to dump fqpns */
-+ const char *rpmcommand; /* deault /bin/rpm */
- tn_array *rpmopts; /* rpm cmdline opts (char *opts[]) */
- tn_array *rpmacros; /* rpm macros to pass to cmdline (char *opts[]) */
- tn_array *hold_patterns;
-@@ -190,7 +191,7 @@
-
- #define packages_unmark_all(pkgs) packages_mark(pkgs, 0, PKG_INDIRMARK | PKG_DIRMARK)
-
--int packages_fetch(tn_array *pkgs, const char *destdir, int nosubdirs);
-+int packages_fetch(tn_array *pkgs, const char *destdir, int nosubdirs, const char *rpmcommand);
- int packages_rpminstall(tn_array *pkgs, struct pkgset *ps, struct inst_s *inst);
-
- int packages_uninstall(tn_array *pkgs, struct inst_s *inst, struct install_info *iinf);
-@@ -206,10 +207,10 @@
- #define PKGVERIFY_GPG (1 << 1)
- #define PKGVERIFY_PGP (1 << 2)
-
--int package_verify_sign(const char *path, unsigned flags);
-+int package_verify_sign(const char *path, unsigned flags, const char *rpmcommand);
-
- /* looks if pkg->pkgdir has set VERSIGN flag */
--int package_verify_pgpg_sign(const struct pkg *pkg, const char *localpath);
-+int package_verify_pgpg_sign(const struct pkg *pkg, const char *localpath, const char *rpmcommand);
-
- #include "pkgset-load.h"
-
-diff -ur poldek-0.18.8/rpminstall.c poldek-0.18.8-rpm/rpminstall.c
---- poldek-0.18.8/rpminstall.c 2004-12-01 17:22:38.000000000 +0100
-+++ poldek-0.18.8-rpm/rpminstall.c 2005-05-21 00:19:48.887117504 +0200
-@@ -236,21 +236,21 @@
- n = 0;
-
-
-- if (!packages_fetch(pkgs, inst->cachedir, 0))
-+ if (!packages_fetch(pkgs, inst->cachedir, 0, inst->rpmcommand))
- return 0;
-
- if (inst->flags & INSTS_RPMTEST) {
-- cmd = "/bin/rpm";
-- argv[n++] = "rpm";
-+ cmd = inst->rpmcommand;
-+ argv[n++] = inst->rpmcommand;
-
- } else if (inst->flags & INSTS_USESUDO) {
- cmd = "/usr/bin/sudo";
- argv[n++] = "sudo";
-- argv[n++] = "/bin/rpm";
-+ argv[n++] = inst->rpmcommand;
-
- } else {
-- cmd = "/bin/rpm";
-- argv[n++] = "rpm";
-+ cmd = inst->rpmcommand;
-+ argv[n++] = inst->rpmcommand;
- }
-
- if (inst->flags & INSTS_INSTALL)
-@@ -343,7 +343,7 @@
- buf, name);
- }
-
-- if (!package_verify_pgpg_sign(pkg, path))
-+ if (!package_verify_pgpg_sign(pkg, path, inst->rpmcommand))
- nsignerr++;
-
- s = alloca(len + 1);
-diff -ur poldek-0.18.8/shell/get.c poldek-0.18.8-rpm/shell/get.c
---- poldek-0.18.8/shell/get.c 2002-03-25 21:30:08.000000000 +0100
-+++ poldek-0.18.8-rpm/shell/get.c 2005-05-21 00:20:40.173320816 +0200
-@@ -119,7 +119,7 @@
- destdirp = destdir;
- }
-
-- if (!packages_fetch(pkgs, destdirp, 1))
-+ if (!packages_fetch(pkgs, destdirp, 1, cmdarg->sh_s->inst->rpmcommand))
- err++;
-
- l_end:
-diff -ur poldek-0.18.8/uninstall.c poldek-0.18.8-rpm/uninstall.c
---- poldek-0.18.8/uninstall.c 2002-11-22 18:07:26.000000000 +0100
-+++ poldek-0.18.8-rpm/uninstall.c 2005-05-21 00:19:48.889117200 +0200
-@@ -340,17 +340,17 @@
- n = 0;
-
- if (inst->flags & INSTS_RPMTEST) {
-- cmd = "/bin/rpm";
-- argv[n++] = "rpm";
-+ cmd = inst->rpmcommand;
-+ argv[n++] = inst->rpmcommand;
-
- } else if (inst->flags & INSTS_USESUDO) {
- cmd = "/usr/bin/sudo";
- argv[n++] = "sudo";
-- argv[n++] = "/bin/rpm";
-+ argv[n++] = inst->rpmcommand;
-
- } else {
-- cmd = "/bin/rpm";
-- argv[n++] = "rpm";
-+ cmd = inst->rpmcommand;
-+ argv[n++] = inst->rpmcommand;
- }
-
- argv[n++] = "--erase";