From 9f1f68f17ade67dbd52a58837f7a47a8458055e4 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 16 May 2015 12:57:28 +0200 Subject: [PATCH] pakfire: fix dep resolve at upgrade. --- src/pakfire/lib/functions.pl | 21 ++++++++++++++++++++- src/pakfire/pakfire | 33 +++++++++++++++++++-------------- 2 files changed, 39 insertions(+), 15 deletions(-) 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") { -- 2.39.2