Skip to content

Commit

Permalink
Add DEB file support.
Browse files Browse the repository at this point in the history
You can now generate a debian file for the project by running `./build-deb.sh`.
  • Loading branch information
RicardoEPRodrigues committed Feb 21, 2021
1 parent 197383d commit fef19d7
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pkg-debian/*
!pkg-debian/DEBIAN
*.deb
39 changes: 39 additions & 0 deletions build-deb.sh
Original file line number Diff line number Diff line change
@@ -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}
1 change: 1 addition & 0 deletions pkg-debian/DEBIAN/conffiles
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/modprobe.d/hid-magicmouse.conf
13 changes: 13 additions & 0 deletions pkg-debian/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Package: magicmouse-hid
Version: 1.0.0-0
Maintainer: Ricardo Rodrigues <[email protected]>
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
15 changes: 15 additions & 0 deletions pkg-debian/DEBIAN/md5sums
Original file line number Diff line number Diff line change
@@ -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
20 changes: 20 additions & 0 deletions pkg-debian/DEBIAN/postinst
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions pkg-debian/DEBIAN/prerm
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit fef19d7

Please sign in to comment.