summaryrefslogtreecommitdiffstats
path: root/lib/MGA/DrakISO/Media.pm
blob: d69854fe8e99fc20a03667497735bf6633849d6a (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
package MGA::DrakISO::Media;

use strict;

use MDK::Common;
use POSIX;
use common;

use MGA::DrakISO::Storage;

sub new {
    my ($media) = @_;

    bless $media, 'MGA::DrakISO::Media';

    $media->{partitions} ||= [ { mntpoint => '/' } ];

    foreach my $mntpoint (qw(/ OEM_RESCUE)) {
        my $part = find { $_->{mntpoint} eq $mntpoint } @{$media->{partitions}};
        $part->{fs_type} ||= $media->get_media_setting('fs');
        if (my $label = $mntpoint eq '/' && $media->get_media_label) {
            $part->{device_LABEL} ||= $label;
        }
    }

    $media->{boot_entries} ||= [ '' => '' ];

    $media;
}

sub get_storage_setting {
    my ($media, $setting) = @_;
    $MGA::DrakISO::Storage::storage_types{$media->{storage}}{$setting};
}

#- for user-customisable media setting, that can override storage setting
sub get_media_setting {
    my ($media, $setting) = @_;
    $media->{$setting} || $media->get_storage_setting($setting);
}

sub get_media_label {
    my ($media) = @_;
    first($media->get_media_setting('source') =~ /^LABEL=(.*)$/);
}

1;