Repository: irql-notlessorequal/intel-vaapi-driver
Pull request #6: rpm build script
Author: login: sergiorussia
Created: 2025-03-14T22:54:04Z | Merged: 2025-03-29T15:01:49Z

@irql-notlessorequal, hi.

i've tested your fork after mentioning here https://bbs.archlinux.org/viewtopic.php?pid=2231155#p2231155 and it worked for me, finally! that annoying error finally got away and i got working gpu acceleration for my intel haswell in Chrome, thank you!

the only thing i was missing initially was a rpm build script for Fedora in my case, so i decided to make one for your (and for myself of course :) )

it is based on specs from another interesting fork https://github.com/negativo17/intel-vaapi-driver - guys just apply patches on top of mainline. but that fork didn't work for me. but their spec is a great starter :)

anyway, i think there will be more requests for installation instruction for non-tech-savvy. i'd prefer to have all basic distro scripts in one repo - that's why i created distribution/xxx to have rpm/deb/whatever later. but maybe you'll decide to create sidecar repos like you did with https://github.com/irql-notlessorequal/intel-vaapi-driver-arch


Diff:
diff --git a/distribution/rpm/build-rpm.sh b/distribution/rpm/build-rpm.sh
new file mode 100755
index 000000000..1ce7c9470
--- /dev/null
+++ b/distribution/rpm/build-rpm.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+set -Eeuo pipefail
+
+declare -r repo='irql-notlessorequal/intel-vaapi-driver'
+
+# https://docs.github.com/en/rest/reference/repos#get-the-latest-release
+function latest_version() {
+  curl -sSL "https://api.github.com/repos/$repo/releases/latest" | jq -er '.tag_name'
+}
+
+declare -r src="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
+cd "$src"
+
+# see .spec's BuildRequires, also see
+# dnf provides "pkgconfig(egl)" "pkgconfig(libdrm)" "pkgconfig(libva)" "pkgconfig(libva-drm)" "pkgconfig(libva-wayland)" "pkgconfig(libva-x11)" "pkgconfig(wayland-client)" "pkgconfig(wayland-scanner)"
+echo 'Installing build dependencies...'
+sudo dnf install gcc meson rpm-build jq \
+  libglvnd-devel libdrm-devel libva-devel wayland-devel
+
+declare -r version="${1:-"$(latest_version)"}"
+echo "Building rpm for version $version..."
+
+# see https://stackoverflow.com/a/46153901
+rpmbuild \
+  --undefine '_disable_source_fetch' --undefine 'source_date_epoch_from_changelog' \
+  --define "_sourcedir $src" --define "_topdir $src" --define "version $version" \
+  -bb --nodebuginfo \
+  intel-vaapi-driver.spec
+
+echo ''
+echo 'You can now install the built package:'
+echo "sudo dnf install $(find "$src/RPMS/x86_64" -name "intel-vaapi-driver-$version"\* -print -quit)"
+
+echo ''
+echo 'To revert to the stock driver:'
+echo 'sudo dnf swap intel-vaapi-driver libva-intel-driver'
diff --git a/distribution/rpm/intel-vaapi-driver.metainfo-chipsets.sh b/distribution/rpm/intel-vaapi-driver.metainfo-chipsets.sh
new file mode 100755
index 000000000..a2b9467c5
--- /dev/null
+++ b/distribution/rpm/intel-vaapi-driver.metainfo-chipsets.sh
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+# Based on https://github.com/negativo17/intel-vaapi-driver/blob/master/intel-vaapi-driver.py
+
+if [[ $# != 1 ]]; then
+  echo "usage: $0 src/i965_pciids.h" >&2
+  exit 1
+fi
+
+declare -A pids # to avoid duplicates
+while IFS= read -r line; do
+  [[ "$line" != CHIPSET* ]] && continue
+  hex_pid="${line:10:4}"
+  pids["$((16#$hex_pid))"]=1
+done <"$1"
+
+declare -r vid=$((0x8086))
+for pid in "${!pids[@]}"; do
+  printf 'pci:v%08Xd%08Xsv*sd*bc*sc*i*\n' "$vid" "$pid"
+done
diff --git a/distribution/rpm/intel-vaapi-driver.metainfo.xml b/distribution/rpm/intel-vaapi-driver.metainfo.xml
new file mode 100644
index 000000000..d0a5bcdeb
--- /dev/null
+++ b/distribution/rpm/intel-vaapi-driver.metainfo.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<component type="driver">
+  <id>libva-intel-driver</id>
+  <name>Intel VA-API driver (legacy)</name>
+  <summary>Intel GEN Graphics family video acceleration driver</summary>
+  <description><p>VA-API implementation for Intel G45 and HD Graphics family (IRQL fork).</p></description>
+  <keywords>
+    <keyword>Decode</keyword>
+    <keyword>Encode</keyword>
+    <keyword>HW</keyword>
+    <keyword>Intel</keyword>
+    <keyword>Media</keyword>
+    <keyword>VA-API</keyword>
+    <keyword>Video</keyword>
+    <keyword>av1</keyword>
+    <keyword>avc</keyword>
+    <keyword>driver</keyword>
+    <keyword>h264</keyword>
+    <keyword>h265</keyword>
+    <keyword>hevc</keyword>
+    <keyword>jpeg</keyword>
+    <keyword>mpeg2</keyword>
+    <keyword>vaapi</keyword>
+    <keyword>vc-1</keyword>
+    <keyword>vp8</keyword>
+    <keyword>vp9</keyword>
+  </keywords>
+  <metadata_license>CC0-1.0</metadata_license>
+  <project_license>MIT</project_license>
+  <url type="homepage">https://github.com/irql-notlessorequal/intel-vaapi-driver</url>
+  <update_contact>https://github.com/irql-notlessorequal/intel-vaapi-driver/issues/new?template=BLANK_ISSUE</update_contact>
+</component>
diff --git a/distribution/rpm/intel-vaapi-driver.spec b/distribution/rpm/intel-vaapi-driver.spec
new file mode 100644
index 000000000..18fc3b8b6
--- /dev/null
+++ b/distribution/rpm/intel-vaapi-driver.spec
@@ -0,0 +1,67 @@
+%if !%{defined version}
+%define version 2.4.3
+%endif
+
+# Based on https://github.com/negativo17/intel-vaapi-driver/blob/master/intel-vaapi-driver.spec
+# and https://pkgs.rpmfusion.org/cgit/free/libva-intel-driver.git/tree/libva-intel-driver.spec
+Name:       intel-vaapi-driver
+Epoch:      1
+Version:    %{version}
+Release:    1%{?dist}
+Summary:    VA-API implementation for Intel G45 and HD Graphics family (IRQL fork)
+License:    MIT
+URL:        https://github.com/irql-notlessorequal/%{name}
+
+Source0:    %{url}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
+Source1:    %{name}.metainfo.xml
+Source2:    %{name}.metainfo-chipsets.sh
+
+ExclusiveArch:  %{ix86} x86_64
+
+BuildRequires:  gcc
+BuildRequires:  git
+# AppStream metadata generation
+BuildRequires:  libappstream-glib >= 0.6.3
+BuildRequires:  meson >= 0.43.0
+BuildRequires:  pkgconfig(egl)
+BuildRequires:  pkgconfig(libdrm) >= 2.4.52
+BuildRequires:  pkgconfig(libva) >= 1.4.0
+BuildRequires:  pkgconfig(libva-drm) >= 1.4.0
+BuildRequires:  pkgconfig(libva-wayland) >= 1.1.0
+BuildRequires:  pkgconfig(libva-x11) >= 1.4.0
+BuildRequires:  pkgconfig(wayland-client) >= 1.11.0
+BuildRequires:  pkgconfig(wayland-scanner) >= 1.11.0
+
+Provides:       libva-intel-driver%{?_isa} = %{epoch}:%{version}-%{release}
+Obsoletes:      libva-intel-driver < %{epoch}:%{version}-%{release}
+
+%description
+VA-API (Video Acceleration API) user mode driver for Intel GEN Graphics family (IRQL fork).
+
+%prep
+%autosetup -p1
+
+%build
+%meson \
+  -D enable_hybrid_codec=true \
+  -D with_x11=yes \
+  -D with_wayland=yes
+
+%meson_build
+
+%install
+%meson_install
+find %{buildroot} -name "*.la" -delete
+
+# Install AppData and add modalias provides
+install -pm 0644 -D %{SOURCE1} %{buildroot}%{_metainfodir}/%{name}.metainfo.xml
+%{SOURCE2} src/i965_pciids.h | xargs appstream-util add-provide %{buildroot}%{_metainfodir}/%{name}.metainfo.xml modalias
+
+%check
+appstream-util validate --nonet %{buildroot}%{_metainfodir}/%{name}.metainfo.xml
+
+%files
+%license LICENSE
+%doc AUTHORS NEWS README
+%{_libdir}/dri/i965_drv_video.so
+%{_metainfodir}/%{name}.metainfo.xml


Reviews:
user: login: irql-notlessorequal
body: Aside from these minor nits, looks good to me.
state: DISMISSED
author_association: OWNER
submitted_at: 2025-03-15T13:58:26Z
user: login: irql-notlessorequal
state: COMMENTED
author_association: OWNER
submitted_at: 2025-03-25T21:46:04Z

Review comments:
diff_hunk: @@ -0,0 +1,65 @@
+%if !%{defined version}
+%define version 2.4.3
+%endif
+
+# Based on https://github.com/negativo17/intel-vaapi-driver/blob/master/intel-vaapi-driver.spec
+Name:       intel-vaapi-driver
+Epoch:      1
+Version:    %{version}
+Release:    1%{?dist}
+Summary:    VA-API implementation for Intel G45 and HD Graphics family (IRQL fork)
+License:    MIT
+URL:        https://github.com/irql-notlessorequal/%{name}
+
+Source0:    https://github.com/irql-notlessorequal/%{name}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
+Source1:    %{name}.metainfo.xml
+Source2:    %{name}.metainfo-chipsets.sh
+
+ExclusiveArch:  %{ix86} x86_64
+
+BuildRequires:  gcc
+BuildRequires:  git
+BuildRequires:  libappstream-glib >= 0.6.3
+BuildRequires:  meson >= 0.43.0
+BuildRequires:  pkgconfig(egl)
+BuildRequires:  pkgconfig(libdrm) >= 2.4.52
+BuildRequires:  pkgconfig(libva) >= 1.4.0
+BuildRequires:  pkgconfig(libva-drm) >= 1.4.0
+BuildRequires:  pkgconfig(libva-wayland) >= 1.1.0
+BuildRequires:  pkgconfig(libva-x11) >= 1.4.0
+BuildRequires:  pkgconfig(wayland-client) >= 1.11.0
+BuildRequires:  pkgconfig(wayland-scanner) >= 1.11.0
+
+Provides:       libva-intel-driver%{?_isa} = %{epoch}:%{version}-%{release}
+Obsoletes:      libva-intel-driver < %{epoch}:%{version}-%{release}
+
+%description
+VA-API (Video Acceleration API) user mode driver for Intel GEN Graphics family (IRQL fork).
+
+%prep
+%autosetup -p1
+
+%build
+%meson \
+  -D enable_hybrid_codec=true \
path: distribution/rpm/intel-vaapi-driver.spec
user: login: irql-notlessorequal
body: The hybrid codec driver while great is a buggy mess, I'm not sure if it's worth enabling it at all.
created_at: 2025-03-15T13:55:51Z
author_association: OWNER
diff_hunk: @@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+set -Eeuo pipefail
+
+declare -r repo='irql-notlessorequal/intel-vaapi-driver'
+
+# https://docs.github.com/en/rest/reference/repos#get-the-latest-release
+function latest_version() {
+  curl -sSL "https://api.github.com/repos/$repo/releases/latest" | jq -er '.tag_name'
+}
+
+declare -r src="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
+cd "$src"
+
+# see .spec's BuildRequires, also see
+# dnf provides "pkgconfig(egl)" "pkgconfig(libdrm)" "pkgconfig(libva)" "pkgconfig(libva-drm)" "pkgconfig(libva-wayland)" "pkgconfig(libva-x11)" "pkgconfig(wayland-client)" "pkgconfig(wayland-scanner)"
+echo 'Installing build dependencies...'
+sudo dnf install gcc meson rpm-build jq \
+  libglvnd-devel libdrm-devel libva-devel wayland-devel
+
+declare -r version="${1:-"$(latest_version)"}"
+echo "Building rpm for version $version..."
+
+# see https://stackoverflow.com/a/46153901
+rpmbuild \
+  --undefine '_disable_source_fetch' --undefine 'source_date_epoch_from_changelog' \
+  --define "_sourcedir $src" --define "_topdir $src" --define "version $version" \
+  -bb --nodebuginfo \
+  intel-vaapi-driver.spec
+
+echo ''
+echo 'You can now install built package:'
path: distribution/rpm/build-rpm.sh
user: login: irql-notlessorequal
body: `You can now install the built package:'`
created_at: 2025-03-15T13:57:29Z
author_association: OWNER
diff_hunk: @@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+set -Eeuo pipefail
+
+declare -r repo='irql-notlessorequal/intel-vaapi-driver'
+
+# https://docs.github.com/en/rest/reference/repos#get-the-latest-release
+function latest_version() {
+  curl -sSL "https://api.github.com/repos/$repo/releases/latest" | jq -er '.tag_name'
+}
+
+declare -r src="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
+cd "$src"
+
+# see .spec's BuildRequires, also see
+# dnf provides "pkgconfig(egl)" "pkgconfig(libdrm)" "pkgconfig(libva)" "pkgconfig(libva-drm)" "pkgconfig(libva-wayland)" "pkgconfig(libva-x11)" "pkgconfig(wayland-client)" "pkgconfig(wayland-scanner)"
+echo 'Installing build dependencies...'
+sudo dnf install gcc meson rpm-build jq \
+  libglvnd-devel libdrm-devel libva-devel wayland-devel
+
+declare -r version="${1:-"$(latest_version)"}"
+echo "Building rpm for version $version..."
+
+# see https://stackoverflow.com/a/46153901
+rpmbuild \
+  --undefine '_disable_source_fetch' --undefine 'source_date_epoch_from_changelog' \
+  --define "_sourcedir $src" --define "_topdir $src" --define "version $version" \
+  -bb --nodebuginfo \
+  intel-vaapi-driver.spec
+
+echo ''
+echo 'You can now install built package:'
+echo "sudo dnf install $(find "$src/RPMS/x86_64" -name intel-vaapi-driver-2.4.3-\* -print -quit)"
+
+echo ''
+echo 'To revert to stock driver:'
path: distribution/rpm/build-rpm.sh
user: login: irql-notlessorequal
body: 'To revert to the stock driver:'
created_at: 2025-03-15T13:57:39Z
author_association: OWNER
diff_hunk: @@ -0,0 +1,65 @@
+%if !%{defined version}
+%define version 2.4.3
+%endif
+
+# Based on https://github.com/negativo17/intel-vaapi-driver/blob/master/intel-vaapi-driver.spec
+Name:       intel-vaapi-driver
+Epoch:      1
+Version:    %{version}
+Release:    1%{?dist}
+Summary:    VA-API implementation for Intel G45 and HD Graphics family (IRQL fork)
+License:    MIT
+URL:        https://github.com/irql-notlessorequal/%{name}
+
+Source0:    https://github.com/irql-notlessorequal/%{name}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
+Source1:    %{name}.metainfo.xml
+Source2:    %{name}.metainfo-chipsets.sh
+
+ExclusiveArch:  %{ix86} x86_64
+
+BuildRequires:  gcc
+BuildRequires:  git
+BuildRequires:  libappstream-glib >= 0.6.3
+BuildRequires:  meson >= 0.43.0
+BuildRequires:  pkgconfig(egl)
+BuildRequires:  pkgconfig(libdrm) >= 2.4.52
+BuildRequires:  pkgconfig(libva) >= 1.4.0
+BuildRequires:  pkgconfig(libva-drm) >= 1.4.0
+BuildRequires:  pkgconfig(libva-wayland) >= 1.1.0
+BuildRequires:  pkgconfig(libva-x11) >= 1.4.0
+BuildRequires:  pkgconfig(wayland-client) >= 1.11.0
+BuildRequires:  pkgconfig(wayland-scanner) >= 1.11.0
+
+Provides:       libva-intel-driver%{?_isa} = %{epoch}:%{version}-%{release}
+Obsoletes:      libva-intel-driver < %{epoch}:%{version}-%{release}
+
+%description
+VA-API (Video Acceleration API) user mode driver for Intel GEN Graphics family (IRQL fork).
+
+%prep
+%autosetup -p1
+
+%build
+%meson \
+  -D enable_hybrid_codec=true \
path: distribution/rpm/intel-vaapi-driver.spec
user: login: irql-notlessorequal
body: Had a think about this, will let it pass for now.
created_at: 2025-03-25T21:46:03Z
author_association: OWNER

PR comments:
user: login: sergiorussia
created_at: 2025-03-15T08:17:55Z
body: @irql-notlessorequal btw maybe you could collaborate with @scaronni as https://github.com/negativo17/intel-vaapi-driver contains potentially great features you would wish to incorporate
author_association: NONE
user: login: irql-notlessorequal
created_at: 2025-03-15T11:19:47Z
body: Hello, thanks for the contribution!

I'll review the scripts later today, regarding https://github.com/negativo17/intel-vaapi-driver, the patches seem to all be from older versions from the driver, since all of the changes are in this driver already.
author_association: OWNER
user: login: irql-notlessorequal
created_at: 2025-03-25T21:46:52Z
body: LGTM.

Will merge this when I have a moment.
author_association: OWNER