diff --git a/auto-krokodil.spec b/auto-krokodil.spec index 48e7f86..435f3aa 100644 --- a/auto-krokodil.spec +++ b/auto-krokodil.spec @@ -3,8 +3,8 @@ Name: auto-krokodil Group: System/Kernel and hardware License: GPLv3 Url: https://abf.io/import/auto-krokodil -Version: 0.1 -Release: 2 +Version: 0.2 +Release: 1 BuildArch: noarch # for php -l (syntax check) BuildRequires: /usr/bin/php @@ -24,6 +24,8 @@ Source21: test.nvidia470.json Source22: LICENSE.nvidia-json Source23: test.spec.in +Source31: krokodil-legacy-converter.php + %description Scripts to automate packaging and installation of proprietary drivers for Nvidia GPUs @@ -59,6 +61,21 @@ Generators of RPM provides for proprietary Nvidia drivers #---------------------------------------- +%package legacy-converter +Summary: Convert JSON from newer Nvidia driver to an older one +Requires: /usr/bin/php + +%description legacy-converter +Old Nvidia drivers do not have a JSON with supported models, +but JSONs of newer drivers specify GPUs supported by older drivers. +This scripts takes a JSON from a newer driver and converts it +into a JSON for an older driver which does not ship a native JSON. + +%files legacy-converter +%{_bindir}/krokodil-legacy-converter + +#---------------------------------------- + %prep %build @@ -73,9 +90,12 @@ install -m0755 %{SOURCE10} %{buildroot}%{_bindir}/krokodil-rpm-provides mkdir -p %{buildroot}%{_fileattrsdir} install -m0644 %{SOURCE11} %{buildroot}%{_fileattrsdir}/krokodilnvidia.attr +install -m0755 %{SOURCE31} %{buildroot}%{_bindir}/krokodil-legacy-converter + %check # check syntax /usr/bin/php -l %{buildroot}%{_bindir}/krokodil-rpm-provides +/usr/bin/php -l %{buildroot}%{_bindir}/krokodil-legacy-converter # very basic check of the generator FILE="%{SOURCE21}" EVR=888-777 %{buildroot}%{_bindir}/krokodil-rpm-provides | grep -q '^nvidia-blob-devid(1f9d) = 888-777$' diff --git a/krokodil-legacy-converter.php b/krokodil-legacy-converter.php new file mode 100644 index 0000000..fba3bb5 --- /dev/null +++ b/krokodil-legacy-converter.php @@ -0,0 +1,57 @@ +#!/usr/bin/php + +chips as $chip) { + if (empty($chip->legacybranch)) + continue; + // php 8+ has str_starts_with() + if (!(strpos($chip->legacybranch, $BRANCH . ".", 0) === 0)) + continue; + // devid (Device ID) cannot be empty, other params can be empty + if (empty($chip->devid)) { + fwrite(STDERR, "Device ID cannot be empty!" . PHP_EOL); + exit(EXIT_CODE_PARSEERROR); + } + $arr = array("devid" => $chip->devid, + "subdevid" => $chip->subdevid, + "subvendorid" => $chip->subvendorid, + "name" => $chip->name, + "features" => $chip->features); + array_push($chips_arr, $arr); +} + +$chips_arr = array("chips" => $chips_arr); +echo json_encode($chips_arr); + +?> diff --git a/krokodil-rpm-provides.php b/krokodil-rpm-provides.php index 2c0024f..f1486c0 100644 --- a/krokodil-rpm-provides.php +++ b/krokodil-rpm-provides.php @@ -2,6 +2,9 @@