aboutsummaryrefslogtreecommitdiffstats
path: root/dumpdistribconf
blob: fcb6e57e0b0b4a3b5400073a92c1fbae8219cb4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/perl

(our $VERSION) = q$Id$ =~ /(\d+\.\d+)/;

use strict;
use Getopt::Long;
use Distribconf::Build;
use Pod::Usage;

sub usage () {
    pod2usage({ -verbose => 1 });
    exit 0;
}

my ($out, $outputtype) = (\*STDOUT, 'm');
GetOptions(
    h => sub { $outputtype = 'h' },
    m => sub { $outputtype = 'm' },
    d => sub { undef $out },
    'v|version' => sub { warn "$0 version $VERSION\n"; exit 0 },
    'h|help' => \&usage,
);

@ARGV or usage;

foreach (@ARGV) {
    print "Using root $_...\n";
    my $d = Distribconf::Build->new($_);
    $d->load and do {
	warn "Can't load configuration from $_\n";
	next;
    };
    if ($outputtype eq 'h') {
	$d->write_hdlists($out) or warn "Can't write hdlists file\n";
    } else {
	$d->write_mediacfg($out) or warn "Can't write media.cfg file\n";
    }
}

__END__

=head1 NAME

dumpdistribconf - dumps a media.cfg from a distribution tree

=head1 SYNOPSIS

    dumpdistribconf [-h|-m] [-d] path [path...]

=head1 DESCRIPTION

This will dump a F<media.cfg> (or an F<hdlists> file if B<-h> is
specified) from a Mandriva Linux distribution tree. By default
it's dumped to the standard output.

=head1 OPTIONS

=over 4

=item B<-h>

Dump an F<hdlists> file.

=item B<-m>

Dump a F<media.cfg> file (default)

=item B<-d>

Instead of writing to the standard output, write to a file placed in the
standard location (e.g. F<< <root>/media/media_info/media.cfg >>).

=back

=cut