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

@ -1,5 +1,5 @@
Icon="NerdPack.png" Icon="NerdPack.png"
Menu="NetworkServices" Menu="UserPreferences"
Title="Nerd Pack" Title="Nerd Pack"
--- ---
<link type="text/css" rel="stylesheet" href="/plugins/tablesorter/css/tablesorter.css"> <link type="text/css" rel="stylesheet" href="/plugins/tablesorter/css/tablesorter.css">
@ -7,8 +7,8 @@ Title="Nerd Pack"
<link type="text/css" rel="stylesheet" href="/webGui/styles/jquery.switchbutton.css"> <link type="text/css" rel="stylesheet" href="/webGui/styles/jquery.switchbutton.css">
<link type="text/css" rel="stylesheet" href="/plugins/NerdPack/css/NerdPack.css"> <link type="text/css" rel="stylesheet" href="/plugins/NerdPack/css/NerdPack.css">
<span class="status" style="display: inline-block;margin-right: 110px;margin-top: -45px;"><input id="uninstallpkg" type="checkbox"></span> <span id="uninstall" class="status" style="display: inline-block;margin-right: 110px;margin-top: -45px;"><input id="uninstallpkg" type="checkbox"></span>
<span class="status" style="display: inline-block;margin-top: -45px;"><input id="deletepkg" type="checkbox"></span> <span id="delete" class="status" style="display: inline-block;margin-top: -45px;"><input id="deletepkg" type="checkbox"></span>
<form markdown="1" id="package_form" name="package_settings" method="POST" action="/update.php" target="progressFrame"> <form markdown="1" id="package_form" name="package_settings" method="POST" action="/update.php" target="progressFrame">
@ -20,6 +20,7 @@ Title="Nerd Pack"
<th class="sorter-metric filter-false" data-placeholder="by size" data-metric-name-full="byte|Byte|BYTE" data-metric-name-abbr="b|B"> Size </th> <th class="sorter-metric filter-false" data-placeholder="by size" data-metric-name-full="byte|Byte|BYTE" data-metric-name-abbr="b|B"> Size </th>
<th class="filter-downloaded" data-placeholder="by download"> Downloaded </th> <th class="filter-downloaded" data-placeholder="by download"> Downloaded </th>
<th class="filter-installed" data-placeholder="by install"> Installed </th> <th class="filter-installed" data-placeholder="by install"> Installed </th>
<th class="filter-plugins" data-placeholder="Search..."> Plugins </th>
<th class="parser-false filter-false"><input id="checkall" type="checkbox"></th> <th class="parser-false filter-false"><input id="checkall" type="checkbox"></th>
</tr> </tr>
</thead> </thead>

View File

