File: dkms-autopkgtest

package info (click to toggle)
v4l2loopback 0.12.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 372 kB
  • sloc: ansic: 3,105; sh: 323; makefile: 121
file content (64 lines) | stat: -rwxr-xr-x 1,724 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/sh
# Common autopkgtest script for testing a dkms source package.
# Author: Martin Pitt <martin.pitt@ubuntu.com>
# Copyright: (C) 2014 Canonical Ltd.

# IOhannes m zmölnig
# - 2018-07-13: removed cruft, simplified and don't require apt install
set -eu

purge_adt_artifacts=no
if [ -z ${ADT_ARTIFACTS+x} ]; then
  ADT_ARTIFACTS=$(mktemp -d)
  echo "I: created temporaray ARTIFACTS directory ${AUTOPKGTEST_ARTIFACTS}"
  purge_adt_artifacts=yes
fi

run_pkg() {
    pkg="$1"

    if ! dkms_conf=$(dpkg -L $pkg | grep 'dkms.conf$'); then
        echo "I: Package $pkg has no dkms.conf, skipping"
        return
    fi

    # collect build logs as artifacts
    if [ -d /var/lib/dkms ]; then
        (cd /var/lib/dkms; find -name "make.log" -print0 | xargs -0 tar c | echo "") > "$AUTOPKGTEST_ARTIFACTS/$pkg-make-logs.tar"
    fi

    echo "I: Testing binary package $pkg"
    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
}

pkgs="$@"
if [ x"${pkgs}" = "x" ]; then
  pkgs=$(awk '/^Package:.*/ { print $2 }' debian/control)
fi

for pkg in $pkgs; do
    # package might be arch: restriction or udeb etc.
    if ! dpkg-query -W "${pkg}" >/dev/null 2>&1; then
        echo "I: Skipping unavailable package $pkg"
        continue
    fi
    run_pkg $pkg
done

if [ "x${purge_adt_artifacts}" = "xyes" ]; then
  rm -rf "${AUTOPKGTEST_ARTIFACTS}"
fi