]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - src/pakfire/lib/functions.pl
validate GPG keys by fingerprint
[ipfire-2.x.git] / src / pakfire / lib / functions.pl
index d14e0314da05e1a7bfd5377cd7811c1812e22afd..cfb7e51175f30a7ffb790ade89a7ae5a19bc38f9 100644 (file)
@@ -2,7 +2,7 @@
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2007  Michael Tremer & Christian Schmidt                      #
+# Copyright (C) 2007-2015   IPFire Team   <info@ipfire.org>                   #
 #                                                                             #
 # 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;
@@ -393,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 = <FILE>;
@@ -518,8 +519,13 @@ sub dblist {
                        } elsif ("$filter" eq "installed") {
                                next unless ( -e "$Conf::dbdir/installed/meta-$templine[0]" );
                        }
-                       if ("$forweb" eq "forweb") {
-                               print "<option value=\"$templine[0]\">$templine[0]-$templine[1]-$templine[2]</option>\n";
+                       if ("$forweb" eq "forweb")
+                        {
+                               if ("$filter" eq "notinstalled") {
+                                       print "<option value=\"$templine[0]\">$templine[0]-$templine[1]-$templine[2]</option>\n";
+                               } else {
+                                       print "<option value=\"$templine[0]\">$templine[0]</option>\n";
+                               }
                        } else {
                                if ("$Pakfire::enable_colors" eq "1") {
                                        if (&isinstalled("$templine[0]")) {
@@ -535,7 +541,7 @@ sub dblist {
        }
 }
 
-sub resolvedeps {
+sub resolvedeps_one {
        my $pak = shift;
        
        getmetafile("$pak");
@@ -547,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") {
@@ -562,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;
@@ -695,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;
        }
        
@@ -870,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");