Rewrite bootstrap script to drop git dependency
This commit is contained in:
43
setup.pl
Executable file
43
setup.pl
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env perl
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
|
||||
use Archive::Tar;
|
||||
use File::Temp ();
|
||||
use IPC::System::Simple qw(capture);
|
||||
use LWP::Simple;
|
||||
|
||||
|
||||
print "Setting up...\n";
|
||||
|
||||
# GitHub repository to clone
|
||||
my $author = $ENV{'DOTFILES_AUTHOR'} // 'andrejusk';
|
||||
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.sh';
|
||||
print "Using installer $installer\n";
|
||||
|
||||
# Download repo
|
||||
my $repository_url = "https://github.com/$author/$repository/archive/$branch.tar.gz";
|
||||
my $temp_handle = File::Temp->new();
|
||||
my $repository_temp = $temp_handle->filename;
|
||||
print "Downloading $repository_url to $repository_temp\n";
|
||||
getstore($repository_url, $repository_temp);
|
||||
|
||||
# Extract repo
|
||||
my $temp_dir = File::Temp->newdir();
|
||||
my $tar = Archive::Tar->new;
|
||||
print "Extracting $repository_temp to $temp_dir\n";
|
||||
$tar->read($repository_temp);
|
||||
$tar->setcwd($temp_dir);
|
||||
$tar->extract();
|
||||
|
||||
# Install repo
|
||||
my $installer_path = "$temp_dir/$repository-$branch/$installer";
|
||||
print 'Running installer <' . $installer_path . ">\n";
|
||||
my $output = capture([0,1,2], $^X, $installer_path);
|
||||
print $output;
|
||||
Reference in New Issue
Block a user