From aeccfede0d26c5c7db74cccf91e74ae29552117a Mon Sep 17 00:00:00 2001 From: Thierry Lelegard Date: Wed, 12 Apr 2017 17:39:06 +0200 Subject: [PATCH] Added Ubuntu support --- build-dektec-dkms | 22 ++++++++++++++++++++++ control.template | 17 +++++++++++++++++ dektec-dkms.spec | 2 +- postinst.template | 18 ++++++++++++++++++ prerm.template | 8 ++++++++ 5 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 control.template create mode 100755 postinst.template create mode 100755 prerm.template diff --git a/build-dektec-dkms b/build-dektec-dkms index d1973f9..2d98234 100755 --- a/build-dektec-dkms +++ b/build-dektec-dkms @@ -340,5 +340,27 @@ if $RPM_DISTRO; then "$PKGDIR" fi +# Build DEB distro. +if $DEB_DISTRO; then + verbose "building DEB package" + + # Root of .deb package build. + DEBDIR="$TMPDIR/deb" + rm -rf "$DEBDIR" + + # Build file structure of the package. + mkdir -p -m 0755 "$DEBDIR/DEBIAN" "$DEBDIR/usr/src" "$DEBDIR/etc/udev/rules.d" "$DEBDIR/usr/share/doc/dektec-dkms" + for f in control postinst prerm; do + sed -e "s/{{VERSION}}/$VERSION/g" $f.template >"$DEBDIR/DEBIAN/$f" + done + chmod 755 "$DEBDIR/DEBIAN/postinst" "$DEBDIR/DEBIAN/prerm" + cp -rp "$SRCDIR/dektec-$VERSION" "$DEBDIR/usr/src" + install -m 644 "$SRCDIR/51-dta.rules" "$SRCDIR/51-dtu.rules" "$DEBDIR/etc/udev/rules.d" + install -m 644 "$SRCDIR/Readme" "$SRCDIR/License" "$DEBDIR/usr/share/doc/dektec-dkms" + + # Build the binary package + dpkg --build "$DEBDIR" "$PKGDIR" +fi + # Final cleanup. cleanexit 0 diff --git a/control.template b/control.template new file mode 100644 index 0000000..425bda7 --- /dev/null +++ b/control.template @@ -0,0 +1,17 @@ +Package: dektec-dkms +Version: {{VERSION}} +Architecture: all +Maintainer: DekTec Digital Video B.V. +Section: free/kernel +Priority: optional +Depends: dkms +Description: Source code and DKMS setup for the Dektec device drivers. + This package installs the source code and DKMS setup for the kernel modules + of the Dektec device drivers. Each time the kernel is upgraded, the Dektec + modules are automatically recompiled. The provided drivers are Dta, DtaNw, Dtu. + . + Dektec is a manufacturer of PC add-on cards, USB devices, IP converters and + software for the professional digital-television market. Their products are + used for test and measurement and to build broadcast infrastructure. + . + This is an independent packaging of the Dektec original drivers. diff --git a/dektec-dkms.spec b/dektec-dkms.spec index 6e465a4..a1bfe74 100644 --- a/dektec-dkms.spec +++ b/dektec-dkms.spec @@ -37,7 +37,7 @@ cp -r dektec-%{version} $RPM_BUILD_ROOT/usr/src install -m 644 51-dta.rules 51-dtu.rules $RPM_BUILD_ROOT/etc/udev/rules.d %post -[[ -n $(/usr/sbin/dkms status | grep dektec | grep "%{version}" | wc -l) ]] && /usr/sbin/dkms add -m dektec -v "%{version}" +[[ $(/usr/sbin/dkms status | grep dektec | grep "%{version}" | wc -l) -eq 0 ]] && /usr/sbin/dkms add -m dektec -v "%{version}" /usr/sbin/dkms build -m dektec -v "%{version}" /usr/sbin/dkms install -m dektec -v "%{version}" exit 0 diff --git a/postinst.template b/postinst.template new file mode 100755 index 0000000..f5a66a4 --- /dev/null +++ b/postinst.template @@ -0,0 +1,18 @@ +#!/bin/bash +# QtlMovie post-installation script on Ubuntu and Debian systems. + +if [[ "$1" = "configure" ]]; then + # Fix file permissions and ownership. + chown -R root:root /usr/src/dektec-{{VERSION}} /etc/udev/rules.d/51-dta.rules /etc/udev/rules.d/51-dtu.rules /usr/share/doc/dektec-dkms + find /usr/src/dektec-{{VERSION}} -type f -print0 | xargs -0 chmod 644 + find /usr/src/dektec-{{VERSION}} -type d -print0 | xargs -0 chmod 755 + chmod 755 /usr/share/doc/dektec-dkms + chmod 644 /etc/udev/rules.d/51-dta.rules /etc/udev/rules.d/51-dtu.rules /usr/share/doc/dektec-dkms/* + + # Build the initial version of the driver. + [[ $(/usr/sbin/dkms status | grep dektec | grep "{{VERSION}}" | wc -l) -eq 0 ]] && /usr/sbin/dkms add -m dektec -v "{{VERSION}}" + /usr/sbin/dkms build -m dektec -v "{{VERSION}}" + /usr/sbin/dkms install -m dektec -v "{{VERSION}}" +fi + +exit 0 diff --git a/prerm.template b/prerm.template new file mode 100755 index 0000000..89809e2 --- /dev/null +++ b/prerm.template @@ -0,0 +1,8 @@ +#!/bin/bash +# Dektec DKMS pre-uninstallation script on Ubuntu and Debian systems. + +if [[ "$1" = "remove" || "$1" = "deconfigure" ]]; then + [[ $(/usr/sbin/dkms status | grep dektec | grep "{{VERSION}}" | wc -l) -gt 0 ]] && /usr/sbin/dkms remove -m dektec -v "{{VERSION}}" --all +fi + +exit 0