aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-02-25 20:43:07 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-02-25 20:43:07 +0000
commitf3dd5972ec4f943f0b3a0e5504aa9cefa3a7c561 (patch)
tree2bff40fa29bca03aae18dc485d44de21fbbabad7
parent6b75bf9915b11b9066ba7ca0356d25bfabe1b12c (diff)
downloadperl-URPM-f3dd5972ec4f943f0b3a0e5504aa9cefa3a7c561.tar
perl-URPM-f3dd5972ec4f943f0b3a0e5504aa9cefa3a7c561.tar.gz
perl-URPM-f3dd5972ec4f943f0b3a0e5504aa9cefa3a7c561.tar.bz2
perl-URPM-f3dd5972ec4f943f0b3a0e5504aa9cefa3a7c561.tar.xz
perl-URPM-f3dd5972ec4f943f0b3a0e5504aa9cefa3a7c561.zip
- add filesize to synthesis, add ->filesize to get it, and add
selected_size_filesize() to compute the sum
-rw-r--r--NEWS2
-rw-r--r--URPM.pm4
-rw-r--r--URPM.xs27
-rw-r--r--URPM/Resolve.pm23
4 files changed, 51 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index 6507890..d4daa08 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+- add filesize to synthesis, add ->filesize to get it, and add
+ selected_size_filesize() to compute the sum
- allow urpmi to know a package was not selected because a newer version is
installed (#29838)
- handle new package providing xxx which conflicts with an installed package (#17106)
diff --git a/URPM.pm b/URPM.pm
index 3453943..41b203e 100644
--- a/URPM.pm
+++ b/URPM.pm
@@ -630,6 +630,10 @@ The rpm's bare name.
=item $package->rflags()
+=item $package->filesize()
+
+Size of the rpm file (ie the rpm header + cpio body)
+
=item $package->set_flag($name, $value)
=item $package->set_flag_base($value)
diff --git a/URPM.xs b/URPM.xs
index da07a17..edbb151 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -213,6 +213,11 @@ get_int(Header header, int_32 tag) {
}
static int
+sigsize_to_filesize(int sigsize) {
+ return sigsize + 440; /* 440 is the rpm header size (?) empirical, but works */
+}
+
+static int
print_list_entry(char *buff, int sz, char *name, int_32 flags, char *evr) {
int len = strlen(name);
char *p = buff;
@@ -831,9 +836,9 @@ pack_header(URPM__Package pkg) {
char *release = get_name(pkg->h, RPMTAG_RELEASE);
char *arch = headerIsEntry(pkg->h, RPMTAG_SOURCERPM) ? get_name(pkg->h, RPMTAG_ARCH) : "src";
- p += snprintf(buff, sizeof(buff), "%s-%s-%s.%s@%d@%d@%s@", name, version, release, arch,
- get_int(pkg->h, RPMTAG_EPOCH), get_int(pkg->h, RPMTAG_SIZE), get_name(pkg->h, RPMTAG_GROUP));
- p[-1] = 0;
+ p += 1 + snprintf(buff, sizeof(buff), "%s-%s-%s.%s@%d@%d@%s@%d", name, version, release, arch,
+ get_int(pkg->h, RPMTAG_EPOCH), get_int(pkg->h, RPMTAG_SIZE),
+ get_name(pkg->h, RPMTAG_GROUP), sigsize_to_filesize(get_int(pkg->h, RPMTAG_SIGSIZE)));
pkg->info = memcpy(malloc(p-buff), buff, p-buff);
}
if (pkg->requires == NULL && pkg->suggests == NULL)
@@ -1963,6 +1968,22 @@ Pkg_size(pkg)
OUTPUT:
RETVAL
+int
+Pkg_filesize(pkg)
+ URPM::Package pkg
+ CODE:
+ if (pkg->info) {
+ char *s;
+
+ if ((s = strchr(pkg->info, '@')) != NULL && (s = strchr(s+1, '@')) != NULL && (s = strchr(s+1, '@')) != NULL && (s = strchr(s+1, '@')) != NULL) {
+ RETVAL = atoi(s+1);
+ } else RETVAL = 0;
+ } else if (pkg->h) {
+ RETVAL = sigsize_to_filesize(get_int(pkg->h, RPMTAG_SIGSIZE));
+ } else RETVAL = 0;
+ OUTPUT:
+ RETVAL
+
void
Pkg_group(pkg)
URPM::Package pkg
diff --git a/URPM/Resolve.pm b/URPM/Resolve.pm
index bc6da6b..3619c62 100644
--- a/URPM/Resolve.pm
+++ b/URPM/Resolve.pm
@@ -1373,11 +1373,30 @@ sub disable_selected_and_unrequested_dependencies {
#- side-effects: none
sub selected_size {
my ($urpm, $state) = @_;
- my $size;
+ my ($size) = _selected_size_filesize($urpm, $state, 0);
+ $size;
+}
+#- side-effects: none
+sub selected_size_filesize {
+ my ($urpm, $state) = @_;
+ _selected_size_filesize($urpm, $state, 1);
+}
+#- side-effects: none
+sub _selected_size_filesize {
+ my ($urpm, $state, $compute_filesize) = @_;
+ my ($size, $filesize, $bad_filesize);
foreach (keys %{$state->{selected} || {}}) {
my $pkg = $urpm->{depslist}[$_];
$size += $pkg->size;
+ $compute_filesize or next;
+
+ if (my $n = $pkg->filesize) {
+ $filesize += $n;
+ } elsif (!$bad_filesize) {
+ $urpm->{debug} and $urpm->{debug}("no filesize for package " . $pkg->fullname);
+ $bad_filesize = 1;
+ }
}
foreach (values %{$state->{rejected} || {}}) {
@@ -1385,7 +1404,7 @@ sub selected_size {
$size -= $_->{size};
}
- $size;
+ $size, $bad_filesize ? 0 : $filesize;
}
#- compute installed flags for all packages in depslist.