]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - src/pakfire/lib/functions.pl
core90: Add changed vpnmain.cgi
[ipfire-2.x.git] / src / pakfire / lib / functions.pl
index ff330b54639aea3ed70fa6aa7c284e8aa6ac629b..d14e0314da05e1a7bfd5377cd7811c1812e22afd 100644 (file)
@@ -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;
@@ -220,7 +220,7 @@ sub fetchfile {
                                        $allok = 1;
                                        return 0;
                                } else {
-                                       logger("DOWNLOAD ERROR: Could not open $Conf::cachedir/$bfile for writing.");
+                                       logger("DOWNLOAD ERROR: Could not open $Conf::tmpdir/$bfile for writing.");
                                }
                        } else {
                                return 0;
@@ -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.
@@ -369,6 +374,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 = <FILE>;
+       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 = <FILE>;
+               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 {
@@ -820,7 +870,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.");
-               my $command = "gpg --keyserver pgp.mit.edu --always-trust --status-fd 2";
+               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");
        } else {