summaryrefslogtreecommitdiffstats
path: root/lib/MGA/DrakISO/Config.pm
diff options
context:
space:
mode:
authorMartin Whitaker <mageia@martin-whitaker.me.uk>2017-12-18 10:54:01 +0000
committerMartin Whitaker <mageia@martin-whitaker.me.uk>2017-12-18 10:54:01 +0000
commit296dc5bb53c430c8842ab7327d8a76b5750c64b4 (patch)
tree5670e983d5d459466dac2b7a49b7ce14827c7e9d /lib/MGA/DrakISO/Config.pm
parent7e53518a7d8709998482eef1e9da21ee1a1886a9 (diff)
downloaddrakiso-296dc5bb53c430c8842ab7327d8a76b5750c64b4.tar
drakiso-296dc5bb53c430c8842ab7327d8a76b5750c64b4.tar.gz
drakiso-296dc5bb53c430c8842ab7327d8a76b5750c64b4.tar.bz2
drakiso-296dc5bb53c430c8842ab7327d8a76b5750c64b4.tar.xz
drakiso-296dc5bb53c430c8842ab7327d8a76b5750c64b4.zip
Start creating a new set of tools for generating Mageia ISO images.
The aim is to share as much code as possible between the tool used to generate the Live ISOs and the tool used to generate the classic installer ISOs. This is derived from the user/martinw/use-grub2 branch of draklive.
Diffstat (limited to 'lib/MGA/DrakISO/Config.pm')
-rw-r--r--lib/MGA/DrakISO/Config.pm100
1 files changed, 100 insertions, 0 deletions
diff --git a/lib/MGA/DrakISO/Config.pm b/lib/MGA/DrakISO/Config.pm
new file mode 100644
index 0000000..a8b8e88
--- /dev/null
+++ b/lib/MGA/DrakISO/Config.pm
@@ -0,0 +1,100 @@
+package MGA::DrakISO::Config;
+
+use MDK::Common;
+use Pod::Usage;
+use Cwd 'getcwd';
+
+#- we bless Media objects here
+use MGA::DrakISO::Media;
+#- these modules can be used from config files
+use MGA::DrakISO::Mounts;
+use MGA::DrakISO::CustomMedia;
+
+our $default_config_root = '/etc/draklive';
+our $default_config_path = 'config/live.cfg';
+our $default_settings_path = 'config/settings.cfg';
+
+sub read_config {
+ my ($live, $config_root, $config_path, $settings_path) = @_;
+
+ if ($config_path && -e getcwd() . '/' . $config_path) {
+ $config_root = getcwd();
+ }
+ print "using $config_root as directory root\n";
+
+ add2hash($live->{settings} ||= {}, { getVarsFromSh($config_root . '/' . $settings_path) }) if $settings_path;
+ if ($config_path) {
+ #- don't use do(), since it can't see lexicals in the enclosing scope
+ my $cfg = eval(cat_($config_root . '/' . $config_path)) or die "unable to load $config_path: $@\n";
+ put_in_hash($live, $cfg);
+ print "loaded $config_path as config file\n";
+ }
+ $live->{settings}{config_root} = $config_root;
+}
+
+sub check_config {
+ my ($live) = @_;
+ unless (keys(%$live)) {
+ warn "no live definition\n";
+ Pod::Usage::pod2usage();
+ }
+ #- check for minimum requirements
+ ref $live->{media} && $live->{media}{storage} or die "no media storage definition\n";
+ ref $live->{system} or die "no system definition\n";
+}
+
+sub complete_config {
+ my ($live) = @_;
+
+ my $default_prefix = {
+ build => {
+ EFI => '/EFI',
+ boot => '/boot',
+ dist => '/dist',
+ files => '/files',
+ images => '/images',
+ initrd => '/initrd',
+ loopbacks => '/loopbacks',
+ modules => '/modules',
+ scripts => '/scripts',
+ },
+ media => {
+ EFI => '/EFI',
+ boot => '/boot',
+ hidden_boot => '/.boot',
+ loopbacks => '/loopbacks',
+ hidden_loopbacks => '/.loopbacks',
+ mnt => '/media',
+ },
+ live => {
+ mnt => '/live',
+ },
+ };
+
+ #- set unsupplied config dirs
+ add2hash($live->{prefix}{$_} ||= {}, $default_prefix->{$_}) foreach keys %$default_prefix;
+
+ $live->{settings}{builddir} ||= '/var/lib/draklive/build';
+ $live->{settings}{chroot} ||= '/var/lib/draklive/chroot';
+
+ $live->{settings}{arch} ||= chomp_(`rpm --eval '%{_target_cpu}'`);
+ $live->{media}{title} ||= "live";
+
+ $_ = MGA::DrakISO::Media::new($_) foreach (
+ $live->{media},
+ ($live->{replicator} ? $live->{replicator}{media} : ()),
+ ($live->{oem_rescue} ? $live->{oem_rescue}{media} : ()),
+ );
+
+ mkdir_p($live->get_builddir);
+ mkdir_p($live->get_system_root);
+ $live->{mnt} ||= $live->get_builddir . "/mnt";
+}
+
+sub dump_config {
+ my ($live) = @_;
+ use Data::Dumper;
+ print Data::Dumper->Dump([ $live ], [ "live" ]);
+}
+
+1;