aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--URPM.xs168
-rw-r--r--URPM/Build.pm45
2 files changed, 200 insertions, 13 deletions
diff --git a/URPM.xs b/URPM.xs
index dcb9a7d..de32a27 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -654,6 +654,124 @@ return_list_uint_16(Header header, int_32 tag_name) {
}
void
+return_list_tag_modifier(Header header, int_32 tag_name) {
+ dSP;
+ int_32 *list;
+ int_16 *list16;
+ int_32 count, type;
+ headerGetEntry(header, tag_name, &type, (void **) &list, &count);
+
+ int i;
+ for (i=0; i<count; i++) {
+ char *buff[15];
+ char *s= buff;
+ switch (tag_name) {
+ case RPMTAG_FILEFLAGS:
+ if (list[i] & RPMFILE_CONFIG) *s++ = 'c';
+ if (list[i] & RPMFILE_DOC) *s++ = 'd';
+ if (list[i] & RPMFILE_GHOST) *s++ = 'g';
+ if (list[i] & RPMFILE_LICENSE) *s++ = 'l';
+ if (list[i] & RPMFILE_ICON) *s++ = 'i';
+ if (list[i] & RPMFILE_MISSINGOK) *s++ = 'm';
+ if (list[i] & RPMFILE_NOREPLACE) *s++ = 'n';
+ if (list[i] & RPMFILE_SPECFILE) *s++ = 'S';
+ if (list[i] & RPMFILE_README) *s++ = 'R';
+ if (list[i] & RPMFILE_EXCLUDE) *s++ = 'e';
+ if (list[i] & RPMFILE_UNPATCHED) *s++ = 'u';
+ if (list[i] & RPMFILE_PUBKEY) *s++ = 'p';
+
+ break;
+ default:
+ return;
+ }
+ *s = '\0';
+ XPUSHs(sv_2mortal(newSVpv(buff, strlen(buff))));
+ }
+ PUTBACK;
+}
+
+void
+return_list_tag(Header header, int_32 tag_name) {
+ dSP;
+ if (header) {
+ int_32 *list = NULL;
+ uint_16 *list16;
+ int_32 count, type;
+ headerGetEntry(header, tag_name, &type, (void **) &list, &count);
+ if (list) {
+ if (count == 1 ) {
+ switch (type) {
+ case RPM_NULL_TYPE:
+ break;
+ case RPM_CHAR_TYPE:
+ XPUSHs(sv_2mortal(newSVpv((char *) list,strlen((char *) list))));
+ break;
+ case RPM_INT8_TYPE:
+ break;
+ case RPM_INT16_TYPE:
+ list16 = list;
+ XPUSHs(sv_2mortal(newSViv(list16)));
+ break;
+ case RPM_INT32_TYPE:
+ XPUSHs(sv_2mortal(newSViv((int_32 *) list)));
+ break;
+/*
+ case RPM_INT64_TYPE:
+ break;
+*/
+ case RPM_STRING_TYPE:
+ XPUSHs(sv_2mortal(newSVpv((char *) list, strlen((char *) list))));
+
+ break;
+ case RPM_BIN_TYPE:
+ break;
+ case RPM_STRING_ARRAY_TYPE:
+ break;
+ case RPM_I18NSTRING_TYPE:
+ break;
+ }
+ } else {
+ int i;
+ for (i=0; i< count; i++) {
+ switch (type) {
+ case RPM_NULL_TYPE:
+ break;
+ case RPM_CHAR_TYPE:
+ XPUSHs(sv_2mortal(newSVpv((char *) list,strlen((char *) list))));
+ break;
+ case RPM_INT8_TYPE:
+ break;
+ case RPM_INT16_TYPE:
+ list16 = list;
+ XPUSHs(sv_2mortal(newSViv(list16[i])));
+ break;
+ case RPM_INT32_TYPE:
+ XPUSHs(sv_2mortal(newSViv((int_32 *) list[i])));
+ break;
+/*
+ case RPM_INT64_TYPE:
+ break;
+*/
+ case RPM_STRING_TYPE:
+ XPUSHs(sv_2mortal(newSVpv((char *) list[i], strlen((char *) list[i]))));
+ break;
+ case RPM_BIN_TYPE:
+ break;
+ case RPM_STRING_ARRAY_TYPE:
+ XPUSHs(sv_2mortal(newSVpv((char *) list[i],strlen((char *) list[i]))));
+ break;
+ case RPM_I18NSTRING_TYPE:
+ break;
+ }
+ }
+ }
+ }
+ }
+ PUTBACK;
+}
+
+
+void
return_files(Header header, int filter_mode) {
dSP;
if (header) {
@@ -1499,6 +1617,30 @@ Pkg_license(pkg)
}
void
+Pkg_distribution(pkg)
+ URPM::Package pkg
+ PPCODE:
+ if (pkg->h) {
+ XPUSHs(sv_2mortal(newSVpv(get_name(pkg->h, RPMTAG_DISTRIBUTION), 0)));
+ }
+
+void
+Pkg_vendor(pkg)
+ URPM::Package pkg
+ PPCODE:
+ if (pkg->h) {
+ XPUSHs(sv_2mortal(newSVpv(get_name(pkg->h, RPMTAG_VENDOR), 0)));
+ }
+
+void
+Pkg_os(pkg)
+ URPM::Package pkg
+ PPCODE:
+ if (pkg->h) {
+ XPUSHs(sv_2mortal(newSVpv(get_name(pkg->h, RPMTAG_OS), 0)));
+ }
+
+void
Pkg_fullname(pkg)
URPM::Package pkg
PREINIT:
@@ -2099,6 +2241,14 @@ Pkg_files_mode(pkg)
SPAGAIN;
void
+Pkg_files_flags(pkg)
+ URPM::Package pkg
+ PPCODE:
+ PUTBACK;
+ return_list_int_32(pkg->h, RPMTAG_FILEFLAGS);
+ SPAGAIN;
+
+void
Pkg_conf_files(pkg)
URPM::Package pkg
PPCODE:
@@ -2139,6 +2289,24 @@ Pkg_changelog_text(pkg)
SPAGAIN;
void
+Pkg_get_tag(pkg, tagname)
+ URPM::Package pkg
+ int tagname;
+ PPCODE:
+ PUTBACK;
+ return_list_tag(pkg->h, tagname);
+ SPAGAIN;
+
+void
+Pkg_get_tag_modifiers(pkg, tagname)
+ URPM::Package pkg
+ int tagname;
+ PPCODE:
+ PUTBACK;
+ return_list_tag_modifier(pkg->h, tagname);
+ SPAGAIN;
+
+void
Pkg_pack_header(pkg)
URPM::Package pkg
CODE:
diff --git a/URPM/Build.pm b/URPM/Build.pm
index 839746e..797d5f0 100644
--- a/URPM/Build.pm
+++ b/URPM/Build.pm
@@ -48,14 +48,21 @@ sub parse_rpms_build_headers {
$filename = $cache{$key}{file};
} else {
($id, undef) = $urpm->parse_rpm($_);
- defined $id or die "bad rpm $_\n";
+ defined $id or do {
+ if ($options{dontdie}) {
+ print STDERR "bad rpm $_\n";
+ next;
+ } else {
+ die "bad rpm $_\n";
+ }
+ };
my $pkg = $urpm->{depslist}[$id];
$filename = $pkg->fullname;
"$filename.rpm" eq $pkg->filename or $filename .= ":$key";
- print STDERR "$dir/$filename\n";
+ $options{silent} or print STDERR "$dir/$filename\n";
unless (-s "$dir/$filename") {
open F, ">$dir/$filename" or die "unable to open $dir/$filename for writing\n";
$pkg->build_header(fileno *F);
@@ -65,7 +72,7 @@ sub parse_rpms_build_headers {
#- make smart use of memory (no need to keep header in memory now).
if ($options{callback}) {
- $options{callback}->($urpm, $id, %options);
+ $options{callback}->($urpm, $id, %options, (file => $_));
} else {
$pkg->pack_header;
}
@@ -327,17 +334,23 @@ sub compute_deps {
#- dir : directory wich contains headers (default to /tmp/.build_hdlist)
#- start : index of first package (default to first index of depslist).
#- end : index of last package (default to last index of depslist).
+#- idlist : ids list to rpm to compute (default is start .. end)
#- ratio : compression ratio (default 4).
#- split : split ratio (default 400000).
sub build_hdlist {
my ($urpm, %options) = @_;
- my ($dir, $start, $end, $ratio, $split);
+ my ($dir, $start, $end, $ratio, $split, @idlist);
$dir = $options{dir} || ($ENV{TMPDIR} || "/tmp") . "/.build_hdlist";
-d $dir or die "no directory $dir\n";
- $start = $options{start} || 0;
- $end = $options{end} || $#{$urpm->{depslist}};
+ if (@{$options{idlist}}) {
+ @idlist = @{$options{idlist}};
+ } else {
+ $start = $options{start} || 0;
+ $end = $options{end} || $#{$urpm->{depslist}};
+ @idlist = ($start .. $end);
+ }
#- compression ratio are not very high, sample for cooker
#- gives the following (main only and cache fed up):
@@ -352,7 +365,7 @@ sub build_hdlist {
local *B;
open B, "| " . ($ENV{LD_LOADER} || '') . " packdrake -b${ratio}ds '$options{hdlist}' '$dir' $split";
- foreach my $pkg (@{$urpm->{depslist}}[$start .. $end]) {
+ foreach my $pkg (@{$urpm->{depslist}}[@idlist]) {
my $filename = $pkg->fullname;
"$filename.rpm" ne $pkg->filename && $pkg->filename =~ m!([^/]*)\.rpm$! and $filename .= ":$1";
-s "$dir/$filename" or die "bad header $dir/$filename\n";
@@ -368,14 +381,20 @@ sub build_hdlist {
#- dir : directory wich contains headers (default to /tmp/.build_hdlist)
#- start : index of first package (default to first index of depslist).
#- end : index of last package (default to last index of depslist).
+#- idlist : ids list to rpm to compute (default is start .. end)
#- ratio : compression ratio (default 9).
sub build_synthesis {
my ($urpm, %options) = @_;
- my ($start, $end, $ratio);
-
- $start = $options{start} || 0;
- $end = $options{end} || $#{$urpm->{depslist}};
- $start > $end and return;
+ my ($start, $end, $ratio, @idlist);
+
+ if (@{$options{idlist}} > 0) {
+ @idlist = @{$options{idlist}};
+ } else {
+ $start = $options{start} || 0;
+ $end = $options{end} || $#{$urpm->{depslist}};
+ $start > $end and return;
+ @idlist = ($start .. $end);
+ }
$ratio = $options{ratio} || 9;
$options{synthesis} || defined $options{fd} or die "invalid parameters given";
@@ -392,7 +411,7 @@ sub build_synthesis {
#- second pass: write each info including files provided.
local *F;
$options{synthesis} and open F, "| " . ($ENV{LD_LOADER} || '') . " gzip -$ratio >'$options{synthesis}'";
- foreach ($start .. $end) {
+ foreach (@idlist) {
my $pkg = $urpm->{depslist}[$_];
my %files;