diff options
author | Scott Ullrich <sullrich@gmail.com> | 2012-03-23 07:06:55 -0700 |
---|---|---|
committer | Scott Ullrich <sullrich@gmail.com> | 2012-03-23 07:06:55 -0700 |
commit | fe5e1374019b74996b11711f57d21cee28d8a0c4 (patch) | |
tree | 8a71dc22ac24be6ae12501d73b7e609a4286e337 /etc | |
parent | f97a5b0419d0350cc85b91d180238975c308ac07 (diff) | |
parent | a1d4a048dc2ae3ab9ba7f2284086a7cf958533ff (diff) | |
download | pfsense-fe5e1374019b74996b11711f57d21cee28d8a0c4.zip pfsense-fe5e1374019b74996b11711f57d21cee28d8a0c4.tar.gz |
Merge pull request #67 from phil-davis/master
Bug #2301: More fixes to pbi package install and removal
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/pkg-utils.inc | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/etc/inc/pkg-utils.inc b/etc/inc/pkg-utils.inc index 09ea66b..88a58e7 100644 --- a/etc/inc/pkg-utils.inc +++ b/etc/inc/pkg-utils.inc @@ -110,11 +110,18 @@ function remove_freebsd_package($packagestring) { else { $linkdirs = array('bin','sbin'); foreach($linkdirs as $dir) { - if(is_dir("{$pbidir}/{$dir}")) { - $files = scandir("{$pbidir}/{$dir}"); + $target_dir = $pbidir . "/" . $dir; + if(is_dir($target_dir)) { + $files = scandir($target_dir); foreach($files as $f) { if($f != '.' && $f != '..') { - unlink("/usr/local/{$dir}/{$f}"); + // Only try to unlink the file if it is a link to the expected pbi dir. + $local_name = "/usr/local/{$dir}/{$f}"; + if(is_link($local_name)) { + if(substr(readlink($local_name),0,strlen($target_dir)) == $target_dir) { + unlink($local_name); + } + } } } } @@ -553,7 +560,7 @@ function pkg_fetch_recursive($pkgname, $filename, $dependlevel = 0, $base_url = $files = scandir("{$pbidir}/{$dir}"); foreach($files as $f) { if(!file_exists("/usr/local/{$dir}/{$f}")) { - symlink("{$pbidir}/{$dir}/${$f}","/usr/local/{$dir}/{$f}"); + symlink("{$pbidir}/{$dir}/{$f}","/usr/local/{$dir}/{$f}"); } } } @@ -816,15 +823,19 @@ function install_package_xml($pkg) { // 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); + 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); - if (is_file($pbiconf) || is_link($pbiconf)) { + if(is_file($pbiconf) || is_link($pbiconf)) { unlink($pbiconf); } - symlink($f,$pbiconf); + if(is_dir(dirname($pbiconf))) { + symlink($f,$pbiconf); + } else { + log_error("The dir for {$pbiconf} does not exist. Cannot add symlink to {$f}."); + } } eval_once($pkg_config['custom_php_install_command']); $static_output .= gettext("done.") . "\n"; |