diff options
Diffstat (limited to 'draklive')
-rwxr-xr-x | draklive | 220 |
1 files changed, 220 insertions, 0 deletions
diff --git a/draklive b/draklive new file mode 100755 index 0000000..d4f1c36 --- /dev/null +++ b/draklive @@ -0,0 +1,220 @@ +#!/usr/bin/perl + +# 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. + +use lib qw(/usr/lib/libDrakX); + +use strict; + +use MDK::Common; +use common; + +use Getopt::Long; +use Pod::Usage; + +use MGA::DrakISO::Config; +use MGA::DrakISO::Live; +use MGA::DrakISO::Utils; + +use MGA::DrakISO::BuildRoot; +use MGA::DrakISO::BuildBoot; +use MGA::DrakISO::BuildLoop; +use MGA::DrakISO::BuildISO; + +############################################################################### +# Actions +############################################################################### + +sub clean { + my ($live) = @_; + # make sure no external filesystems are mounted before cleaning + umount_external_fs($live); + rm_rf($_) foreach grep { -e $_ } $live->get_builddir, $live->get_system_root; +} + +sub prepare_root { + my ($live) = @_; + MGA::DrakISO::BuildRoot::install_live_system($live); + MGA::DrakISO::BuildRoot::customise_live_system($live); +} + +sub prepare_boot { + my ($live) = @_; + MGA::DrakISO::BuildBoot::prepare_live_system_boot($live); + MGA::DrakISO::BuildBoot::prepare_iso_bootloader($live); +} + +############################################################################### +# Main Program +############################################################################### + +my @actions = ( + { name => 'dump-config', do => \&MGA::DrakISO::Config::dump_config }, + { name => 'clean', do => \&clean }, + { name => 'root', do => \&prepare_root }, + { name => 'root-create', do => \&MGA::DrakISO::BuildRoot::install_live_system }, + { name => 'root-customise', do => \&MGA::DrakISO::BuildRoot::customise_live_system }, + { name => 'boot', do => \&prepare_boot }, + { name => 'boot-system', do => \&MGA::DrakISO::BuildBoot::prepare_live_system_boot }, + { name => 'boot-loader', do => \&MGA::DrakISO::BuildBoot::prepare_iso_bootloader }, + { name => 'loop', do => \&MGA::DrakISO::BuildLoop::build_live_loopback_files }, + { name => 'master', do => \&MGA::DrakISO::BuildISO::build_live_iso }, +); +my @all = qw(root boot loop master); + +die "you must be root to run this program\n" if $>; + +my $live_object = 'MGA::DrakISO::Live'->new; +my $config_root = $MGA::DrakISO::Config::default_config_root; +my $config_path = $MGA::DrakISO::Config::default_config_path; +my $settings_path = $MGA::DrakISO::Config::default_settings_path; + +GetOptions( + "help" => sub { Pod::Usage::pod2usage('-verbose' => 1) }, + "all" => sub { $_->{to_run} = 1 foreach grep { member($_->{name}, @all) } @actions }, + (map { $_->{name} => \$_->{to_run} } @actions), + "all-regions" => sub { $live_object->{all_regions} = 1 }, + "config-root=s" => \$config_root, + "config=s" => \$config_path, + "settings=s" => \$settings_path, + "define=s" => \%{$live_object->{settings}}, +) or Pod::Usage::pod2usage(); + +require standalone; + every { !$_->{to_run} } @actions and Pod::Usage::pod2usage(); + + MGA::DrakISO::Config::read_config($live_object, $config_root, $config_path, $settings_path); + MGA::DrakISO::Config::check_config($live_object); + MGA::DrakISO::Config::complete_config($live_object); + + foreach my $region ($live_object->{all_regions} ? sort(keys %{$live_object->{regions}}) : $live_object->{settings}{region}) { + $region and print qq(=== proceeding with region "$region"\n); + $live_object->{settings}{region} = $region; + foreach (grep { $_->{to_run} } @actions) { + print qq(* entering step "$_->{name}"\n); + $_->{do}->($live_object); + print qq(* step "$_->{name}" done\n); + } + } + +__END__ + +############################################################################### +# Documentation +############################################################################### + +=head1 NAME + +draklive - A live distribution mastering tool + +=head1 SYNOPSIS + +draklive [options] + + Options: + --help long help message + + --root install and customise Live system in chroot + --boot prepare system boot and ISO bootloader files + --loop build compressed loopback files + --master build master image + + --all run all the above steps + + --clean clean installation chroot and work directory + + --root-install (for debug) run base install of Live system + --root-customise (for debug) run system customisation steps + + --boot-system (for debug) prepare kernel and initrd for system boot + --boot-loader (for debug) prepare bootloader for ISO + + --config-root <dir> + root directory containing config and additional files + defaults to current directory if it contains a + configuration file, otherwise to "/etc/draklive" + + --config <file> use this configuration file as live description + defaults to "config/live.cfg" + + --settings <file> use this file as live settings (key=value format) + defaults to "config/settings.cfg" + + --define key=value + set setting "key" to "value" + takes precedence over values from a settings file + + --all-regions proceed with all configured regions + +Examples: + + draklive --clean + + draklive --all + + draklive --config config/live.cfg --root + +=head1 OPTIONS + +=over 8 + +=item B<--config> + +Makes draklive use the next argument as a configuration file. +This file should contain a hash describing the live distribution. +See the "drakiso-live" page on the Mageia Wiki for details. + +=item B<--settings> + +Makes draklive load the next argument as a file in key=value format into +the $live->{settings} hash ($live being the global live configuration hash). + +Built-in keys: + + arch: build architecture + + builddir: directory hosting build files (initrd, loopbacks, images) + + chroot: directory hosting chrooted installations + + region: use the matching set of langs from the regions configuration hash + + repository: path to the Mandriva distribution repository (ftp/http/local) + +Example keys: + desktop + media + product + +=back + +=head1 DESCRIPTION + +B<draklive> builds a live distribution according to a configuration file, +creates a master image, and optionally installs it on a device. + +See L<https://wiki.mageia.org/en/drakiso-live> + +=head1 AUTHORS + +Olivier Blin <oblin@mandriva.com> +Martin Whitaker <mageia@martin-whitaker.me.uk> + +=cut |