aboutsummaryrefslogtreecommitdiffstats
path: root/dumpdistribconf
blob: 5ea82b2f16645e9400e1ab4a121ca346e283ab51 (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
#!/usr/bin/perl

# $Id$

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

sub usage {
    print STDERR <<EOF;
$0 -h|-m [options] path1 [path2 ...]
Dump Mandriva Linux distrib configuration.

-h      output an hdlists file
-m      output an media.cfg file
-d      write the directly into the dedicated location
EOF
    exit 1;
};

my ($out, $outputtype) = (\*STDOUT, 'm');
GetOptions(
    h => sub { $outputtype = 'h' },
    m => sub { $outputtype = 'm' },
    d => sub { undef $out },
);

@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__