remove old packages when upgrading

This commit is contained in:
jsavargas 2023-06-07 17:59:33 -04:00
parent a307d22556
commit 8aed83e529
2 changed files with 8 additions and 3 deletions

View File

@ -67,7 +67,7 @@ foreach ($pkgs_github_array as $pkg_github) {
$pkg = [ $pkg = [
'name' => str_replace("_nerdtools.txz",".txz",$pkg_github['name']) , // add full package name '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 'pkgname' => $pkg_name, // add package name only
'pkgnver' => $pkg_nver, // add package name with underscored version 'pkgnver' => $pkg_nver, // add package name with underscored version
'pkgversion' => $pkg_version, // add package name with raw version 'pkgversion' => $pkg_version, // add package name with raw version

View File

@ -137,6 +137,11 @@ foreach ($pkg_cfg as $pkg_name => $pkg_pref) { // get preferences for each packa
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);
$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{ }else{
if ($pkg_pref == 'yes'){ if ($pkg_pref == 'yes'){
if (file_exists($pkg_file)){ 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...'); logger('Cleaning up packages...');
#$cmd = "find ".$pkg_extra_path." -type f ! -name 'packages.json' ! -name 'packages-desc'".$pkg_find." -delete 2>&1"; $cmd = 'find '.$pkg_extra_path.' -type f '.$pkg_find.' -name "*nerdtools*" -delete 2>&1';
#shell_exec($cmd); shell_exec($cmd);
logger('All packages processed...'); logger('All packages processed...');