pkg-get.pl: support the -fr (force reinstall) option
This commit is contained in:
parent
44f3da7c5a
commit
3224209ff7
@ -30,15 +30,15 @@ my $curraction = ""; my %deps; my @dependencies; my %missingdeps;
|
||||
my %locked; my %installed;
|
||||
|
||||
# CL Options
|
||||
my $download_only; my $pre_install; my $post_install;
|
||||
my $install_scripts; my $filter = ""; my $all; my $unused;
|
||||
my $aargs=""; my $ignore_md5sum; my $force; my $root="";
|
||||
my $download_only; my $pre_install; my $post_install; my $root="";
|
||||
my $install_scripts; my $all; my $filter = ""; my $unused;
|
||||
my $aargs=""; my $ignore_md5sum; my $force; my $force_reinst;
|
||||
GetOptions("do"=>\$download_only,
|
||||
"pre-install"=>\$pre_install, "post-install"=>\$post_install,
|
||||
"install-scripts"=>\$install_scripts, "all"=>\$all,
|
||||
"filter=s"=>\$filter, "config=s"=>\$CFGFILE, "aargs=s"=>\$aargs,
|
||||
"f"=>\$force, "im"=>\$ignore_md5sum, "margs=s"=>\$unused,
|
||||
"rargs=s"=>\$unused, "r=s"=>\$root);
|
||||
"fr"=>\$force_reinst, "rargs=s"=>\$unused, "r=s"=>\$root);
|
||||
|
||||
# use compression-mode defined in pkgmk.conf
|
||||
our $compress = "gz";
|
||||
@ -395,8 +395,13 @@ sub getdependencies {
|
||||
# Download given package (if needed), check md5sum
|
||||
sub downloadpkg {
|
||||
my %pkg = @_;
|
||||
my $url = $pkg{'url'}; $url =~ s/\#/\%23/;
|
||||
my $fullpath = $pkg{'path'}."/".$pkg{'name'}."#".$pkg{'version'}."-".$pkg{'release'}.".pkg.tar.$compress";
|
||||
if (-f $fullpath) {
|
||||
return 0 if (($url eq "") and (! -f $fullpath)); # repo is local and pkg does not exist
|
||||
my $downloadcmd = "curl --retry 3 --retry-delay 3 -o $fullpath $url";
|
||||
(! $force_reinst) or system ($downloadcmd) == 0 or return 0;
|
||||
(-f $fullpath) or system ($downloadcmd) == 0 or return 0;
|
||||
# by now there should be a file in the expected location
|
||||
my $md5 = digest_file_hex($fullpath,"MD5");
|
||||
if ($md5 ne $pkg{'md5sum'} and not $ignore_md5sum) {
|
||||
print STDERR "=======> ERROR: md5sum mismatch for $pkg{'name'}:\n";
|
||||
@ -405,20 +410,6 @@ sub downloadpkg {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
} else {
|
||||
return 1 if ($pkg{'url'} eq ""); # repo is local and pkg does not exist
|
||||
my $url = $pkg{'url'};
|
||||
$url =~ s/\#/\%23/;
|
||||
system ("curl --retry 3 --retry-delay 3 -o $fullpath $url") == 0 or return 0;
|
||||
my $md5 = digest_file_hex($fullpath,"MD5");
|
||||
if ($md5 ne $pkg{'md5sum'} and not $ignore_md5sum) {
|
||||
print STDERR "=======> ERROR: md5sum mismatch for $pkg{'name'}:\n";
|
||||
print STDERR "required : $pkg{'md5sum'}\n";
|
||||
print STDERR "found : $md5\n";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Install given package
|
||||
@ -832,7 +823,9 @@ sub upinst {
|
||||
if (not %pkg) {
|
||||
push(@failtasks, "not found,$pkgname");
|
||||
} elsif ( ($cmd . getshortstatus(%pkg))
|
||||
=~ /^(update.i|update. |install.u|install.i)/ ) {
|
||||
=~ /^(update. |install.u|install.i)/ ) {
|
||||
push(@prevtasks, "$pkgname");
|
||||
} elsif ( (($cmd . getshortstatus(%pkg)) =~ /^update.i/) and (! $force_reinst) ) {
|
||||
push(@prevtasks, "$pkgname");
|
||||
} elsif (downloadpkg(%pkg)) {
|
||||
($download_only) or installpkg($aa, %pkg) or $failed=1;
|
||||
|
Loading…
Reference in New Issue
Block a user