aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--URPM.xs62
-rw-r--r--perl-URPM.spec6
-rw-r--r--t/rpmdb.t28
3 files changed, 53 insertions, 43 deletions
diff --git a/URPM.xs b/URPM.xs
index f0a6654..2ccff09 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -484,7 +484,7 @@ open_archive(char *filename, pid_t *pid) {
fd = open(filename, O_RDONLY);
if (fd >= 0) {
- lseek(fd, -sizeof(buf), SEEK_END);
+ lseek(fd, -(int)sizeof(buf), SEEK_END);
if (read(fd, &buf, sizeof(buf)) != sizeof(buf) || strncmp(buf.header, "cz[0", 4) || strncmp(buf.trailer, "0]cz", 4)) {
/* this is not an archive, open it without magic, but first rewind at begin of file */
lseek(fd, 0, SEEK_SET);
@@ -529,8 +529,8 @@ open_archive(char *filename, pid_t *pid) {
lseek(fd, 0, SEEK_SET);
dup2(fd, STDIN_FILENO); close(fd);
dup2(fdno[1], STDOUT_FILENO); close(fdno[1]);
- fd = open("/dev/null", O_WRONLY);
- dup2(fd, STDERR_FILENO); close(fd);
+ /*fd = open("/dev/null", O_WRONLY);
+ dup2(fd, STDERR_FILENO); close(fd);*/
execvp(unpacker[0], unpacker);
exit(1);
}
@@ -1187,7 +1187,6 @@ Db_open(prefix="/")
old_cb = rpmErrorSetCallback(callback_empty);
rpmSetVerbosity(RPMMESS_FATALERROR);
RETVAL = rpmdbOpen(prefix, &db, O_RDONLY, 0644) == 0 ? db : NULL;
- fprintf(stderr, "opening read only rpm db %p\n", db);
rpmErrorSetCallback(old_cb);
rpmSetVerbosity(RPMMESS_NORMAL);
OUTPUT:
@@ -1204,7 +1203,6 @@ Db_open_rw(prefix="/")
old_cb = rpmErrorSetCallback(callback_empty);
rpmSetVerbosity(RPMMESS_FATALERROR);
RETVAL = rpmdbOpen(prefix, &db, O_RDWR | O_CREAT, 0644) == 0 ? db : NULL;
- fprintf(stderr, "opening read-write rpm db %p\n", db);
rpmErrorSetCallback(old_cb);
rpmSetVerbosity(RPMMESS_NORMAL);
OUTPUT:
@@ -1214,7 +1212,6 @@ void
Db_DESTROY(db)
URPM::DB db
CODE:
- fprintf(stderr, "closing rpm db %p\n", db);
rpmdbClose(db);
int
@@ -1398,32 +1395,39 @@ Urpm_parse_hdlist(urpm, filename, packing=0)
if (fdFileno(fd) >= 0) {
Header header;
- int count;
int start_id = 1 + av_len(depslist);
- for (count = 0; count < 20 && (header=headerRead(fd, HEADER_MAGIC_YES)) == 0; ++count) {
- struct timeval timeout;
-
- timeout.tv_sec = 0;
- timeout.tv_usec = 10000;
- select(0, NULL, NULL, NULL, &timeout);
- }
- while (header != 0) {
- struct s_Package pkg;
-
- memset(&pkg, 0, sizeof(struct s_Package));
- pkg.id = 1 + av_len(depslist);
- pkg.h = header;
- if (provides) {
- update_provides(&pkg, provides);
- update_provides_files(&pkg, provides);
- }
- if (packing) pack_header(&pkg);
- av_push(depslist, sv_setref_pv(newSVpv("", 0), "URPM::Package",
- memcpy(malloc(sizeof(struct s_Package)), &pkg, sizeof(struct s_Package))));
-
+ do {
+ int count = 4;
header=headerRead(fd, HEADER_MAGIC_YES);
- }
+ while (header == NULL && count > 0) {
+ fd_set readfds;
+ struct timeval timeout;
+
+ FD_ZERO(&readfds);
+ FD_SET(fdFileno(fd), &readfds);
+ timeout.tv_sec = 1;
+ timeout.tv_usec = 0;
+ select(fdFileno(fd)+1, &readfds, NULL, NULL, &timeout);
+
+ header=headerRead(fd, HEADER_MAGIC_YES);
+ --count;
+ }
+ if (header != NULL) {
+ struct s_Package pkg;
+
+ memset(&pkg, 0, sizeof(struct s_Package));
+ pkg.id = 1 + av_len(depslist);
+ pkg.h = header;
+ if (provides) {
+ update_provides(&pkg, provides);
+ update_provides_files(&pkg, provides);
+ }
+ if (packing) pack_header(&pkg);
+ av_push(depslist, sv_setref_pv(newSVpv("", 0), "URPM::Package",
+ memcpy(malloc(sizeof(struct s_Package)), &pkg, sizeof(struct s_Package))));
+ }
+ } while (header != NULL);
fdClose(fd);
if (pid) {
kill(pid, SIGTERM);
diff --git a/perl-URPM.spec b/perl-URPM.spec
index a3c9668..96176e6 100644
--- a/perl-URPM.spec
+++ b/perl-URPM.spec
@@ -1,6 +1,6 @@
%define name perl-URPM
%define real_name URPM
-%define release 2mdk
+%define release 3mdk
%{expand:%%define version %(perl -ne '/VERSION\s+=[^0-9\.]*([0-9\.]+)/ and print "$1\n"' URPM.pm)}
@@ -47,6 +47,10 @@ rm -rf $RPM_BUILD_ROOT
%changelog
+* Wed Jun 5 2002 François Pons <fpons@mandrakesoft.com> 0.02-3mdk
+- removed log on opening/closing rpmdb.
+- modified reading of archive to avoid incomplete read.
+
* Wed Jun 5 2002 François Pons <fpons@mandrakesoft.com> 0.02-2mdk
- added log on opening/closing rpmdb.
diff --git a/t/rpmdb.t b/t/rpmdb.t
index c6a1040..898588d 100644
--- a/t/rpmdb.t
+++ b/t/rpmdb.t
@@ -14,19 +14,21 @@ use URPM;
print "1..5\n";
-my $db;
-ok(1, $db = URPM::DB::open);
-
-my @all_pkgs_extern = sort { $a cmp $b } split '\n', `rpm -qa`;
-ok(2, @all_pkgs_extern > 0);
-
-my @all_pkgs;
-my $count = $db->traverse(sub {
- my ($pkg) = @_;
- my ($name, $version, $release, $arch) = $pkg->fullname;
- $arch or return;
- push @all_pkgs, "$name-$version-$release";
- });
+my ($count, @all_pkgs_extern, @all_pkgs);
+{
+ my $db;
+ ok(1, $db = URPM::DB::open);
+
+ @all_pkgs_extern = sort { $a cmp $b } split '\n', `rpm -qa`;
+ ok(2, @all_pkgs_extern > 0);
+
+ $count = $db->traverse(sub {
+ my ($pkg) = @_;
+ my ($name, $version, $release, $arch) = $pkg->fullname;
+ $arch or return;
+ push @all_pkgs, "$name-$version-$release";
+ });
+}
ok(3, $count == @all_pkgs_extern);
ok(4, $count == @all_pkgs);