summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--urpm.pm18
-rw-r--r--urpm/bug_report.pm57
-rwxr-xr-xurpmi28
3 files changed, 64 insertions, 39 deletions
diff --git a/urpm.pm b/urpm.pm
index fc1eb6d3..7d2332d1 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -741,24 +741,6 @@ sub configure {
},
);
}
- if ($options{bug}) {
- #- and a dump of rpmdb itself as synthesis file.
- my $db = db_open_or_die($urpm, $options{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 >'$options{bug}/rpmdb.cz'"
- 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;
- }
}
#- add a new medium, sync the config file accordingly.
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;
diff --git a/urpmi b/urpmi
index 6ea4188b..0a5b4db4 100755
--- a/urpmi
+++ b/urpmi
@@ -338,7 +338,6 @@ unless ($env || $nolock) {
if ($urpm->{options}{ignorearch}) { urpm::shunt_ignorearch() }
my %config_hash = (
- bug => $bug,
excludemedia => $excludemedia,
media => $media,
nocheck_access => $env || $< != 0,
@@ -375,6 +374,11 @@ if ($auto_update && !$bug && !$env) {
$urpm->configure(%config_hash);
+if ($bug) {
+ require urpm::bug_report;
+ urpm::bug_report::rpmdb_to_synthesis($urpm, "$bug/rpmdb.cz", $root);
+}
+
#- get back activated default values of boolean options.
exists $urpm->{options}{'split-level'} or $urpm->{options}{'split-level'} = $split_level;
exists $urpm->{options}{'split-length'} or $urpm->{options}{'split-length'} = $split_length;
@@ -388,26 +392,8 @@ my %requested = $urpm->register_rpms(@files, @src_files);
#- finish bug environment creation.
if ($bug) {
- 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/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/urpmi.cfg";
- $urpm->write_config;
- #- handle local packages, copy them directly in bug environment.
- foreach (keys %requested) {
- if ($urpm->{source}{$_}) {
- system "cp", "-af", $urpm->{source}{$_}, $bug
- and die N("Copying failed");
- }
- }
+ urpm::bug_report::write_urpmdb($urpm, $bug);
+ urpm::bug_report::copy_requested($urpm, $bug, \%requested);
}
#- search the packages according to the selection given by the user.