commit 9e1b8f5d50385852b76773e8693a4ea30ab21fd5
parent 30143ebecda1e65dc72a5ff1f4e789762206b647
Author: Andreas Guldstrand <andreas.guldstrand@gmail.com>
Date: Sat, 25 Mar 2017 16:27:28 +0100
sboinstall: add --reinstall commandline option.
This fixes #58.
Diffstat:
3 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/man1/sboinstall.1 b/man1/sboinstall.1
@@ -56,6 +56,11 @@ Skip viewing of the README and the yes or no question which accompanies it. Anyt
This option causes sboinstall to skip requirement handling, but still show the README and prompt the user to proceed.
.RE
.P
+--reinstall
+.RS
+This option asks if we should reinstall anything among the requirements that is already installed.
+.RE
+.P
--create-template (FILE)
.RS
Create a template for the SlackBuilds including any optional commands or build options that you wish to set and store this in the specified FILE.
diff --git a/sboinstall b/sboinstall
@@ -44,6 +44,8 @@ Options (defaults shown first where applicable):
non-interactive; skips README and all prompts.
-R|--norequirements:
view the README but do not parse requirements, commands, or options.
+ --reinstall:
+ Ask to reinstall any already-installed packages in the requirement list.
--create-template (FILE):
create a template with specified requirements, commands, and options.
--use-template (FILE):
@@ -57,7 +59,7 @@ EOF
my $noclean = $config{NOCLEAN};
my $distclean = $config{DISTCLEAN};
my $jobs = $config{JOBS};
-my ($help, $vers, $no_install, $non_int, $no_reqs, $compat32, $ctemp, $utemp);
+my ($help, $vers, $no_install, $non_int, $no_reqs, $compat32, $ctemp, $utemp, $reinstall);
GetOptions(
'help|h' => \$help,
@@ -69,6 +71,7 @@ GetOptions(
'compat32|p' => \$compat32,
'nointeractive|r' => \$non_int,
'norequirements|R' => \$no_reqs,
+ 'reinstall' => \$reinstall,
'create-template=s' => \$ctemp,
'use-template=s' => \$utemp,
);
@@ -150,8 +153,13 @@ FIRST: for my $sbo (@$build_queue) {
my $name = $compat32 ? "$sbo-compat32" : $sbo;
if ($inst_names{$name}) {
- say sprintf "%s (%s) is already installed.", $name, $inst_names{$name}{pkg};
- next FIRST;
+ my $inst_msg = sprintf "%s (%s) is already installed.", $name, $inst_names{$name}{pkg};
+ if ($reinstall and not $non_int) {
+ next FIRST unless prompt("$inst_msg Do you want to reinstall from SBo?", default => 'no');
+ } else {
+ say $inst_msg;
+ next FIRST;
+ }
} else {
if ($sbo =~ /^perl-/) {
my $pm_name = $sbo;
diff --git a/t/15-usage.t b/t/15-usage.t
@@ -130,6 +130,8 @@ Options (defaults shown first where applicable):
non-interactive; skips README and all prompts.
-R|--norequirements:
view the README but do not parse requirements, commands, or options.
+ --reinstall:
+ Ask to reinstall any already-installed packages in the requirement list.
--create-template (FILE):
create a template with specified requirements, commands, and options.
--use-template (FILE):