add check for other plugin dependencies
This commit is contained in:
parent
15a21a538a
commit
1f36544657
@ -1,5 +1,5 @@
|
||||
Icon="NerdPack.png"
|
||||
Menu="NetworkServices"
|
||||
Menu="UserPreferences"
|
||||
Title="Nerd Pack"
|
||||
---
|
||||
<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="/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 class="status" style="display: inline-block;margin-top: -45px;"><input id="deletepkg" 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 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">
|
||||
|
||||
@ -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="filter-downloaded" data-placeholder="by download"> Downloaded </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>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -35,4 +36,4 @@ Title="Nerd Pack"
|
||||
<script type="text/javascript" src="/plugins/tablesorter/js/jquery.tablesorter.combined.min.js"></script>
|
||||
<script type="text/javascript" src="/plugins/tablesorter/js/parsers/parser-metric.min.js"></script>
|
||||
<script type="text/javascript" src="/webGui/javascript/jquery.switchbutton.js"></script>
|
||||
<script type="text/javascript" src="/plugins/NerdPack/js/jquery.NerdPack.js"></script>
|
||||
<script type="text/javascript" src="/plugins/NerdPack/js/jquery.NerdPack.js"></script>
|
@ -6,4 +6,4 @@
|
||||
}
|
||||
.switch-button-label.off {
|
||||
color: inherit;
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ foreach ($pkgs_github_array as $pkg_github) {
|
||||
$pkg_nameArray = explode('-', $pkg_github['name']); // split package name into array
|
||||
|
||||
$pkg_name = $pkg_nameArray[0];
|
||||
|
||||
if (sizeof($pkg_nameArray) > 4) { //if package name has a subset get it
|
||||
for ($ii = 1; $ii < sizeof($pkg_nameArray)-3; $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
|
||||
|
||||
$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 = [
|
||||
'name' => $pkg_github['name'], // add full package name
|
||||
'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
|
||||
'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
|
||||
'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
|
||||
'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
|
||||
'plugins' => $pkg_plgs, // checks plugins dependency on package
|
||||
'desc' => $pkgs_desc_array[$pkg_name]
|
||||
];
|
||||
|
||||
|
@ -95,13 +95,13 @@ function packageQuery(force) {
|
||||
if (data[i].installeq != data[i].installed)
|
||||
Installed = 'old';
|
||||
|
||||
$("#tblPackages tbody").append(
|
||||
"<tr>"+
|
||||
$("#tblPackages tbody").append("<tr>"+
|
||||
"<td class='package' title='"+data[i].desc+"'>"+data[i].name+"</td>"+ // package name
|
||||
"<td>"+Update+"</td>"+ // package status
|
||||
"<td>"+data[i].size+"</td>"+ // package size
|
||||
"<td>"+Downloaded+"</td>"+ // package installed
|
||||
"<td>"+Downloaded+"</td>"+ // package downloaded
|
||||
"<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":"")+">"+
|
||||
"<input class='pkgvalue' type='hidden' id='"+data[i].pkgname+"_value' name='"+data[i].pkgnver+"' value='"+data[i].config+"'></td>"+
|
||||
"</tr>");
|
||||
@ -137,4 +137,4 @@ function checkDepends() {
|
||||
$("#python").switchButton({checked: true});
|
||||
$("#python", ".pkgvalue").val("yes");
|
||||
}
|
||||
}
|
||||
}
|
@ -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 ');
|
||||
?>
|
Loading…
Reference in New Issue
Block a user