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 |
$pcpu=1 if ($pcpu==0); |
453 |
$cpuname=$pcpu."x $modelname $cachesize"; |
454 |
$cpuname=~ s/ /%20/g; |
455 |
$retval=LWP::Simple::get("http://gentoo.linuxhowtos.org/query.php?cpuname=$cpuname&vcpu=$vcpu&packetname=$packet"); |
456 |
if ($retval =~ m/estimate: (\d*) seconds/) |
457 |
{ |
458 |
$$countref=1; |
459 |
return $1; |
460 |
} |
461 |
if ($retval =~ /unknown cpu/) |
462 |
{ |
463 |
$lhtomsg="Your CPU is not yet known, please add it by following the instructions on http://gentoo.linuxhowtos.org/compiletimeestimator/"; |
464 |
} |
465 |
return 0; |
466 |
} |
467 |
|
421 |
# --pretend or -p takes an emerge -p `-e -D world, system`, anything you want |
468 |
# --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 |
469 |
# and elaborates its output. for each package is calculated the average build |
423 |
# time and summed together. this is the estimated merge time |
470 |
# time and summed together. this is the estimated merge time |
Lines 453-458
Link Here
|
453 |
} |
500 |
} |
454 |
} |
501 |
} |
455 |
if ($e_count == 0) { |
502 |
if ($e_count == 0) { |
|
|
503 |
if ($online_query) |
504 |
{ |
505 |
#query gentoo.linuxhowtos.org |
506 |
$tm_secondi+=lhtoquery($last_ebuild,\$e_count); |
507 |
} |
508 |
} |
509 |
if ($e_count == 0) { |
456 |
$ebuild_arg =~ s/\\//g; |
510 |
$ebuild_arg =~ s/\\//g; |
457 |
print "\n!!! Error: couldn't get previous ", |
511 |
print "\n!!! Error: couldn't get previous ", |
458 |
"merge of $ebuild_arg; skipping..."; |
512 |
"merge of $ebuild_arg; skipping..."; |
Lines 475-480
Link Here
|
475 |
"estimated time unknown."; |
529 |
"estimated time unknown."; |
476 |
print color 'reset'; |
530 |
print color 'reset'; |
477 |
print "\n"; |
531 |
print "\n"; |
|
|
532 |
if ($lhtomsg) |
533 |
{ |
534 |
print color 'bold yellow'; |
535 |
print "$lhtomsg\n"; |
536 |
print color 'reset'; |
537 |
} |
538 |
|
478 |
exit; |
539 |
exit; |
479 |
} |
540 |
} |
480 |
print "\n\nEstimated update time: "; |
541 |
print "\n\nEstimated update time: "; |
Lines 555-560
Link Here
|
555 |
$current_found = 1; |
616 |
$current_found = 1; |
556 |
print "\n"; |
617 |
print "\n"; |
557 |
print " ETA: "; |
618 |
print " ETA: "; |
|
|
619 |
if (!$e_count &&$online_query) |
620 |
{ |
621 |
#query gentoo.linuxhowtos.org |
622 |
$tm_secondi=lhtoquery($ebuild_arg,\$e_count); |
623 |
$e_count=1; |
624 |
} |
558 |
|
625 |
|
559 |
if ($e_count && $e_start) { |
626 |
if ($e_count && $e_start) { |
560 |
>ime(($tm_secondi / $e_count) - ($e_end - $e_start)); |
627 |
>ime(($tm_secondi / $e_count) - ($e_end - $e_start)); |
Lines 832-840
Link Here
|
832 |
} |
899 |
} |
833 |
} |
900 |
} |
834 |
if (!$e_count and !$list_found and !$rsync_found) { |
901 |
if (!$e_count and !$list_found and !$rsync_found) { |
835 |
print color 'bold red'; |
902 |
if ($e_count == 0) { |
836 |
print "!!! Error: no merge found for \'$ebuild_arg\'"; |
903 |
if ($online_query) { |
837 |
print color 'reset'; |
904 |
#query gentoo.linuxhowtos.org |
|
|
905 |
$tm_secondi+=lhtoquery($ebuild_arg,\$e_count); |
906 |
} |
907 |
} |
908 |
if ($e_count >0) { |
909 |
print "Estimated merge time: "; |
910 |
>ime($tm_secondi); |
911 |
&print_gtime(); |
912 |
} |
913 |
else |
914 |
{ |
915 |
print color 'bold red'; |
916 |
print "!!! Error: no merge found for \'$ebuild_arg\'"; |
917 |
print color 'reset'; |
918 |
} |
838 |
print "\n"; |
919 |
print "\n"; |
839 |
} elsif ($info_found) { |
920 |
} elsif ($info_found) { |
840 |
&info($info_target); |
921 |
&info($info_target); |
Lines 842-845
Link Here
|
842 |
$e_count = 0; |
923 |
$e_count = 0; |
843 |
} |
924 |
} |
844 |
} |
925 |
} |
|
|
926 |
if ($lhtomsg) |
927 |
{ |
928 |
print color 'bold yellow'; |
929 |
print "$lhtomsg\n"; |
930 |
print color 'reset'; |
931 |
} |
932 |
|
845 |
|
933 |
|