Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 157103 | Differences between
and this patch

Collapse All | Expand All

(-)genlop.org (-4 / +84 lines)
Lines 23-28 Link Here
23
use POSIX;
23
use POSIX;
24
use Term::ANSIColor;
24
use Term::ANSIColor;
25
use Date::Manip;
25
use Date::Manip;
26
use LWP::Simple;
26
27
27
my $version  = "0.30.4";
28
my $version  = "0.30.4";
28
my @logfiles = ("/var/log/emerge.log");
29
my @logfiles = ("/var/log/emerge.log");
Lines 37-43 Link Here
37
    $search_found,  $unmerge_found, $list_found,    $file_found,
38
    $search_found,  $unmerge_found, $list_found,    $file_found,
38
    $time_found,    $help_found,    $current_found, $pretend_found,
39
    $time_found,    $help_found,    $current_found, $pretend_found,
39
    $version_found, $info_found,    $gmt_found,     $rsync_found,
40
    $version_found, $info_found,    $gmt_found,     $rsync_found,
40
    $info_ok,       $info_target,   $ssearch_found
41
    $info_ok,       $info_target,   $ssearch_found, $lhtomsg
41
);
42
);
42
# variabili globali del programma
43
# variabili globali del programma
43
my ($e_start, $e_end, $search_string, $m_count, $ebuild_found);
44
my ($e_start, $e_end, $search_string, $m_count, $ebuild_found);
Lines 216-221 Link Here
216
                $unmerge_found               = 1, last SSWITCH if ($opt eq "u");
217
                $unmerge_found               = 1, last SSWITCH if ($opt eq "u");
217
                $ENV{'ANSI_COLORS_DISABLED'} = 1, last SSWITCH if ($opt eq "n");
218
                $ENV{'ANSI_COLORS_DISABLED'} = 1, last SSWITCH if ($opt eq "n");
218
                $list_found                  = 1, last SSWITCH if ($opt eq "l");
219
                $list_found                  = 1, last SSWITCH if ($opt eq "l");
220
                $online_query                = 1, last SSWITCH if ($opt eq "q");
219
                $search_found                = 1, last SSWITCH if ($opt eq "s");
221
                $search_found                = 1, last SSWITCH if ($opt eq "s");
220
                $version_found               = 1, last SSWITCH if ($opt eq "v");
222
                $version_found               = 1, last SSWITCH if ($opt eq "v");
221
                $info_found                  = 1, last SSWITCH if ($opt eq "i");
223
                $info_found                  = 1, last SSWITCH if ($opt eq "i");
Lines 291-296 Link Here
291
      colored("  -n   ", $COLORS{'green'}), "no color in output\n",
293
      colored("  -n   ", $COLORS{'green'}), "no color in output\n",
292
      colored("  -p   ", $COLORS{'green'}),
294
      colored("  -p   ", $COLORS{'green'}),
293
      "estimate build time from a piped \"emerge -p\" output\n",
295
      "estimate build time from a piped \"emerge -p\" output\n",
296
      colored("  -q   ", $COLORS{'green'}),
297
      "query gentoo.linuxhowtos.org database if no local emerge was found\n",
294
      colored("  -r   ", $COLORS{'green'}),
298
      colored("  -r   ", $COLORS{'green'}),
295
      "search for portage tree sync/rsync history.\n",
299
      "search for portage tree sync/rsync history.\n",
296
      colored("  -s   ", $COLORS{'green'}),
300
      colored("  -s   ", $COLORS{'green'}),
Lines 418-423 Link Here
418
    return "$regexp";
422
    return "$regexp";
