packaging: Add module restart/install logic

- For clevo interfaces
- For tuxedo_io from tuxedo_cc_wmi
This commit is contained in:
Christoffer Sandberg 2020-12-07 16:58:05 +01:00
parent 596212e17a
commit a8230d47f6
No known key found for this signature in database
GPG key ID: BF563F71B6C7A96D
3 changed files with 91 additions and 31 deletions

View file

@ -3,8 +3,8 @@ Version: x.x.x
Section: admin Section: admin
Priority: optional Priority: optional
Depends: dkms (>= 1.95) Depends: dkms (>= 1.95)
Conflicts: tuxedo-keyboard-dkms (<= 2.0.0), tuxedo-wmi-dkms (<= 1.5.1), tuxedo-xp-xc-touchpad-key-fix, tuxedo-touchpad-fix (<= 1.0.8), tuxedo-xp-xc-airplane-mode-fix (<= 0.6) Conflicts: tuxedo-keyboard-dkms (<= 2.0.0), tuxedo-wmi-dkms (<= 1.5.1), tuxedo-xp-xc-touchpad-key-fix, tuxedo-touchpad-fix (<= 1.0.8), tuxedo-xp-xc-airplane-mode-fix (<= 0.6), tuxedo-cc-wmi
Replaces: tuxedo-keyboard-dkms (<= 2.0.0), tuxedo-wmi-dkms (<= 1.5.1), tuxedo-xp-xc-touchpad-key-fix, tuxedo-touchpad-fix (<= 1.0.8), tuxedo-xp-xc-airplane-mode-fix (<= 0.6) Replaces: tuxedo-keyboard-dkms (<= 2.0.0), tuxedo-wmi-dkms (<= 1.5.1), tuxedo-xp-xc-touchpad-key-fix, tuxedo-touchpad-fix (<= 1.0.8), tuxedo-xp-xc-airplane-mode-fix (<= 0.6), tuxedo-cc-wmi
Maintainer: TUXEDO Computers GmbH <tux@tuxedocomputers.com> Maintainer: TUXEDO Computers GmbH <tux@tuxedocomputers.com>
Homepage: https://www.tuxedocomputers.com Homepage: https://www.tuxedocomputers.com
Architecture: all Architecture: all

View file

