X-Git-Url: http://git.ipfire.org/?p=people%2Fpmueller%2Fipfire-2.x.git;a=blobdiff_plain;f=src%2Fpakfire%2Flib%2Ffunctions.pl;h=5aaa5f41fa872220cda201f41ab80bdff5895560;hp=650976281f348f2a3ec5c56a2a835258d475fdfd;hb=91bc781441cafde27a9b9794eb3ecf6f0776e92f;hpb=d1d1cb422688575df43fd6e5d37242af144a838e diff --git a/src/pakfire/lib/functions.pl b/src/pakfire/lib/functions.pl index 650976281f..5aaa5f41fa 100644 --- a/src/pakfire/lib/functions.pl +++ b/src/pakfire/lib/functions.pl @@ -116,7 +116,7 @@ sub usage { sub pinghost { my $host = shift; - $p = Net::Ping->new(); + $p = Net::Ping->new("icmp"); if ($p->ping($host)) { logger("PING INFO: $host is alive"); return 1; @@ -311,6 +311,7 @@ sub selectmirror { # This will never give up. my $found = 0; my $servers = 0; + my $pingdelay = 1; while ($found == 0) { $server = int(rand($scount) + 1); $servers = 0; @@ -323,10 +324,22 @@ sub selectmirror { $proto = $templine[0]; $host = $templine[1]; $path = $templine[2]; - if (pinghost("$host")) { + if ($pakfiresettings{'HEALTHCHECK'} eq "off") { + logger("PING INFO: Healthcheck is disabled"); $found = 1; return ($proto, $host, $path); } + elsif (pinghost("$host")) { + $found = 1; + return ($proto, $host, $path); + } + if ($found == 0) { + sleep($pingdelay); + $pingdelay=$pingdelay*2; + if ($pingdelay>1200) { + $pingdelay=1200; + } + } } } } @@ -356,6 +369,51 @@ sub dbgetlist { fetchfile("lists/packages_list.db", ""); move("$Conf::cachedir/packages_list.db", "$Conf::dbdir/lists/packages_list.db"); } + + # Update the meta database if new packages was in the package list + my @meta; + my $file; + my $line; + my $prog; + my ($name, $version, $release); + my @templine; + + open(FILE, "<$Conf::dbdir/lists/packages_list.db"); + my @db = ; + close(FILE); + + opendir(DIR,"$Conf::dbdir/meta"); + my @files = readdir(DIR); + closedir(DIR); + foreach $file (@files) { + next if ( $file eq "." ); + next if ( $file eq ".." ); + next if ( $file =~ /^old/ ); + open(FILE, "<$Conf::dbdir/meta/$file"); + @meta = ; + close(FILE); + foreach $line (@meta) { + @templine = split(/\: /,$line); + if ("$templine[0]" eq "Name") { + $name = $templine[1]; + chomp($name); + } elsif ("$templine[0]" eq "ProgVersion") { + $version = $templine[1]; + chomp($version); + } elsif ("$templine[0]" eq "Release") { + $release = $templine[1]; + chomp($release); + } + } + foreach $prog (@db) { + @templine = split(/\;/,$prog); + if (("$name" eq "$templine[0]") && ("$release" ne "$templine[2]")) { + move("$Conf::dbdir/meta/meta-$name","$Conf::dbdir/meta/old_meta-$name"); + fetchfile("meta/meta-$name", ""); + move("$Conf::cachedir/meta-$name", "$Conf::dbdir/meta/meta-$name"); + } + } + } } sub dblist { @@ -381,11 +439,14 @@ sub dblist { close(FILE); if ("$filter" eq "upgrade") { - if ("$forweb" ne "forweb") {getcoredb("noforce");} + if ("$forweb" ne "forweb" && "$forweb" ne "notice" ) {getcoredb("noforce");} eval(`grep "core_" $Conf::dbdir/lists/core-list.db`); if ("$core_release" > "$Conf::core_mine") { if ("$forweb" eq "forweb") { print "\n"; + } + elsif ("$forweb" eq "notice") { + print "


$Lang::tr{'core notice 1'} $Conf::core_mine $Lang::tr{'core notice 2'} $core_release $Lang::tr{'core notice 3'}"; } else { my $command = "Core-Update $Conf::version\nRelease: $Conf::core_mine -> $core_release\n"; if ("$Pakfire::enable_colors" eq "1") { @@ -396,13 +457,14 @@ sub dblist { } } - opendir(DIR,"$Conf::dbdir/meta"); + opendir(DIR,"$Conf::dbdir/installed"); my @files = readdir(DIR); closedir(DIR); foreach $file (@files) { next if ( $file eq "." ); next if ( $file eq ".." ); - open(FILE, "<$Conf::dbdir/meta/$file"); + next if ( $file =~ /^old/ ); + open(FILE, "<$Conf::dbdir/installed/$file"); @meta = ; close(FILE); foreach $line (@meta) { @@ -420,7 +482,7 @@ sub dblist { } foreach $prog (@db) { @templine = split(/\;/,$prog); - if (("$name" eq "$templine[0]") && ("$release" < "$templine[2]" )) { + if (("$name" eq "$templine[0]") && ("$release" < "$templine[2]" && "$forweb" ne "notice")) { push(@updatepaks,$name); if ("$forweb" eq "forweb") { print "\n";