diff options
author | Martin Whitaker <mageia@martin-whitaker.me.uk> | 2017-12-19 15:56:01 +0000 |
---|---|---|
committer | Martin Whitaker <mageia@martin-whitaker.me.uk> | 2017-12-19 15:56:01 +0000 |
commit | 059b5c2a18e61cc7e4348e955025f9d77466647d (patch) | |
tree | 7afd2fa87166b389aaaf270397532aba8f394af0 /lib/MGA/DrakISO/LiveBuild.pm | |
parent | c0814f2d23fa79238624cbc541dc1b5ad5917292 (diff) | |
download | drakiso-059b5c2a18e61cc7e4348e955025f9d77466647d.tar drakiso-059b5c2a18e61cc7e4348e955025f9d77466647d.tar.gz drakiso-059b5c2a18e61cc7e4348e955025f9d77466647d.tar.bz2 drakiso-059b5c2a18e61cc7e4348e955025f9d77466647d.tar.xz drakiso-059b5c2a18e61cc7e4348e955025f9d77466647d.zip |
Split Live class into ISOBuild base class and LiveBuild subclass.
Diffstat (limited to 'lib/MGA/DrakISO/LiveBuild.pm')
-rw-r--r-- | lib/MGA/DrakISO/LiveBuild.pm | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/lib/MGA/DrakISO/LiveBuild.pm b/lib/MGA/DrakISO/LiveBuild.pm new file mode 100644 index 0000000..dbfda48 --- /dev/null +++ b/lib/MGA/DrakISO/LiveBuild.pm @@ -0,0 +1,81 @@ +# 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 LiveBuild subclass that is used to hold all the +# settings and configuration values needed to build a Live ISO. It provides +# a number of helper functions over and above those provided by the ISOBuild +# superclass. + +package MGA::DrakISO::LiveBuild; + +use strict; + +use MDK::Common; + +use MGA::DrakISO::ISOBuild; + +our @ISA = qw(MGA::DrakISO::ISOBuild); + +sub new { + my ($class) = @_; + bless {}, $class; +} + +sub default_name_fields { + my ($live) = @_; + [ qw(name version product desktop), + if_($live->{settings}{region} ne 'all', $live->{settings}{region}), + qw(arch media) + ]; +} + +sub get_langs { + my ($live) = @_; + uniq( + (ref $live->{regions} ? @{$live->{regions}{$live->{settings}{region}}} : ()), + @{$live->{system}{langs_always}} + ); +} + +sub get_system_root { + my ($live) = @_; + $live->{settings}{chroot} . '/' . $live->get_name . $live->get_set_suffix; +} + +sub find_kernel { + my ($live) = @_; + require bootloader; + local $::prefix = $live->get_system_root; + my @kernels = bootloader::get_kernels_and_labels(); + my $kernel; + if ($live->{system}{kernel}) { + $kernel = find { $_->{version} eq $live->{system}{kernel} } @kernels; + $kernel or die "kernel $live->{system}{kernel} can not be found\n"; + } + $kernel ||= first(@kernels) or die "no kernel can be found\n"; +} + +sub get_initrd_name { + my ($live) = @_; + 'initrd-' . $live->find_kernel->{version} . '.img'; +} + +1; |