summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@gmail.com>2012-03-21 11:20:48 -0700
committerScott Ullrich <sullrich@gmail.com>2012-03-21 11:20:48 -0700
commit2e5de33c8b42c82924566013d85d31c067b6a1cf (patch)
tree6e73e42f80a80bb36672f57cd252a36c40227419 /etc
parentdd65598e5258da1373b9101ca6e31acb7ae22a8e (diff)
parent44988c5e22cbc803273d133fffe35dd324f8862a (diff)
downloadpfsense-2e5de33c8b42c82924566013d85d31c067b6a1cf.zip
pfsense-2e5de33c8b42c82924566013d85d31c067b6a1cf.tar.gz
Merge pull request #66 from phil-davis/master
Bug #2301: Mixed-case package names and package deletion
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/pkg-utils.inc49
1 files changed, 37 insertions, 12 deletions
diff --git a/etc/inc/pkg-utils.inc b/etc/inc/pkg-utils.inc
index 7734cc7..09ea66b 100644
--- a/etc/inc/pkg-utils.inc
+++ b/etc/inc/pkg-utils.inc
@@ -99,21 +99,29 @@ conf_mount_ro();
*
******/
function remove_freebsd_package($packagestring) {
+ // The packagestring passed in must be the full PBI package name,
+ // as displayed by the pbi_info utility. e.g. "package-1.2.3_4-i386"
+ // It must NOT have ".pbi" on the end.
exec("/usr/local/sbin/pbi_info {$packagestring} | /usr/bin/awk '/Prefix/ {print $2}'",$pbidir);
$pbidir = $pbidir[0];
- $linkdirs = array('bin','sbin');
- foreach($linkdirs as $dir) {
- if(is_dir("{$pbidir}/{$dir}")) {
- $files = scandir("{$pbidir}/{$dir}");
- foreach($files as $f) {
- if($f != '.' && $f != '..') {
- unlink("/usr/local/{$dir}/{$f}");
+ if ($pbidir == "") {
+ log_error("PBI dir for {$packagestring} was not found - cannot cleanup PBI files");
+ }
+ else {
+ $linkdirs = array('bin','sbin');
+ foreach($linkdirs as $dir) {
+ if(is_dir("{$pbidir}/{$dir}")) {
+ $files = scandir("{$pbidir}/{$dir}");
+ foreach($files as $f) {
+ if($f != '.' && $f != '..') {
+ unlink("/usr/local/{$dir}/{$f}");
+ }
}
}
}
- }
- exec("/usr/local/sbin/pbi_delete {$packagestring} 2>>/tmp/pbi_delete_errors.txt");
+ exec("/usr/local/sbin/pbi_delete {$packagestring} 2>>/tmp/pbi_delete_errors.txt");
+ }
}
/****f* pkg-utils/is_package_installed
@@ -352,7 +360,17 @@ function uninstall_package($pkg_name) {
foreach ($pkg_depends as $pkg_depend)
delete_package($pkg_depend);
} else {
- delete_package($pkg_depends);
+ // The packages (1 or more) are all in one long string.
+ // We need to pass them 1 at a time to delete_package.
+ // Compress any multiple whitespace (sp, tab, cr, lf...) into a single space char.
+ $pkg_dep_str = preg_replace("'\s+'", ' ', $pkg_depends);
+ // Get rid of any leading or trailing space.
+ $pkg_dep_str = trim($pkg_dep_str);
+ // Now we have a space-separated string. Make it into an array and process it.
+ $pkg_dep_array = explode(" ", $pkg_dep_str);
+ foreach ($pkg_dep_array as $pkg_depend) {
+ delete_package($pkg_depend);
+ }
}
}
delete_package_xml($pkg_name);
@@ -794,12 +812,18 @@ function install_package_xml($pkg) {
* change packages to store configs at /usr/pbi/pkg/etc and remove this
*/
eval_once($pkg_config['custom_php_install_command']);
- exec("/usr/local/sbin/pbi_info | grep {$pkg}- | xargs /usr/local/sbin/pbi_info | awk '/Prefix/ {print $2}'",$pbidirarray);
+ // Note: pkg may be mixed-case, e.g. "squidGuard" but the PBI names are lowercase.
+ // e.g. "squidguard-1.4_4-i386" so feed lowercase to pbi_info below.
+ // Also add the "-" so that examples like "squid-" do not match "squidguard-".
+ $pkg_name_for_pbi_match = strtolower($pkg) . "-";
+ exec("/usr/local/sbin/pbi_info | grep {$pkg_name_for_pbi_match} | xargs /usr/local/sbin/pbi_info | awk '/Prefix/ {print $2}'",$pbidirarray);
$pbidir0 = $pbidirarray[0];
exec("find /usr/local/etc/ -name *.conf | grep {$pkg}",$files);
foreach($files as $f) {
$pbiconf = str_replace('/usr/local',$pbidir0,$f);
- unlink($pbiconf);
+ if (is_file($pbiconf) || is_link($pbiconf)) {
+ unlink($pbiconf);
+ }
symlink($f,$pbiconf);
}
eval_once($pkg_config['custom_php_install_command']);
@@ -906,6 +930,7 @@ function delete_package($pkg) {
if(!$pkg)
return;
+ // Note: $pkg has the full PBI package name followed by ".pbi". Strip off ".pbi".
$pkg = substr(reverse_strrchr($pkg, "."), 0, -1);
if($pkg)
OpenPOWER on IntegriCloud