fix-dependencies

This commit is contained in:
jsavargas 2023-05-03 10:45:02 -04:00
parent cae1b3907d
commit d427df6451
6 changed files with 32 additions and 22 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
upgrade-packages
develop/rsync.txt
*.bak

View File

@ -17,6 +17,8 @@
<CHANGES>
##&name;
###2023.05.04
- Enhanced: improvements in the treatment of dependencies
###2023.05.02
- Update: borgbackup-1.2.4
- Update: python3-3.9.16-3

View File

@ -28,7 +28,7 @@ function get_content_from_github($repo, $file) {
curl_setopt($ch, CURLOPT_URL, $repo);
$content = curl_exec($ch);
curl_close($ch);
if (!empty($content) && (!is_file($file) || $content != file_get_contents($file)))
if (!empty($content))
file_put_contents($file, $content);
}

View File

@ -13,10 +13,12 @@ if (!is_dir($pkg_extra_path))
$pkg_desc = 'https://raw.githubusercontent.com/UnRAIDES/unRAID-NerdTools/main/packages/packages-desc';
$pkg_repo = "https://api.github.com/repos/UnRAIDES/unRAID-NerdTools/contents/packages/$os_version";
$pkg_depends = 'https://raw.githubusercontent.com/UnRAIDES/unRAID-NerdTools/main/packages/packages-depends';
$desc_file = $pkg_path.'packages-desc';
$repo_file = $pkg_path.'packages.json';
$config_file = $plg_path.'NerdTools.cfg';
$desc_file = $pkg_path.'packages-desc';
$repo_file = $pkg_path.'packages.json';
$config_file = $plg_path.'NerdTools.cfg';
$depends_file = $plg_path.'packages-depends';
// get package configs
$pkg_cfg = file_exists($config_file) ? parse_ini_file($config_file) : [];
@ -31,6 +33,8 @@ $pkgs_desc_array = file_exists($desc_file) ? json_decode(file_get_contents($de
$pkgs_github_array = file_exists($repo_file) ? json_decode(file_get_contents($repo_file), true) : [];
$depends_file_array = file_exists($depends_file) ? json_decode(file_get_contents($depends_file), true) : [];
function logger($output, $quiet = false) {
exec('echo '.escapeshellarg($output).' 2>&1 | logger -tnerdpack');
if (!$quiet) {

View File

@ -6,8 +6,10 @@ require_once '/usr/local/emhttp/plugins/NerdTools/include/DownloadHelpers.php';
if (!file_exists($repo_file) || !empty($_GET['force']) || (filemtime($repo_file) < (time() - 3600))) {
get_content_from_github($pkg_repo, $repo_file);
get_content_from_github($pkg_desc, $desc_file);
get_content_from_github($pkg_depends, $depends_file);
$pkgs_desc_array = file_exists($desc_file) ? json_decode(file_get_contents($desc_file), true) : [];
$pkgs_github_array = file_exists($repo_file) ? json_decode(file_get_contents($repo_file), true) : [];
$depends_file_array = file_exists($depends_file) ? json_decode(file_get_contents($depends_file), true) : [];
}
$pkgs_array = [];
@ -64,21 +66,22 @@ foreach ($pkgs_github_array as $pkg_github) {
if (!array_key_exists($pkg_name, $pkgs_desc_array)) $pkgs_desc_array[$pkg_name] = "";
$pkg = [
'name' => str_replace("_nerdtools.txz",".txz",$pkg_github['name']) , // add full package name
'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
'updatePkg' => $updatePkg, // add package name with raw version
'updatePkgs' => "$pkg_version => $downloadedpkgv", // add package name with raw version
'size' => format_size($pkg_github['size'], 1, '?'), // add package size
'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' => !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
'actualpkgv' => $downloadedpkgv ? $downloadedpkgv:" - ", // checks if package name is downloaded
'config' => $pkg_set, // install preference
'plugins' => $pkg_plgs, // plugins dependency on package
'desc' => $pkgs_desc_array[$pkg_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]) : '', // 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
'updatePkg' => $updatePkg, // add package name with raw version
'updatePkgs' => "$pkg_version => $downloadedpkgv", // add package name with raw version
'size' => format_size($pkg_github['size'], 1, '?'), // add package size
'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' => !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
'actualpkgv' => $downloadedpkgv ? $downloadedpkgv:" - ", // checks if package name is downloaded
'config' => $pkg_set, // install preference
'plugins' => $pkg_plgs, // plugins dependency on package
'desc' => $pkgs_desc_array[$pkg_name]
];
$pkgs_array[] = $pkg;

View File

@ -140,10 +140,10 @@ function checkDepends() {
console.log(data)
$.each(data,function(index, value){
if ($('#'+index)[0]){
value.split(",").forEach(function (item) {
value.split(",").forEach(function (item) {
if (item && $('#'+index)[0].checked) {
$('#' + item).switchButton({ checked: true });
$('#' + item, '.pkgvalue').val('yes');
$('#' + item.trim()).switchButton({ checked: true });
$('#' + item.trim(), '.pkgvalue').val('yes');
}
});
}