...
 
Commits (3)
......@@ -1119,31 +1119,58 @@ sub create_and_copy_plugin_dir {
# function that install all the FD's plugins from a directory
sub install_plugins {
# ask for the plugins archive
my $plugins_archive = ask_user_input ("Where is your plugins archive ?");
my $plugins_archive = ask_user_input ("Where is your plugins archive or folder?");
die ("! ".$plugins_archive." doesn't exists") if (!-e $plugins_archive);
# check the archive format
$plugins_archive =~ /^.*\/(.*).tar.gz$/;
my $name = $1 or die ("! Unkwnow archive $plugins_archive");
my $dir;
if (-d $plugins_archive) {
$dir = dir ($plugins_archive);
} else {
# check the archive format
$plugins_archive =~ /^.*\/(.*).tar.gz$/;
my $name = $1 or die ("! Unkwnow archive $plugins_archive");
# where the extract files will go
my $tmp_plugins_dir = "/tmp";
print ("Installing plugins into $vars{fd_home}, please wait...\n");
# where the extract files will go
my $tmp_plugins_dir = "/tmp";
# extract the plugins archive
my $archive = Archive::Extract->new (archive => $plugins_archive);
my $extract = $archive->extract( to => "$tmp_plugins_dir" ) or die ("! Unable to extract $plugins_archive\n");
print ("Installing plugins into $vars{fd_home}, please wait...\n");
$dir = dir ($tmp_plugins_dir."/".$name);
}
my $dir = dir ($tmp_plugins_dir."/".$name);
# List non-hidden children, grep directories, and sort by name
my @plugins =
sort {$a->basename cmp $b->basename}
grep {$_->is_dir}
$dir->children(no_hidden => 1);
# extract the plugins archive
my $archive = Archive::Extract->new (archive => $plugins_archive);
my $extract = $archive->extract( to => "$tmp_plugins_dir" ) or die ("! Unable to extract $plugins_archive\n");
print "Available plugins:\n";
my @plugins = $dir->children;
my $i = 1;
foreach my $plugin_path (@plugins) {
print $i++.":".$plugin_path->basename."\n";
}
my $user_input = ask_user_input("Which plugins do you want to install (use \"all\" to install all plugins)?");
my @plugins_to_install = split(/\s/, $user_input);
chdir ($dir) or die ("! Unable to move to $dir\n");
$i = 0;
foreach my $plugin_path (@plugins) {
$plugin_path =~ /^$tmp_plugins_dir\/$name\/(.*)$/;
my $plugin = $1;
$i++;
my $plugin = $plugin_path->basename;
if (grep {($_ eq "all") or ($_ eq $i) or ($_ eq $plugin)} @plugins_to_install) {
print "Installing plugin $plugin\n";
} else {
next;
}
# copy addons into plugins
create_and_copy_plugin_dir($plugin_path."/addons/", $vars{fd_home}."/plugins/addons/");
......