diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..884b9e5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +pkg-debian/* +!pkg-debian/DEBIAN +*.deb diff --git a/build-deb.sh b/build-deb.sh new file mode 100755 index 0000000..d42f3da --- /dev/null +++ b/build-deb.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +set -e +set -x + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +ETC_DIR="/etc" +PKG_DIR="/pkg-debian" +OPT_DIR="/opt/magicmouse-hid" + +DEB="magicmouse-hid_1.0.0-0_amd64.deb" + +cp -rf ${DIR}${ETC_DIR} ${DIR}${PKG_DIR} + +mkdir -p ${DIR}${PKG_DIR}${OPT_DIR} +# Copy scripts to /opt +cp -f ${DIR}/scripts/magic-mouse-2-add.sh ${DIR}${PKG_DIR}${OPT_DIR}/magic-mouse-2-add.sh +# cp -f ${DIR}/install.sh ${DIR}${PKG_DIR}${OPT_DIR}/install.sh +# cp -f ${DIR}/remove.sh ${DIR}${PKG_DIR}${OPT_DIR}/remove.sh + +mkdir -p ${DIR}${PKG_DIR}${OPT_DIR}/scripts +cp -f ${DIR}/scripts/install.sh ${DIR}${PKG_DIR}${OPT_DIR}/scripts/install.sh +cp -f ${DIR}/scripts/remove.sh ${DIR}${PKG_DIR}${OPT_DIR}/scripts/remove.sh + +# Copy source to /opt +cp -rf ${DIR}/linux ${DIR}${PKG_DIR}${OPT_DIR}/linux + +# Generate MD5sums +cd ${DIR}${PKG_DIR} +find ${DIR}${PKG_DIR} -type f ! -regex '.*?debian-binary.*' ! -regex '.*?DEBIAN.*' -printf '%P ' | xargs md5sum > ${DIR}${PKG_DIR}/DEBIAN/md5sums +cd ${DIR} + +# Set correct permissions +chmod 0775 ${DIR}${PKG_DIR}/DEBIAN/postinst +chmod 0775 ${DIR}${PKG_DIR}/DEBIAN/prerm + +dpkg -b ${DIR}${PKG_DIR} ${DIR}/${DEB} + +dpkg -I ${DIR}/${DEB} \ No newline at end of file diff --git a/pkg-debian/DEBIAN/conffiles b/pkg-debian/DEBIAN/conffiles new file mode 100644 index 0000000..c8c51ba --- /dev/null +++ b/pkg-debian/DEBIAN/conffiles @@ -0,0 +1 @@ +/etc/modprobe.d/hid-magicmouse.conf diff --git a/pkg-debian/DEBIAN/control b/pkg-debian/DEBIAN/control new file mode 100644 index 0000000..66c7d0b --- /dev/null +++ b/pkg-debian/DEBIAN/control @@ -0,0 +1,13 @@ +Package: magicmouse-hid +Version: 1.0.0-0 +Maintainer: Ricardo Rodrigues +Description: Magic Mouse 2 driver for Linux + This driver makes use of DKMS to load the driver in the kernel, while + making use of udev rules to load the driver when a mouse is connected. +Homepage: https://github.com/RicardoEPRodrigues/Linux-Magic-Trackpad-2-Driver +Architecture: all +Depends: dkms, bash +Section: utils +Priority: optional +Essential: no +Installed-Size: 354 diff --git a/pkg-debian/DEBIAN/md5sums b/pkg-debian/DEBIAN/md5sums new file mode 100644 index 0000000..cfdb339 --- /dev/null +++ b/pkg-debian/DEBIAN/md5sums @@ -0,0 +1,15 @@ +4e98e3ddfe2f2677c4ba7d40160ad805 opt/magicmouse-hid/scripts/remove.sh +19394e43a8b68454dd1ecb0b053b1eb4 opt/magicmouse-hid/scripts/install.sh +9d8311a258e4a5f2d21621c510d2865b opt/magicmouse-hid/magic-mouse-2-add.sh +a01b7f00714f6281bf2489654825d920 opt/magicmouse-hid/linux/linux/drivers/hid/Makefile +db55932808cb9137512a48a5f10e91ca opt/magicmouse-hid/linux/linux/drivers/hid/dkms.conf +65e911f8a2c968a242bdeea3483822e6 opt/magicmouse-hid/linux/linux/drivers/hid/hid-quirks.c +09cc6d34174bd1d0b1f81bd28954524f opt/magicmouse-hid/linux/linux/drivers/hid/hid-magicmouse.c +2cc66b539552c6edd592484e3e1d5ba3 opt/magicmouse-hid/linux/linux/drivers/hid/hid-ids.h +a01b7f00714f6281bf2489654825d920 opt/magicmouse-hid/linux/drivers/hid/Makefile +db55932808cb9137512a48a5f10e91ca opt/magicmouse-hid/linux/drivers/hid/dkms.conf +65e911f8a2c968a242bdeea3483822e6 opt/magicmouse-hid/linux/drivers/hid/hid-quirks.c +09cc6d34174bd1d0b1f81bd28954524f opt/magicmouse-hid/linux/drivers/hid/hid-magicmouse.c +2cc66b539552c6edd592484e3e1d5ba3 opt/magicmouse-hid/linux/drivers/hid/hid-ids.h +44c561036e33a298dcf6729bdf475826 etc/udev/rules.d/10-magicmouse.rules +968e12ffccc68d19011cc2f29a4badad etc/modprobe.d/hid-magicmouse.conf diff --git a/pkg-debian/DEBIAN/postinst b/pkg-debian/DEBIAN/postinst new file mode 100755 index 0000000..126044c --- /dev/null +++ b/pkg-debian/DEBIAN/postinst @@ -0,0 +1,20 @@ +#!/bin/bash + +DIR="/opt/magicmouse-hid" +cd ${DIR} + +# Install drive through DKMS +chmod u+x ${DIR}/scripts/install.sh +${DIR}/scripts/install.sh + +# Copy script to load the driver to OPT directory +chmod +x ${DIR}/magic-mouse-2-add.sh + +# Copy udev rule and reload udev +udevadm control -R + +# Disable eSCO mode in Bluetooth to fix disconnection problems with the mouse +echo 1 | tee /sys/module/bluetooth/parameters/disable_esco +systemctl restart bluetooth +# persist eSCO mode in Bluetooth setting +echo "options bluetooth disable_esco=1" | tee /etc/modprobe.d/bluetooth-tweaks.conf \ No newline at end of file diff --git a/pkg-debian/DEBIAN/prerm b/pkg-debian/DEBIAN/prerm new file mode 100755 index 0000000..3a9d6eb --- /dev/null +++ b/pkg-debian/DEBIAN/prerm @@ -0,0 +1,14 @@ +#!/bin/bash + +DIR="/opt/magicmouse-hid" +cd ${DIR} + +# Remove drive through DKMS +chmod u+x ${DIR}/scripts/remove.sh +${DIR}/scripts/remove.sh + +# Reload udev after removing the udev rule +udevadm control -R + +# Restart Bluetooth +systemctl restart bluetooth