Revision 9a2d499c
Added by Colin Smith about 20 years ago
usr/local/www/guiconfig.inc | ||
---|---|---|
538 | 538 |
} |
539 | 539 |
|
540 | 540 |
function read_body($ch, $string) { |
541 |
global $fout, $file_size, $downloaded, $counter; |
|
541 |
global $fout, $file_size, $downloaded, $counter, $sendto, $static_output;
|
|
542 | 542 |
$length = strlen($string); |
543 | 543 |
$downloaded += intval($length); |
544 | 544 |
$downloadProgress = round(100 * (1 - $downloaded / $file_size), 0); |
... | ... | |
554 | 554 |
$text .= " Percent : {$c}%\\n"; |
555 | 555 |
$text .= "---------------------------------\\n"; |
556 | 556 |
*/ |
557 |
$counter++; |
|
558 |
if($counter > 150) { |
|
559 |
$tostatus = $static_status . $downloadProgress; |
|
560 |
update_status($tostatus); |
|
557 |
// $counter++; |
|
558 |
// if($counter > 150) { |
|
559 |
if($sendto == "status") { |
|
560 |
$tostatus = $static_status . $downloadProgress . "%"; |
|
561 |
update_status($tostatus); |
|
562 |
} else { |
|
563 |
$tooutput = $static_output . $downloadProgress . "%"; |
|
564 |
update_output_window($tooutput); |
|
565 |
} |
|
561 | 566 |
update_progress_bar($downloadProgress); |
562 |
$counter = 0; |
|
563 |
} |
|
567 |
// $counter = 0;
|
|
568 |
// }
|
|
564 | 569 |
fwrite($fout, $string); |
565 | 570 |
return $length; |
566 | 571 |
} |
572 |
|
|
573 |
function pkg_fetch_recursive($pkgname, $filename, $dependlevel = 0, $base_url = 'http://ftp2.freebsd.org/pub/FreeBSD/ports/i386/packages-5-stable/Latest') { |
|
574 |
global $static_status, $static_output, $g; |
|
575 |
$pkg_extension = strrchr($filename, '.'); |
|
576 |
$static_output .= "\n" . str_repeat(" ", $dependlevel * 2) . $pkgname . " "; |
|
577 |
$fetchto = "/tmp/apkg_" . $pkgname . $pkg_extension; |
|
578 |
download_file_with_progress_bar($base_url . "/" . $filename, $fetchto); |
|
579 |
// update_output_window($static_output . "\n\n" . $pkg_progress); |
|
580 |
exec("/usr/bin/tar -O -f {$fetchto} -x +CONTENTS", $slaveout); |
|
581 |
$workingdir = preg_grep("/instmp/", $slaveout); |
|
582 |
$workingdir = $workingdir[0]; |
|
583 |
$raw_depends_list = array_values(preg_grep("/\@pkgdep/", $slaveout)); |
|
584 |
if($raw_depends_list != "") { |
|
585 |
foreach($raw_depends_list as $adepend) { |
|
586 |
$working_depend = explode(" ", $adepend); |
|
587 |
$working_depend = explode("-", $working_depend[1]); |
|
588 |
$depend_filename = $working_depend[0] . $pkg_extension; |
|
589 |
exec("ls /var/db/pkg", $is_installed); |
|
590 |
$is_installed = array_values(preg_grep("/{$working_depend[0]}/i", $is_installed)); |
|
591 |
if($is_installed[0] == "") pkg_fetch_recursive($working_depend[0], $depend_filename, $dependlevel + 1); |
|
592 |
} |
|
593 |
} |
|
594 |
mwexec("cat {$g['tmp_path']}/y | /usr/sbin/pkg_add {$fetchto}"); |
|
595 |
return true; |
|
596 |
} |
|
597 |
|
|
567 | 598 |
?> |
Also available in: Unified diff
*Rework package installation interface. * Use progress bar to indicate download progress. * Handle nested dependencies. * Handle dependencies needed by more than one package/depend (please test) * Some minor optimizations.
*Add pkg_fetch_recursive().