use File::Path qw(mkpath);
use File::Spec::Functions qw(rel2abs);
+use make::console;
+
our @EXPORT = qw(create_directory
get_cpu_count
get_version
read_config_file
- module_installed);
+ write_config_file);
sub create_directory($$) {
my ($location, $permissions) = @_;
# Attempt to retrieve missing version information from Git
chomp(my $gr = `git describe --tags 2>/dev/null`);
- if ($gr =~ /^v([0-9]+)\.([0-9]+)\.([0-9]+)(?:-\d+-g(\w+))?$/) {
+ if ($gr =~ /^v([0-9]+)\.([0-9]+)\.([0-9]+)(?:[a-z]+\d+)?(?:-\d+-g(\w+))?$/) {
$version{MAJOR} //= $1;
$version{MINOR} //= $2;
$version{PATCH} //= $3;
return %version;
}
-sub module_installed($) {
- my $module = shift;
- eval("use $module;");
- return !$@;
-}
-
sub get_cpu_count {
my $count = 1;
if ($^O =~ /bsd/) {
return %config;
}
+sub write_config_file($%) {
+ my $path = shift;
+ my %config = @_;
+ open(my $fh, '>', $path) or print_error "unable to write to $path: $!";
+ while (my ($key, $value) = each %config) {
+ $value //= '';
+ say $fh "$key $value";
+ }
+ close $fh;
+}
+
1;