@ -20,45 +20,73 @@ CVERSION=`dpkg-query -W -f='${Version}' $DEB_NAME | awk -F "-" '{print $1}' | cu
ARCH=`dpkg --print-architecture` ARCH=`dpkg --print-architecture`
dkms_configure () { dkms_configure () {
for POSTINST in /usr/lib/dkms/common.postinst "/usr/share/$PACKAGE_NAME/postinst"; do for POSTINST in /usr/lib/dkms/common.postinst "/usr/share/$PACKAGE_NAME/postinst"; do
if [ -f "$POSTINST" ]; then if [ -f "$POSTINST" ]; then
"$POSTINST" "$NAME" "$CVERSION" "/usr/share/$PACKAGE_NAME" "$ARCH" "$2" "$POSTINST" "$NAME" "$CVERSION" "/usr/share/$PACKAGE_NAME" "$ARCH" "$2"
return $? return $?
fi fi
echo "WARNING: $POSTINST does not exist." >&2 echo "WARNING: $POSTINST does not exist." >&2
done done
echo "ERROR: DKMS version is too old and $PACKAGE_NAME was not" >&2 echo "ERROR: DKMS version is too old and $PACKAGE_NAME was not" >&2
echo "built with legacy DKMS support." >&2 echo "built with legacy DKMS support." >&2
echo "You must either rebuild $PACKAGE_NAME with legacy postinst" >&2 echo "You must either rebuild $PACKAGE_NAME with legacy postinst" >&2
echo "support or upgrade DKMS to a more current version." >&2 echo "support or upgrade DKMS to a more current version." >&2
return 1 return 1
} }
# End dkms standard postinst # End dkms standard postinst
case "$1" in case "$1" in
configure) configure)
# Run standard dkms build/install for all kernels with headers installed # Run standard dkms build/install for all kernels with headers installed
dkms_configure dkms_configure
# Attempt to (re-)load module immediately, fail silently if not possible at this stage # Attempt to (re-)load module immediately, fail silently if not possible at this stage
rmmod ${module} > /dev/null 2>&1 || true
modprobe ${module} > /dev/null 2>&1 || true
# Install default config if none exist already # Also stop tccd service if running before
if [ ! -f "/etc/modprobe.d/tuxedo_keyboard.conf" ]; then echo "Check tccd running status"
cp -f /usr/share/tuxedo-keyboard/tuxedo_keyboard.conf /etc/modprobe.d/tuxedo_keyboard.conf if systemctl is-active --quiet tccd.service; then
fi TCCD_RUNNING=true
else
TCCD_RUNNING=false
fi
;; if $TCCD_RUNNING; then
echo "Stop tccd temporarily"
systemctl stop tccd 2>&1 || true
fi
abort-upgrade|abort-remove|abort-deconfigure) echo "(Re)load modules if possible"
;; rmmod tuxedo_io > /dev/null 2>&1 || true
rmmod clevo_wmi > /dev/null 2>&1 || true
rmmod clevo_acpi > /dev/null 2>&1 || true
rmmod tuxedo_keyboard > /dev/null 2>&1 || true
modprobe tuxedo_keyboard > /dev/null 2>&1 || true
modprobe clevo_wmi > /dev/null 2>&1 || true
modprobe clevo_acpi > /dev/null 2>&1 || true
modprobe tuxedo_io > /dev/null 2>&1 || true
*) # Restart tccd after reload if it was running
echo "postinst called with unknown argument \`$1'" >&2 if $TCCD_RUNNING; then
exit 1 echo "Start tccd again"
;; systemctl start tccd 2>&1 || true
fi
# Install default config if none exist already
if [ ! -f "/etc/modprobe.d/tuxedo_keyboard.conf" ]; then
cp -f /usr/share/tuxedo-keyboard/tuxedo_keyboard.conf /etc/modprobe.d/tuxedo_keyboard.conf
fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac esac
exit 0 exit 0

View file

@ -31,6 +31,7 @@ Provides: tuxedo_keyboard = %{version}-%{release}
Obsoletes: tuxedo_keyboard < %{version}-%{release} Obsoletes: tuxedo_keyboard < %{version}-%{release}
Obsoletes: tuxedo-xp-xc-touchpad-key-fix Obsoletes: tuxedo-xp-xc-touchpad-key-fix
Obsoletes: tuxedo-touchpad-fix <= 1.0.1 Obsoletes: tuxedo-touchpad-fix <= 1.0.1
Obsoletes: tuxedo-cc-wmi
Requires: dkms >= 1.95 Requires: dkms >= 1.95
BuildRoot: %{_tmppath} BuildRoot: %{_tmppath}
Packager: Tomte <tux@tuxedocomputers.com> Packager: Tomte <tux@tuxedocomputers.com>
@ -71,14 +72,45 @@ for POSTINST in /usr/lib/dkms/common.postinst /usr/share/%{module}/postinst; do
if [ -f $POSTINST ]; then if [ -f $POSTINST ]; then
$POSTINST %{module} %{version} /usr/share/%{module} $POSTINST %{module} %{version} /usr/share/%{module}
RET=$? RET=$?
rmmod %{module} > /dev/null 2>&1 || true
modprobe %{module} > /dev/null 2>&1 || true # Attempt to (re-)load module immediately, fail silently if not possible at this stage
# Also stop tccd service if running before
echo "Check tccd running status"
if systemctl is-active --quiet tccd.service; then
TCCD_RUNNING=true
else
TCCD_RUNNING=false
fi
if $TCCD_RUNNING; then
echo "Stop tccd temporarily"
systemctl stop tccd 2>&1 || true
fi
echo "(Re)load modules if possible"
rmmod tuxedo_io > /dev/null 2>&1 || true
rmmod clevo_wmi > /dev/null 2>&1 || true
rmmod clevo_acpi > /dev/null 2>&1 || true
rmmod tuxedo_keyboard > /dev/null 2>&1 || true
modprobe tuxedo_keyboard > /dev/null 2>&1 || true
modprobe clevo_wmi > /dev/null 2>&1 || true
modprobe clevo_acpi > /dev/null 2>&1 || true
modprobe tuxedo_io > /dev/null 2>&1 || true
# Install default config if none exist already # Install default config if none exist already
if [ ! -f "/etc/modprobe.d/tuxedo_keyboard.conf" ]; then if [ ! -f "/etc/modprobe.d/tuxedo_keyboard.conf" ]; then
cp -f /usr/share/tuxedo-keyboard/tuxedo_keyboard.conf /etc/modprobe.d/tuxedo_keyboard.conf cp -f /usr/share/tuxedo-keyboard/tuxedo_keyboard.conf /etc/modprobe.d/tuxedo_keyboard.conf
fi fi
# Restart tccd after reload if it was running
if $TCCD_RUNNING; then
echo "Start tccd again"
systemctl start tccd 2>&1 || true
fi
exit $RET exit $RET
fi fi
echo "WARNING: $POSTINST does not exist." echo "WARNING: $POSTINST does not exist."