]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/pakfire/lib/functions.pl
Asynchrones Syslogging aktiviert (Performancegruende)
[people/pmueller/ipfire-2.x.git] / src / pakfire / lib / functions.pl
1 #!/usr/bin/perl -w
2
3 require "/opt/pakfire/etc/pakfire.conf";
4 require "/var/ipfire/general-functions.pl";
5
6 use File::Basename;
7 use File::Copy;
8 use LWP::UserAgent;
9 use HTTP::Response;
10 use HTTP::Headers;
11 use HTTP::Message;
12 use HTTP::Request;
13 use Net::Ping;
14
15 package Pakfire;
16
17 # A small color-hash :D
18 my %color;
19 $color{'normal'} = "\033[0m";
20 $color{'black'} = "\033[0;30m";
21 $color{'darkgrey'} = "\033[1;30m";
22 $color{'blue'} = "\033[0;34m";
23 $color{'lightblue'} = "\033[1;34m";
24 $color{'green'} = "\033[0;32m";
25 $color{'lightgreen'} = "\033[1;32m";
26 $color{'cyan'} = "\033[0;36m";
27 $color{'lightcyan'} = "\033[1;36m";
28 $color{'red'} = "\033[0;31m";
29 $color{'lightred'} = "\033[1;31m";
30 $color{'purple'} = "\033[0;35m";
31 $color{'lightpurple'} = "\033[1;35m";
32 $color{'brown'} = "\033[0;33m";
33 $color{'lightgrey'} = "\033[0;37m";
34 $color{'yellow'} = "\033[1;33m";
35 $color{'white'} = "\033[1;37m";
36
37 my $final_data;
38 my $total_size;
39 my $bfile;
40
41 my %pakfiresettings = ();
42 &General::readhash("${General::swroot}/pakfire/settings", \%pakfiresettings);
43
44 sub message {
45 my $message = shift;
46
47 logger("$message");
48 if ("$message" =~ /ERROR/) {
49 $message = "$color{'red'}$message$color{'normal'}";
50 } elsif ("$message" =~ /INFO/) {
51 $message = "$color{'cyan'}$message$color{'normal'}";
52 } elsif ("$message" =~ /WARN/) {
53 $message = "$color{'yellow'}$message$color{'normal'}";
54 } elsif ("$message" =~ /RESV/) {
55 $message = "$color{'purple'}$message$color{'normal'}";
56 } elsif ("$message" =~ /INST/) {
57 $message = "$color{'green'}$message$color{'normal'}";
58 } elsif ("$message" =~ /REMV/) {
59 $message = "$color{'lightred'}$message$color{'normal'}";
60 } elsif ("$message" =~ /UPGR/) {
61 $message = "$color{'lightblue'}$message$color{'normal'}";
62 }
63 print "$message\n";
64
65 }
66
67 sub logger {
68 my $log = shift;
69 system("logger -f /var/log/pakfire.log -t pakfire \"$log\"") if "$log";
70 }
71
72 sub usage {
73 &Pakfire::message("Usage: pakfire <install|remove> <pak(s)>");
74 &Pakfire::message(" <update> - Contacts the servers for new lists of paks.");
75 &Pakfire::message(" <upgrade> - Installs the latest version of all paks.");
76 &Pakfire::message(" <list> - Outputs a short list with all available paks.");
77 &Pakfire::message("");
78 exit 1;
79 }
80
81 sub pinghost {
82 my $host = shift;
83
84 $p = Net::Ping->new();
85 if ($p->ping($host)) {
86 logger("PING INFO: $host is alive");
87 return 1;
88 } else {
89 logger("PING INFO: $host is unreachable");
90 return 0;
91 }
92 $p->close();
93 }
94
95 sub fetchfile {
96 my $getfile = shift;
97 my $gethost = shift;
98 my (@server, $host, $proto, $file, $allok, $i);
99
100 logger("DOWNLOAD STARTED: $getfile") unless ($bfile =~ /^counter\?.*/);
101 use File::Basename;
102 $bfile = basename("$getfile");
103
104 $i = 0;
105 while (($allok == 0) && $i < 5) {
106 $i++;
107
108 if ("$gethost" eq "") {
109 @server = selectmirror();
110 $proto = $server[0];
111 $host = $server[1];
112 $file = "$server[2]/$getfile";
113 } else {
114 $host = $gethost;
115 $file = $getfile;
116 }
117
118 $proto = "HTTP" unless $proto;
119
120 unless ($bfile =~ /^counter\?.*/) {
121 logger("DOWNLOAD INFO: Host: $host ($proto) - File: $file");
122 #message("DOWNLOAD INFO: Loading $bfile from ($proto) $host...");
123 }
124
125 my $ua = LWP::UserAgent->new;
126 $ua->agent("Pakfire/$Conf::version");
127 $ua->timeout(5);
128
129 my %proxysettings=();
130 &General::readhash("${General::swroot}/proxy/advanced/settings", \%proxysettings);
131
132 if ($proxysettings{'UPSTREAM_PROXY'}) {
133 logger("DOWNLOAD INFO: Upstream proxy: \"$proxysettings{'UPSTREAM_PROXY'}\"") unless ($bfile =~ /^counter\?.*/);
134 if ($proxysettings{'UPSTREAM_USER'}) {
135 $ua->proxy("http","http://$proxysettings{'UPSTREAM_USER'}:$proxysettings{'UPSTREAM_PASSWORD'}@"."$proxysettings{'UPSTREAM_PROXY'}/");
136 logger("DOWNLOAD INFO: Logging in with: \"$proxysettings{'UPSTREAM_USER'}\" - \"$proxysettings{'UPSTREAM_PASSWORD'}\"") unless ($bfile =~ /^counter\?.*/);
137 } else {
138 $ua->proxy("http","http://$proxysettings{'UPSTREAM_PROXY'}/");
139 }
140 }
141
142 $final_data = undef;
143 my $url = "http://$host/$file";
144 my $response;
145
146 unless ($bfile =~ /^counter\?.*/) {
147 my $result = $ua->head($url);
148 my $remote_headers = $result->headers;
149 $total_size = $remote_headers->content_length;
150 logger("DOWNLOAD INFO: $file has size of $total_size bytes");
151
152 $response = $ua->get($url, ':content_cb' => \&callback );
153 message("");
154 } else {
155 $response = $ua->get($url);
156 }
157
158 my $code = $response->code();
159 my $log = $response->status_line;
160 logger("DOWNLOAD INFO: HTTP-Status-Code: $code - $log");
161
162 if ( $code eq "500" ) {
163 message("Giving up: There was no chance to get the file \"$getfile\" from any available server.\nThere was an error on the way. Please fix it.");
164 return 1;
165 }
166
167 if ($response->is_success) {
168 unless ($bfile =~ /^counter\?.*/) {
169 if (open(FILE, ">$Conf::tmpdir/$bfile")) {
170 print FILE $final_data;
171 close(FILE);
172 logger("DOWNLOAD INFO: File received. Start checking signature...");
173 if (system("gpg --verify \"$Conf::tmpdir/$bfile\" &>/dev/null") eq 0) {
174 logger("DOWNLOAD INFO: Signature of $bfile is fine.");
175 move("$Conf::tmpdir/$bfile","$Conf::cachedir/$bfile");
176 } else {
177 message("DOWNLOAD ERROR: The downloaded file ($file) wasn't verified by IPFire.org. Sorry - Exiting...");
178 exit 1;
179 }
180 logger("DOWNLOAD FINISHED: $file");
181 $allok = 1;
182 return 0;
183 } else {
184 logger("DOWNLOAD ERROR: Could not open $Conf::cachedir/$bfile for writing.");
185 }
186 } else {
187 return 0;
188 }
189 } else {
190 logger("DOWNLOAD ERROR: $log");
191 }
192 }
193 message("DOWNLOAD ERROR: There was no chance to get the file \"$getfile\" from any available server.\nMay be you should run \"pakfire update\" to get some new servers.");
194 return 1;
195 }
196
197 sub getmirrors {
198 use File::Copy;
199
200 logger("MIRROR: Trying to get a mirror list.");
201
202 fetchfile("$Conf::version/lists/server-list.db", "$Conf::mainserver");
203 move("$Conf::cachedir/server-list.db", "$Conf::dbdir/lists/server-list.db");
204 }
205
206 sub selectmirror {
207 ### Check if there is a current server list and read it.
208 # If there is no list try to get one.
209 my $count = 0;
210 while (!(open(FILE, "<$Conf::dbdir/lists/server-list.db")) && ($count lt 5)) {
211 $count++;
212 getmirrors();
213 }
214 if ($count == 5) {
215 message("MIRROR ERROR: Could not find or download a server list");
216 exit 1;
217 }
218 my @lines = <FILE>;
219 close(FILE);
220
221 ### Count the number of the servers in the list
222 my $scount = 0;
223 my @newlines;
224 foreach (@lines) {
225 if ("$_" =~ /.*;.*;.*;/ ) {
226 push(@newlines,$_);
227 $scount++;
228 }
229 }
230 logger("MIRROR INFO: $scount servers found in list");
231
232 ### Choose a random server and test if it is online
233 # If the check fails try a new server.
234 # This will never give up.
235 my $found = 0;
236 my $servers = 0;
237 while ($found == 0) {
238 $server = int(rand($scount) + 1);
239 $servers = 0;
240 my ($line, $proto, $path, $host);
241 my @templine;
242 foreach $line (@newlines) {
243 $servers++;
244 if ($servers eq $server) {
245 @templine = split(/\;/, $line);
246 $proto = $templine[0];
247 $host = $templine[1];
248 $path = $templine[2];
249 if (pinghost("$host")) {
250 $found = 1;
251 return ($proto, $host, $path);
252 }
253 }
254 }
255 }
256 }
257
258 sub dbgetlist {
259 ### Update the database if the file is older than one day.
260 # If you pass &Pakfire::dbgetlist(force) the list will be downloaded.
261 # Usage is always with an argument.
262 my $force = shift;
263 my $age;
264
265 use File::Copy;
266
267 if ( -e "$Conf::dbdir/lists/packages_list.db" ) {
268 my @stat = stat("$Conf::dbdir/lists/packages_list.db");
269 my $time = time();
270 $age = $time - $stat[9];
271 } else {
272 # Force an update.
273 $age = "86401";
274 }
275
276 if (("$age" gt "86400") || ("$force" eq "force")) {
277 fetchfile("lists/packages_list.db", "");
278 move("$Conf::cachedir/packages_list.db", "$Conf::dbdir/lists/packages_list.db");
279 }
280 }
281
282 sub dblist {
283 ### This subroutine lists the packages.
284 # You may also pass a filter: &Pakfire::dblist(filter)
285 # Usage is always with two arguments.
286 # filter may be: all, notinstalled, installed
287 my $filter = shift;
288 my $forweb = shift;
289 my @meta;
290 my @updatepaks;
291 my $file;
292 my $line;
293 my $prog;
294 my ($name, $version, $release);
295 my @templine;
296
297 ### Make sure that the list is not outdated.
298 dbgetlist("noforce");
299
300 open(FILE, "<$Conf::dbdir/lists/packages_list.db");
301 my @db = <FILE>;
302 close(FILE);
303
304 if ("$filter" eq "upgrade") {
305 opendir(DIR,"$Conf::dbdir/meta");
306 my @files = readdir(DIR);
307 closedir(DIR);
308 foreach $file (@files) {
309 next if ( $file eq "." );
310 next if ( $file eq ".." );
311 open(FILE, "<$Conf::dbdir/meta/$file");
312 @meta = <FILE>;
313 close(FILE);
314 foreach $line (@meta) {
315 @templine = split(/\: /,$line);
316 if ("$templine[0]" eq "Name") {
317 $name = $templine[1];
318 chomp($name);
319 } elsif ("$templine[0]" eq "ProgVersion") {
320 $version = $templine[1];
321 chomp($version);
322 } elsif ("$templine[0]" eq "Release") {
323 $release = $templine[1];
324 chomp($release);
325 }
326 }
327 foreach $prog (@db) {
328 @templine = split(/\;/,$prog);
329 if (("$name" eq "$templine[0]") && ("$release" < "$templine[2]" )) {
330 push(@updatepaks,$name);
331 if ("$forweb" eq "forweb") {
332 print "<option value=\"$name\">Update: $name -- Version: $version -> $templine[1] -- Release: $release -> $templine[2]</option>\n";
333 } else {
334 print "Update: $name\nVersion: $version -> $templine[1]\nRelease: $release -> $templine[2]\n\n";
335 }
336 }
337 }
338 }
339 return @updatepaks;
340 } else {
341 my $line;
342 my @templine;
343 foreach $line (sort @db) {
344 next unless ($line =~ /.*;.*;.*;/ );
345 @templine = split(/\;/,$line);
346 if ("$filter" eq "notinstalled") {
347 next if ( -e "$Conf::dbdir/installed/meta-$templine[0]" );
348 } elsif ("$filter" eq "installed") {
349 next unless ( -e "$Conf::dbdir/installed/meta-$templine[0]" );
350 }
351 if ("$forweb" eq "forweb") {
352 print "<option value=\"$templine[0]\">$templine[0]-$templine[1]-$templine[2]</option>\n";
353 } else {
354 print "Name: $templine[0]\nProgVersion: $templine[1]\nRelease: $templine[2]\n\n";
355 }
356 }
357 }
358 }
359
360 sub resolvedeps {
361 my $pak = shift;
362
363 getmetafile("$pak");
364
365 message("PAKFIRE RESV: $pak: Resolving dependencies...");
366
367 open(FILE, "<$Conf::dbdir/meta/meta-$pak");
368 my @file = <FILE>;
369 close(FILE);
370
371 my $line;
372 my (@templine, @deps, @tempdeps, @all);
373 foreach $line (@file) {
374 @templine = split(/\: /,$line);
375 if ("$templine[0]" eq "Dependencies") {
376 @deps = split(/ /, $templine[1]);
377 }
378 }
379 chomp (@deps);
380 foreach (@deps) {
381 if ($_) {
382 my $return = &isinstalled($_);
383 if ($return eq 0) {
384 message("PAKFIRE RESV: $pak: Dependency is already installed: $_");
385 } else {
386 message("PAKFIRE RESV: $pak: Need to install dependency: $_");
387 push(@tempdeps,$_);
388 push(@all,$_);
389 }
390 }
391 }
392
393 foreach (@tempdeps) {
394 if ($_) {
395 my @newdeps = resolvedeps("$_");
396 foreach(@newdeps) {
397 unless (($_ eq " ") || ($_ eq "")) {
398 my $return = &isinstalled($_);
399 if ($return eq 0) {
400 message("PAKFIRE RESV: $pak: Dependency is already installed: $_");
401 } else {
402 message("PAKFIRE RESV: $pak: Need to install dependency: $_");
403 push(@all,$_);
404 }
405 }
406 }
407 }
408 }
409 message("");
410 chomp (@all);
411 return @all;
412 }
413
414 sub cleanup {
415 my $dir = shift;
416 my $path;
417
418 logger("CLEANUP: $dir");
419
420 if ( "$dir" eq "meta" ) {
421 $path = "$Conf::dbdir/meta";
422 } elsif ( "$dir" eq "tmp" ) {
423 $path = "$Conf::tmpdir";
424 }
425 chdir("$path");
426 opendir(DIR,".");
427 my @files = readdir(DIR);
428 closedir(DIR);
429 foreach (@files) {
430 unless (($_ eq ".") || ($_ eq "..")) {
431 system("rm -rf $_");
432 }
433 }
434 }
435
436 sub getmetafile {
437 my $pak = shift;
438
439 unless ( -e "$Conf::dbdir/meta/meta-$pak") {
440 fetchfile("meta/meta-$pak", "");
441 move("$Conf::cachedir/meta-$pak", "$Conf::dbdir/meta/meta-$pak");
442 }
443
444 open(FILE, "<$Conf::dbdir/meta/meta-$pak");
445 my @line = <FILE>;
446 close(FILE);
447
448 open(FILE, ">$Conf::dbdir/meta/meta-$pak");
449 foreach (@line) {
450 my $string = $_;
451 $string =~ s/\r\n/\n/g;
452 print FILE $string;
453 }
454 close(FILE);
455 return 1;
456 }
457
458 sub getsize {
459 my $pak = shift;
460
461 getmetafile("$pak");
462
463 open(FILE, "<$Conf::dbdir/meta/meta-$pak");
464 my @file = <FILE>;
465 close(FILE);
466
467 my $line;
468 my @templine;
469 foreach $line (@file) {
470 @templine = split(/\: /,$line);
471 if ("$templine[0]" eq "Size") {
472 chomp($templine[1]);
473 return $templine[1];
474 }
475 }
476 return 0;
477 }
478
479 sub decryptpak {
480 my $pak = shift;
481
482 cleanup("tmp");
483
484 my $file = getpak("$pak", "noforce");
485
486 logger("DECRYPT STARTED: $pak");
487 my $return = system("cd $Conf::tmpdir/ && gpg -d --batch --quiet --no-verbose --status-fd 2 --output - < $Conf::cachedir/$file 2>/dev/null | tar x");
488 $return %= 255;
489 logger("DECRYPT FINISHED: $pak - Status: $return");
490 if ($return != 0) { exit 1; }
491 }
492
493 sub getpak {
494 my $pak = shift;
495 my $force = shift;
496
497 getmetafile("$pak");
498
499 open(FILE, "<$Conf::dbdir/meta/meta-$pak");
500 my @file = <FILE>;
501 close(FILE);
502
503 my $line;
504 my $file;
505 my @templine;
506 foreach $line (@file) {
507 @templine = split(/\: /,$line);
508 if ("$templine[0]" eq "File") {
509 chomp($templine[1]);
510 $file = $templine[1];
511 }
512 }
513
514 unless ($file) {
515 message("No filename given in meta-file. Please phone the developers.");
516 exit 1;
517 }
518
519 unless ( "$force" eq "force" ) {
520 if ( -e "$Conf::cachedir/$file" ) {
521 return $file;
522 }
523 }
524
525 fetchfile("paks/$file", "");
526 return $file;
527 }
528
529 sub setuppak {
530 my $pak = shift;
531
532 message("PAKFIRE INST: $pak: Decrypting...");
533 decryptpak("$pak");
534
535 message("PAKFIRE INST: $pak: Copying files and running post-installation scripts...");
536 my $return = system("cd $Conf::tmpdir && NAME=$pak ./install.sh >> $Conf::logdir/install-$pak.log 2>&1");
537 $return %= 255;
538 if ($pakfiresettings{'UUID'} ne "off") {
539 fetchfile("cgi-bin/counter?ver=$Conf::version&uuid=$Conf::uuid&ipak=$pak&return=$return", "$Conf::mainserver");
540 }
541 if ($return == 0) {
542 move("$Conf::tmpdir/ROOTFILES", "$Conf::dbdir/rootfiles/$pak");
543 cleanup("tmp");
544 copy("$Conf::dbdir/meta/meta-$pak","$Conf::dbdir/installed/");
545 message("PAKFIRE INST: $pak: Finished.");
546 message("");
547 } else {
548 message("PAKFIRE ERROR: Returncode: $return. Sorry. Please search our forum to find a solution for this problem.");
549 exit $return;
550 }
551 return $return;
552 }
553
554 sub isinstalled {
555 my $pak = shift;
556 if ( open(FILE,"<$Conf::dbdir/installed/meta-$pak") ) {
557 close(FILE);
558 return 0;
559 } else {
560 return 1;
561 }
562 }
563
564 sub upgradepak {
565 my $pak = shift;
566
567 message("PAKFIRE UPGR: $pak: Decrypting...");
568 decryptpak("$pak");
569
570 message("PAKFIRE UPGR: $pak: Upgrading files and running post-upgrading scripts...");
571 my $return = system("cd $Conf::tmpdir && NAME=$pak ./update.sh >> $Conf::logdir/update-$pak.log 2>&1");
572 $return %= 255;
573 if ($pakfiresettings{'UUID'} ne "off") {
574 fetchfile("cgi-bin/counter?ver=$Conf::version&uuid=$Conf::uuid&upak=$pak&return=$return", "$Conf::mainserver");
575 }
576 if ($return == 0) {
577 move("$Conf::tmpdir/ROOTFILES", "$Conf::dbdir/rootfiles/$pak");
578 cleanup("tmp");
579 copy("$Conf::dbdir/meta/meta-$pak","$Conf::dbdir/installed/");
580 message("PAKFIRE UPGR: $pak: Finished.");
581 message("");
582 } else {
583 message("PAKFIRE ERROR: Returncode: $return. Sorry. Please search our forum to find a solution for this problem.");
584 exit $return;
585 }
586 return $return;
587 }
588
589 sub removepak {
590 my $pak = shift;
591
592 message("PAKFIRE REMV: $pak: Decrypting...");
593 decryptpak("$pak");
594
595 message("PAKFIRE REMV: $pak: Removing files and running post-removing scripts...");
596 my $return = system("cd $Conf::tmpdir && NAME=$pak ./uninstall.sh >> $Conf::logdir/uninstall-$pak.log 2>&1");
597 $return %= 255;
598 if ($pakfiresettings{'UUID'} ne "off") {
599 fetchfile("cgi-bin/counter?ver=$Conf::version&uuid=$Conf::uuid&dpak=$pak&return=$return", "$Conf::mainserver");
600 }
601 if ($return == 0) {
602 open(FILE, "<$Conf::dbdir/rootfiles/$pak");
603 my @file = <FILE>;
604 close(FILE);
605 foreach (@file) {
606 my $line = $_;
607 chomp($line);
608 system("echo \"Removing: $line\" >> $Conf::logdir/uninstall-$pak.log 2>&1");
609 system("cd / && rm -rf $line >> $Conf::logdir/uninstall-$pak.log 2>&1");
610 }
611 unlink("$Conf::dbdir/rootfiles/$pak");
612 unlink("$Conf::dbdir/installed/meta-$pak");
613 cleanup("tmp");
614 message("PAKFIRE REMV: $pak: Finished.");
615 message("");
616 } else {
617 message("PAKFIRE ERROR: Returncode: $return. Sorry. Please search our forum to find a solution for this problem.");
618 exit $return;
619 }
620 return $return;
621 }
622
623 sub beautifysize {
624 my $size = shift;
625 #$size = $size / 1024;
626 my $unit;
627
628 if ($size > 1023*1024) {
629 $size = ($size / (1024*1024));
630 $unit = "MB";
631 } elsif ($size > 1023) {
632 $size = ($size / 1024);
633 $unit = "KB";
634 } else {
635 $unit = "B";
636 }
637 $size = sprintf("%.2f" , $size);
638 my $string = "$size $unit";
639 return $string;
640 }
641
642 sub makeuuid {
643 unless ( -e "$Conf::dbdir/uuid" ) {
644 open(FILE, "</proc/sys/kernel/random/uuid");
645 my @line = <FILE>;
646 close(FILE);
647
648 open(FILE, ">$Conf::dbdir/uuid");
649 foreach (@line) {
650 print FILE $_;
651 }
652 close(FILE);
653 }
654 }
655
656 sub senduuid {
657 if ($pakfiresettings{'UUID'} ne "off") {
658 unless("$Conf::uuid") {
659 $Conf::uuid = `cat $Conf::dbdir/uuid`;
660 }
661 logger("Sending my uuid: $Conf::uuid");
662 fetchfile("cgi-bin/counter?ver=$Conf::version&uuid=$Conf::uuid", "$Conf::mainserver");
663 system("rm -f $Conf::tmpdir/counter* 2>/dev/null");
664 }
665 }
666
667 sub checkcryptodb {
668 logger("CRYPTO INFO: Checking GnuPG Database");
669 my $myid = "64D96617"; # Our own gpg-key
670 my $trustid = "65D0FD58"; # Id of CaCert
671 my $ret = system("gpg --list-keys | grep -q $myid");
672 unless ( "$ret" eq "0" ) {
673 message("CRYPTO WARN: The GnuPG isn't configured corectly. Trying now to fix this.");
674 message("CRYPTO WARN: It's normal to see this on first execution.");
675 system("gpg --keyserver wwwkeys.de.pgp.net --always-trust --recv-key $myid &>>$Conf::logdir/gnupg-database.log");
676 system("gpg --keyserver wwwkeys.de.pgp.net --always-trust --recv-key $trustid &>>$Conf::logdir/gnupg-database.log");
677 } else {
678 logger("CRYPTO INFO: Database is okay");
679 }
680 }
681
682 sub callback {
683 my ($data, $response, $protocol) = @_;
684 $final_data .= $data;
685 print progress_bar( length($final_data), $total_size, 30, '=' );
686 }
687
688 sub progress_bar {
689 my ( $got, $total, $width, $char ) = @_;
690 my $show_bfile;
691 $width ||= 30; $char ||= '=';
692 my $len_bfile = length $bfile;
693 if ("$len_bfile" >= "17") {
694 $show_bfile = substr($bfile,0,17)."...";
695 } else {
696 $show_bfile = $bfile;
697 }
698 $progress = sprintf("%.2f%%", 100*$got/+$total);
699 sprintf "$color{'lightgreen'}%-20s %7s |%-${width}s| %10s$color{'normal'}\r",$show_bfile, $progress, $char x (($width-1)*$got/$total). '>', beautifysize($got);
700 }
701
702 1;