From: Michael Tremer Date: Sat, 16 May 2015 10:57:28 +0000 (+0200) Subject: pakfire: fix dep resolve at upgrade. X-Git-Tag: v2.17-core91~30^2^2~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9f1f68f17ade67dbd52a58837f7a47a8458055e4;p=ipfire-2.x.git pakfire: fix dep resolve at upgrade. --- diff --git a/src/pakfire/lib/functions.pl b/src/pakfire/lib/functions.pl index d14e0314da..85e01a060a 100644 --- a/src/pakfire/lib/functions.pl +++ b/src/pakfire/lib/functions.pl @@ -2,7 +2,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007 Michael Tremer & Christian Schmidt # +# Copyright (C) 2007-2015 IPFire Team # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -589,6 +589,25 @@ sub resolvedeps { return @all; } +sub resolvedeps_recursive { + my @packages = shift; + my @result = (); + + foreach my $pkg (@packages) { + my @deps = &Pakfire::resolvedeps($pkg); + + foreach my $dep (@deps) { + push(@result, $dep); + } + } + + # Sort the result array and remove dupes + my %sort = map{ $_, 1 } @result; + @result = keys %sort; + + return @result; +} + sub cleanup { my $dir = shift; my $path; diff --git a/src/pakfire/pakfire b/src/pakfire/pakfire index 3d0270aa41..8bca061aba 100644 --- a/src/pakfire/pakfire +++ b/src/pakfire/pakfire @@ -2,7 +2,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007 Michael Tremer & Christian Schmidt # +# Copyright (C) 2007-2015 IPFire Team # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -255,14 +255,11 @@ } elsif ("$ARGV[0]" eq "upgrade") { &Pakfire::upgradecore(); my @upgradepaks = &Pakfire::dblist("upgrade", "noweb"); - my @temp, $pak; - - foreach (@upgradepaks) { - @temp = &Pakfire::resolvedeps("$_"); - foreach (@temp) { push(@upgradepaks,$_) if $_; } - } - + if (@upgradepaks) { + # Resolve the dependencies of the to be upgraded packages + my @deps = &Pakfire::resolvedeps_recursive(@upgradepaks); + &Pakfire::message(""); &Pakfire::message("PAKFIRE UPGR: We are going to install all packages listed above."); if ($interactive) { @@ -277,16 +274,24 @@ } } - ### Download first + # Download packages foreach $pak (@upgradepaks) { - #system("mv $Conf::dbdir/meta/meta-$pak $Conf::dbdir/meta/old-meta-$pak"); &Pakfire::getpak("$pak", ""); } - + + # Download dependencies + foreach $pak (@deps) { + &Pakfire::getpak("$pak", ""); + } + + # Install dependencies first + foreach $pak (@deps) { + &Pakfire::setuppak("$pak"); + } + + # Install all upgrades foreach $pak (@upgradepaks) { - if (&Pakfire::upgradepak("$pak")) { - #system("mv $Conf::dbdir/meta/old-meta-$pak $Conf::dbdir/meta/meta-$pak"); - } + &Pakfire::upgradepak("$pak"); } } elsif ("$ARGV[0]" eq "list") {