419
}
423
}
420
424
425
sub lhtoquery($$)
426
{
427
  my $vcpu=0,$pcpu=0,$opcpu=-1;
428
  my $modelname="";
429
  $packet=shift(@_);
430
  $countref=shift(@_);
431
  open(my $cmdline, "/proc/cpuinfo");
432
  while (<$cmdline>) {
433
    if (m/processor\s*:\s*(\d*)/)
434
    {
435
      $vcpu=$1 if ($1>$vcpu);
436
    }
437
    if (m/model name\s*:\s*(.*)$/)
438
    {
439
      $modelname=$1;
440
    }
441
    if (m/cache size\s*:\s*(.*)$/)
442
    {
443
      $cachesize=$1;
444
    }
445
    if (m/physical id\s*:\s*(\d*)$/)
446
    {
447
      $pcpu++ if ($1!=$opcpu);
448
      $opcpu=$1;
449
    }
450
  }
451
  $vcpu++;
452
  $cpuname=$pcpu."x $modelname $cachesize";
453
  $cpuname=~ s/ /%20/g;
454
  $retval=LWP::Simple::get("http://gentoo.linuxhowtos.org/query.php?cpuname=$cpuname&vcpu=$vcpu&packetname=$packet");
455
  if ($retval =~ m/estimate: (\d*) seconds/)
456
  {
457
    $$countref=1;
458
    return $1;
459
  }
460
  if ($retval =~ /unknown cpu/)
461
  {
462
    $lhtomsg="Your CPU is not yet known, please add it by following the instructions on http://gentoo.linuxhowtos.org/compiletimeestimator/";
463
  }
464
  return 0;
465
}
466
421
# --pretend or -p takes an emerge -p `-e -D world, system`, anything you want
467
# --pretend or -p takes an emerge -p `-e -D world, system`, anything you want
422
# and elaborates its output. for each package is calculated the average build
468
# and elaborates its output. for each package is calculated the average build
423
# time and summed together. this is the estimated merge time
469
# time and summed together. this is the estimated merge time
Lines 453-458 Link Here
453
                }
499
                }
454
            }
500
            }
455
            if ($e_count == 0) {
501
            if ($e_count == 0) {
502
              if ($online_query)
503
	      {
504
	        #query gentoo.linuxhowtos.org
505
		$tm_secondi+=lhtoquery($last_ebuild,\$e_count);
506
	      }
507
	    }
508
            if ($e_count == 0) {
456
                $ebuild_arg =~ s/\\//g;
509
                $ebuild_arg =~ s/\\//g;
457
                print "\n!!! Error: couldn't get previous ",
510
                print "\n!!! Error: couldn't get previous ",
458
                  "merge of $ebuild_arg; skipping...";
511
                  "merge of $ebuild_arg; skipping...";
Lines 460-465 Link Here
460
                # stored in logfile (ie a new package required by
513
                # stored in logfile (ie a new package required by
461
                # another, or a logfile corruption), prints a warning
514
                # another, or a logfile corruption), prints a warning
462
                # and keep track with $last_skipped
515
                # and keep track with $last_skipped
516
463
                $last_skipped = $ebuild_arg;
517
                $last_skipped = $ebuild_arg;
464
            } else {
518
            } else {
465
                $m_secondi += $tm_secondi / ($e_count);
519
                $m_secondi += $tm_secondi / ($e_count);
Lines 555-560 Link Here
555
        $current_found = 1;
609
        $current_found = 1;
556
        print "\n";
610
        print "\n";
557
        print "       ETA: ";
611
        print "       ETA: ";
612
        if (!$e_count &&$online_query)
613
        {
614
           #query gentoo.linuxhowtos.org
615
           $tm_secondi=lhtoquery($ebuild_arg,\$e_count);
616
	   $e_count=1;
617
        }
558
618
559
        if ($e_count && $e_start) {
619
        if ($e_count && $e_start) {
560
            &gtime(($tm_secondi / $e_count) - ($e_end - $e_start));
620
            &gtime(($tm_secondi / $e_count) - ($e_end - $e_start));
Lines 832-845 Link Here
832
        }
892
        }
833
    }
893
    }
834
    if (!$e_count and !$list_found and !$rsync_found) {
894
    if (!$e_count and !$list_found and !$rsync_found) {
835
        print color 'bold red';
895
        if ($e_count == 0) {
836
        print "!!! Error: no merge found for \'$ebuild_arg\'";
896
           if ($online_query) {
837
        print color 'reset';
897
	      #query gentoo.linuxhowtos.org
898
	      $tm_secondi+=lhtoquery($ebuild_arg,\$e_count);
899
	   }
900
	}
901
	if ($e_count >0) {
902
            print "Estimated merge time: ";
903
            &gtime($tm_secondi);
904
            &print_gtime();
905
	}
906
	else
907
	{
908
          print color 'bold red';
909
          print "!!! Error: no merge found for \'$ebuild_arg\'";
910
          print color 'reset';
911
	}
838
        print "\n";
912
        print "\n";
839
    } elsif ($info_found) {
913
    } elsif ($info_found) {
840
        &info($info_target);
914
        &info($info_target);
841
    } else {
915
    } else {
842
        $e_count = 0;
916
        $e_count = 0;
843
    }
917
    }
918
    if ($lhtomsg)
919
    {
920
      print color 'bold yellow';
921
      print "$lhtomsg\n";
922
      print color 'reset';
923
    }
844
}
924
}
845
925

Return to bug 157103