aboutsummaryrefslogtreecommitdiffstats
path: root/URPM.xs
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 /URPM.xs
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
Diffstat (limited to 'URPM.xs')
-rw-r--r--URPM.xs27
1 files changed, 24 insertions, 3 deletions
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