diff options
author | Colin Smith <colin@pfsense.org> | 2005-04-11 23:14:16 +0000 |
---|---|---|
committer | Colin Smith <colin@pfsense.org> | 2005-04-11 23:14:16 +0000 |
commit | 9a2d499c251a650b0e60994d63306d1584c1f013 (patch) | |
tree | 723209af2a79b89b6b277a6bf96eebc585a89490 /usr/local/www/guiconfig.inc | |
parent | 131bb57602c94b6017a0662def73cdfeb6f9eae9 (diff) | |
download | pfsense-9a2d499c251a650b0e60994d63306d1584c1f013.zip pfsense-9a2d499c251a650b0e60994d63306d1584c1f013.tar.gz |
*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().
Diffstat (limited to 'usr/local/www/guiconfig.inc')
-rwxr-xr-x | usr/local/www/guiconfig.inc | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/usr/local/www/guiconfig.inc b/usr/local/www/guiconfig.inc index ec01164..1f92e45 100755 --- a/usr/local/www/guiconfig.inc +++ b/usr/local/www/guiconfig.inc @@ -538,7 +538,7 @@ function read_header($ch, $string) { } function read_body($ch, $string) { - global $fout, $file_size, $downloaded, $counter; + global $fout, $file_size, $downloaded, $counter, $sendto, $static_output; $length = strlen($string); $downloaded += intval($length); $downloadProgress = round(100 * (1 - $downloaded / $file_size), 0); @@ -554,14 +554,45 @@ function read_body($ch, $string) { $text .= " Percent : {$c}%\\n"; $text .= "---------------------------------\\n"; */ - $counter++; - if($counter > 150) { - $tostatus = $static_status . $downloadProgress; - update_status($tostatus); +// $counter++; +// if($counter > 150) { + if($sendto == "status") { + $tostatus = $static_status . $downloadProgress . "%"; + update_status($tostatus); + } else { + $tooutput = $static_output . $downloadProgress . "%"; + update_output_window($tooutput); + } update_progress_bar($downloadProgress); - $counter = 0; - } +// $counter = 0; +// } fwrite($fout, $string); return $length; } + +function pkg_fetch_recursive($pkgname, $filename, $dependlevel = 0, $base_url = 'http://ftp2.freebsd.org/pub/FreeBSD/ports/i386/packages-5-stable/Latest') { + global $static_status, $static_output, $g; + $pkg_extension = strrchr($filename, '.'); + $static_output .= "\n" . str_repeat(" ", $dependlevel * 2) . $pkgname . " "; + $fetchto = "/tmp/apkg_" . $pkgname . $pkg_extension; + download_file_with_progress_bar($base_url . "/" . $filename, $fetchto); +// update_output_window($static_output . "\n\n" . $pkg_progress); + exec("/usr/bin/tar -O -f {$fetchto} -x +CONTENTS", $slaveout); + $workingdir = preg_grep("/instmp/", $slaveout); + $workingdir = $workingdir[0]; + $raw_depends_list = array_values(preg_grep("/\@pkgdep/", $slaveout)); + if($raw_depends_list != "") { + foreach($raw_depends_list as $adepend) { + $working_depend = explode(" ", $adepend); + $working_depend = explode("-", $working_depend[1]); + $depend_filename = $working_depend[0] . $pkg_extension; + exec("ls /var/db/pkg", $is_installed); + $is_installed = array_values(preg_grep("/{$working_depend[0]}/i", $is_installed)); + if($is_installed[0] == "") pkg_fetch_recursive($working_depend[0], $depend_filename, $dependlevel + 1); + } + } + mwexec("cat {$g['tmp_path']}/y | /usr/sbin/pkg_add {$fetchto}"); + return true; +} + ?> |