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 1 commit
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
93 changes: 93 additions & 0 deletions packages/xone-git/xone-git.pacscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
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=('git' 'curl' 'cabextract')
FelisDiligens marked this conversation as resolved.
Show resolved Hide resolved
depends=('dkms' 'linux-headers-generic')
maintainer="FelisDiligens <[email protected]>"

FelisDiligens marked this conversation as resolved.
Show resolved Hide resolved
pkgver() {
git ls-remote "${url}" master | cut -f1 | cut -c1-8
}

prepare() {
if lsmod | grep -q '^xone_'; then
echo '* xone already installed... uninstall it before updating! (Run: pacstall -R xone-git)' >&2
exit 1
fi

if [[ -f "/usr/local/bin/xow" ]]; then
echo '* Please uninstall xow!' >&2
exit 1
fi
}
FelisDiligens marked this conversation as resolved.
Show resolved Hide resolved

package() {
echo "* Preparing module..."
FelisDiligens marked this conversation as resolved.
Show resolved Hide resolved
# 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}/" {} +

echo "* Copying module into /usr/src..."
FelisDiligens marked this conversation as resolved.
Show resolved Hide resolved
sudo install -dm755 "${pkgdir}/usr/src/xone-${version}"
sudo cp -r ./* "${pkgdir}/usr/src/xone-${version}"

echo "* Blacklisting xpad module..."
FelisDiligens marked this conversation as resolved.
Show resolved Hide resolved
sudo install -D -m 644 install/modprobe.conf "${pkgdir}/etc/modprobe.d/xone-blacklist.conf"

echo "* Extracting dongle firmware..."
echo "* The firmware for the wireless dongle is subject to Microsoft's Terms of Use:"
echo "* https://www.microsoft.com/en-us/legal/terms-of-use"

FelisDiligens marked this conversation as resolved.
Show resolved Hide resolved
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
echo "* Checksum did not match!"
FelisDiligens marked this conversation as resolved.
Show resolved Hide resolved
exit 1
FelisDiligens marked this conversation as resolved.
Show resolved Hide resolved
fi
}

post_install() {
echo "* Getting xone version"
FelisDiligens marked this conversation as resolved.
Show resolved Hide resolved
version="$(find /usr/src -maxdepth 1 -type d -name "xone-*" | head -n 1 | sed 's|/usr/src/xone-||')"

echo "* Running 'dkms install'"
FelisDiligens marked this conversation as resolved.
Show resolved Hide resolved
sudo dkms install -m xone -v "${version}"

echo "* Unloading conflicting kernel modules"
FelisDiligens marked this conversation as resolved.
Show resolved Hide resolved
# 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
echo "* Unloading modules: ${modules}"
FelisDiligens marked this conversation as resolved.
Show resolved Hide resolved
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:
echo "* Deleting xone dkms files"
FelisDiligens marked this conversation as resolved.
Show resolved Hide resolved
sudo rm -rfv /var/lib/dkms/xone
sudo rm -rfv /lib/modules/**/updates/dkms/xone-*.ko
}