summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Whitaker <mageia@martin-whitaker.me.uk>2017-12-19 20:31:56 +0000
committerMartin Whitaker <mageia@martin-whitaker.me.uk>2017-12-19 20:31:56 +0000
commitfb05b3866e0f591bbaa990f94c3755b544761778 (patch)
treea9010efeed1b7538898c34b6ffabde89832b7ba3
parent89841f2e2d8f4fe277b681fe97116ca2343e36e2 (diff)
downloaddrakiso-fb05b3866e0f591bbaa990f94c3755b544761778.tar
drakiso-fb05b3866e0f591bbaa990f94c3755b544761778.tar.gz
drakiso-fb05b3866e0f591bbaa990f94c3755b544761778.tar.bz2
drakiso-fb05b3866e0f591bbaa990f94c3755b544761778.tar.xz
drakiso-fb05b3866e0f591bbaa990f94c3755b544761778.zip
Add top-level program for building classic installer ISOs.
-rwxr-xr-xdrakclassic193
1 files changed, 193 insertions, 0 deletions
diff --git a/drakclassic b/drakclassic
new file mode 100755
index 0000000..b1c4c61
--- /dev/null
+++ b/drakclassic
@@ -0,0 +1,193 @@
+#!/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::ClassicBuild;
+use MGA::DrakISO::Utils;
+
+use MGA::DrakISO::BuildMedia;
+use MGA::DrakISO::BuildBoot;
+use MGA::DrakISO::BuildISO;
+
+###############################################################################
+# Actions
+###############################################################################
+
+sub clean {
+ my ($build) = @_;
+ rm_rf($_) foreach grep { -e $_ } $build->get_builddir, $build->get_system_root;
+}
+
+sub prepare_boot {
+ my ($build) = @_;
+ MGA::DrakISO::BuildBoot::prepare_classic_boot($build);
+ MGA::DrakISO::BuildBoot::prepare_iso_bootloader($build);
+}
+
+###############################################################################
+# Main Program
+###############################################################################
+
+my @actions = (
+ { name => 'dump-config', do => \&MGA::DrakISO::Config::dump_config },
+ { name => 'clean', do => \&clean },
+ { name => 'media', do => \&MGA::DrakISO::BuildMedia::prepare_media },
+ { name => 'boot', do => \&prepare_boot },
+ { name => 'boot-classic', do => \&MGA::DrakISO::BuildBoot::prepare_classic_boot },
+ { name => 'boot-loader', do => \&MGA::DrakISO::BuildBoot::prepare_iso_bootloader },
+ { name => 'master', do => \&MGA::DrakISO::BuildISO::build_classic_iso },
+);
+my @all = qw(media boot master);
+
+die "you must be root to run this program\n" if $>;
+
+my $build_object = 'MGA::DrakISO::ClassicBuild'->new;
+my $config_root = '/etc/drakclassic';
+my $config_path = 'config/build.cfg';
+my $settings_path = 'config/settings.cfg';
+
+GetOptions(
+ "help" => sub { Pod::Usage::pod2usage('-verbose' => 1) },
+ "all" => sub { $_->{to_run} = 1 foreach grep { member($_->{name}, @all) } @actions },
+ (map { $_->{name} => \$_->{to_run} } @actions),
+ "config-root=s" => \$config_root,
+ "config=s" => \$config_path,
+ "settings=s" => \$settings_path,
+ "define=s" => \%{$build_object->{settings}},
+) or Pod::Usage::pod2usage();
+
+require standalone;
+ every { !$_->{to_run} } @actions and Pod::Usage::pod2usage();
+
+ MGA::DrakISO::Config::read_config($build_object, $config_root, $config_path, $settings_path);
+ MGA::DrakISO::Config::check_config($build_object);
+ MGA::DrakISO::Config::complete_config($build_object);
+
+ foreach (grep { $_->{to_run} } @actions) {
+ print qq(* entering step "$_->{name}"\n);
+ $_->{do}->($build_object);
+ print qq(* step "$_->{name}" done\n);
+ }
+
+__END__
+
+###############################################################################
+# Documentation
+###############################################################################
+
+=head1 NAME
+
+drakclassic - A classic installer ISO mastering tool
+
+=head1 SYNOPSIS
+
+drakclassic [options]
+
+ Options:
+ --help long help message
+
+ --media prepare the installation media to be included on the ISO
+ --boot prepare installer boot and ISO bootloader files
+ --master build master image
+
+ --all run all the above steps
+
+ --clean clean installation chroot and work directory
+
+ --boot-system (for debug) prepare kernel and initrd for installer 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/drakclassic"
+
+ --config <file> use this configuration file to control the build
+ defaults to "config/build.cfg"
+
+ --settings <file> use this file as build 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
+
+Examples:
+
+ drakclassic --clean
+
+ drakclassic --all
+
+ drakclassic --config config/classic.cfg --media
+
+=head1 OPTIONS
+
+=over 8
+
+=item B<--config>
+
+Makes drakclassic use the next argument as a configuration file.
+This file should contain a hash specifying the ISO makeup.
+See the "drakiso-classic" page on the Mageia Wiki for details.
+
+=item B<--settings>
+
+Makes drakclassic load the next argument as a file in key=value format into
+the $build->{settings} hash ($build being the global configuration hash).
+
+Built-in keys:
+
+ arch: build architecture
+
+ builddir: directory hosting build files (initrd, loopbacks, images)
+
+ chroot: directory hosting chrooted urpm queries
+
+ repository: path to the Mandriva distribution repository (ftp/http/local)
+
+Example keys:
+ media
+ product
+
+=back
+
+=head1 DESCRIPTION
+
+B<drakclassic> builds a classic installer ISO according to a configuration file,
+creates a master image, and optionally installs it on a device.
+
+See L<https://wiki.mageia.org/en/drakiso-classic>
+
+=head1 AUTHORS
+
+Martin Whitaker <mageia@martin-whitaker.me.uk>
+
+=cut