From 90eaf68e171024fcb0cbb2fea00b546f67dd1cc4 Mon Sep 17 00:00:00 2001 From: crt0mega Date: Thu, 26 Aug 2021 17:38:51 +0200 Subject: [PATCH] Initial commit --- .gitignore | 8 ++ debian/README.Debian | 10 +++ debian/README.source | 15 ++++ debian/changelog | 5 ++ debian/control | 21 +++++ debian/copyright | 39 ++++++++ debian/install | 1 + debian/patches/fwinst.patch | 15 ++++ debian/patches/series | 1 + debian/postinst | 41 +++++++++ debian/postrm | 45 ++++++++++ debian/rules | 25 ++++++ debian/sixfireusb-fwcutter-docs.docs | 2 + debian/source/format | 1 + fwinst.sh | 127 +++++++++++++++++++++++++++ fwinst.txt | 18 ++++ 16 files changed, 374 insertions(+) create mode 100644 .gitignore create mode 100644 debian/README.Debian create mode 100644 debian/README.source create mode 100644 debian/changelog create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/install create mode 100644 debian/patches/fwinst.patch create mode 100644 debian/patches/series create mode 100644 debian/postinst create mode 100644 debian/postrm create mode 100755 debian/rules create mode 100644 debian/sixfireusb-fwcutter-docs.docs create mode 100644 debian/source/format create mode 100755 fwinst.sh create mode 100644 fwinst.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5815dc8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +.pc +debian/.debhelper +debian/*.ex +debian/*.EX +debian/*.substvars +debian/debhelper-build-stamp +debian/files +debian/sixfireusb-fwcutter diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 0000000..210f319 --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1,10 @@ +sixfireusb-fwcutter for Debian +----------------------------- + +This script is part of the out-of-tree driver for TerraTec's DMX 6Fire USB +sound card found at sf.net. It downloads the official Windoze driver and +extracts the necessary firmware files into Debian's firmware directory. + +It also takes care of cleaning up that mess with a postrm-trigger. + + -- crt0mega Thu, 26 Aug 2021 12:03:39 +0200 diff --git a/debian/README.source b/debian/README.source new file mode 100644 index 0000000..a40efb7 --- /dev/null +++ b/debian/README.source @@ -0,0 +1,15 @@ +sixfireusb-fwcutter for Debian +----------------------------- + +Patches for the script might be supplied through quilt. There's already +a patch inspired by the unofficial AUR package which choses install over +mkdir which is a more sane approach IMHO. + +If TerraTec decides to release new drivers, please follow the instructions +of fwinst.txt for adding support. + +It might be necessary to obtain the drivers from a web archive in the +future. + + -- crt0mega Thu, 26 Aug 2021 12:03:39 +0200 + diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..30035e5 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +sixfireusb-fwcutter (0.0.1-1) unstable; urgency=medium + + * Initial release + + -- crt0mega Thu, 26 Aug 2021 12:03:39 +0200 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..3c6ef1c --- /dev/null +++ b/debian/control @@ -0,0 +1,21 @@ +Source: sixfireusb-fwcutter +Section: unknown +Priority: optional +Maintainer: crt0mega +Build-Depends: debhelper-compat (= 13) +Standards-Version: 4.5.1 +Homepage: +#Vcs-Browser: https://salsa.debian.org/debian/sixfireusb-fwcutter +#Vcs-Git: https://salsa.debian.org/debian/sixfireusb-fwcutter.git +Rules-Requires-Root: no + +Package: sixfireusb-fwcutter +Architecture: all +Depends: ${misc:Depends}, p7zip, wget +Recommends: sixfireusb-dkms +Description: Firmware installer for TerraTec DMX 6Fire USB + The script fwinst.sh is used to install the firmware for + the TerraTec DMX 6Fire USB. The firmware is required for + the device to work after it has been disconnected from + power. It will download the windows driver version 1.23.0.02 + and extract the firmware from it. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..04636b6 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,39 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: sixfireusb-fwcutter +Upstream-Contact: +Source: + +Files: * +Copyright: + +License: GPL-3.0+ + +Files: debian/* +Copyright: 2021 crt0mega +License: GPL-3.0+ + +License: GPL-3.0+ + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + . + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program. If not, see . + . + On Debian systems, the complete text of the GNU General + Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". + +# Please also look if there are files or directories which have a +# different copyright/license attached and list them here. +# Please avoid picking licenses with terms that are more restrictive than the +# packaged work, as it may make Debian's contributions unacceptable upstream. +# +# If you need, there are some extra license texts available in two places: +# /usr/share/debhelper/dh_make/licenses/ +# /usr/share/common-licenses/ diff --git a/debian/install b/debian/install new file mode 100644 index 0000000..ad06389 --- /dev/null +++ b/debian/install @@ -0,0 +1 @@ +fwinst.sh usr/sbin/sixfireusb-fwcutter diff --git a/debian/patches/fwinst.patch b/debian/patches/fwinst.patch new file mode 100644 index 0000000..c0572f7 --- /dev/null +++ b/debian/patches/fwinst.patch @@ -0,0 +1,15 @@ +Use install instead of mkdir (inspred by Castix' patch + for the AUR package) because it looks more sane +Index: sixfireusb-fwcutter/fwinst.sh +=================================================================== +--- sixfireusb-fwcutter.orig/fwinst.sh ++++ sixfireusb-fwcutter/fwinst.sh +@@ -106,7 +106,7 @@ if ! copy_bymd5 a65eecc11adc87af7307f526 + fi + + step_begin "Installing firmware files" +-if ! mkdir -p $FW_6FIRE_PATH >/dev/null 2>&1 ; then ++if ! install -dm755 $FW_6FIRE_PATH >/dev/null 2>&1 ; then + step_error "Creation of firmware path failed. Are you root?" + fi + diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..22bc93f --- /dev/null +++ b/debian/patches/series @@ -0,0 +1 @@ +fwinst.patch diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..abad319 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,41 @@ +#!/bin/sh +# postinst script for sixfireusb-fwcutter +# +# see: dh_installdeb(1) + +set -e + +PFX="/usr/sbin/sixfireusb-fwcutter" + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see https://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + sh "$PFX/fwinst.sh" + ;; + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/postrm b/debian/postrm new file mode 100644 index 0000000..ecffe14 --- /dev/null +++ b/debian/postrm @@ -0,0 +1,45 @@ +#!/bin/sh +# postrm script for sixfireusb-fwcutter +# +# see: dh_installdeb(1) + +FW_DIR="/lib/firmware/6fire" + +set -e + +# summary of how this script can be called: +# * `remove' +# * `purge' +# * `upgrade' +# * `failed-upgrade' +# * `abort-install' +# * `abort-install' +# * `abort-upgrade' +# * `disappear' +# +# for details, see https://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + if [ -d "$FW_DIR" ]; then + echo "Removing downloaded firmware files" + rm -r /lib/firmware/6fire + else + echo "No firmware files found for removal" + fi + ;; + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..59ea751 --- /dev/null +++ b/debian/rules @@ -0,0 +1,25 @@ +#!/usr/bin/make -f +# See debhelper(7) (uncomment to enable) +# output every command that modifies files on the build system. +#export DH_VERBOSE = 1 + + +# see FEATURE AREAS in dpkg-buildflags(1) +#export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +# see ENVIRONMENT in dpkg-buildflags(1) +# package maintainers to append CFLAGS +#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic +# package maintainers to append LDFLAGS +#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed + + +%: + dh $@ + + +# dh_make generated override targets +# This is example for Cmake (See https://bugs.debian.org/641051 ) +#override_dh_auto_configure: +# dh_auto_configure -- \ +# -DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH) diff --git a/debian/sixfireusb-fwcutter-docs.docs b/debian/sixfireusb-fwcutter-docs.docs new file mode 100644 index 0000000..7319041 --- /dev/null +++ b/debian/sixfireusb-fwcutter-docs.docs @@ -0,0 +1,2 @@ +README.source +README.Debian diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/fwinst.sh b/fwinst.sh new file mode 100755 index 0000000..ddd2991 --- /dev/null +++ b/fwinst.sh @@ -0,0 +1,127 @@ +#!/bin/sh + +# +# This shell script downloads and installs firmware for the Terratec +# DMX 6Fire USB. See fwinst.txt for more information. +# +# Windows driver version used: 1.11.0.19 +# +# Author: Torsten Schenk +# Copyright: (C) Torsten Schenk +# +# Thanks: +# - Richard Lucassen: he fixed minor bugs in this script and +# helped fixing 7z version problems +# +# This script is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# + +export FW_PATH=/lib/firmware +export FW_6FIRE_PATH=$FW_PATH/6fire +cleanup() { + rm -Rf /tmp/dmx + rm -f /tmp/dmx.exe + rm -f /tmp/dmx.tmp + rm -f /tmp/dmx6firel2.ihx + rm -f /tmp/dmx6fireap.ihx + rm -f /tmp/dmx6firecf.bin +} + +success() { + echo -e "\033[1;32m$1\033[m" + cleanup + exit +} + +step_begin() { + echo -e -n "\033[1;33m$1...\033[m" +} + +step_error() { + echo -e "\033[1;33mfailed.\033[0m" + echo -e "\033[1;31m$1\033[0m" + cleanup + exit +} + +step_success() { + echo -e "\033[1;33mdone.\033[m" +} + +copy_bymd5() { + file=`find /tmp/dmx -type f -exec md5sum {} \; | grep "$1"` + + if test -z "$file" ; then + return 1 + fi + file=`echo $file | awk '{ print $2 }'` + cp "$file" "/tmp/$2" + return 0 +} + +cleanup + +step_begin "Checking for firmware directory" +if ! [ -d $FW_PATH ]; then + step_error "Firmware directory\n $FW_PATH\ndoes not exist.\n\nEither you have no firmware installed or your system uses another directory.\nPlease set FW_PATH in this script file accordingly.\nTypical paths you could try are:\n /lib/firmware\n /usr/lib/hotplug/firmware\n\nIf you nevertheless want to install the firmware into this path,\nplease create it manually:\n $ sudo mkdir -p $FW_PATH\nor, if you are root:\n $ mkdir -p $FW_PATH" +fi +step_success + +step_begin "Downloading windows driver" +if ! wget "http://terratec.ultron.info/Audio/DMX_6fire_USB/Updates/History/Windows/DMX_6fire_USB_Setup_1.23.0.02_XP_Vista_7.exe" -q -O /tmp/dmx.exe ; then + step_error "Internet connection alive? Perhaps a new driver version is available.\nIf that is the case, please redownload this script." +fi +step_success + +step_begin "Checking MD-5 checksum of windows driver" +if ! echo "86049155f9326a77329d87f7b027a8b9 /tmp/dmx.exe" | md5sum -c >/dev/null 2>&1 ; then + step_error "Downloaded windows driver has wrong MD-5 checksum." +fi +step_success + +step_begin "Unpacking windows driver" +if ! mkdir /tmp/dmx ; then + step_error "Cannot create temporary directory /tmp/dmx." +fi + +if ! 7z x -aot -o/tmp/dmx /tmp/dmx.exe >/dev/null 2>&1 ; then + step_error "Is 7z installed?" +fi +step_success + +step_begin "Extracting firmware files" +if ! copy_bymd5 fa80973cb8c02097712933bd1d1c23b2 dmx6firel2.ihx ; then + step_error "No file found which has the MD5 checksum of dmx6firel2.ihx" +fi + +if ! copy_bymd5 7497b6b80d43e68f13b6929934ab60f4 dmx6fireap.ihx ; then + step_error "No file found which has the MD5 checksum of dmx6fireap.ihx" +fi + +if ! copy_bymd5 a65eecc11adc87af7307f5266ad31d65 dmx6firecf.bin ; then + step_error "No file found which has the MD5 checksum of dmx6firecf.bin" +fi + +step_begin "Installing firmware files" +if ! mkdir -p $FW_6FIRE_PATH >/dev/null 2>&1 ; then + step_error "Creation of firmware path failed. Are you root?" +fi + +if ! cp /tmp/dmx6firel2.ihx $FW_6FIRE_PATH >/dev/null 2>&1 ; then + step_error "Installation of file 'dmx6firel2.ihx' failed. Are you root?" +fi + +if ! cp /tmp/dmx6fireap.ihx $FW_6FIRE_PATH >/dev/null 2>&1 ; then + step_error "Installation of file 'dmx6fireap.ihx' failed. Are you root?" +fi + +if ! cp /tmp/dmx6firecf.bin $FW_6FIRE_PATH >/dev/null 2>&1 ; then + step_error "Installation of file 'dmx6firecf.bin' failed. Are you root?" +fi +step_success + +success "Installation completed." + diff --git a/fwinst.txt b/fwinst.txt new file mode 100644 index 0000000..98f2cc4 --- /dev/null +++ b/fwinst.txt @@ -0,0 +1,18 @@ +Firmware installer for TerraTec DMX 6Fire USB +========================================================= + +The script fwinst.sh is used to install the firmware for the TerraTec DMX 6Fire USB. The firmware is required for the device to work after it has been disconnected from power. It will download the windows driver version 1.23.0.02 and extract the firmware from it. If TerraTec releases a new driver and the old one is not available any longer, please redownload the script. + +If you have an older version of the driver than 0.5.4, you need to use the fwinst_1.11.0.19.sh script in the old/ folder that will download and install firmware version 1.11.0.19. + +To perform the installation, ensure that your internet connection is up. Also you need to have installed 7z (found in p7zip) and wget. + +Usually the firmware is located in /lib/firmware. If that is not the case for your system, you need to change the line + export FW_PATH=/lib/firmware +accordingly. + +Then, type + $ sudo sh fwinst.sh +or (if you already are logged in as root) + $ sh fwinst.sh +