Bootstrap using stow

This commit is contained in:
Andrejus
2020-07-12 03:07:01 +01:00
parent 21757767d2
commit b748e73e80
18 changed files with 52 additions and 25 deletions

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env perl
use strict;
use warnings;
use autodie;
use Cwd;
@@ -10,28 +11,36 @@ if ($< == 0) {
exit (1);
}
my $dir = getcwd;
# Generate unique logfile
my $uuid = `uuidgen`;
chomp $uuid;
my $log_path = "$ENV{'HOME'}/.dotfiles.$uuid.log";
my $log_path = "$dir/.install.$uuid.log";
print "Logs: $log_path\n";
# Ensure dependencies installed
`sudo apt-get update -y && sudo apt-get install -y liblocal-lib-perl cpanminus stow >> $log_path 2>&1`;
my $dir = getcwd;
my $install_dir = "$dir/install";
print "Installing $install_dir\n";
# Bootstrap files
my $exit_status = `./bootstrap.pl >> $log_path 2>&1`;
print $exit_status;
# Read scripts to be installed
my $install_dir = "$dir/install";
print "Installing $install_dir\n";
opendir(DIR, $install_dir) or die "Could not open $install_dir\n";
my @files = readdir(DIR);
closedir(DIR);
@files = grep(/^\d{2}-.*\.sh$/, @files);
@files = sort { lc($a) cmp lc($b) } @files;
foreach my $file (@files)
{
# Install all scripts by default
next if($file !~ /^\d{2}-.*\.sh$/);
# Install selected targets
my $target = $ENV{'TARGET'} // 'all';
if ($target ne 'all') {
@files = grep(/${target}/, @files);
}
foreach my $file (@files) {
print "Running $file...\r";
my $exit_status = system("/bin/bash -l $install_dir/$file >> $log_path 2>&1");
if ($exit_status != 0) {