Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: xone-git #4222

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packagelist
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ xapps-common-deb
xfce4-deb
xfce4-settings-pine-git
xmind-vana-deb
xone-git
yabridge
yad
yafetch-git
Expand Down
68 changes: 68 additions & 0 deletions packages/xone-git/xone-git.pacscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name="xone-git"
pkgname="xone"
pkgdesc="Linux kernel driver for Xbox One and Xbox Series X|S accessories"
pkgver="0.3"
provides=('xone')
homepage='https://github.com/medusalix/xone#readme'
url="https://github.com/medusalix/xone.git"
arch=('amd64')
makedepends=('cabextract')
depends=('dkms' 'linux-headers-generic')
optdepends=("linux-headers-$(uname -r): Linux kernel headers for the currently installed version")
maintainer="FelisDiligens <[email protected]>"
pkgver() {
git ls-remote "${url}" master | cut -f1 | cut -c1-8
}

package() {
# We can't use "git describe" because the repo is cloned shallowly by pacstall...
# version=$(git describe --tags 2> /dev/null || echo unknown) # "v0.3-2-gbbf0dcc"
version="v${pkgver}-$(git rev-parse HEAD | cut -c1-8)" # "v0.3-bbf0dcc4", close enough...
find . -type f \( -name 'dkms.conf' -o -name '*.c' \) -exec sed -i "s/#VERSION#/${version}/" {} +

sudo install -dm755 "${pkgdir}/usr/src/xone-${version}"
sudo cp -r ./* "${pkgdir}/usr/src/xone-${version}"

sudo install -D -m 644 install/modprobe.conf "${pkgdir}/etc/modprobe.d/xone-blacklist.conf"

driver_url='http://download.windowsupdate.com/c/msdownload/update/driver/drvs/2017/07/1cd6a87c-623f-4407-a52d-c31be49e925c_e19f60808bdcbfbd3c3df6be3e71ffc52e43261e.cab'
firmware_hash='48084d9fa53b9bb04358f3bb127b7495dc8f7bb0b3ca1437bd24ef2b6eabdf66'

curl -L -o driver.cab "${driver_url}"
cabextract -F FW_ACC_00U.bin driver.cab
if echo "${firmware_hash}" FW_ACC_00U.bin | sha256sum -c; then
sudo install -D -m 644 "${srcdir}/FW_ACC_00U.bin" "${pkgdir}/usr/lib/firmware/xow_dongle.bin"
else
return 1
fi
}

post_install() {
version="$(find /usr/src -maxdepth 1 -type d -name "xone-*" | head -n 1 | sed 's|/usr/src/xone-||')"

sudo dkms install -m xone -v "${version}"

# Avoid conflicts between xpad and xone
if lsmod | grep -q '^xpad'; then
sudo modprobe -r xpad
fi

# Avoid conflicts between mt76x2u and xone
if lsmod | grep -q '^mt76x2u'; then
sudo modprobe -r mt76x2u
fi
}

post_remove() {
modules=$(lsmod | grep '^xone_' | cut -d ' ' -f 1 | tr '\n' ' ')

if [[ -n ${modules} ]]; then
read -ra modules_array <<< "${modules}"
sudo modprobe -r -a "${modules_array[@]}" # SC2086
fi

# There is no pre_remove() function, so we cannot run "dkms remove" before removing "dkms.conf".
# Therefore we have to delete the modules manually:
sudo rm -rfv /var/lib/dkms/xone
sudo rm -rfv /lib/modules/**/updates/dkms/xone-*.ko
}
Loading