@ -14,6 +14,7 @@ foreach ($pkgs_github_array as $pkg_github) {
$pkg_nameArray = explode('-', $pkg_github['name']); // split package name into array $pkg_nameArray = explode('-', $pkg_github['name']); // split package name into array
$pkg_name = $pkg_nameArray[0]; $pkg_name = $pkg_nameArray[0];
if (sizeof($pkg_nameArray) > 4) { //if package name has a subset get it if (sizeof($pkg_nameArray) > 4) { //if package name has a subset get it
for ($ii = 1; $ii < sizeof($pkg_nameArray)-3; $ii++) { for ($ii = 1; $ii < sizeof($pkg_nameArray)-3; $ii++) {
$pkg_name .= '-'.$pkg_nameArray[$ii]; $pkg_name .= '-'.$pkg_nameArray[$ii];
@ -26,6 +27,15 @@ foreach ($pkgs_github_array as $pkg_github) {
$pkg_pattern = '/^'.$pkg_name.'.*/'; // search patter for packages $pkg_pattern = '/^'.$pkg_name.'.*/'; // search patter for packages
$plugins = [];
exec("cd /boot/config/plugins ; find *.plg | xargs grep '${pkg_github['name']}' -sl",$plugins);
$pkg_plgs = "";
if ($plugins){
foreach ($plugins as $plugin){
$pkg_plgs .= pathinfo($plugin, PATHINFO_FILENAME)." ";
}
}
$pkg = [ $pkg = [
'name' => $pkg_github['name'], // add full package name 'name' => $pkg_github['name'], // add full package name
'pkgname' => $pkg_name, // add package name only 'pkgname' => $pkg_name, // add package name only
@ -33,10 +43,11 @@ foreach ($pkgs_github_array as $pkg_github) {
'pkgversion' => $pkg_version, // add package name with raw version 'pkgversion' => $pkg_version, // add package name with raw version
'size' => format_size($pkg_github['size'], 1, '?'), // add package size 'size' => format_size($pkg_github['size'], 1, '?'), // add package size
'installed' => preg_grep($pkg_pattern, $pkgs_installed) ? 'yes' : 'no', // checks if package name is installed 'installed' => preg_grep($pkg_pattern, $pkgs_installed) ? 'yes' : 'no', // checks if package name is installed
'installeq' => in_array(pathinfo($pkg_github['name'], PATHINFO_FILENAME), $pkgs_installed) ? 'yes' : 'no', // checks if package is installed equals github exactly 'installeq' => in_array(pathinfo($pkg_github['name'], PATHINFO_FILENAME), $pkgs_installed) ? 'yes' : 'no', // checks if package installed equals github exactly
'downloaded' => preg_grep($pkg_pattern, $pkgs_downloaded) ? 'yes' : 'no', // checks if package name is downloaded 'downloaded' => preg_grep($pkg_pattern, $pkgs_downloaded) ? 'yes' : 'no', // checks if package name is downloaded
'downloadeq' => in_array($pkg_github['name'], $pkgs_downloaded) ? 'yes' : 'no', // checks if package is downloaded equals github exactly 'downloadeq' => in_array($pkg_github['name'], $pkgs_downloaded) ? 'yes' : 'no', // checks if package downloaded equals github exactly
'config' => isset($pkg_cfg[$pkg_nver]) ? $pkg_cfg[$pkg_nver] : 'no', // checks config for install preference 'config' => isset($pkg_cfg[$pkg_nver]) ? $pkg_cfg[$pkg_nver] : 'no', // checks config for install preference
'plugins' => $pkg_plgs, // checks plugins dependency on package
'desc' => $pkgs_desc_array[$pkg_name] 'desc' => $pkgs_desc_array[$pkg_name]
]; ];

View File

@ -95,13 +95,13 @@ function packageQuery(force) {
if (data[i].installeq != data[i].installed) if (data[i].installeq != data[i].installed)
Installed = 'old'; Installed = 'old';
$("#tblPackages tbody").append( $("#tblPackages tbody").append("<tr>"+
"<tr>"+
"<td class='package' title='"+data[i].desc+"'>"+data[i].name+"</td>"+ // package name "<td class='package' title='"+data[i].desc+"'>"+data[i].name+"</td>"+ // package name
"<td>"+Update+"</td>"+ // package status "<td>"+Update+"</td>"+ // package status
"<td>"+data[i].size+"</td>"+ // package size "<td>"+data[i].size+"</td>"+ // package size
"<td>"+Downloaded+"</td>"+ // package installed "<td>"+Downloaded+"</td>"+ // package downloaded
"<td>"+Installed+"</td>"+ // package installed "<td>"+Installed+"</td>"+ // package installed
"<td>"+data[i].plugins+"</td>"+ // package dependents
"<td><input class='pkgcheckbox' id='"+data[i].pkgname+"' type='checkbox' "+(data[i].config=="yes"?"checked":"")+">"+ "<td><input class='pkgcheckbox' id='"+data[i].pkgname+"' type='checkbox' "+(data[i].config=="yes"?"checked":"")+">"+
"<input class='pkgvalue' type='hidden' id='"+data[i].pkgname+"_value' name='"+data[i].pkgnver+"' value='"+data[i].config+"'></td>"+ "<input class='pkgvalue' type='hidden' id='"+data[i].pkgname+"_value' name='"+data[i].pkgnver+"' value='"+data[i].config+"'></td>"+
"</tr>"); "</tr>");

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_name = str_replace('_', '.', $pkg_name); // replace "_" with "." in package names
$pkg_pattern = '/^'.$pkg_name.'.*/'; // search patter for packages $pkg_pattern = '/^'.$pkg_name.'.*/'; // search patter for packages
$pkg_install_status = preg_grep($pkg_pattern, $pkgs_installed); // check install status $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 ($pkg_pref == 'yes') {
// if executing from the wegui check status and download if necessary // if executing from the wegui check status and download if necessary
if ($argd) { if ($argd) {
if (!preg_grep($pkg_pattern, $pkgs_downloaded)) { if (!$pkg_download_status) {
$pkg_online_status = preg_grep($pkg_pattern, $pkgs_github_array); $pkg_online_status = preg_grep($pkg_pattern, $pkgs_github_array);
@ -88,6 +100,9 @@ foreach ($pkg_cfg as $pkg_name => $pkg_pref) { // get preferences for each packa
$pkg_cmd = 'upgradepkg --install-new '.$pkg_path.$pkg_name.'* 2>&1'; $pkg_cmd = 'upgradepkg --install-new '.$pkg_path.$pkg_name.'* 2>&1';
} }
} else if ($pkg_pref == 'no' && $pkg_install_status && $argu) { } else if ($pkg_pref == 'no' && $pkg_install_status && $argu) {
if($plugins){
logger("Unable to uninstall $pkg_name",$argq);
}else{
$pkg_msg = 'Uninstalling'; $pkg_msg = 'Uninstalling';
$pkg_cmd = 'removepkg '.$pkg_path.$pkg_name.'* 2>&1'; $pkg_cmd = 'removepkg '.$pkg_path.$pkg_name.'* 2>&1';
if ($argr) { if ($argr) {
@ -95,13 +110,14 @@ foreach ($pkg_cfg as $pkg_name => $pkg_pref) { // get preferences for each packa
$pkg_msg .= ' and deleting'; $pkg_msg .= ' and deleting';
} }
} }
}
if (!empty($pkg_cmd)) { if (!empty($pkg_cmd)) {
logger($pkg_msg.' '.$pkg_name.' package...'); logger("$pkg_msg $pkg_name package...");
shell_exec($pkg_cmd); shell_exec($pkg_cmd);
//$output = shell_exec($pkg_cmd); //$output = shell_exec($pkg_cmd);
//logger($output); //logger($output);
} else } 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 ');