feat: XPadNeo DKMS (#3539) (#3637)

* The great refactoring

* Thanks Kate!! Didn't want to save that AT ALL

* Make those nightly

* Cleanup

* Oh

* ...

* Better license format

* updbranch

* Fixing up modules and deps

* Missed some deps

* Remove redundant `mkdir`s

Signed-off-by: Gilver <rockgrub@disroot.org>

* Move BuildArch, it bothered me

Signed-off-by: Gilver <rockgrub@disroot.org>

* Add no weak modules config to Fedora just in case

* LOL

Signed-off-by: Gilver <rockgrub@disroot.org>

* Update xpadneo-kmod-common.spec

Signed-off-by: Gilver <rockgrub@disroot.org>

* Inline modules file for better automated updates

* Macro

Signed-off-by: Gilver <rockgrub@disroot.org>

* Packager...?

* Requires

---------

Signed-off-by: Gilver <rockgrub@disroot.org>
(cherry picked from commit 259d0957b1)

Co-authored-by: Gilver <rockgrub@disroot.org>
This commit is contained in:
Raboneko
2025-03-01 08:32:18 -08:00
committed by GitHub
parent 48e344c5ba
commit de90bd4968
15 changed files with 218 additions and 106 deletions
@@ -1,8 +1,9 @@
project pkg {
rpm {
spec = "xpadneo.spec"
spec = "xpadneo-kmod.spec"
}
labels {
mock = 1
updbranch = 1
}
}
+3
View File
@@ -0,0 +1,3 @@
import "andax/bump_extras.rhai" as bump;
rpm.version(bump::madoguchi("xpadneo-kmod-common", labels.branch));
@@ -0,0 +1,63 @@
%global commit 8d20a23e38883f45c78f48c8574ac93945b4cb03
%global date 20241224
%global shortcommit %(c=%{commit}; echo ${c:0:7})
%global ver 0.9.7
%define buildforkernels akmod
%global debug_package %{nil}
%global real_name xpadneo
Name: %{real_name}-kmod
Version: %{ver}^%{date}git.%{shortcommit}
Release: 2%{?dist}
Summary: Advanced Linux Driver for Xbox One Wireless Gamepad
License: GPL-3.0
URL: https://atar-axis.github.io/xpadneo
Source0: https://github.com/atar-axis/xpadneo/archive/%{commit}.tar.gz#/xpadneo-%{shortcommit}.tar.gz
BuildRequires: kmodtool
BuildRequires: systemd-rpm-macros
Requires: bluez
Requires: bluez-tools
Requires: %{real_name}-kmod-common = %{?epoch:%{epoch}:}%{version}
Packager: ShinyGil <rockgrub@disroot.org>
%{expand:%(kmodtool --target %{_target_cpu} --repo terra --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null) }
%description
Advanced Linux Driver for Xbox One Wireless Gamepad.
%prep
%{?kmodtool_check}
kmodtool --target %{_target_cpu} --repo terra --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null
%autosetup -p1 -n %{real_name}-%{commit}
/usr/bin/sed -nE '/^BUILT_MODULE_NAME/{s@^.+"(.+)"@\1@; s|-|_|g; p}' hid-%{real_name}/dkms.conf.in > %{real_name}.conf
for kernel_version in %{?kernel_versions}; do
mkdir _kmod_build_${kernel_version%%___*}
cp -fr hid-xpadneo/src/* _kmod_build_${kernel_version%%___*}
done
%build
for kernel_version in %{?kernel_versions}; do
pushd _kmod_build_${kernel_version%%___*}/
%make_build -C "${kernel_version##*___}" M=$(pwd) VERSION="v%{version}" modules
popd
done
%install
install -Dm644 %{real_name}.conf -t %{buildroot}%{_modulesloaddir}
for kernel_version in %{?kernel_versions}; do
mkdir -p %{buildroot}/%{kmodinstdir_prefix}/${kernel_version%%___*}/%{kmodinstdir_postfix}/
install -p -m 0755 _kmod_build_${kernel_version%%___*}/*.ko \
%{buildroot}/%{kmodinstdir_prefix}/${kernel_version%%___*}/%{kmodinstdir_postfix}/
done
%{?akmod_install}
%files
%{_modulesloaddir}/%{real_name}.conf
%changelog
* Thu Feb 27 2025 ShinyGil <rockgrub@disroot.org>
- Package refactoring for alternative DKMS package compatibility
+10
View File
@@ -0,0 +1,10 @@
project pkg {
arches = ["x86_64"]
rpm {
spec = "dkms-xpadneo.spec"
}
labels {
mock = 1
updbranch = 1
}
}
@@ -0,0 +1,6 @@
PACKAGE_NAME="xpadneo"
PACKAGE_VERSION="__VERSION_STRING"
AUTOINSTALL="yes"
BUILT_MODULE_NAME[0]="hid-xpadneo"
DEST_MODULE_LOCATION[0]="/extra"
@@ -0,0 +1,67 @@
%global commit 8d20a23e38883f45c78f48c8574ac93945b4cb03
%global date 20241224
%global shortcommit %(c=%{commit}; echo ${c:0:7})
%global ver 0.9.7
%global debug_package %{nil}
%global dkms_name xpadneo
Name: dkms-%{dkms_name}
Version: %{ver}^%{date}git.%{shortcommit}
Release: 1%{?dist}
Summary: Advanced Linux Driver for Xbox One Wireless Gamepad
License: GPL-3.0
URL: https://atar-axis.github.io/%{dkms_name}
Source0: https://github.com/atar-axis/%{dkms_name}/archive/%{commit}.tar.gz#/%{dkms_name}-%{shortcommit}.tar.gz
Source1: %{name}.conf
Source2: no-weak-modules.conf
BuildRequires: sed
Requires: bluez
Requires: bluez-tools
Requires: %{dkms_name}-kmod-common = %{?epoch:%{epoch}:}%{version}
Requires: dkms
BuildArch: noarch
Packager: ShinyGil <rockgrub@disroot.org>
%description
Advanced Linux Driver for Xbox One Wireless Gamepad.
%prep
%autosetup -p1 -n %{dkms_name}-%{commit}
cp -f %{SOURCE1} hid-xpadneo/src/dkms.conf
sed -i -e 's/__VERSION_STRING/%{version}/g' hid-xpadneo/src/dkms.conf
sed -i -e 's/$(VERSION)/v%{version}/g' hid-xpadneo/src/Makefile
%build
%install
# Create empty tree:
mkdir -p %{buildroot}%{_usrsrc}/%{dkms_name}-%{version}/
cp -fr hid-xpadneo/src/* %{buildroot}%{_usrsrc}/%{dkms_name}-%{version}/
%if 0%{?fedora}
# Do not enable weak modules support in Fedora (no kABI):
install -Dpm644 %{SOURCE2} %{buildroot}%{_sysconfdir}/dkms/%{dkms_name}.conf
%endif
%post
dkms add -m %{dkms_name} -v %{version} -q --rpm_safe_upgrade || :
# Rebuild and make available for the currently running kernel:
dkms build -m %{dkms_name} -v %{version} -q || :
dkms install -m %{dkms_name} -v %{version} -q --force || :
%preun
# Remove all versions from DKMS registry:
dkms remove -m %{dkms_name} -v %{version} -q --all --rpm_safe_upgrade || :
%files
%{_usrsrc}/%{dkms_name}-%{version}
%if 0%{?fedora}
%{_sysconfdir}/dkms/%{dkms_name}.conf
%endif
%changelog
* Thu Feb 27 2025 ShinyGil <rockgrub@disroot.org>
- Initial package
@@ -0,0 +1 @@
NO_WEAK_MODULES="yes"
+3
View File
@@ -0,0 +1,3 @@
import "andax/bump_extras.rhai" as bump;
rpm.version(bump::madoguchi("xpadneo-kmod-common", labels.branch));
+10
View File
@@ -0,0 +1,10 @@
project pkg {
arches = ["x86_64"]
rpm {
spec = "xpadneo-kmod-common.spec"
}
labels {
mock = 1
nightly = 1
}
}
@@ -0,0 +1,8 @@
rpm.global("commit", gh_commit("atar-axis/xpadneo"));
if rpm.changed() {
rpm.release();
rpm.global("commit_date", date());
let ver = gh("atar-axis/xpadneo");
ver.crop(1);
rpm.global("ver", ver);
}
@@ -0,0 +1,45 @@
%global commit 8d20a23e38883f45c78f48c8574ac93945b4cb03
%global date 20241224
%global shortcommit %(c=%{commit}; echo ${c:0:7})
%global ver 0.9.7
%global real_name xpadneo
Name: %{real_name}-kmod-common
Version: %{ver}^%{date}git.%{shortcommit}
Release: 1%{?dist}
Summary: Advanced Linux Driver for Xbox One Wireless Gamepad common files
License: GPL-3.0
URL: https://atar-axis.github.io/%{real_name}
Source0: https://github.com/atar-axis/%{real_name}/archive/%{commit}.tar.gz#/%{real_name}-%{shortcommit}.tar.gz
Source1: io.github.xpadneo.metainfo.xml
BuildRequires: systemd-rpm-macros
Provides: %{real_name}-kmod-common = %{?epoch:%{epoch}:}%{version}
BuildArch: noarch
Packager: ShinyGil <rockgrub@disroot.org>
%description
Advanced Linux Driver for Xbox One Wireless Gamepad common files.
%prep
%autosetup -p1 -n %{real_name}-%{commit}
%install
# Aliases:
install -Dpm644 hid-%{real_name}/etc-modprobe.d/%{real_name}.conf -t %{buildroot}%{_modprobedir}
# UDev rules:
install -Dpm644 hid-%{real_name}/etc-udev-rules.d/*.rules -t %{buildroot}%{_udevrulesdir}/
# Metadata
install -Dm644 %{SOURCE1} %{buildroot}%{_datadir}/metainfo/io.github.xpadneo.metainfo.xml
%files
%license LICENSE
%doc docs/*.md
%{_modprobedir}/%{real_name}.conf
%{_udevrulesdir}/60-%{real_name}.rules
%{_udevrulesdir}/70-%{real_name}-disable-hidraw.rules
%{_datadir}/metainfo/io.github.xpadneo.metainfo.xml
%changelog
%autochangelog
@@ -1 +0,0 @@
hid_xpadneo
-1
View File
@@ -1 +0,0 @@
rpm.version(gh("atar-axis/xpadneo"));
-103
View File
@@ -1,103 +0,0 @@
%if 0%{?fedora}
%global buildforkernels akmod
%global debug_package %{nil}
%endif
Name: xpadneo
Version: 0.9.7
Release: 1%?dist
Summary: Advanced Linux Driver for Xbox One Wireless Gamepad
Group: System Environment/Kernel
License: GPL-3.0
URL: https://github.com/atar-axis/xpadneo
Source0: %url/archive/v%version/%name-%version.tar.gz
Source1: modules-load-d-xpadneo.conf
Source2: io.github.xpadneo.metainfo.xml
%global srcname hid-%name
BuildRequires: gcc
BuildRequires: make
BuildRequires: kmodtool
BuildRequires: systemd-rpm-macros
Requires: bash
Requires: bluez bluez-tools
Provides: %{name}-kmod-common = %{version}-%{release}
Requires: %{name}-kmod >= %{version}
Obsoletes: %{name} < 0.9.1-2
# kmodtool does its magic here
%{expand:%(kmodtool --target %{_target_cpu} --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null) }
%description
Advanced Linux Driver for Xbox One Wireless Controller
%package kmod
Summary: Kernel module (kmod) for %{name}
Requires: kernel-devel
%description kmod
This is the first driver for the Xbox One Wireless Gamepad (which is shipped with the Xbox One S).
%prep
# error out if there was something wrong with kmodtool
%{?kmodtool_check}
# print kmodtool output for debugging purposes:
kmodtool --target %{_target_cpu} --kmodname %{name} %{?buildforkernels:--%{buildforkernels}} %{?kernels:--for-kernels "%{?kernels}"} 2>/dev/null
%setup -q
for kernel_version in %{?kernel_versions} ; do
cp -a hid-xpadneo/src _kmod_build_${kernel_version%%___*}
done
%build
for kernel_version in %{?kernel_versions} ; do
make V=1 %{?_smp_mflags} -C ${kernel_version##*___} M=${PWD}/_kmod_build_${kernel_version%%___*} VERSION=v%{version} modules
done
%install
for kernel_version in %{?kernel_versions}; do
mkdir -p %{buildroot}%{kmodinstdir_prefix}/${kernel_version%%___*}/%{kmodinstdir_postfix}/
install -D -m 755 _kmod_build_${kernel_version%%___*}/hid-xpadneo.ko %{buildroot}%{kmodinstdir_prefix}/${kernel_version%%___*}/%{kmodinstdir_postfix}/
chmod a+x %{buildroot}%{kmodinstdir_prefix}/${kernel_version%%___*}/%{kmodinstdir_postfix}/*.ko
done
%{?akmod_install}
install -Dm644 hid-xpadneo/etc-modprobe.d/xpadneo.conf %{buildroot}%{_modprobedir}/60-xpadneo.conf
install -Dm644 %{SOURCE1} %{buildroot}%{_modulesloaddir}/xpadneo.conf
install -Dm644 hid-xpadneo/etc-udev-rules.d/60-xpadneo.rules %{buildroot}%{_udevrulesdir}/60-xpadneo.rules
install -Dm644 %{SOURCE2} %{buildroot}%{_datadir}/metainfo/io.github.xpadneo.metainfo.xml
%files
%doc NEWS.md docs/README.md docs/CONFIGURATION.md
%license LICENSE
%{_modprobedir}/60-xpadneo.conf
%{_modulesloaddir}/xpadneo.conf
%{_udevrulesdir}/60-xpadneo.rules
%{_datadir}/metainfo/io.github.xpadneo.metainfo.xml
%changelog
* Wed Oct 12 2022 Jan Drögehoff <sentrycraft123@gmail.com> - 0.9.5-1
- Update to 0.9.5
* Mon Jul 04 2022 Jan Drögehoff <sentrycraft123@gmail.com> - 0.9.4-1
- Update to 0.9.4
* Sun May 29 2022 Jan Drögehoff <sentrycraft123@gmail.com> - 0.9.2-1
- Update to 0.9.2
* Thu Jun 17 2021 Jan Drögehoff <sentrycraft123@gmail.com> - 0.9.1-2
- Move from DKMS to Akmods
* Fri May 21 2021 Jan Drögehoff <sentrycraft123@gmail.com> - 0.9.1-1
- Update to 0.9.1
* Mon Dec 28 21:58:05 CET 2020 Jan Drögehoff <sentrycraft123@gmail.com> - 0.9-2
- remove configure script
* Mon Dec 28 21:01:47 CET 2020 Jan Drögehoff <sentrycraft123@gmail.com> - 0.9-1
- Initial Spec