summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2011-01-06 17:37:49 -0500
committerScott Ullrich <sullrich@pfsense.org>2011-01-06 17:37:49 -0500
commit64974db724dd0e6eeb4de63c63b56450a43903be (patch)
tree5bb33eb25fc21a270d4447185477370808ca7cd1
parent28ed552d3d62789d08fb4422c7b8457d1aaf4248 (diff)
downloadpfsense-64974db724dd0e6eeb4de63c63b56450a43903be.zip
pfsense-64974db724dd0e6eeb4de63c63b56450a43903be.tar.gz
Fix package dependency check code now that we no longer nuke /var/db/pkg/ before operating on packages
-rw-r--r--etc/inc/pkg-utils.inc26
1 files changed, 22 insertions, 4 deletions
diff --git a/etc/inc/pkg-utils.inc b/etc/inc/pkg-utils.inc
index 3f44d21..f2ee955 100644
--- a/etc/inc/pkg-utils.inc
+++ b/etc/inc/pkg-utils.inc
@@ -809,20 +809,36 @@ function install_package_xml($pkg) {
return true;
}
+function does_package_depend($pkg) {
+ // Should not happen, but just in case.
+ if(!$pkg)
+ return;
+ $pkg_var_db_dir = glob("/var/db/pkg/{$pkg}*");
+ // If this package has dependency then return true
+ foreach($pkg_var_db_dir as $pvdd) {
+ if (file_exists("{$vardb}/{$pvdd}/+REQUIRED_BY") && count(file("{$vardb}/{$pvdd}/+REQUIRED_BY")) > 0)
+ return true;
+ }
+ // Did not find a record of dependencies, so return false.
+ return false;
+}
+
function delete_package($pkg) {
global $config, $g, $static_output, $vardb;
$pkg = substr(reverse_strrchr($pkg, "."), 0, -1);
- if (file_exists("{$vardb}/{$pkg}/+REQUIRED_BY") && count(file("{$vardb}/{$pkg}/+REQUIRED_BY")) > 0) {
+ // If package has dependencies then skip it
+ if(does_package_depend($pkg)) {
$static_output .= "Skipping package deletion for {$pkg} because it is required by other packages.\n";
update_output_window($static_output);
- return;
+ return;
} else {
if($pkg)
$static_output .= "Starting package deletion for {$pkg}...";
- update_output_window($static_output);
+ update_output_window($static_output);
}
+
$info = "";
exec("/usr/sbin/pkg_info -qrx {$pkg}", $info);
remove_freebsd_package($pkg);
@@ -830,7 +846,9 @@ function delete_package($pkg) {
update_output_window($static_output);
foreach($info as $line) {
$depend = trim(str_replace("@pkgdep ", "", $line), " \n");
- delete_package($depend);
+ // If package has dependencies then skip it
+ if(!does_package_depend($depend))
+ delete_package($depend);
}
return;
OpenPOWER on IntegriCloud