summaryrefslogtreecommitdiffstats
path: root/urpm/bug_report.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2006-11-20 10:48:48 +0000
committerPascal Rigaux <pixel@mandriva.com>2006-11-20 10:48:48 +0000
commitd76557c69f2494ced405080980590f9e05a0ff2d (patch)
tree4ae90b577bb1b1adc4a116f7f882c9b91aae9157 /urpm/bug_report.pm
parent856fdb0c7c9981f74646253c92042dfede8fd015 (diff)
downloadurpmi-d76557c69f2494ced405080980590f9e05a0ff2d.tar
urpmi-d76557c69f2494ced405080980590f9e05a0ff2d.tar.gz
urpmi-d76557c69f2494ced405080980590f9e05a0ff2d.tar.bz2
urpmi-d76557c69f2494ced405080980590f9e05a0ff2d.tar.xz
urpmi-d76557c69f2494ced405080980590f9e05a0ff2d.zip
move some things to new module urpm::bug_report
Diffstat (limited to 'urpm/bug_report.pm')
-rw-r--r--urpm/bug_report.pm57
1 files changed, 57 insertions, 0 deletions
diff --git a/urpm/bug_report.pm b/urpm/bug_report.pm
new file mode 100644
index 00000000..858becfa
--- /dev/null
+++ b/urpm/bug_report.pm
@@ -0,0 +1,57 @@
+package urpm::bug_report;
+
+use urpm;
+use urpm::msg;
+
+
+sub rpmdb_to_synthesis {
+ my ($urpm, $synthesis, $root) = @_;
+
+ my $db = urpm::db_open_or_die($urpm, $root);
+ my $sig_handler = sub { undef $db; exit 3 };
+ local $SIG{INT} = $sig_handler;
+ local $SIG{QUIT} = $sig_handler;
+
+ open my $rpmdb, "| " . ($ENV{LD_LOADER} || '') . " gzip -9 >'$synthesis'"
+ or $urpm->syserror("Can't fork", "gzip");
+ $db->traverse(sub {
+ my ($p) = @_;
+ #- this is not right but may be enough.
+ my $files = join '@', grep { exists($urpm->{provides}{$_}) } $p->files;
+ $p->pack_header;
+ $p->build_info(fileno $rpmdb, $files);
+ });
+ close $rpmdb;
+}
+
+sub write_urpmdb {
+ my ($urpm, $bug_report_dir) = @_;
+
+ require URPM::Build;
+ foreach (@{$urpm->{media}}) {
+ #- take care of virtual medium this way.
+ $_->{hdlist} ||= "hdlist.$_->{name}.cz";
+ #- now build directly synthesis file, this is by far the simplest method.
+ if (urpm::is_valid_medium($_)) {
+ $urpm->build_synthesis(start => $_->{start}, end => $_->{end}, synthesis => "$bug_report_dir/synthesis.$_->{hdlist}");
+ $urpm->{log}(N("built hdlist synthesis file for medium \"%s\"", $_->{name}));
+ }
+ }
+ #- fake configuration written to convert virtual media on the fly.
+ local $urpm->{config} = "$bug_report_dir/urpmi.cfg";
+ $urpm->write_config;
+}
+
+sub copy_requested {
+ my ($urpm, $bug_report_dir, $requested) = @_;
+
+ #- handle local packages, copy them directly in bug environment.
+ foreach (keys %$requested) {
+ if ($urpm->{source}{$_}) {
+ system "cp", "-af", $urpm->{source}{$_}, $bug_report_dir
+ and die N("Copying failed");
+ }
+ }
+}
+
+1;