]>
git.ipfire.org Git - ipfire-2.x.git/blob - src/pakfire/lib/functions.pl
460eaf303c383721e535c11e02200a920329fc70
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" ;
38 my @VALID_KEY_FINGERPRINTS = (
40 "3ECA8AA4478208B924BB96206FEF7A8ED713594B" ,
42 "179740DC4D8C47DC63C099C74BDE364C64D96617" ,
45 # A small color-hash :D
47 $color { 'normal' } = " \033 [0m" ;
48 $color { 'black' } = " \033 [0;30m" ;
49 $color { 'darkgrey' } = " \033 [1;30m" ;
50 $color { 'blue' } = " \033 [0;34m" ;
51 $color { 'lightblue' } = " \033 [1;34m" ;
52 $color { 'green' } = " \033 [0;32m" ;
53 $color { 'lightgreen' } = " \033 [1;32m" ;
54 $color { 'cyan' } = " \033 [0;36m" ;
55 $color { 'lightcyan' } = " \033 [1;36m" ;
56 $color { 'red' } = " \033 [0;31m" ;
57 $color { 'lightred' } = " \033 [1;31m" ;
58 $color { 'purple' } = " \033 [0;35m" ;
59 $color { 'lightpurple' } = " \033 [1;35m" ;
60 $color { 'brown' } = " \033 [0;33m" ;
61 $color { 'lightgrey' } = " \033 [0;37m" ;
62 $color { 'yellow' } = " \033 [1;33m" ;
63 $color { 'white' } = " \033 [1;37m" ;
64 our $enable_colors = 1 ;
70 my %pakfiresettings = ();
71 & General
:: readhash
( "${General::swroot}/pakfire/settings" , \
%pakfiresettings );
77 if ( $enable_colors == 1 ) {
78 if ( " $message " =~ /ERROR/ ) {
79 $message = " $color {'red'} $message $color {'normal'}" ;
80 } elsif ( " $message " =~ /INFO/ ) {
81 $message = " $color {'cyan'} $message $color {'normal'}" ;
82 } elsif ( " $message " =~ /WARN/ ) {
83 $message = " $color {'yellow'} $message $color {'normal'}" ;
84 } elsif ( " $message " =~ /RESV/ ) {
85 $message = " $color {'purple'} $message $color {'normal'}" ;
86 } elsif ( " $message " =~ /INST/ ) {
87 $message = " $color {'green'} $message $color {'normal'}" ;
88 } elsif ( " $message " =~ /REMV/ ) {
89 $message = " $color {'lightred'} $message $color {'normal'}" ;
90 } elsif ( " $message " =~ /UPGR/ ) {
91 $message = " $color {'lightblue'} $message $color {'normal'}" ;
101 #system("echo \"`date`: $log\" >> /var/log/pakfire.log");
102 system ( "logger -t pakfire \" $log \" " );
107 & Pakfire
:: message
( "Usage: pakfire <install|remove> [options] <pak(s)>" );
108 & Pakfire
:: message
( " <update> - Contacts the servers for new lists of paks." );
109 & Pakfire
:: message
( " <upgrade> - Installs the latest version of all paks." );
110 & Pakfire
:: message
( " <list> - Outputs a short list with all available paks." );
111 & Pakfire
:: message
( " <status> - Outputs a summary about available core upgrades, updates and a required reboot" );
112 & Pakfire
:: message
( "" );
113 & Pakfire
:: message
( " Global options:" );
114 & Pakfire
:: message
( " --non-interactive --> Enables the non-interactive mode." );
115 & Pakfire
:: message
( " You won't see any question here." );
116 & Pakfire
:: message
( " -y --> Short for --non-interactive." );
117 & Pakfire
:: message
( " --no-colors --> Turns off the wonderful colors." );
118 & Pakfire
:: message
( "" );
125 my ( @server , $host , $proto , $file , $i );
129 $bfile = basename
( " $getfile " );
131 logger
( "DOWNLOAD STARTED: $getfile " );
134 while (( $allok == 0 ) && $i < 5 ) {
137 if ( " $gethost " eq "" ) {
138 @server = selectmirror
();
141 $file = " $server [2]/ $getfile " ;
147 $proto = "HTTP" unless $proto ;
149 logger
( "DOWNLOAD INFO: Host: $host ( $proto ) - File: $file " );
151 my $ua = LWP
:: UserAgent
-> new ;
152 $ua -> agent ( "Pakfire/ $Conf ::version" );
155 my %proxysettings =();
156 & General
:: readhash
( "${General::swroot}/proxy/advanced/settings" , \
%proxysettings );
158 if ( $proxysettings { 'UPSTREAM_PROXY' }) {
159 logger
( "DOWNLOAD INFO: Upstream proxy: \" $proxysettings {'UPSTREAM_PROXY'} \" " );
160 if ( $proxysettings { 'UPSTREAM_USER' }) {
161 $ua -> proxy ([[ "http" , "https" ] => "http:// $proxysettings {'UPSTREAM_USER'}: $proxysettings {'UPSTREAM_PASSWORD'}@" . " $proxysettings {'UPSTREAM_PROXY'}/" ]);
162 logger
( "DOWNLOAD INFO: Logging in with: \" $proxysettings {'UPSTREAM_USER'} \" - \" $proxysettings {'UPSTREAM_PASSWORD'} \" " );
164 $ua -> proxy ([[ "http" , "https" ] => "http:// $proxysettings {'UPSTREAM_PROXY'}/" ]);
172 case
"HTTP" { $url = "http:// $host / $file " ; }
173 case
"HTTPS" { $url = "https:// $host / $file " ; }
175 # skip all lines with unknown protocols
176 logger
( "DOWNLOAD WARNING: Skipping Host: $host due to unknown protocol ( $proto ) in mirror database" );
181 my $result = $ua -> head ( $url );
182 my $remote_headers = $result -> headers ;
183 $total_size = $remote_headers -> content_length ;
184 logger
( "DOWNLOAD INFO: $file has size of $total_size bytes" );
186 my $response = $ua -> get ( $url , ':content_cb' => \
& callback
);
189 my $code = $response -> code ();
190 my $log = $response -> status_line ;
191 logger
( "DOWNLOAD INFO: HTTP-Status-Code: $code - $log " );
193 if ( $code eq "500" ) {
194 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." );
198 if ( $response -> is_success ) {
199 if ( open ( FILE
, "> $Conf ::tmpdir/ $bfile " )) {
200 print FILE
$final_data ;
202 logger
( "DOWNLOAD INFO: File received. Start checking signature..." );
203 if (& valid_signature
( " $Conf ::tmpdir/ $bfile " )) {
204 logger
( "DOWNLOAD INFO: Signature of $bfile is fine." );
205 move
( " $Conf ::tmpdir/ $bfile " , " $Conf ::cachedir/ $bfile " );
207 message
( "DOWNLOAD ERROR: The downloaded file ( $file ) wasn't verified by IPFire.org. Sorry - Exiting..." );
208 my $ntp = `ntpdate -q -t 10 pool.ntp.org 2>/dev/null | tail -1` ;
209 if ( $ntp !~ /time\ server(.*)offset(.*)/ ){ message
( "TIME ERROR: Unable to get the nettime, this may lead to the verification error." );}
210 else { $ntp =~ /time\ server(.*)offset(.*)/ ; message
( "TIME INFO: Time Server $1has $2 offset to localtime." );}
213 logger
( "DOWNLOAD FINISHED: $file " );
217 logger
( "DOWNLOAD ERROR: Could not open $Conf ::tmpdir/ $bfile for writing." );
220 logger
( "DOWNLOAD ERROR: $log " );
223 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." );
233 if ( - e
" $Conf ::dbdir/lists/server-list.db" ) {
234 my @stat = stat ( " $Conf ::dbdir/lists/server-list.db" );
236 $age = $time - $stat [ 9 ];
237 $force = "force" if ( " $age " >= "3600" );
238 logger
( "MIRROR INFO: server-list.db is $age seconds old. - DEBUG: $force " );
244 if ( " $force " eq "force" ) {
245 fetchfile
( " $Conf ::version/lists/server-list.db" , " $Conf ::mainserver" );
246 move
( " $Conf ::cachedir/server-list.db" , " $Conf ::dbdir/lists/server-list.db" );
256 if ( - e
" $Conf ::dbdir/lists/core-list.db" ) {
257 my @stat = stat ( " $Conf ::dbdir/lists/core-list.db" );
259 $age = $time - $stat [ 9 ];
260 $force = "force" if ( " $age " >= "3600" );
261 logger
( "CORE INFO: core-list.db is $age seconds old. - DEBUG: $force " );
267 if ( " $force " eq "force" ) {
268 fetchfile
( "lists/core-list.db" , "" );
269 move
( " $Conf ::cachedir/core-list.db" , " $Conf ::dbdir/lists/core-list.db" );
273 sub valid_signature
($) {
274 my $filename = shift ;
276 open ( my $cmd , "gpg --verify --status-fd 1 \" $filename \" 2>/dev/null |" );
278 # Process valid signature lines
279 if ( /VALIDSIG ([A-Z0-9]+)/ ) {
280 # Check if we know the key
281 foreach my $key ( @VALID_KEY_FINGERPRINTS ) {
283 return 1 if ( $key eq $1 );
289 # Signature is invalid
294 ### Check if there is a current server list and read it.
295 # If there is no list try to get one.
297 while (!( open ( FILE
, "< $Conf ::dbdir/lists/server-list.db" )) && ( $count lt 5 )) {
299 getmirrors
( "noforce" );
302 message
( "MIRROR ERROR: Could not find or download a server list" );
308 ### Count the number of the servers in the list
312 if ( " $_ " =~ /.*;.*;.*;/ ) {
317 logger
( "MIRROR INFO: $scount servers found in list" );
320 logger
( "MIRROR INFO: Could not find any servers. Falling back to main server $Conf ::mainserver" );
321 return ( "HTTP" , $Conf :: mainserver
, "/ $Conf ::version" );
324 ### Choose a random server and test if it is online
325 # If the check fails try a new server.
326 # This will never give up.
329 $server = int ( rand ( $scount ) + 1 );
331 my ( $line , $proto , $path , $host );
333 foreach $line ( @newlines ) {
335 if ( $servers eq $server ) {
336 @templine = split ( /\;/ , $line );
337 $proto = $templine [ 0 ];
338 $host = $templine [ 1 ];
339 $path = $templine [ 2 ];
341 return ( $proto , $host , $path );
348 ### Update the database if the file is older than one day.
349 # If you pass &Pakfire::dbgetlist(force) the list will be downloaded.
350 # Usage is always with an argument.
356 if ( - e
" $Conf ::dbdir/lists/packages_list.db" ) {
357 my @stat = stat ( " $Conf ::dbdir/lists/packages_list.db" );
359 $age = $time - $stat [ 9 ];
360 $force = "force" if ( " $age " >= "3600" );
361 logger
( "DB INFO: packages_list.db is $age seconds old. - DEBUG: $force " );
367 if ( " $force " eq "force" ) {
368 fetchfile
( "lists/packages_list.db" , "" );
369 move
( " $Conf ::cachedir/packages_list.db" , " $Conf ::dbdir/lists/packages_list.db" );
372 # Update the meta database if new packages was in the package list
377 my ( $name , $version , $release );
380 open ( FILE
, "< $Conf ::dbdir/lists/packages_list.db" );
384 opendir ( DIR
, " $Conf ::dbdir/meta" );
385 my @files = readdir ( DIR
);
387 foreach $file ( @files ) {
388 next if ( $file eq "." );
389 next if ( $file eq ".." );
390 next if ( $file eq "meta-" );
391 next if ( $file =~ /^old/ );
392 open ( FILE
, "< $Conf ::dbdir/meta/ $file " );
395 foreach $line ( @meta ) {
396 @templine = split ( /\: / , $line );
397 if ( " $templine [0]" eq "Name" ) {
398 $name = $templine [ 1 ];
400 } elsif ( " $templine [0]" eq "ProgVersion" ) {
401 $version = $templine [ 1 ];
403 } elsif ( " $templine [0]" eq "Release" ) {
404 $release = $templine [ 1 ];
408 foreach $prog ( @db ) {
409 @templine = split ( /\;/ , $prog );
410 if (( " $name " eq " $templine [0]" ) && ( " $release " ne " $templine [2]" )) {
411 move
( " $Conf ::dbdir/meta/meta- $name " , " $Conf ::dbdir/meta/old_meta- $name " );
412 fetchfile
( "meta/meta- $name " , "" );
413 move
( " $Conf ::cachedir/meta- $name " , " $Conf ::dbdir/meta/meta- $name " );
420 ### This subroutine lists the packages.
421 # You may also pass a filter: &Pakfire::dblist(filter)
422 # Usage is always with two arguments.
423 # filter may be: all, notinstalled, installed
431 my ( $name , $version , $release );
434 ### Make sure that the list is not outdated.
435 #dbgetlist("noforce");
437 open ( FILE
, "< $Conf ::dbdir/lists/packages_list.db" );
441 if ( " $filter " eq "upgrade" ) {
442 if ( " $forweb " ne "forweb" && " $forweb " ne "notice" ) { getcoredb
( "noforce" );}
443 eval ( `grep "core_" $Conf ::dbdir/lists/core-list.db` );
444 if ( " $core_release " > " $Conf ::core_mine" ) {
445 if ( " $forweb " eq "forweb" ) {
446 print "<option value= \" core \" >Core-Update -- $Conf ::version -- Release: $Conf ::core_mine -> $core_release </option> \n " ;
448 elsif ( " $forweb " eq "notice" ) {
449 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>" ;
451 my $command = "Core-Update $Conf ::version \n Release: $Conf ::core_mine -> $core_release \n " ;
452 if ( " $Pakfire ::enable_colors" eq "1" ) {
453 print " $color {'lila'} $command $color {'normal'} \n " ;
460 opendir ( DIR
, " $Conf ::dbdir/installed" );
461 my @files = readdir ( DIR
);
463 foreach $file ( @files ) {
464 next if ( $file eq "." );
465 next if ( $file eq ".." );
466 next if ( $file =~ /^old/ );
467 open ( FILE
, "< $Conf ::dbdir/installed/ $file " );
470 foreach $line ( @meta ) {
471 @templine = split ( /\: / , $line );
472 if ( " $templine [0]" eq "Name" ) {
473 $name = $templine [ 1 ];
475 } elsif ( " $templine [0]" eq "ProgVersion" ) {
476 $version = $templine [ 1 ];
478 } elsif ( " $templine [0]" eq "Release" ) {
479 $release = $templine [ 1 ];
483 foreach $prog ( @db ) {
484 @templine = split ( /\;/ , $prog );
485 if (( " $name " eq " $templine [0]" ) && ( " $release " < " $templine [2]" && " $forweb " ne "notice" )) {
486 push ( @updatepaks , $name );
487 if ( " $forweb " eq "forweb" ) {
488 print "<option value= \" $name \" >Update: $name -- Version: $version -> $templine [1] -- Release: $release -> $templine [2]</option> \n " ;
490 my $command = "Update: $name \n Version: $version -> $templine [1] \n Release: $release -> $templine [2] \n " ;
491 if ( " $Pakfire ::enable_colors" eq "1" ) {
492 print " $color {'lila'} $command $color {'normal'} \n " ;
506 foreach $line ( sort @db ) {
507 next unless ( $line =~ /.*;.*;.*;/ );
510 @templine = split ( /\;/ , $line );
511 if ( " $filter " eq "notinstalled" ) {
512 next if ( - e
" $Conf ::dbdir/installed/meta- $templine [0]" );
513 } elsif ( " $filter " eq "installed" ) {
514 next unless ( - e
" $Conf ::dbdir/installed/meta- $templine [0]" );
516 if ( " $forweb " eq "forweb" )
518 if ( " $filter " eq "notinstalled" ) {
519 print "<option value= \" $templine [0] \" > $templine [0]- $templine [1]- $templine [2]</option> \n " ;
521 print "<option value= \" $templine [0] \" > $templine [0]</option> \n " ;
524 if ( " $Pakfire ::enable_colors" eq "1" ) {
525 if (& isinstalled
( " $templine [0]" )) {
526 $use_color = " $color {'red'}"
528 $use_color = " $color {'green'}"
531 print "${use_color}Name: $templine [0] \n ProgVersion: $templine [1] \n Release: $templine [2] $color {'normal'} \n\n " ;
534 print " $count packages total. \n " unless ( " $forweb " eq "forweb" );
538 sub resolvedeps_one
{
543 message
( "PAKFIRE RESV: $pak : Resolving dependencies..." );
545 open ( FILE
, "< $Conf ::dbdir/meta/meta- $pak " );
550 my ( @templine , @deps , @all );
551 foreach $line ( @file ) {
552 @templine = split ( /\: / , $line );
553 if ( " $templine [0]" eq "Dependencies" ) {
554 @deps = split ( / / , $templine [ 1 ]);
560 my $return = & isinstalled
( $_ );
562 message
( "PAKFIRE RESV: $pak : Dependency is already installed: $_ " );
564 message
( "PAKFIRE RESV: $pak : Need to install dependency: $_ " );
577 # Resolve all not yet installed dependencies of $pak
578 my @deps = & resolvedeps_one
( $pak );
581 # For each dependency, we check if more dependencies exist
583 my $dep = pop ( @deps );
585 my @subdeps = & resolvedeps_one
( $dep );
586 foreach my $subdep ( @subdeps ) {
587 # Skip the package we are currently resolving for
588 next if ( $pak eq $subdep );
590 # If the package is not already to be installed,
591 # we add it to the list (@all) and check if it has
592 # more dependencies on its own.
593 unless ( grep { $_ eq $subdep } @all ) {
594 push ( @deps , $subdep );
603 sub resolvedeps_recursive
{
607 foreach my $pkg ( @packages ) {
608 my @deps = & Pakfire
:: resolvedeps
( $pkg );
610 foreach my $dep ( @deps ) {
615 # Sort the result array and remove dupes
616 my %sort = map { $_ , 1 } @result ;
617 @result = keys %sort ;
626 logger
( "CLEANUP: $dir " );
628 if ( " $dir " eq "meta" ) {
629 $path = " $Conf ::dbdir/meta" ;
630 } elsif ( " $dir " eq "tmp" ) {
631 $path = " $Conf ::tmpdir" ;
635 my @files = readdir ( DIR
);
638 unless (( $_ eq "." ) || ( $_ eq ".." )) {
647 unless ( - e
" $Conf ::dbdir/meta/meta- $pak " ) {
648 fetchfile
( "meta/meta- $pak " , "" );
649 move
( " $Conf ::cachedir/meta- $pak " , " $Conf ::dbdir/meta/meta- $pak " );
652 if ( - z
" $Conf ::dbdir/meta/meta- $pak " ) {
653 fetchfile
( "meta/meta- $pak " , "" );
654 move
( " $Conf ::cachedir/meta- $pak " , " $Conf ::dbdir/meta/meta- $pak " );
657 open ( FILE
, "< $Conf ::dbdir/meta/meta- $pak " );
661 open ( FILE
, "> $Conf ::dbdir/meta/meta- $pak " );
664 $string =~ s/\r\n/\n/g ;
676 open ( FILE
, "< $Conf ::dbdir/meta/meta- $pak " );
682 foreach $line ( @file ) {
683 @templine = split ( /\: / , $line );
684 if ( " $templine [0]" eq "Size" ) {
697 my $file = getpak
( " $pak " , "noforce" );
699 logger
( "DECRYPT STARTED: $pak " );
700 my $return = system ( "cd $Conf ::tmpdir/ && gpg -d --batch --quiet --no-verbose --status-fd 2 --output - < $Conf ::cachedir/ $file 2>/dev/null | tar x" );
702 logger
( "DECRYPT FINISHED: $pak - Status: $return " );
703 if ( $return != 0 ) { exit 1 ; }
712 open ( FILE
, "< $Conf ::dbdir/meta/meta- $pak " );
719 foreach $line ( @file ) {
720 @templine = split ( /\: / , $line );
721 if ( " $templine [0]" eq "File" ) {
723 $file = $templine [ 1 ];
728 message
( "No filename given in meta-file." );
732 unless ( " $force " eq "force" ) {
733 if ( - e
" $Conf ::cachedir/ $file " ) {
738 fetchfile
( "paks/ $file " , "" );
745 message
( "PAKFIRE INST: $pak : Decrypting..." );
748 message
( "PAKFIRE INST: $pak : Copying files and running post-installation scripts..." );
749 my $return = system ( "cd $Conf ::tmpdir && NAME= $pak ./install.sh >> $Conf ::logdir/install- $pak .log 2>&1" );
752 move
( " $Conf ::tmpdir/ROOTFILES" , " $Conf ::dbdir/rootfiles/ $pak " );
754 copy
( " $Conf ::dbdir/meta/meta- $pak " , " $Conf ::dbdir/installed/" );
755 message
( "PAKFIRE INST: $pak : Finished." );
758 message
( "PAKFIRE ERROR: Returncode: $return . Sorry. Please search our forum to find a solution for this problem." );
765 getcoredb
( "noforce" );
766 eval ( `grep "core_" $Conf ::dbdir/lists/core-list.db` );
767 if ( " $core_release " > " $Conf ::core_mine" ) {
768 message
( "CORE UPGR: Upgrading from release $Conf ::core_mine to $core_release " );
770 my @seq = `seq $Conf ::core_mine $core_release ` ;
773 foreach $release ( @seq ) {
775 getpak
( "core-upgrade- $release " );
778 foreach $release ( @seq ) {
780 upgradepak
( "core-upgrade- $release " );
783 system ( "echo $core_release > $Conf ::coredir/mine" );
786 message
( "CORE ERROR: No new upgrades available. You are on release $Conf ::core_mine." );
792 if ( open ( FILE
, "< $Conf ::dbdir/installed/meta- $pak " ) ) {
803 message
( "PAKFIRE UPGR: $pak : Decrypting..." );
806 message
( "PAKFIRE UPGR: $pak : Upgrading files and running post-upgrading scripts..." );
807 my $return = system ( "cd $Conf ::tmpdir && NAME= $pak ./update.sh >> $Conf ::logdir/update- $pak .log 2>&1" );
810 move
( " $Conf ::tmpdir/ROOTFILES" , " $Conf ::dbdir/rootfiles/ $pak " );
812 copy
( " $Conf ::dbdir/meta/meta- $pak " , " $Conf ::dbdir/installed/" );
813 message
( "PAKFIRE UPGR: $pak : Finished." );
816 message
( "PAKFIRE ERROR: Returncode: $return . Sorry. Please search our forum to find a solution for this problem." );
825 message
( "PAKFIRE REMV: $pak : Decrypting..." );
828 message
( "PAKFIRE REMV: $pak : Removing files and running post-removing scripts..." );
829 my $return = system ( "cd $Conf ::tmpdir && NAME= $pak ./uninstall.sh >> $Conf ::logdir/uninstall- $pak .log 2>&1" );
832 unlink ( " $Conf ::dbdir/rootfiles/ $pak " );
833 unlink ( " $Conf ::dbdir/installed/meta- $pak " );
835 message
( "PAKFIRE REMV: $pak : Finished." );
838 message
( "PAKFIRE ERROR: Returncode: $return . Sorry. Please search our forum to find a solution for this problem." );
846 #$size = $size / 1024;
849 if ( $size > 1023 * 1024 ) {
850 $size = ( $size / ( 1024 * 1024 ));
852 } elsif ( $size > 1023 ) {
853 $size = ( $size / 1024 );
858 $size = sprintf ( "%.2f" , $size );
859 my $string = " $size $unit " ;
864 unless ( - e
" $Conf ::dbdir/uuid" ) {
865 open ( FILE
, "</proc/sys/kernel/random/uuid" );
869 open ( FILE
, "> $Conf ::dbdir/uuid" );
878 my ( $data , $response , $protocol ) = @_ ;
879 $final_data .= $data ;
880 print progress_bar
( length ( $final_data ), $total_size , 30 , '=' );
884 my ( $got , $total , $width , $char ) = @_ ;
886 $width ||= 30 ; $char ||= '=' ;
887 my $len_bfile = length $bfile ;
888 if ( " $len_bfile " >= "17" ) {
889 $show_bfile = substr ( $bfile , 0 , 17 ). "..." ;
891 $show_bfile = $bfile ;
893 $progress = sprintf ( "%.2f%%" , 100 * $got /+ $total );
894 sprintf " $color {'lightgreen'}%-20s %7s |%-${width}s| %10s $color {'normal'} \r " , $show_bfile , $progress , $char x
(( $width - 1 )* $got / $total ). '>' , beautifysize
( $got );
897 sub updates_available
{
898 # Get packets with updates available
899 my @upgradepaks = & Pakfire
:: dblist
( "upgrade" , "noweb" );
901 # Get the length of the returned array
902 my $updatecount = scalar @upgradepaks ;
904 return " $updatecount " ;
907 sub coreupdate_available
{
908 eval ( `grep "core_" $Conf ::dbdir/lists/core-list.db` );
909 if ( " $core_release " > " $Conf ::core_mine" ) {
910 return "yes ( $core_release )" ;
917 sub reboot_required
{
918 if ( - e
"/var/run/need_reboot" ) {
928 my $return = "Core-Version: $Conf ::version \n " ;
929 $return .= "Core-Update-Level: $Conf ::core_mine \n " ;
930 $return .= "Last update: " . & General
:: age
( "/opt/pakfire/db/core/mine" ) . " ago \n " ;
931 $return .= "Last core-list update: " . & General
:: age
( "/opt/pakfire/db/lists/core-list.db" ) . " ago \n " ;
932 $return .= "Last server-list update: " . & General
:: age
( "/opt/pakfire/db/lists/server-list.db" ) . " ago \n " ;
933 $return .= "Last packages-list update: " . & General
:: age
( "/opt/pakfire/db/lists/packages_list.db" ) . " ago \n " ;
935 # Get availability of core updates
936 $return .= "Core-Update available: " . & Pakfire
:: coreupdate_available
() . " \n " ;
938 # Get availability of package updates
939 $return .= "Package-Updates available: " . & Pakfire
:: updates_available
() . " \n " ;
941 # Test if reboot is required
942 $return .= "Reboot required: " . & Pakfire
:: reboot_required
() . " \n " ;