summaryrefslogtreecommitdiffstats
path: root/usr/local/www/guiconfig.inc
diff options
context:
space:
mode:
authorColin Smith <colin@pfsense.org>2005-04-11 23:14:16 +0000
committerColin Smith <colin@pfsense.org>2005-04-11 23:14:16 +0000
commit9a2d499c251a650b0e60994d63306d1584c1f013 (patch)
tree723209af2a79b89b6b277a6bf96eebc585a89490 /usr/local/www/guiconfig.inc
parent131bb57602c94b6017a0662def73cdfeb6f9eae9 (diff)
downloadpfsense-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-xusr/local/www/guiconfig.inc45
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;
+}
+
?>
OpenPOWER on IntegriCloud