diff --git a/lib/adt_testbed.py b/lib/adt_testbed.py index 2e6dffd..3fc477e 100644 --- a/lib/adt_testbed.py +++ b/lib/adt_testbed.py @@ -770,9 +770,9 @@ fi ''' # check if we are in a click+AppArmor environment if self.execute(['sh', '-ec', - '[ -d /var/cache/apparmor -a -d /var/lib/apparmor/clicks ] && ' + '[ -d /var/cache/apparmor -a -d /var/lib/apparmor/clicks -a ! -e /var/cache/apparmor/click-ap.rules ] && ' 'type aa-clickhook >/dev/null 2>&1'])[0] != 0: - adtlog.debug('testbed does not have AppArmor/click, no need to adjust rules') + adtlog.debug('testbed does not have AppArmor/click or already has Autopilot click rules, no need to adjust rules') return False adtlog.debug('testbed has AppArmor/click') diff --git a/setup-commands/apparmor-rules-update-lite b/setup-commands/apparmor-rules-update-lite new file mode 100644 index 0000000..b9937b0 --- /dev/null +++ b/setup-commands/apparmor-rules-update-lite @@ -0,0 +1,36 @@ +#!/bin/sh +# This script is part of autopkgtest +# Copyright (C) 2016 Canonical Ltd. +# Authors: Martin Pitt +# Omer Akram +# +# --setup-commands script to speed up test run by not calling +# aa-clickhook with --force parameter. Primary use case here is +# to make test development faster by not having to wait more than +# a minute each time a test is run. + +set -e + +RULES_FILE=/var/cache/apparmor/click-ap.rules + +# Check if the click rules file exists to determine if +# we should be using --force with aa-clickhook or not. +rules_file_exists=false +if [ -e $RULES_FILE ]; then + rules_file_exists=true +fi + +cat < $RULES_FILE +dbus (receive, send) bus=session path=/com/canonical/Autopilot/**, +/tmp/adt-run.** r, +EOF + +# If .rules file already exists, we can assume aa-clickhook ran +# at least once, so we don't really have to use --force. +if [ $rules_file_exists = true ]; then + echo "Updating apparmor rules (lite)" + aa-clickhook --include=$RULES_FILE +else + echo "Updating apparmor rules (will take a minute)..." + aa-clickhook --force --include=$RULES_FILE +fi