mirror of
https://abf.rosa.ru/djam/auto-krokodil.git
synced 2025-02-23 10:32:57 +00:00
Init (rpm generator only for now)
This commit is contained in:
commit
6cd61bdae8
7 changed files with 21119 additions and 0 deletions
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
*.rpm
|
||||
BUILD
|
||||
BUILDROOT
|
||||
SRPMS
|
19
LICENSE.nvidia-json
Normal file
19
LICENSE.nvidia-json
Normal file
|
@ -0,0 +1,19 @@
|
|||
The supported-gpus.json file is provided under the following license terms:
|
||||
|
||||
Copyright (c) 2020 NVIDIA Corporation
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
78
auto-krokodil.spec
Normal file
78
auto-krokodil.spec
Normal file
|
@ -0,0 +1,78 @@
|
|||
Summary: Scripts to automate packaging and installation of proprietary drivers for Nvidia GPUs
|
||||
Name: auto-krokodil
|
||||
Group: System/Kernel and hardware
|
||||
License: GPLv3
|
||||
Url: https://abf.io/import/auto-krokodil
|
||||
Version: 0.1
|
||||
Release: 1
|
||||
BuildArch: noarch
|
||||
# for php -l (syntax check)
|
||||
BuildRequires: /usr/bin/php
|
||||
|
||||
# rpm generators
|
||||
Source10: krokodil-rpm-provides.php
|
||||
Source11: krokodilnvidia.attr
|
||||
|
||||
# Test data, to run tests:
|
||||
# - build and install auto-krokodil-rpm-generators from this spec
|
||||
# - install it
|
||||
# - run: rpmbuild --define "_sourcedir $PWD" --define "_topdir $PWD" --define "_rpmdir $PWD" --define "_build_name_fmt %%{NAME}.rpm" -bb test.spec.in
|
||||
# - run: rpm -qp --provides test-auto-krokodil-provides.rpm, check provides
|
||||
# from nvidia470, licensed according to LICENSE.nvidia-json
|
||||
Source21: test.nvidia470.json
|
||||
# taken from nvidia 470.74/supported-gpus/LICENSE
|
||||
Source22: LICENSE.nvidia-json
|
||||
Source23: test.spec.in
|
||||
|
||||
%description
|
||||
Scripts to automate packaging and installation of proprietary drivers for Nvidia GPUs
|
||||
|
||||
#----------------------------------------
|
||||
|
||||
%package filesystem
|
||||
Summary: Filesystem skeleton for %{name}
|
||||
|
||||
%description filesystem
|
||||
Filesystem skeleton for %{name}
|
||||
|
||||
%files filesystem
|
||||
%dir %{_datadir}/auto-krokodil
|
||||
# Directory to put supported-gpus.json as e.g. nvidia470.json
|
||||
# inside nvidia470 package so that RPM generator could parse it
|
||||
%dir %{_datadir}/auto-krokodil/drivers
|
||||
# License for JSON files from Nvidia
|
||||
%{_datadir}/auto-krokodil/drivers/LICENSE.nvidia-json
|
||||
|
||||
#----------------------------------------
|
||||
|
||||
%package rpm-generators
|
||||
Summary: Generators of RPM provides for proprietary Nvidia drivers
|
||||
Requires: /usr/bin/php
|
||||
Requires: /bin/sh
|
||||
|
||||
%description rpm-generators
|
||||
Generators of RPM provides for proprietary Nvidia drivers
|
||||
|
||||
%files rpm-generators
|
||||
%{_bindir}/krokodil-rpm-provides
|
||||
%{_fileattrsdir}/krokodilnvidia.attr
|
||||
|
||||
#----------------------------------------
|
||||
|
||||
%prep
|
||||
|
||||
%build
|
||||
|
||||
%install
|
||||
|
||||
mkdir -p %{buildroot}%{_datadir}/auto-krokodil/drivers
|
||||
install -m0644 %{SOURCE22} %{buildroot}%{_datadir}/auto-krokodil/drivers/LICENSE.nvidia-json
|
||||
|
||||
mkdir -p %{buildroot}%{_bindir}
|
||||
install -m0755 %{SOURCE10} %{buildroot}%{_bindir}/krokodil-rpm-provides
|
||||
mkdir -p %{buildroot}%{_fileattrsdir}
|
||||
install -m0644 %{SOURCE11} %{buildroot}%{_fileattrsdir}/krokodilnvidia.attr
|
||||
|
||||
%check
|
||||
# check syntax
|
||||
/usr/bin/php -l %{buildroot}%{_bindir}/krokodil-rpm-provides
|
61
krokodil-rpm-provides.php
Normal file
61
krokodil-rpm-provides.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
#!/usr/bin/php
|
||||
|
||||
<?php
|
||||
|
||||
define("EXIT_CODE_EINPUT", 10);
|
||||
define("EXIT_CODE_PARSEERROR", 20);
|
||||
|
||||
$FILE = getenv("FILE");
|
||||
if (empty($FILE)) {
|
||||
fwrite(STDERR, "Env FILE is not set! Set FILE=supported-gpus.json" . PHP_EOL);
|
||||
exit(EXIT_CODE_EINPUT);
|
||||
}
|
||||
|
||||
$data = file_get_contents($FILE);
|
||||
$array = json_decode($data);
|
||||
|
||||
if (empty($array)) {
|
||||
fwrite(STDERR, "Error decoding JSON from file " . $FILE . " !" . PHP_EOL);
|
||||
exit(EXIT_CODE_EINPUT);
|
||||
}
|
||||
|
||||
// EVR=%{version}-%{release}
|
||||
$EVR = getenv("EVR");
|
||||
|
||||
if (empty($EVR)) {
|
||||
fwrite(STDERR, "Empty package version! Set env EVR=version-release" . PHP_EOL);
|
||||
exit(EXIT_CODE_EINPUT);
|
||||
}
|
||||
|
||||
// 0x1E90 -> 1e90
|
||||
function _dec_to_text($text) {
|
||||
return strtolower(preg_replace("/^0x/", "", $text));
|
||||
}
|
||||
|
||||
foreach($array->chips as $chip) {
|
||||
// Skip GPUs not supported by this branch
|
||||
if (!empty($chip->legacybranch)) {
|
||||
continue;
|
||||
} else {
|
||||
$devid = _dec_to_text($chip->devid);
|
||||
$subdevid = _dec_to_text($chip->subdevid);
|
||||
$subvendorid = _dec_to_text($chip->subvendorid);
|
||||
$name = $chip->name;
|
||||
// Nvidia's JSON always specifies device ID but specifies other params not always
|
||||
if (!(empty($devid))) {
|
||||
echo "nvidia-blob-devid(" . $devid . ") = " . $EVR . PHP_EOL;
|
||||
} else {
|
||||
fwrite(STDERR, "Device ID must not be empty!" . PHP_EOL);
|
||||
exit(EXIT_CODE_PARSEERROR);
|
||||
}
|
||||
if (!(empty($subdevid)))
|
||||
echo "nvidia-blob-subdevid(" . $subdevid . ") = " . $EVR . PHP_EOL;
|
||||
if (!(empty($subvendorid)))
|
||||
echo "nvidia-blob-subvendorid(" . $subvendorid . ") = " . $EVR . PHP_EOL;
|
||||
if (!(empty($name)))
|
||||
echo "nvidia-blob-name(" . preg_replace("/ /", "+", $name) . ") = " . $EVR . PHP_EOL;
|
||||
echo "nvidia-blob-info()" . "(devid=" . $devid . ")" . "(subdevid=" . $subdevid . ")" . "(subvendorid=" . $subvendorid . ")" . " = " . $EVR . PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
2
krokodilnvidia.attr
Normal file
2
krokodilnvidia.attr
Normal file
|
@ -0,0 +1,2 @@
|
|||
%__krokodilnvidia_provides /bin/sh -c 'while read -r line; do FILE="$line" EVR="%{VERSION}-%{RELEASE}" %{_bindir}/krokodil-rpm-provides; done'
|
||||
%__krokodilnvidia_path ^%{_datadir}/auto-krokodil/drivers/.*\\.json$
|
20929
test.nvidia470.json
Normal file
20929
test.nvidia470.json
Normal file
File diff suppressed because it is too large
Load diff
26
test.spec.in
Normal file
26
test.spec.in
Normal file
|
@ -0,0 +1,26 @@
|
|||
%define debug_package %{nil}
|
||||
|
||||
Name: test-auto-krokodil-provides
|
||||
Summary: Test RPM provides generator from auto-krokodil
|
||||
License: GPLv3
|
||||
Group: System/Kernel and hardware
|
||||
Version: 0
|
||||
Release: 0
|
||||
BuildRequires: auto-krokodil-rpm-generators
|
||||
|
||||
Source1: test.nvidia470.json
|
||||
|
||||
%description
|
||||
%{summary}
|
||||
|
||||
%files
|
||||
%{_datadir}/auto-krokodil/drivers/test470.json
|
||||
|
||||
#------------------------------------------
|
||||
|
||||
%prep
|
||||
%build
|
||||
%install
|
||||
|
||||
mkdir -p %{buildroot}%{_datadir}/auto-krokodil/drivers
|
||||
install -m0644 %{SOURCE1} %{buildroot}%{_datadir}/auto-krokodil/drivers/test470.json
|
Loading…
Add table
Reference in a new issue