summaryrefslogtreecommitdiffstats
path: root/lib/MGA/DrakISO/ISOBuild.pm
blob: 2f4bce9c0f342e7734e9e2c741e66ab9607f8d02 (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
# Copyright (C) 2005 Mandriva
#                    Olivier Blin <oblin@mandriva.com>
# Copyright (C) 2017 Mageia
#                    Martin Whitaker <mageia@martin-whitaker.me.uk>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

# SYNOPSIS
# --------
# This package defines the base ISOBuild class that is used to hold all the
# settings and configuration values needed to build an ISO. It provides a
# number of helper functions which are used when building either type ISO.
# The subclasses ClassicBuild and LiveBuild extend this class with functions
# specific to building the two types of ISO.

package MGA::DrakISO::ISOBuild;

use strict;

use MDK::Common;

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

sub get_name {
    my ($build) = @_;
    my $fields = $build->{name_fields} || $build->default_name_fields;
    join('-', grep { $_ } @{$build->{settings}}{@$fields});
}

sub get_set_suffix {
    my ($build) = @_;
    $build->{settings}{set} ? "-$build->{settings}{set}" : "";
}

sub get_builddir {
    my ($build, $o_subdir) = @_;
    $build->{settings}{builddir} . '/' . $build->get_name . $build->get_set_suffix . if_($o_subdir, '/' . $o_subdir);
}

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

sub get_absolute_path {
    my ($build, $path) = @_;
    if (defined $path && substr($path, 0, 1) ne '/') {
        $build->{settings}{config_root} . '/' . $path;
    } else {
        $path;
    }
}

1;