]>
git.ipfire.org Git - ipfire-2.x.git/blob - src/pakfire/lib/functions.pl
c97d4254dc8aa17578e3533208db7015fb88bacc
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2015 IPFire Team <info@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 require "/opt/pakfire/etc/pakfire.conf" ;
23 require "/var/ipfire/general-functions.pl" ;
36 # A small color-hash :D
38 $color { 'normal' } = " \033 [0m" ;
39 $color { 'black' } = " \033 [0;30m" ;
40 $color { 'darkgrey' } = " \033 [1;30m" ;
41 $color { 'blue' } = " \033 [0;34m" ;
42 $color { 'lightblue' } = " \033 [1;34m" ;
43 $color { 'green' } = " \033 [0;32m" ;
44 $color { 'lightgreen' } = " \033 [1;32m" ;
45 $color { 'cyan' } = " \033 [0;36m" ;
46 $color { 'lightcyan' } = " \033 [1;36m" ;
47 $color { 'red' } = " \033 [0;31m" ;
48 $color { 'lightred' } = " \033 [1;31m" ;
49 $color { 'purple' } = " \033 [0;35m" ;
50 $color { 'lightpurple' } = " \033 [1;35m" ;
51 $color { 'brown' } = " \033 [0;33m" ;
52 $color { 'lightgrey' } = " \033 [0;37m" ;
53 $color { 'yellow' } = " \033 [1;33m" ;
54 $color { 'white' } = " \033 [1;37m" ;
55 our $enable_colors = 1 ;
61 my %pakfiresettings = ();
62 & General
:: readhash
( "${General::swroot}/pakfire/settings" , \
%pakfiresettings );
68 if ( $enable_colors == 1 ) {
69 if ( " $message " =~ /ERROR/ ) {
70 $message = " $color {'red'} $message $color {'normal'}" ;
71 } elsif ( " $message " =~ /INFO/ ) {
72 $message = " $color {'cyan'} $message $color {'normal'}" ;
73 } elsif ( " $message " =~ /WARN/ ) {
74 $message = " $color {'yellow'} $message $color {'normal'}" ;
75 } elsif ( " $message " =~ /RESV/ ) {
76 $message = " $color {'purple'} $message $color {'normal'}" ;
77 } elsif ( " $message " =~ /INST/ ) {
78 $message = " $color {'green'} $message $color {'normal'}" ;
79 } elsif ( " $message " =~ /REMV/ ) {
80 $message = " $color {'lightred'} $message $color {'normal'}" ;
81 } elsif ( " $message " =~ /UPGR/ ) {
82 $message = " $color {'lightblue'} $message $color {'normal'}" ;
92 #system("echo \"`date`: $log\" >> /var/log/pakfire.log");
93 system ( "logger -t pakfire \" $log \" " );
98 & Pakfire
:: message
( "Usage: pakfire <install|remove> [options] <pak(s)>" );
99 & Pakfire
:: message
( " <update> - Contacts the servers for new lists of paks." );
100 & Pakfire
:: message
( " <upgrade> - Installs the latest version of all paks." );
101 & Pakfire
:: message
( " <list> - Outputs a short list with all available paks." );
102 & Pakfire
:: message
( "" );
103 & Pakfire
:: message
( " Global options:" );
104 & Pakfire
:: message
( " --non-interactive --> Enables the non-interactive mode." );
105 & Pakfire
:: message
( " You won't see any question here." );
106 & Pakfire
:: message
( " -y --> Short for --non-interactive." );
107 & Pakfire
:: message
( " --no-colors --> Turns off the wonderful colors." );
108 & Pakfire
:: message
( "" );
115 $p = Net
:: Ping
-> new ( "icmp" );
116 if ( $p -> ping ( $host )) {
117 logger
( "PING INFO: $host is alive" );
120 logger
( "PING INFO: $host is unreachable" );
129 my ( @server , $host , $proto , $file , $i );
133 $bfile = basename
( " $getfile " );
135 logger
( "DOWNLOAD STARTED: $getfile " ) unless ( $bfile =~ /^counter\?.*/ );
138 while (( $allok == 0 ) && $i < 5 ) {
141 if ( " $gethost " eq "" ) {
142 @server = selectmirror
();
145 $file = " $server [2]/ $getfile " ;
151 $proto = "HTTP" unless $proto ;
153 unless ( $bfile =~ /^counter\?.*/ ) {
154 logger
( "DOWNLOAD INFO: Host: $host ( $proto ) - File: $file " );
157 my $ua = LWP
:: UserAgent
-> new ;
158 $ua -> agent ( "Pakfire/ $Conf ::version" );
161 my %proxysettings =();
162 & General
:: readhash
( "${General::swroot}/proxy/advanced/settings" , \
%proxysettings );
164 if ( $proxysettings { 'UPSTREAM_PROXY' }) {
165 logger
( "DOWNLOAD INFO: Upstream proxy: \" $proxysettings {'UPSTREAM_PROXY'} \" " ) unless ( $bfile =~ /^counter.py\?.*/ );
166 if ( $proxysettings { 'UPSTREAM_USER' }) {
167 $ua -> proxy ( "http" , "http:// $proxysettings {'UPSTREAM_USER'}: $proxysettings {'UPSTREAM_PASSWORD'}@" . " $proxysettings {'UPSTREAM_PROXY'}/" );
168 logger
( "DOWNLOAD INFO: Logging in with: \" $proxysettings {'UPSTREAM_USER'} \" - \" $proxysettings {'UPSTREAM_PASSWORD'} \" " ) unless ( $bfile =~ /^counter.py\?.*/ );
170 $ua -> proxy ( "http" , "http:// $proxysettings {'UPSTREAM_PROXY'}/" );
175 my $url = "http:// $host / $file " ;
178 unless ( $bfile =~ /^counter.py\?.*/ ) {
179 my $result = $ua -> head ( $url );
180 my $remote_headers = $result -> headers ;
181 $total_size = $remote_headers -> content_length ;
182 logger
( "DOWNLOAD INFO: $file has size of $total_size bytes" );
184 $response = $ua -> get ( $url , ':content_cb' => \
& callback
);
187 $response = $ua -> get ( $url );
190 my $code = $response -> code ();
191 my $log = $response -> status_line ;
192 logger
( "DOWNLOAD INFO: HTTP-Status-Code: $code - $log " );
194 if ( $code eq "500" ) {
195 message
( "Giving up: There was no chance to get the file \" $getfile \" from any available server. \n There was an error on the way. Please fix it." );
199 if ( $response -> is_success ) {
200 unless ( $bfile =~ /^counter.py\?.*/ ) {
201 if ( open ( FILE
, "> $Conf ::tmpdir/ $bfile " )) {
202 print FILE
$final_data ;
204 logger
( "DOWNLOAD INFO: File received. Start checking signature..." );
205 if ( system ( "gpg --verify \" $Conf ::tmpdir/ $bfile \" &>/dev/null" ) eq 0 ) {
206 logger
( "DOWNLOAD INFO: Signature of $bfile is fine." );
207 move
( " $Conf ::tmpdir/ $bfile " , " $Conf ::cachedir/ $bfile " );
209 message
( "DOWNLOAD ERROR: The downloaded file ( $file ) wasn't verified by IPFire.org. Sorry - Exiting..." );
210 my $ntp = `ntpdate -q -t 10 pool.ntp.org 2>/dev/null | tail -1` ;
211 if ( $ntp !~ /time\ server(.*)offset(.*)/ ){ message
( "TIME ERROR: Unable to get the nettime, this may lead to the verification error." );}
212 else { $ntp =~ /time\ server(.*)offset(.*)/ ; message
( "TIME INFO: Time Server $1has $2 offset to localtime." );}
215 logger
( "DOWNLOAD FINISHED: $file " );
219 logger
( "DOWNLOAD ERROR: Could not open $Conf ::tmpdir/ $bfile for writing." );
225 logger
( "DOWNLOAD ERROR: $log " );
228 message
( "DOWNLOAD ERROR: There was no chance to get the file \" $getfile \" from any available server. \n May be you should run \" pakfire update \" to get some new servers." );
238 if ( - e
" $Conf ::dbdir/lists/server-list.db" ) {
239 my @stat = stat ( " $Conf ::dbdir/lists/server-list.db" );
241 $age = $time - $stat [ 9 ];
242 $force = "force" if ( " $age " >= "3600" );
243 logger
( "MIRROR INFO: server-list.db is $age seconds old. - DEBUG: $force " );
249 if ( " $force " eq "force" ) {
250 fetchfile
( " $Conf ::version/lists/server-list.db" , " $Conf ::mainserver" );
251 move
( " $Conf ::cachedir/server-list.db" , " $Conf ::dbdir/lists/server-list.db" );
261 if ( - e
" $Conf ::dbdir/lists/core-list.db" ) {
262 my @stat = stat ( " $Conf ::dbdir/lists/core-list.db" );
264 $age = $time - $stat [ 9 ];
265 $force = "force" if ( " $age " >= "3600" );
266 logger
( "CORE INFO: core-list.db is $age seconds old. - DEBUG: $force " );
272 if ( " $force " eq "force" ) {
273 fetchfile
( "lists/core-list.db" , "" );
274 move
( " $Conf ::cachedir/core-list.db" , " $Conf ::dbdir/lists/core-list.db" );
280 ### Check if there is a current server list and read it.
281 # If there is no list try to get one.
283 while (!( open ( FILE
, "< $Conf ::dbdir/lists/server-list.db" )) && ( $count lt 5 )) {
285 getmirrors
( "noforce" );
288 message
( "MIRROR ERROR: Could not find or download a server list" );
294 ### Count the number of the servers in the list
298 if ( " $_ " =~ /.*;.*;.*;/ ) {
303 logger
( "MIRROR INFO: $scount servers found in list" );
306 logger
( "MIRROR INFO: Could not find any servers. Falling back to main server $Conf ::mainserver" );
307 return ( "HTTP" , $Conf :: mainserver
, "/ $Conf ::version" );
310 ### Choose a random server and test if it is online
311 # If the check fails try a new server.
312 # This will never give up.
316 while ( $found == 0 ) {
317 $server = int ( rand ( $scount ) + 1 );
319 my ( $line , $proto , $path , $host );
321 foreach $line ( @newlines ) {
323 if ( $servers eq $server ) {
324 @templine = split ( /\;/ , $line );
325 $proto = $templine [ 0 ];
326 $host = $templine [ 1 ];
327 $path = $templine [ 2 ];
328 if ( $pakfiresettings { 'HEALTHCHECK' } eq "off" ) {
329 logger
( "PING INFO: Healthcheck is disabled" );
331 return ( $proto , $host , $path );
333 elsif ( pinghost
( " $host " )) {
335 return ( $proto , $host , $path );
339 $pingdelay = $pingdelay * 2 ;
340 if ( $pingdelay > 1200 ) {
350 ### Update the database if the file is older than one day.
351 # If you pass &Pakfire::dbgetlist(force) the list will be downloaded.
352 # Usage is always with an argument.
358 if ( - e
" $Conf ::dbdir/lists/packages_list.db" ) {
359 my @stat = stat ( " $Conf ::dbdir/lists/packages_list.db" );
361 $age = $time - $stat [ 9 ];
362 $force = "force" if ( " $age " >= "3600" );
363 logger
( "DB INFO: packages_list.db is $age seconds old. - DEBUG: $force " );
369 if ( " $force " eq "force" ) {
370 fetchfile
( "lists/packages_list.db" , "" );
371 move
( " $Conf ::cachedir/packages_list.db" , " $Conf ::dbdir/lists/packages_list.db" );
374 # Update the meta database if new packages was in the package list
379 my ( $name , $version , $release );
382 open ( FILE
, "< $Conf ::dbdir/lists/packages_list.db" );
386 opendir ( DIR
, " $Conf ::dbdir/meta" );
387 my @files = readdir ( DIR
);
389 foreach $file ( @files ) {
390 next if ( $file eq "." );
391 next if ( $file eq ".." );
392 next if ( $file eq "meta-" );
393 next if ( $file =~ /^old/ );
394 open ( FILE
, "< $Conf ::dbdir/meta/ $file " );
397 foreach $line ( @meta ) {
398 @templine = split ( /\: / , $line );
399 if ( " $templine [0]" eq "Name" ) {
400 $name = $templine [ 1 ];
402 } elsif ( " $templine [0]" eq "ProgVersion" ) {
403 $version = $templine [ 1 ];
405 } elsif ( " $templine [0]" eq "Release" ) {
406 $release = $templine [ 1 ];
410 foreach $prog ( @db ) {
411 @templine = split ( /\;/ , $prog );
412 if (( " $name " eq " $templine [0]" ) && ( " $release " ne " $templine [2]" )) {
413 move
( " $Conf ::dbdir/meta/meta- $name " , " $Conf ::dbdir/meta/old_meta- $name " );
414 fetchfile
( "meta/meta- $name " , "" );
415 move
( " $Conf ::cachedir/meta- $name " , " $Conf ::dbdir/meta/meta- $name " );
422 ### This subroutine lists the packages.
423 # You may also pass a filter: &Pakfire::dblist(filter)
424 # Usage is always with two arguments.
425 # filter may be: all, notinstalled, installed
433 my ( $name , $version , $release );
436 ### Make sure that the list is not outdated.
437 #dbgetlist("noforce");
439 open ( FILE
, "< $Conf ::dbdir/lists/packages_list.db" );
443 if ( " $filter " eq "upgrade" ) {
444 if ( " $forweb " ne "forweb" && " $forweb " ne "notice" ) { getcoredb
( "noforce" );}
445 eval ( `grep "core_" $Conf ::dbdir/lists/core-list.db` );
446 if ( " $core_release " > " $Conf ::core_mine" ) {
447 if ( " $forweb " eq "forweb" ) {
448 print "<option value= \" core \" >Core-Update -- $Conf ::version -- Release: $Conf ::core_mine -> $core_release </option> \n " ;
450 elsif ( " $forweb " eq "notice" ) {
451 print "<br /><br /><br /><a href='pakfire.cgi'> $Lang ::tr{'core notice 1'} $Conf ::core_mine $Lang ::tr{'core notice 2'} $core_release $Lang ::tr{'core notice 3'}</a>" ;
453 my $command = "Core-Update $Conf ::version \n Release: $Conf ::core_mine -> $core_release \n " ;
454 if ( " $Pakfire ::enable_colors" eq "1" ) {
455 print " $color {'lila'} $command $color {'normal'} \n " ;
462 opendir ( DIR
, " $Conf ::dbdir/installed" );
463 my @files = readdir ( DIR
);
465 foreach $file ( @files ) {
466 next if ( $file eq "." );
467 next if ( $file eq ".." );
468 next if ( $file =~ /^old/ );
469 open ( FILE
, "< $Conf ::dbdir/installed/ $file " );
472 foreach $line ( @meta ) {
473 @templine = split ( /\: / , $line );
474 if ( " $templine [0]" eq "Name" ) {
475 $name = $templine [ 1 ];
477 } elsif ( " $templine [0]" eq "ProgVersion" ) {
478 $version = $templine [ 1 ];
480 } elsif ( " $templine [0]" eq "Release" ) {
481 $release = $templine [ 1 ];
485 foreach $prog ( @db ) {
486 @templine = split ( /\;/ , $prog );
487 if (( " $name " eq " $templine [0]" ) && ( " $release " < " $templine [2]" && " $forweb " ne "notice" )) {
488 push ( @updatepaks , $name );
489 if ( " $forweb " eq "forweb" ) {
490 print "<option value= \" $name \" >Update: $name -- Version: $version -> $templine [1] -- Release: $release -> $templine [2]</option> \n " ;
492 my $command = "Update: $name \n Version: $version -> $templine [1] \n Release: $release -> $templine [2] \n " ;
493 if ( " $Pakfire ::enable_colors" eq "1" ) {
494 print " $color {'lila'} $command $color {'normal'} \n " ;
508 foreach $line ( sort @db ) {
509 next unless ( $line =~ /.*;.*;.*;/ );
512 @templine = split ( /\;/ , $line );
513 if ( " $filter " eq "notinstalled" ) {
514 next if ( - e
" $Conf ::dbdir/installed/meta- $templine [0]" );
515 } elsif ( " $filter " eq "installed" ) {
516 next unless ( - e
" $Conf ::dbdir/installed/meta- $templine [0]" );
518 if ( " $forweb " eq "forweb" )
520 if ( " $filter " eq "notinstalled" ) {
521 print "<option value= \" $templine [0] \" > $templine [0]- $templine [1]- $templine [2]</option> \n " ;
523 print "<option value= \" $templine [0] \" > $templine [0]</option> \n " ;
526 if ( " $Pakfire ::enable_colors" eq "1" ) {
527 if (& isinstalled
( " $templine [0]" )) {
528 $use_color = " $color {'red'}"
530 $use_color = " $color {'green'}"
533 print "${use_color}Name: $templine [0] \n ProgVersion: $templine [1] \n Release: $templine [2] $color {'normal'} \n\n " ;
536 print " $count packages total. \n " unless ( " $forweb " eq "forweb" );
540 sub resolvedeps_one
{
545 message
( "PAKFIRE RESV: $pak : Resolving dependencies..." );
547 open ( FILE
, "< $Conf ::dbdir/meta/meta- $pak " );
552 my ( @templine , @deps , @all );
553 foreach $line ( @file ) {
554 @templine = split ( /\: / , $line );
555 if ( " $templine [0]" eq "Dependencies" ) {
556 @deps = split ( / / , $templine [ 1 ]);
562 my $return = & isinstalled
( $_ );
564 message
( "PAKFIRE RESV: $pak : Dependency is already installed: $_ " );
566 message
( "PAKFIRE RESV: $pak : Need to install dependency: $_ " );
579 # Resolve all not yet installed dependencies of $pak
580 my @deps = & resolvedeps_one
( $pak );
583 # For each dependency, we check if more dependencies exist
585 my $dep = pop ( @deps );
587 my @subdeps = & resolvedeps_one
( $dep );
588 foreach my $subdep ( @subdeps ) {
589 # Skip the package we are currently resolving for
590 next if ( $pak eq $subdep );
592 # If the package is not already to be installed,
593 # we add it to the list (@all) and check if it has
594 # more dependencies on its own.
595 unless ( grep { $_ eq $subdep } @all ) {
596 push ( @deps , $subdep );
605 sub resolvedeps_recursive
{
609 foreach my $pkg ( @packages ) {
610 my @deps = & Pakfire
:: resolvedeps
( $pkg );
612 foreach my $dep ( @deps ) {
617 # Sort the result array and remove dupes
618 my %sort = map { $_ , 1 } @result ;
619 @result = keys %sort ;
628 logger
( "CLEANUP: $dir " );
630 if ( " $dir " eq "meta" ) {
631 $path = " $Conf ::dbdir/meta" ;
632 } elsif ( " $dir " eq "tmp" ) {
633 $path = " $Conf ::tmpdir" ;
637 my @files = readdir ( DIR
);
640 unless (( $_ eq "." ) || ( $_ eq ".." )) {
649 unless ( - e
" $Conf ::dbdir/meta/meta- $pak " ) {
650 fetchfile
( "meta/meta- $pak " , "" );
651 move
( " $Conf ::cachedir/meta- $pak " , " $Conf ::dbdir/meta/meta- $pak " );
654 if ( - z
" $Conf ::dbdir/meta/meta- $pak " ) {
655 fetchfile
( "meta/meta- $pak " , "" );
656 move
( " $Conf ::cachedir/meta- $pak " , " $Conf ::dbdir/meta/meta- $pak " );
659 open ( FILE
, "< $Conf ::dbdir/meta/meta- $pak " );
663 open ( FILE
, "> $Conf ::dbdir/meta/meta- $pak " );
666 $string =~ s/\r\n/\n/g ;
678 open ( FILE
, "< $Conf ::dbdir/meta/meta- $pak " );
684 foreach $line ( @file ) {
685 @templine = split ( /\: / , $line );
686 if ( " $templine [0]" eq "Size" ) {
699 my $file = getpak
( " $pak " , "noforce" );
701 logger
( "DECRYPT STARTED: $pak " );
702 my $return = system ( "cd $Conf ::tmpdir/ && gpg -d --batch --quiet --no-verbose --status-fd 2 --output - < $Conf ::cachedir/ $file 2>/dev/null | tar x" );
704 logger
( "DECRYPT FINISHED: $pak - Status: $return " );
705 if ( $return != 0 ) { exit 1 ; }
714 open ( FILE
, "< $Conf ::dbdir/meta/meta- $pak " );
721 foreach $line ( @file ) {
722 @templine = split ( /\: / , $line );
723 if ( " $templine [0]" eq "File" ) {
725 $file = $templine [ 1 ];
730 message
( "No filename given in meta-file." );
734 unless ( " $force " eq "force" ) {
735 if ( - e
" $Conf ::cachedir/ $file " ) {
740 fetchfile
( "paks/ $file " , "" );
747 message
( "PAKFIRE INST: $pak : Decrypting..." );
750 message
( "PAKFIRE INST: $pak : Copying files and running post-installation scripts..." );
751 my $return = system ( "cd $Conf ::tmpdir && NAME= $pak ./install.sh >> $Conf ::logdir/install- $pak .log 2>&1" );
753 if ( $pakfiresettings { 'UUID' } ne "off" ) {
754 fetchfile
( "counter.py?ver= $Conf ::version&uuid= $Conf ::uuid&ipak= $pak &return= $return " , " $Conf ::mainserver" );
757 move
( " $Conf ::tmpdir/ROOTFILES" , " $Conf ::dbdir/rootfiles/ $pak " );
759 copy
( " $Conf ::dbdir/meta/meta- $pak " , " $Conf ::dbdir/installed/" );
760 message
( "PAKFIRE INST: $pak : Finished." );
763 message
( "PAKFIRE ERROR: Returncode: $return . Sorry. Please search our forum to find a solution for this problem." );
770 getcoredb
( "noforce" );
771 eval ( `grep "core_" $Conf ::dbdir/lists/core-list.db` );
772 if ( " $core_release " > " $Conf ::core_mine" ) {
773 message
( "CORE UPGR: Upgrading from release $Conf ::core_mine to $core_release " );
775 my @seq = `seq $Conf ::core_mine $core_release ` ;
778 foreach $release ( @seq ) {
780 getpak
( "core-upgrade- $release " );
783 foreach $release ( @seq ) {
785 upgradepak
( "core-upgrade- $release " );
788 system ( "echo $core_release > $Conf ::coredir/mine" );
791 message
( "CORE ERROR: No new upgrades available. You are on release $Conf ::core_mine." );
797 if ( open ( FILE
, "< $Conf ::dbdir/installed/meta- $pak " ) ) {
808 message
( "PAKFIRE UPGR: $pak : Decrypting..." );
811 message
( "PAKFIRE UPGR: $pak : Upgrading files and running post-upgrading scripts..." );
812 my $return = system ( "cd $Conf ::tmpdir && NAME= $pak ./update.sh >> $Conf ::logdir/update- $pak .log 2>&1" );
814 if ( $pakfiresettings { 'UUID' } ne "off" ) {
815 fetchfile
( "counter.py?ver= $Conf ::version&uuid= $Conf ::uuid&upak= $pak &return= $return " , " $Conf ::mainserver" );
818 move
( " $Conf ::tmpdir/ROOTFILES" , " $Conf ::dbdir/rootfiles/ $pak " );
820 copy
( " $Conf ::dbdir/meta/meta- $pak " , " $Conf ::dbdir/installed/" );
821 message
( "PAKFIRE UPGR: $pak : Finished." );
824 message
( "PAKFIRE ERROR: Returncode: $return . Sorry. Please search our forum to find a solution for this problem." );
833 message
( "PAKFIRE REMV: $pak : Decrypting..." );
836 message
( "PAKFIRE REMV: $pak : Removing files and running post-removing scripts..." );
837 my $return = system ( "cd $Conf ::tmpdir && NAME= $pak ./uninstall.sh >> $Conf ::logdir/uninstall- $pak .log 2>&1" );
839 if ( $pakfiresettings { 'UUID' } ne "off" ) {
840 fetchfile
( "counter.py?ver= $Conf ::version&uuid= $Conf ::uuid&dpak= $pak &return= $return " , " $Conf ::mainserver" );
843 unlink ( " $Conf ::dbdir/rootfiles/ $pak " );
844 unlink ( " $Conf ::dbdir/installed/meta- $pak " );
846 message
( "PAKFIRE REMV: $pak : Finished." );
849 message
( "PAKFIRE ERROR: Returncode: $return . Sorry. Please search our forum to find a solution for this problem." );
857 #$size = $size / 1024;
860 if ( $size > 1023 * 1024 ) {
861 $size = ( $size / ( 1024 * 1024 ));
863 } elsif ( $size > 1023 ) {
864 $size = ( $size / 1024 );
869 $size = sprintf ( "%.2f" , $size );
870 my $string = " $size $unit " ;
875 unless ( - e
" $Conf ::dbdir/uuid" ) {
876 open ( FILE
, "</proc/sys/kernel/random/uuid" );
880 open ( FILE
, "> $Conf ::dbdir/uuid" );
889 if ( $pakfiresettings { 'UUID' } ne "off" ) {
890 unless ( " $Conf ::uuid" ) {
891 $Conf :: uuid
= `cat $Conf ::dbdir/uuid` ;
893 logger
( "Sending my uuid: $Conf ::uuid" );
894 fetchfile
( "counter.py?ver= $Conf ::version&uuid= $Conf ::uuid" , " $Conf ::mainserver" );
895 system ( "rm -f $Conf ::tmpdir/counter* 2>/dev/null" );
900 my ( $data , $response , $protocol ) = @_ ;
901 $final_data .= $data ;
902 print progress_bar
( length ( $final_data ), $total_size , 30 , '=' );
906 my ( $got , $total , $width , $char ) = @_ ;
908 $width ||= 30 ; $char ||= '=' ;
909 my $len_bfile = length $bfile ;
910 if ( " $len_bfile " >= "17" ) {
911 $show_bfile = substr ( $bfile , 0 , 17 ). "..." ;
913 $show_bfile = $bfile ;
915 $progress = sprintf ( "%.2f%%" , 100 * $got /+ $total );
916 sprintf " $color {'lightgreen'}%-20s %7s |%-${width}s| %10s $color {'normal'} \r " , $show_bfile , $progress , $char x
(( $width - 1 )* $got / $total ). '>' , beautifysize
( $got );