From cb238b20cc6bd7390047442066a8f0e89b764b53 Mon Sep 17 00:00:00 2001 From: dmacias72 Date: Sat, 8 Jul 2017 22:54:42 -0600 Subject: [PATCH] check for download instead of install --- .../emhttp/plugins/NerdPack/include/PackageQuery.php | 4 ++-- .../local/emhttp/plugins/NerdPack/scripts/packagemanager | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/PackageQuery.php b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/PackageQuery.php index f9b32725..916fbfe7 100644 --- a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/PackageQuery.php +++ b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/include/PackageQuery.php @@ -60,9 +60,9 @@ foreach ($pkgs_github_array as $pkg_github) { 'pkgnver' => $pkg_nver, // add package name with underscored version '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 + 'installed' => !empty(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 installed equals github exactly - 'downloaded' => preg_grep($pkg_pattern, $pkgs_downloaded) ? 'yes' : 'no', // checks if package name is downloaded + 'downloaded' => !empty(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 downloaded equals github exactly 'config' => $pkg_set, // install preference 'plugins' => $pkg_plgs, // plugins dependency on package diff --git a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/scripts/packagemanager b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/scripts/packagemanager index 77eee2b7..fce384ef 100755 --- a/source/NerdPack/usr/local/emhttp/plugins/NerdPack/scripts/packagemanager +++ b/source/NerdPack/usr/local/emhttp/plugins/NerdPack/scripts/packagemanager @@ -67,11 +67,12 @@ $pkg_find = ''; foreach ($pkg_cfg as $pkg_name => $pkg_pref) { // get preferences for each package $pkg_cmd = ''; + $pkg_msg = ''; $pkg_name = str_replace('_', '.', $pkg_name); // replace "_" with "." in package names $pkg_pattern = '/^'.$pkg_name.'.-*/'; // search pattern 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 - $pkg_online_status = preg_grep($pkg_pattern, $pkgs_github_array); + $pkg_install_status = !empty(preg_grep($pkg_pattern, $pkgs_installed)); // check install status + $pkg_download_status = !empty(preg_grep($pkg_pattern, $pkgs_downloaded)); // check package download status + $pkg_online_status = !empty(preg_grep($pkg_pattern, $pkgs_github_array)); $pkg_find .= " ! -name '".$pkg_name."*'"; $pkg_matches = array_filter($pkgs_github_array, function($a) use ($pkg_pattern) { @@ -119,7 +120,7 @@ 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) { + } elseif ($pkg_pref == 'no' && $pkg_download_status && $argu) { if($plugins){ logger("$pkg_name in use by another plugin, not uninstalled.",$argq); }else{