Bootstrap using stow
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,7 +1,7 @@
|
||||
# install
|
||||
tmp
|
||||
.dotlock
|
||||
*.deb
|
||||
*.log
|
||||
|
||||
# pytest
|
||||
**/__pycache__
|
||||
|
||||
10
Makefile
10
Makefile
@@ -1,12 +1,18 @@
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Local commands
|
||||
# ---------------------------------------------------------------------------- #
|
||||
.PHONY: clean
|
||||
.PHONY: clean install
|
||||
|
||||
all:
|
||||
./bootstrap.pl
|
||||
|
||||
# @arg $TARGET binary to install
|
||||
all:
|
||||
install:
|
||||
./install.pl
|
||||
|
||||
clean:
|
||||
rm ./.install.*.log
|
||||
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Docker commands
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
19
bootstrap.pl
Executable file
19
bootstrap.pl
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use autodie;
|
||||
|
||||
use Cwd;
|
||||
use Stow;
|
||||
|
||||
|
||||
# Stow files
|
||||
my $dir = getcwd;
|
||||
my %stow_options = (
|
||||
dir => "$dir/files",
|
||||
target => "$ENV{'HOME'}"
|
||||
);
|
||||
my $stow = new Stow(%stow_options);
|
||||
my %conflicts = $stow->get_conflicts;
|
||||
$stow->process_tasks() unless %conflicts;
|
||||
|
||||
27
install.pl
27
install.pl
@@ -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) {
|
||||
|
||||
@@ -2,16 +2,15 @@
|
||||
source "$(dirname $0)/utils.sh"
|
||||
|
||||
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
|
||||
unzip awscliv2.zip -d "$dotfiles_dir/tmp"
|
||||
temp_dir=$(mktemp -d)
|
||||
unzip awscliv2.zip -d "$temp_dir"
|
||||
rm awscliv2.zip
|
||||
|
||||
if not_installed "aws"; then
|
||||
echo "Installing awscli..."
|
||||
sudo ./tmp/aws/install
|
||||
sudo $temp_dir/aws/install
|
||||
fi
|
||||
|
||||
echo "awscli is installed, upgrading..."
|
||||
sudo ./tmp/aws/install --update
|
||||
sudo $temp_dir/aws/install --update
|
||||
aws --version
|
||||
|
||||
rm -rf ./tmp/aws
|
||||
|
||||
10
setup.pl
10
setup.pl
@@ -18,10 +18,6 @@ my $repository = $ENV{'DOTFILES_REPOSITORY'} // 'dotfiles';
|
||||
my $branch = $ENV{'DOTFILES_BRANCH'} // 'master';
|
||||
print "Using repository $author/$repository at $branch\n";
|
||||
|
||||
# Installer filename
|
||||
my $installer = $ENV{'DOTFILES_INSTALLER'} // 'install.pl';
|
||||
print "Using installer $installer\n";
|
||||
|
||||
# Install location
|
||||
my $dotfiles_dir = $ENV{'DOTFILES_DIR'} // "$ENV{'HOME'}/.dotfiles";
|
||||
|
||||
@@ -46,7 +42,5 @@ print "Moving $temp_dotfiles_dir to $dotfiles_dir\n";
|
||||
move($temp_dotfiles_dir, $dotfiles_dir);
|
||||
|
||||
# Install repo
|
||||
my $installer_path = "$dotfiles_dir/$installer";
|
||||
print 'Running installer ' . $installer_path . "\n";
|
||||
my $output = capture([0,1,2], $^X, $installer_path);
|
||||
print $output;
|
||||
print "Running installer\n";
|
||||
my @output = capture([0,1,2], $^X, 'make install');
|
||||
|
||||
Reference in New Issue
Block a user