dkms: Add script for autopkgtesting DKMS packages

Martin Pitt martin.pitt at ubuntu.com
Tue Nov 11 10:27:28 UTC 2014


Package: dkms
Version: 2.2.0.3-2
Severity: wishlist
Tags: patch
User: ubuntu-devel at lists.ubuntu.com
Usertags: origin-ubuntu ubuntu-patch vivid
User: autopkgtest-devel at lists.alioth.debian.org
Usertags: autopkgtest

Hello,

With autodep8 [1] we can now generate autopkgtest metadata for entire
classes of similar packages, such as the already existing Perl/Ruby
ones. We should do the same for DKMS, to check that a particular DKMS
package builds against our default kernel, installs correctly, and has
sufficient dependencies.

This new script provides a general test for DKMS packages. It was
derived from Ubuntu's tailored scripts [2], but we are moving that to
autopkgtest to avoid custom infrastructure and run everything in the
same way. When applying it, please take care to chmod it to 755.

The other half of this is to teach autodep8 to recognize a DKMS
package and generate test metadata. That happens in [3].

After that, one can do

  adt-run dkms_2.2.0.3-2dkms1_all.deb sl-modem --- schroot sid

to test e. g. sl-modem, where dkms_2.2.0.3-2dkms1_all.deb is the
locally built dkms with this patch applied. Once that's in the
archive, that argument gets dropped of course.

Thanks for considering,

Martin

[1] https://packages.debian.org/sid/autodep8
[2] https://jenkins.qa.ubuntu.com/view/DKMS/?
[3] https://bugs.debian.org/766668
-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
-------------- next part --------------
 * Add debian/scripts/dkms-autopkgtest script: Common autopkgtest script for
   testing a dkms source package.
diff -Nru dkms-2.2.0.3/debian/install dkms-2.2.0.3/debian/install
--- dkms-2.2.0.3/debian/install	2014-01-15 12:55:33.000000000 +0100
+++ dkms-2.2.0.3/debian/install	2014-10-24 00:11:06.000000000 +0200
@@ -2,3 +2,4 @@
 debian/scripts/dh_dkms.1    usr/share/man/man1/
 debian/scripts/*-dkms       usr/share/debhelper/autoscripts/
 debian/scripts/dkms.pm      usr/share/perl5/Debian/Debhelper/Sequence/
+debian/scripts/dkms-autopkgtest usr/lib/dkms/
diff -Nru dkms-2.2.0.3/debian/scripts/dkms-autopkgtest dkms-2.2.0.3/debian/scripts/dkms-autopkgtest
--- dkms-2.2.0.3/debian/scripts/dkms-autopkgtest	1970-01-01 01:00:00.000000000 +0100
+++ dkms-2.2.0.3/debian/scripts/dkms-autopkgtest	2014-10-24 18:10:01.000000000 +0200
@@ -0,0 +1,66 @@
+#!/bin/sh
+# Common autopkgtest script for testing a dkms source package.
+# Author: Martin Pitt <martin.pitt at ubuntu.com>
+# Copyright: (C) 2014 Canonical Ltd.
+set -eu
+
+run_pkg() {
+    pkg="$1"
+
+    echo "I: Installing binary package $pkg"
+    export DEBIAN_FRONTEND=noninteractive
+    RC=0
+    apt-get install -yq $pkg </dev/null || RC=$?
+    # collect build logs as artifacts
+    (cd /var/lib/dkms; find -name "make.log" -print0 | xargs -0 tar c) > "$ADT_ARTIFACTS/$pkg-make-logs.tar"
+
+    if [ "$RC" -ne 0 ]; then
+        echo "E: Package $pkg failed to install" >&2
+        exit 1
+    fi
+
+    echo "I: Testing binary package $pkg"
+
+    if ! dkms_conf=$(dpkg -L $pkg | grep 'dkms.conf$'); then
+        echo "I: Package $pkg has no dkms.conf, skipping"
+        return
+    fi
+    dkms_pkg=$(bash -c ". $dkms_conf; echo \$PACKAGE_NAME" 2>/dev/null)
+
+    echo "I: Testing if $dkms_pkg modules are correctly installed"
+    dkmsstatus="$(dkms status $dkms_pkg)"
+    if [ -z "$dkmsstatus" ]; then
+        echo "E: dkms status output is empty!" >&2
+        exit 1
+    fi
+    echo "$dkmsstatus"
+
+    if ! echo "$dkmsstatus" | grep -q "installed$"; then
+        echo "E: not installed" >&2
+        exit 1
+    fi
+
+    # skip modprobing for now; this fails too often (needs particular
+    # hardware/firmware/etc)
+    # for mod in $(awk -F '"' '/^BUILT_MODULE_NAME/ {print $2}' $dkms_conf); do
+    #     echo "I: modprobe $mod"
+    #     if ! modprobe $mod; then
+    #         echo "E: Failed to modprobe module $mod" >&2
+    #         exit 1
+    #     else
+    #         echo "I: $modname loaded"
+    #     fi
+    # done
+}
+
+# Try and remove dkms to spot packages which miss a dkms dependency
+dpkg --remove dkms || true
+
+for pkg in $(awk '/^Package:/ { print $2 }' debian/control); do
+    # package might be arch: restriction or udeb etc.
+    if ! apt-cache show $pkg >/dev/null 2>&1; then
+        echo "I: Skipping unavailable package $pkg"
+        continue
+    fi
+    run_pkg $pkg
+done
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.alioth.debian.org/pipermail/autopkgtest-devel/attachments/20141111/18fae527/attachment.sig>


More information about the autopkgtest-devel mailing list