From 8aed83e5298e0b122ae71830458463f79330cbad Mon Sep 17 00:00:00 2001 From: jsavargas Date: Wed, 7 Jun 2023 17:59:33 -0400 Subject: [PATCH] remove old packages when upgrading --- .../emhttp/plugins/NerdTools/include/PackageQuery.php | 2 +- .../emhttp/plugins/NerdTools/scripts/packagemanager | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/source/NerdTools/usr/local/emhttp/plugins/NerdTools/include/PackageQuery.php b/source/NerdTools/usr/local/emhttp/plugins/NerdTools/include/PackageQuery.php index 0837514..1d3f14f 100644 --- a/source/NerdTools/usr/local/emhttp/plugins/NerdTools/include/PackageQuery.php +++ b/source/NerdTools/usr/local/emhttp/plugins/NerdTools/include/PackageQuery.php @@ -67,7 +67,7 @@ foreach ($pkgs_github_array as $pkg_github) { $pkg = [ 'name' => str_replace("_nerdtools.txz",".txz",$pkg_github['name']) , // add full package name - 'dependencies' => $depends_file_array[$pkg_name] ?? "" ? str_replace(array(" ",","), array("",", "), $depends_file_array[$pkg_name]) : '', + 'dependencies' => isset($depends_file_array[$pkg_name]) ? str_replace(array(" ",","), array("",", "), $depends_file_array[$pkg_name]) : '', // add package name only 'pkgname' => $pkg_name, // add package name only 'pkgnver' => $pkg_nver, // add package name with underscored version 'pkgversion' => $pkg_version, // add package name with raw version diff --git a/source/NerdTools/usr/local/emhttp/plugins/NerdTools/scripts/packagemanager b/source/NerdTools/usr/local/emhttp/plugins/NerdTools/scripts/packagemanager index 2bc3b12..74e2d2a 100755 --- a/source/NerdTools/usr/local/emhttp/plugins/NerdTools/scripts/packagemanager +++ b/source/NerdTools/usr/local/emhttp/plugins/NerdTools/scripts/packagemanager @@ -137,6 +137,11 @@ foreach ($pkg_cfg as $pkg_name => $pkg_pref) { // get preferences for each packa if (!empty($pkg_cmd)) { logger("$pkg_msg $pkg_name package..."); shell_exec($pkg_cmd); + $name = explode("-", $pkg_name)[0] ?? ""; + if ($name) { + $find_rm_old ="find ".$pkg_extra_path." -type f ! -name '$pkg_name*' -name '".explode("-", $pkg_name)[0]."-*' -delete"; + shell_exec($find_rm_old); + } }else{ if ($pkg_pref == 'yes'){ if (file_exists($pkg_file)){ @@ -157,8 +162,8 @@ foreach ($pkg_cfg as $pkg_name => $pkg_pref) { // get preferences for each packa } logger('Cleaning up packages...'); -#$cmd = "find ".$pkg_extra_path." -type f ! -name 'packages.json' ! -name 'packages-desc'".$pkg_find." -delete 2>&1"; -#shell_exec($cmd); +$cmd = 'find '.$pkg_extra_path.' -type f '.$pkg_find.' -name "*nerdtools*" -delete 2>&1'; +shell_exec($cmd); logger('All packages processed...');