X-Git-Url: http://git.ipfire.org/?p=ipfire-2.x.git;a=blobdiff_plain;f=src%2Fpakfire%2Flib%2Ffunctions.pl;h=cfb7e51175f30a7ffb790ade89a7ae5a19bc38f9;hp=133b4950f49a860557f3492edfea7bf5802906fc;hb=bb6481a82072cf2df27306508c8b72b584eb4f80;hpb=4200583c7084c8a048ce9b568bac62a8a4e8bcb1 diff --git a/src/pakfire/lib/functions.pl b/src/pakfire/lib/functions.pl index 133b4950f4..cfb7e51175 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 # @@ -34,8 +34,8 @@ use Net::Ping; package Pakfire; # GPG Keys -my $myid = "64D96617"; # Our own gpg-key paks@ipfire.org -my $trustid = "65D0FD58"; # gpg-key of CaCert +my $myid = "179740DC4D8C47DC63C099C74BDE364C64D96617"; # Our own gpg-key paks@ipfire.org +my $trustid = "A31D4F81EF4EBD07B456FA04D2BB0D0165D0FD58"; # gpg-key of CaCert # A small color-hash :D my %color; @@ -305,7 +305,12 @@ sub selectmirror { } } logger("MIRROR INFO: $scount servers found in list"); - + + if ($scount eq 0) { + logger("MIRROR INFO: Could not find any servers. Falling back to main server $Conf::mainserver"); + return ("HTTP", $Conf::mainserver, "/$Conf::version"); + } + ### Choose a random server and test if it is online # If the check fails try a new server. # This will never give up. @@ -388,6 +393,7 @@ sub dbgetlist { foreach $file (@files) { next if ( $file eq "." ); next if ( $file eq ".." ); + next if ( $file eq "meta-" ); next if ( $file =~ /^old/ ); open(FILE, "<$Conf::dbdir/meta/$file"); @meta = ; @@ -513,8 +519,13 @@ sub dblist { } elsif ("$filter" eq "installed") { next unless ( -e "$Conf::dbdir/installed/meta-$templine[0]" ); } - if ("$forweb" eq "forweb") { - print "\n"; + if ("$forweb" eq "forweb") + { + if ("$filter" eq "notinstalled") { + print "\n"; + } else { + print "\n"; + } } else { if ("$Pakfire::enable_colors" eq "1") { if (&isinstalled("$templine[0]")) { @@ -530,7 +541,7 @@ sub dblist { } } -sub resolvedeps { +sub resolvedeps_one { my $pak = shift; getmetafile("$pak"); @@ -542,7 +553,7 @@ sub resolvedeps { close(FILE); my $line; - my (@templine, @deps, @tempdeps, @all); + my (@templine, @deps, @all); foreach $line (@file) { @templine = split(/\: /,$line); if ("$templine[0]" eq "Dependencies") { @@ -557,33 +568,63 @@ sub resolvedeps { message("PAKFIRE RESV: $pak: Dependency is already installed: $_"); } else { message("PAKFIRE RESV: $pak: Need to install dependency: $_"); - push(@tempdeps,$_); push(@all,$_); } } } - foreach (@tempdeps) { - if ($_) { - my @newdeps = resolvedeps("$_"); - foreach(@newdeps) { - unless (($_ eq " ") || ($_ eq "")) { - my $return = &isinstalled($_); - if ($return eq 0) { - message("PAKFIRE RESV: $pak: Dependency is already installed: $_"); - } else { - message("PAKFIRE RESV: $pak: Need to install dependency: $_"); - push(@all,$_); - } - } + return @all; +} + +sub resolvedeps { + my $pak = shift; + my @all; + + # Resolve all not yet installed dependencies of $pak + my @deps = &resolvedeps_one($pak); + push(@all, @deps); + + # For each dependency, we check if more dependencies exist + while (@deps) { + my $dep = pop(@deps); + + my @subdeps = &resolvedeps_one($dep); + foreach my $subdep (@subdeps) { + # Skip the package we are currently resolving for + next if ($pak eq $subdep); + + # If the package is not already to be installed, + # we add it to the list (@all) and check if it has + # more dependencies on its own. + unless (grep {$_ eq $subdep} @all) { + push(@deps, $subdep); + push(@all, $subdep); } } } - message(""); - chomp (@all); + return @all; } +sub resolvedeps_recursive { + my @packages = @_; + 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; @@ -690,7 +731,7 @@ sub getpak { } unless ($file) { - message("No filename given in meta-file. Please phone the developers."); + message("No filename given in meta-file."); exit 1; } @@ -865,6 +906,7 @@ sub checkcryptodb { unless ( "$ret" eq "0" ) { message("CRYPTO WARN: The GnuPG isn't configured corectly. Trying now to fix this."); message("CRYPTO WARN: It's normal to see this on first execution."); + message("CRYPTO WARN: If this message is being shown repeatedly, check if time and date are set correctly, and if IPFire can connect via port 11371 TCP."); my $command = "gpg --keyserver pgp.ipfire.org --always-trust --status-fd 2"; system("$command --recv-key $myid >> $Conf::logdir/gnupg-database.log 2>&1"); system("$command --recv-key $trustid >> $Conf::logdir/gnupg-database.log 2>&1");