Bootstrap using stow
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,7 +1,7 @@
|
|||||||
# install
|
# install
|
||||||
tmp
|
tmp
|
||||||
.dotlock
|
|
||||||
*.deb
|
*.deb
|
||||||
|
*.log
|
||||||
|
|
||||||
# pytest
|
# pytest
|
||||||
**/__pycache__
|
**/__pycache__
|
||||||
|
|||||||
10
Makefile
10
Makefile
@@ -1,12 +1,18 @@
|
|||||||
# ---------------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------------- #
|
||||||
# Local commands
|
# Local commands
|
||||||
# ---------------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------------- #
|
||||||
.PHONY: clean
|
.PHONY: clean install
|
||||||
|
|
||||||
|
all:
|
||||||
|
./bootstrap.pl
|
||||||
|
|
||||||
# @arg $TARGET binary to install
|
# @arg $TARGET binary to install
|
||||||
all:
|
install:
|
||||||
./install.pl
|
./install.pl
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm ./.install.*.log
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------------- #
|
||||||
# Docker commands
|
# 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
|
#!/usr/bin/env perl
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
use autodie;
|
||||||
|
|
||||||
use Cwd;
|
use Cwd;
|
||||||
|
|
||||||
@@ -10,28 +11,36 @@ if ($< == 0) {
|
|||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $dir = getcwd;
|
||||||
|
|
||||||
# Generate unique logfile
|
# Generate unique logfile
|
||||||
my $uuid = `uuidgen`;
|
my $uuid = `uuidgen`;
|
||||||
chomp $uuid;
|
chomp $uuid;
|
||||||
my $log_path = "$ENV{'HOME'}/.dotfiles.$uuid.log";
|
my $log_path = "$dir/.install.$uuid.log";
|
||||||
print "Logs: $log_path\n";
|
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;
|
# Bootstrap files
|
||||||
my $install_dir = "$dir/install";
|
my $exit_status = `./bootstrap.pl >> $log_path 2>&1`;
|
||||||
print "Installing $install_dir\n";
|
print $exit_status;
|
||||||
|
|
||||||
# Read scripts to be installed
|
# 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";
|
opendir(DIR, $install_dir) or die "Could not open $install_dir\n";
|
||||||
my @files = readdir(DIR);
|
my @files = readdir(DIR);
|
||||||
closedir(DIR);
|
closedir(DIR);
|
||||||
|
@files = grep(/^\d{2}-.*\.sh$/, @files);
|
||||||
@files = sort { lc($a) cmp lc($b) } @files;
|
@files = sort { lc($a) cmp lc($b) } @files;
|
||||||
|
|
||||||
foreach my $file (@files)
|
# Install selected targets
|
||||||
{
|
my $target = $ENV{'TARGET'} // 'all';
|
||||||
# Install all scripts by default
|
if ($target ne 'all') {
|
||||||
next if($file !~ /^\d{2}-.*\.sh$/);
|
@files = grep(/${target}/, @files);
|
||||||
|
}
|
||||||
|
foreach my $file (@files) {
|
||||||
print "Running $file...\r";
|
print "Running $file...\r";
|
||||||
my $exit_status = system("/bin/bash -l $install_dir/$file >> $log_path 2>&1");
|
my $exit_status = system("/bin/bash -l $install_dir/$file >> $log_path 2>&1");
|
||||||
if ($exit_status != 0) {
|
if ($exit_status != 0) {
|
||||||
|
|||||||
@@ -2,16 +2,15 @@
|
|||||||
source "$(dirname $0)/utils.sh"
|
source "$(dirname $0)/utils.sh"
|
||||||
|
|
||||||
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
|
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
|
rm awscliv2.zip
|
||||||
|
|
||||||
if not_installed "aws"; then
|
if not_installed "aws"; then
|
||||||
echo "Installing awscli..."
|
echo "Installing awscli..."
|
||||||
sudo ./tmp/aws/install
|
sudo $temp_dir/aws/install
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "awscli is installed, upgrading..."
|
echo "awscli is installed, upgrading..."
|
||||||
sudo ./tmp/aws/install --update
|
sudo $temp_dir/aws/install --update
|
||||||
aws --version
|
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';
|
my $branch = $ENV{'DOTFILES_BRANCH'} // 'master';
|
||||||
print "Using repository $author/$repository at $branch\n";
|
print "Using repository $author/$repository at $branch\n";
|
||||||
|
|
||||||
# Installer filename
|
|
||||||
my $installer = $ENV{'DOTFILES_INSTALLER'} // 'install.pl';
|
|
||||||
print "Using installer $installer\n";
|
|
||||||
|
|
||||||
# Install location
|
# Install location
|
||||||
my $dotfiles_dir = $ENV{'DOTFILES_DIR'} // "$ENV{'HOME'}/.dotfiles";
|
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);
|
move($temp_dotfiles_dir, $dotfiles_dir);
|
||||||
|
|
||||||
# Install repo
|
# Install repo
|
||||||
my $installer_path = "$dotfiles_dir/$installer";
|
print "Running installer\n";
|
||||||
print 'Running installer ' . $installer_path . "\n";
|
my @output = capture([0,1,2], $^X, 'make install');
|
||||||
my $output = capture([0,1,2], $^X, $installer_path);
|
|
||||||
print $output;
|
|
||||||
|
|||||||
Reference in New Issue
Block a user