add check for other plugin dependencies

This commit is contained in:
Derek Macias
2016-02-02 11:39:44 -07:00
parent 15a21a538a
commit 1f36544657
5 changed files with 48 additions and 20 deletions

View File

@ -56,11 +56,23 @@ foreach ($pkg_cfg as $pkg_name => $pkg_pref) { // get preferences for each packa
$pkg_name = str_replace('_', '.', $pkg_name); // replace "_" with "." in package names
$pkg_pattern = '/^'.$pkg_name.'.*/'; // search patter for packages
$pkg_install_status = preg_grep($pkg_pattern, $pkgs_installed); // check install status
$pkg_download_status = preg_grep($pkg_pattern, $pkgs_downloaded); // check package download status
//check if plugin is dependent on package
$plugins = [];
exec("cd /boot/config/plugins ; find *.plg | xargs grep '$pkg_name' -sl",$plugins);
if ($plugins){
$plg_msg = "$pkg_name used by plugin: ";
foreach ($plugins as $plugin){
$plg_msg .= pathinfo($plugin, PATHINFO_FILENAME)." ";
}
logger($plg_msg);
}
if ($pkg_pref == 'yes') {
// if executing from the wegui check status and download if necessary
if ($argd) {
if (!preg_grep($pkg_pattern, $pkgs_downloaded)) {
if (!$pkg_download_status) {
$pkg_online_status = preg_grep($pkg_pattern, $pkgs_github_array);
@ -88,21 +100,25 @@ foreach ($pkg_cfg as $pkg_name => $pkg_pref) { // get preferences for each packa
$pkg_cmd = 'upgradepkg --install-new '.$pkg_path.$pkg_name.'* 2>&1';
}
} else if ($pkg_pref == 'no' && $pkg_install_status && $argu) {
$pkg_msg = 'Uninstalling';
$pkg_cmd = 'removepkg '.$pkg_path.$pkg_name.'* 2>&1';
if ($argr) {
$pkg_cmd .= '; rm '.$pkg_path.$pkg_name.'* 2>&1';
$pkg_msg .= ' and deleting';
if($plugins){
logger("Unable to uninstall $pkg_name",$argq);
}else{
$pkg_msg = 'Uninstalling';
$pkg_cmd = 'removepkg '.$pkg_path.$pkg_name.'* 2>&1';
if ($argr) {
$pkg_cmd .= '; rm '.$pkg_path.$pkg_name.'* 2>&1';
$pkg_msg .= ' and deleting';
}
}
}
if (!empty($pkg_cmd)) {
logger($pkg_msg.' '.$pkg_name.' package...');
logger("$pkg_msg $pkg_name package...");
shell_exec($pkg_cmd);
//$output = shell_exec($pkg_cmd);
//logger($output);
} else
logger($pkg_name.' package up to date', $argq);
logger("$pkg_name package up to date", $argq);
}
logger('All packages processed');
logger('All packages processed ');
?>