From 750c1528a4f0234ffa757d1e1443ca66b000b53b Mon Sep 17 00:00:00 2001 From: ms Date: Wed, 1 Aug 2007 22:02:51 +0000 Subject: [PATCH] Die Farben im Pakfire sind nun abschaltbar. Hilfe erweitert. git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@731 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8 --- html/cgi-bin/pakfire.cgi | 22 ++++++++-------- src/pakfire/lib/functions.pl | 50 +++++++++++++++++++++--------------- src/pakfire/pakfire | 5 ++++ 3 files changed, 46 insertions(+), 31 deletions(-) diff --git a/html/cgi-bin/pakfire.cgi b/html/cgi-bin/pakfire.cgi index 93c493ea7d..42be29b77d 100644 --- a/html/cgi-bin/pakfire.cgi +++ b/html/cgi-bin/pakfire.cgi @@ -40,12 +40,12 @@ $pakfiresettings{'UUID'} = 'on'; if ($pakfiresettings{'ACTION'} eq 'install'){ $pakfiresettings{'INSPAKS'} =~ s/\|/\ /g; if ("$pakfiresettings{'FORCE'}" eq "on") { - my $command = "/usr/local/bin/pakfire install --non-interactive $pakfiresettings{'INSPAKS'} &>/dev/null &"; + my $command = "/usr/local/bin/pakfire install --non-interactive --no-colors $pakfiresettings{'INSPAKS'} &>/dev/null &"; system("$command"); sleep(2); } else { &Header::openbox("100%", "center", "Abfrage"); - my @output = `/usr/local/bin/pakfire resolvedeps $pakfiresettings{'INSPAKS'}`; + my @output = `/usr/local/bin/pakfire resolvedeps --no-colors $pakfiresettings{'INSPAKS'}`; print <$Lang::tr{'pakfire install package'}.$pakfiresettings{'INSPAKS'}.$Lang::tr{'pakfire possible dependency'}
		
@@ -79,11 +79,11 @@ END
 
 } elsif ($pakfiresettings{'ACTION'} eq 'update') {
 	
-	system("/usr/local/bin/pakfire update --force");
+	system("/usr/local/bin/pakfire update --force --no-colors");
 
 } elsif ($pakfiresettings{'ACTION'} eq 'upgrade') {
 	
-	system("/usr/local/bin/pakfire upgrade -y");
+	system("/usr/local/bin/pakfire upgrade -y --no-colors");
 	
 } elsif ($pakfiresettings{'ACTION'} eq "$Lang::tr{'save'}") {
 
@@ -126,13 +126,13 @@ if ($return) {
 			
 		
 END
-my @output = `tail /var/log/messages | grep pakfire`;
-foreach (@output) {
-	print "$_";
-}
-print <
-	
+	my @output = `tail -20 /var/log/pakfire.log`;
+	foreach (@output) {
+		print "$_";
+	}
+	print <
+		
 END
 	&Header::closebox();
 	&Header::closebigbox();
diff --git a/src/pakfire/lib/functions.pl b/src/pakfire/lib/functions.pl
index 36f1d157c1..95d9cf895f 100644
--- a/src/pakfire/lib/functions.pl
+++ b/src/pakfire/lib/functions.pl
@@ -14,6 +14,10 @@ use Net::Ping;
 
 package Pakfire;
 
+# GPG Keys
+my $myid = "64D96617";			# Our own gpg-key paks@ipfire.org
+my $trustid = "65D0FD58";		# gpg-key of CaCert
+
 # A small color-hash :D
 my %color;
 	$color{'normal'}      = "\033[0m"; 
@@ -33,6 +37,7 @@ my %color;
 	$color{'lightgrey'}   = "\033[0;37m";
 	$color{'yellow'}      = "\033[1;33m";
 	$color{'white'}       = "\033[1;37m";
+our $enable_colors = 1;
 
 my $final_data;
 my $total_size;
@@ -45,20 +50,22 @@ sub message {
 	my $message = shift;
 		
 	logger("$message");
-	if ("$message" =~ /ERROR/) {
-		$message = "$color{'red'}$message$color{'normal'}";
-	} elsif ("$message" =~ /INFO/) {
-		$message = "$color{'cyan'}$message$color{'normal'}";
-	} elsif ("$message" =~ /WARN/) {
-		$message = "$color{'yellow'}$message$color{'normal'}";
-	} elsif ("$message" =~ /RESV/) {
-		$message = "$color{'purple'}$message$color{'normal'}";
-	} elsif ("$message" =~ /INST/) {
-		$message = "$color{'green'}$message$color{'normal'}";
-	} elsif ("$message" =~ /REMV/) {
-		$message = "$color{'lightred'}$message$color{'normal'}";
-	} elsif ("$message" =~ /UPGR/) {
-		$message = "$color{'lightblue'}$message$color{'normal'}";
+	if ( $enable_colors == 1 ) {
+		if ("$message" =~ /ERROR/) {
+			$message = "$color{'red'}$message$color{'normal'}";
+		} elsif ("$message" =~ /INFO/) {
+			$message = "$color{'cyan'}$message$color{'normal'}";
+		} elsif ("$message" =~ /WARN/) {
+			$message = "$color{'yellow'}$message$color{'normal'}";
+		} elsif ("$message" =~ /RESV/) {
+			$message = "$color{'purple'}$message$color{'normal'}";
+		} elsif ("$message" =~ /INST/) {
+			$message = "$color{'green'}$message$color{'normal'}";
+		} elsif ("$message" =~ /REMV/) {
+			$message = "$color{'lightred'}$message$color{'normal'}";
+		} elsif ("$message" =~ /UPGR/) {
+			$message = "$color{'lightblue'}$message$color{'normal'}";
+		}
 	}
 	print "$message\n";
 	
@@ -73,11 +80,17 @@ sub logger {
 }
 
 sub usage {
-  &Pakfire::message("Usage: pakfire  ");
+  &Pakfire::message("Usage: pakfire  [options] ");
   &Pakfire::message("                - Contacts the servers for new lists of paks.");
   &Pakfire::message("                - Installs the latest version of all paks.");
   &Pakfire::message("                - Outputs a short list with all available paks.");
   &Pakfire::message("");
+  &Pakfire::message("       Global options:");
+  &Pakfire::message("               --non-interactive --> Enables the non-interactive mode.");
+  &Pakfire::message("                                     You won't see any question here.");
+  &Pakfire::message("                              -y --> Short for --non-interactive.");
+  &Pakfire::message("                     --no-colors --> Turns off the wonderful colors.");
+  &Pakfire::message("");
   exit 1;
 }
 
@@ -122,7 +135,6 @@ sub fetchfile {
 		
 		unless ($bfile =~ /^counter\?.*/) {
 			logger("DOWNLOAD INFO: Host: $host ($proto) - File: $file");
-			#message("DOWNLOAD INFO: Loading $bfile from ($proto) $host...");
 		}
 
 		my $ua = LWP::UserAgent->new;
@@ -669,14 +681,12 @@ sub senduuid {
 
 sub checkcryptodb {
 	logger("CRYPTO INFO: Checking GnuPG Database");
-	my $myid = "64D96617"; # Our own gpg-key
-	my $trustid = "65D0FD58"; # Id of CaCert
 	my $ret = system("gpg --list-keys | grep -q $myid");
 	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.");
-		system("gpg --keyserver wwwkeys.de.pgp.net --always-trust --recv-key $myid --status-fd 2 >> $Conf::logdir/gnupg-database.log 2>&1");
-		system("gpg --keyserver wwwkeys.de.pgp.net --always-trust --recv-key $trustid --status-fd 2 >> $Conf::logdir/gnupg-database.log 2>&1");
+		system("gpg --keyserver wwwkeys.de.pgp.net --always-trust --status-fd 2 --recv-key $myid >> $Conf::logdir/gnupg-database.log 2>&1");
+		system("gpg --keyserver wwwkeys.de.pgp.net --always-trust --status-fd 2 --recv-key $trustid >> $Conf::logdir/gnupg-database.log 2>&1");
 	} else {
 		logger("CRYPTO INFO: Database is okay");
 	}
diff --git a/src/pakfire/pakfire b/src/pakfire/pakfire
index ef9e427d4d..7ab6f7395c 100644
--- a/src/pakfire/pakfire
+++ b/src/pakfire/pakfire
@@ -39,8 +39,12 @@
 	
 	foreach (@ARGV) {
 		if ("$_" =~ "^-") {
+			# Turn off interactive mode
 			$interactive = 0 if ("$_" eq "--non-interactive");
 			$interactive = 0 if ("$_" eq "-y");
+			
+			# Turn off shell colors - Bad for displaying in webinterface
+			$Pakfire::enable_colors = 0 if ("$_" eq "--no-colors");
 		}
 	}
 
@@ -251,6 +255,7 @@
 	} elsif ("$ARGV[0]" eq "resolvedeps") {
 		foreach (@ARGV) {
 			next if ("$_" eq "resolvedeps");
+			next if ("$_" =~ "^-");
 			&Pakfire::resolvedeps("$_");
 		}
 	} else {
-- 
2.39.2