diff options
-rwxr-xr-x | drakclassic | 5 | ||||
-rwxr-xr-x | draklive2 | 5 | ||||
-rw-r--r-- | lib/MGA/DrakISO/Config.pm | 30 |
3 files changed, 23 insertions, 17 deletions
diff --git a/drakclassic b/drakclassic index d5c6ca0..a7d7fad 100755 --- a/drakclassic +++ b/drakclassic @@ -76,7 +76,7 @@ my @actions = ( my @all = qw(media boot master); my $build_object = 'MGA::DrakISO::ClassicBuild'->new; -my $config_root = '/etc/drakclassic'; +my $config_root = '.'; my $config_path = 'config/build.cfg'; my $settings_path = 'config/settings.cfg'; @@ -132,8 +132,7 @@ drakclassic [options] --config-root <dir> root directory containing config and additional files - defaults to current directory if it contains a - configuration file, otherwise to "/etc/drakclassic" + defaults to current directory --config <file> use this configuration file to control the build defaults to "config/build.cfg" @@ -95,7 +95,7 @@ my @actions = ( my @all = qw(root boot loop master); my $build_object = 'MGA::DrakISO::LiveBuild'->new; -my $config_root = '/etc/draklive'; +my $config_root = '.'; my $config_path = 'config/build.cfg'; my $settings_path = 'config/settings.cfg'; @@ -164,8 +164,7 @@ draklive2 [options] --config-root <dir> root directory containing config and additional files - defaults to current directory if it contains a - configuration file, otherwise to "/etc/draklive" + defaults to current directory --config <file> use this configuration file to control the build defaults to "config/build.cfg" 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); |