summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMartin Whitaker <mageia@martin-whitaker.me.uk>2018-04-01 19:49:13 +0100
committerMartin Whitaker <mageia@martin-whitaker.me.uk>2018-04-01 19:49:13 +0100
commit7cf01146c8f52d3025db18d93a3ff64b9b54e971 (patch)
treec35da9421fea0094b1ea3564a4074be571a11535 /lib
parentc6dd77e2cc4c79b33579a062afe19c3d50bc536a (diff)
downloaddrakiso-7cf01146c8f52d3025db18d93a3ff64b9b54e971.tar
drakiso-7cf01146c8f52d3025db18d93a3ff64b9b54e971.tar.gz
drakiso-7cf01146c8f52d3025db18d93a3ff64b9b54e971.tar.bz2
drakiso-7cf01146c8f52d3025db18d93a3ff64b9b54e971.tar.xz
drakiso-7cf01146c8f52d3025db18d93a3ff64b9b54e971.zip
Revised config and settings path handling.
Don't default to system dirs - we expect to run as normal user now.
Diffstat (limited to 'lib')
-rw-r--r--lib/MGA/DrakISO/Config.pm30
1 files changed, 19 insertions, 11 deletions
diff --git a/lib/MGA/DrakISO/Config.pm b/lib/MGA/DrakISO/Config.pm
index bd99e66..98d25ea 100644
--- a/lib/MGA/DrakISO/Config.pm
+++ b/lib/MGA/DrakISO/Config.pm
@@ -28,7 +28,7 @@ use strict;
use MDK::Common;
use Pod::Usage;
-use Cwd 'getcwd';
+use Cwd 'abs_path';
#- these modules can be used from config files
use MGA::DrakISO::Mounts;
@@ -40,18 +40,26 @@ our @EXPORT = qw(read_config check_config complete_config dump_config);
sub read_config {
my ($build, $config_root, $config_path, $settings_path) = @_;
- if ($config_path && -e getcwd() . '/' . $config_path) {
- $config_root = getcwd();
- }
+ $config_root = abs_path($config_root);
print "Using $config_root as directory root\n";
- add2hash($build->{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 "ERROR: unable to load $config_path: $@\n";
- put_in_hash($build, $cfg);
- print "Loaded $config_path as config file\n";
+ if (substr($config_path, 0, 1) ne '/') {
+ $config_path = $config_root . '/' . $config_path;
+ }
+ -e $config_path or die "ERROR: $config_path does not exist\n";
+
+ if (substr($settings_path, 0, 1) ne '/') {
+ $settings_path = $config_root . '/' . $settings_path;
}
+ -e $settings_path or die "ERROR: $settings_path does not exist\n";
+
+ add2hash($build->{settings} ||= {}, { getVarsFromSh($settings_path) });
+
+ #- don't use do(), since it can't see lexicals in the enclosing scope
+ my $cfg = eval(cat_($config_path)) or die "ERROR: unable to load $config_path: $@\n";
+ put_in_hash($build, $cfg);
+ print "Loaded $config_path as config file\n";
+
$build->{settings}{config_root} = $config_root;
}
@@ -73,7 +81,7 @@ sub check_config {
sub complete_config {
my ($build) = @_;
- $build->{settings}{workdir} ||= '/var/lib/drakiso';
+ $build->{settings}{workdir} = abs_path($build->{settings}{workdir} || '.');
mkdir_p($build->get_build_dir);
mkdir_p($build->get_chroot_dir);