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

# $Id$

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

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

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

my ($out, $outputtype) = (\*STDOUT);

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

defined($outputtype) && @ARGV or do {
    usage;
    exit 1;
};

foreach (@ARGV) {
    print STDERR "$_\n";
    my $d = Distribconf->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";
    }
}