Project

General

Profile

« Previous | Next » 

Revision 62c55268

Added by Colin Smith over 20 years ago

Adjustments to delete_package_recursive().

View differences:

etc/inc/pkg-utils.inc
561 561
	}
562 562
}
563 563

  
564
function delete_package($pkg) {
565
	global $g, $config, $fd_log, $static_output;
566
	update_status("Removing package...");
567
	$static_output .= "Removing package... ";
568
	update_output_window($static_output);
569
	delete_package_recursive($pkg);
570
	$static_output .= "done.\n";
571
	update_output_window($static_output);
572
	return;
573
}
574

  
564 575
function delete_package_recursive($pkg, $pkgdb = "") {
565
	exec("/usr/bin/pkg_info -r " . $pkg, $info);
566
	print_r($info);
567
	if(!$pkgdb) { exec("/bin/ls /var/db/pkg", $pkgdb); print_r($pkgdb); }
576
	exec("/usr/sbin/pkg_info -r " . $pkg . " 2>&1", $info);
577
	if(!$pkgdb) exec("/bin/ls /var/db/pkg", $pkgdb);
568 578
	if(stristr($info[0], "can't find package") != false) return;
569 579
	foreach($info as $line) {
570 580
		$depend = trim(array_pop($line));
571 581
		if(in_array($depend, $pkgdb)) delete_package_recursive($depend, $pkgdb);
572 582
	}
573
	exec("/usr/sbin/pkg_delete " . $pkg);
583
	$fd = fopen("{$g['tmp_path']}/y", "w");
584
	for($line = 0; $line < 10; $line++) {
585
		fwrite($fd, "y\n");
586
	}
587
	fclose($fd);
588
	exec("cat {$g['tmp_path']}/y | /usr/sbin/pkg_delete " . $pkg ." > /dev/null 2>&1");
574 589
	return;
575 590
}
576 591

  
577 592
function delete_package_xml($pkg) {
578 593
	global $g, $config, $fd_log, $static_output;
579 594
	if(($pkgid = get_pkg_id($pkg)) == -1) {
580
                $static_output .= "The {$pkg} package is not installed.\n\nInstallation aborted.";
595
                $static_output .= "The {$pkg} package is not installed.\n\nDeletion aborted.";
581 596
                update_output_window($static_output);
582 597
                echo "\n<script language=\"JavaScript\">document.progressbar.style.visibility='hidden';</script>";
583 598
                echo "\n<script language=\"JavaScript\">document.progholder.style.visibility='hidden';</script>";
......
590 605
                        update_output_window("Warning, could not open log for writing.");
591 606
                }
592 607
        }
608
	update_status("Removing {$pkg} components...");
593 609
	fwrite($fd_log, "Removing {$pkg} package... ");
594
	$static_output .= "Removing {$pkg} package...\n";
610
	$static_output .= "Removing {$pkg} components...\n";
595 611
	update_output_window($static_output);
596 612
	/* parse package configuration */
597 613
	$packages = &$config['installedpackages']['package'];
598 614
	$menus = &$config['installedpackages']['menu'];
599
	$pkg_config = parse_xml_config_pkg("/usr/local/pkg/" . $packages[$pkgid]['configurationfile'], "packagegui");
615
	$pkg_config = parse_xml_config("/usr/local/pkg/" . $packages[$pkgid]['configurationfile'], "packagegui");
600 616
        /* remove menu items */
601 617
	if(is_array($pkg_config['menu'])) {
602 618
		$static_output .= "\tMenu items... ";
......
653 669
	unset($config['installedpackages']['package'][$pkgid]);
654 670
	$static_output .= "done.\n";
655 671
	update_output_window($static_output);
672
	write_config("Removed {$pkg} package.");
656 673
	/* file cleanup */
657 674
	$ctag = file("/etc/crontab");
658 675
	foreach($ctag as $line) {

Also available in: Unified diff