urpm/bug_report.pm

filter: Statementstmt 66.6% 4 / 6 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 75.0% 6 / 8 CC 1 SCAR 1.4
CC
1
Cov
67%
BEGIN
1.3
BEGIN
1.0
CRAP 1.1
« urpmi.pm ↑ Summary urpm/cdrom.pm »
1 package urpm::bug_report;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 0 ▶use urpm;
Subroutine BEGIN: called CC=1 SCAR=2.6
5 use urpm::msg;
6  
7 =head1 NAME
8  
9 urpm::bug_report - Bug reporting routines for urpmi
10  
11 =head1 SYNOPSIS
12  
13 =head1 DESCRIPTION
14  
15 =over
16  
17 =cut
18  
19  
20 sub rpmdb_to_synthesis {
21 my ($urpm, $synthesis) = @_;
22  
23 my $db = urpm::db_open_or_die_($urpm);
24 my $sig_handler = sub { undef $db; exit 3 };
25 local $SIG{INT} = $sig_handler;
26 local $SIG{QUIT} = $sig_handler;
27  
28 open my $rpmdb, "| " . ($ENV{LD_LOADER} || '') . " gzip -9 >'$synthesis'"
29 or urpm::sys::syserror($urpm, "Can't fork", "gzip");
30 $db->traverse(sub {
31 my ($p) = @_;
32 #- this is not right but may be enough.
33 my $files = join '@', grep { exists($urpm->{provides}{$_}) } $p->files;
34 $p->pack_header;
35 $p->build_info(fileno $rpmdb, $files);
36 });
37 close $rpmdb;
38 }
39  
40 sub write_urpmdb {
41 my ($urpm, $bug_report_dir) = @_;
42  
43 foreach (@{$urpm->{media}}) {
44 if (urpm::media::is_valid_medium($_)) {
45 system('cp', urpm::media::any_synthesis($urpm, $_),
46 "$bug_report_dir/" . urpm::media::synthesis($_)) == 0 or $urpm->{fatal}(1, "failed to copy $_->{name} synthesis");
47 my $descr_file = urpm::media::statedir_descriptions($urpm, $_);
48 system('cp', $descr_file,
49 "$bug_report_dir/") if -e $descr_file;
50 }
51 }
52 #- fake configuration written to convert virtual media on the fly.
53 local $urpm->{config} = "$bug_report_dir/urpmi.cfg";
54 urpm::media::write_config($urpm);
55  
56 require urpm::orphans;
57 system('cp', urpm::orphans::unrequested_list__file($urpm), $bug_report_dir);
58 }
59  
60 sub copy_requested {
61 my ($urpm, $bug_report_dir, $requested) = @_;
62  
63 #- handle local packages, copy them directly in bug environment.
64 foreach (keys %$requested) {
65 if ($urpm->{source}{$_}) {
66 system "cp", "-af", $urpm->{source}{$_}, $bug_report_dir
67 and die N("Copying failed");
68 }
69 }
70 }
71  
72 1;
73  
74  
75 =back
76  
77 =head1 COPYRIGHT
78  
79 Copyright (C) 2005 MandrakeSoft SA
80  
81 Copyright (C) 2005-2010 Mandriva SA
82  
83 Copyright (C) 2011-2020 Mageia
84  
85 =cut
« urpmi.pm ↑ Summary urpm/cdrom.pm »