summaryrefslogtreecommitdiffstats
path: root/lib/MDV/Draklive/Live.pm
blob: c8839c256e09f041cebbbea689cad78c70713fbc (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
package MDV::Draklive::Live;

use MDK::Common;

sub new {
    my ($class) = @_;
    bless {}, $class;
}

sub get_name {
    my ($live) = @_;
    join('-', grep { $_ } @{$live->{settings}}{qw(name product version desktop region media arch)});
}

sub get_builddir {
    my ($live) = @_;
    $live->{settings}{builddir} . '/' . $live->get_name;
}

sub get_system_root {
    my ($live) = @_;
    $live->{settings}{chroot} . '/' . $live->get_name;
}

sub get_media_prefix {
    my ($live, $setting, $o_boot) = @_;
    my $hidden = $live->{system}{hide_media_dirs} && $live->{media}->get_boot_setting('can_hide', { boot => $o_boot });
    $live->{prefix}{media}{$hidden ? "hidden_$setting" : $setting};
}

sub find_kernel {
    my ($live) = @_;
    my $kernel = $live->{system}{kernel};
    unless ($kernel) {
        my $vmlinuz = readlink($live->get_system_root . '/boot/vmlinuz');
        $vmlinuz ||= find { -e $_ && ! -l $_ } glob_($live->get_system_root . '/boot/vmlinuz-*');
        ($kernel) = $vmlinuz =~ /\bvmlinuz-(.*)$/ or die "no kernel can be found\n";
    }
    $kernel;
}

1;