improvements in package installation

This commit is contained in:
jsavargas 2023-04-24 12:08:32 -04:00
parent 23e0d3fa0d
commit 1555e0f409
3 changed files with 21 additions and 17 deletions

Binary file not shown.

View File

@ -3,8 +3,8 @@
<!DOCTYPE PLUGIN [
<!ENTITY name "NerdTools">
<!ENTITY author "UnRAIDES">
<!ENTITY version "2023.03.30">
<!ENTITY md5 "6e1b86e01474df79c2ff4936d404086c">
<!ENTITY version "2023.04.24">
<!ENTITY md5 "c07e631c5cf5b4f202b93e167059b29f">
<!ENTITY launch "Settings/&name;">
<!ENTITY github "UnRAIDES/unRAID-&name;">
<!ENTITY pluginURL "https://raw.githubusercontent.com/&github;/main/plugin/&name;.plg">
@ -17,6 +17,8 @@
<CHANGES>
##&name;
###2023.04.24
- Enhanced: improvements in package installation
###2023.03.30
- Enhanced: change category of the plugin (PR #50)
###2023.03.29

View File

@ -73,17 +73,24 @@ foreach ($pkg_cfg as $pkg_name => $pkg_pref) { // get preferences for each packa
$pkg_patternd = '/^'.$pkg_name.'.*_nerdtools.*/'; // search pattern for packages
$pkg_install_status = !empty(preg_grep($pkg_patternd, $pkgs_installed)); // check install status
$pkg_download_status = !empty(preg_grep($pkg_patternd, $pkgs_downloaded)); // check package download status
$pkg_online_status = !empty(preg_grep($pkg_pattern, $pkgs_github_array));
#$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) {
return preg_grep($pkg_pattern, $a);
});
#$pkg_matches = array_filter($pkgs_github_array, function($a) use ($pkg_pattern) {
# return preg_grep($pkg_pattern, $a);
#});
$pkg_gitname = array_values($pkg_matches)[0]['name'];
foreach ($pkgs_github_array as $item) {
if (preg_match($pkg_pattern, $item['name'])) {
$pkg_matches = $item;
break;
}
}
$pkg_gitname = $pkg_matches['name'];
$pkg_file = $pkg_extra_path.$pkg_gitname;
$pkg_url = array_values($pkg_matches)[0]['download_url'];
$pkg_sha1 = array_values($pkg_matches)[0]['sha'];
$pkg_url = $pkg_matches['download_url'];
$pkg_sha1 = $pkg_matches['sha'];
//check if plugin is dependent on package
$plugins = [];
@ -93,7 +100,7 @@ foreach ($pkg_cfg as $pkg_name => $pkg_pref) { // get preferences for each packa
foreach ($plugins as $plugin){
$plg_msg .= pathinfo($plugin, PATHINFO_FILENAME).", ";
}
logger(substr($plg_msg, 0, -2));
#logger(substr($plg_msg, 0, -2));
}
$pkg_file = str_replace("_nerdtools.txz",".txz",$pkg_file);
@ -104,11 +111,6 @@ foreach ($pkg_cfg as $pkg_name => $pkg_pref) { // get preferences for each packa
if ($argd) {
if (!$pkg_download_status) { //if package is not downloaded
//logger('Downloading '.$pkg_gitname.' package...', $argq);
//logger('Downloading pkg_file '.$pkg_file.' package...', $argq);
//logger('Downloading pkg_url '.$pkg_url.' package...', $argq);
//logger('Downloading pkg_sha1 '.$pkg_sha1.' package...', $argq);
get_file_from_url($pkg_file, $pkg_url);
if (file_check_sha1($pkg_file, $pkg_sha1)){
@ -144,12 +146,12 @@ foreach ($pkg_cfg as $pkg_name => $pkg_pref) { // get preferences for each packa
if(!is_dir($pkg_file))
unlink($pkg_file);
$pkg_msg = 'checksum failed! package deleted.';
logger($pkg_name." $pkg_msg", $argq);
}
}else{
$pkg_msg = ' package missing!';
logger($pkg_name." $pkg_msg", $argq);
}
logger($pkg_name." $pkg_msg", $argq);
}
}
}