diff options
author | Francois Pons <fpons@mandriva.com> | 2002-06-05 16:44:24 +0000 |
---|---|---|
committer | Francois Pons <fpons@mandriva.com> | 2002-06-05 16:44:24 +0000 |
commit | 977a0031a904f6690d377d184a5461f639d49201 (patch) | |
tree | 53577423f224d0feba7e310fa8b8a8fc82ab2205 | |
parent | b9ffa68234ad52a371edd9704fdcd51d0948b886 (diff) | |
download | perl-URPM-977a0031a904f6690d377d184a5461f639d49201.tar perl-URPM-977a0031a904f6690d377d184a5461f639d49201.tar.gz perl-URPM-977a0031a904f6690d377d184a5461f639d49201.tar.bz2 perl-URPM-977a0031a904f6690d377d184a5461f639d49201.tar.xz perl-URPM-977a0031a904f6690d377d184a5461f639d49201.zip |
0.02-3mdk
-rw-r--r-- | URPM.xs | 62 | ||||
-rw-r--r-- | perl-URPM.spec | 6 | ||||
-rw-r--r-- | t/rpmdb.t | 28 |
3 files changed, 53 insertions, 43 deletions
@@ -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. @@ -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); |