Fix test regression (#905677)
If running as non-root, don't rely on being able to install build-dependencies. Packages that we unpack non-system-wide as non-root don't satisfy dpkg-checkbuilddeps, so running this test as non-root would result in a failed build: https://bugs.debian.org/905677
======================================================================
FAIL: test_tree_build_needed_success (__main__.NullRunner)
source tree, build-needed restriction, test success
----------------------------------------------------------------------
Traceback (most recent call last):
File "tests/autopkgtest", line 213, in test_tree_build_needed_success
self.assertEqual(code, 0, out + err)
AssertionError: 12 != 0 : blame: /tmp/autopkgtest.test.vhy8zxgq/testpkg
badpkg: rules build failed with exit code 3
autopkgtest [00:06:27]: git checkout: ac5842a Merge branch 'bts-905317-flaky-and-unsatisfiable-depends' into 'master'
autopkgtest [00:06:27]: host espresso; command line: /home/smcv/src/debian/autopkgtest/runner/autopkgtest --no-built-binaries /tmp/autopkgtest.test.vhy8zxgq/testpkg -- null
autopkgtest [00:06:27]: testbed dpkg architecture: amd64
autopkgtest [00:06:27]: testbed running kernel: Linux 4.17.0-1-amd64 #1 SMP Debian 4.17.8-1 (2018-07-20)
autopkgtest [00:06:27]: @@@@@@@@@@@@@@@@@@@@ unbuilt-tree /tmp/autopkgtest.test.vhy8zxgq/testpkg
autopkgtest [00:06:27]: testing package testpkg version 1
autopkgtest [00:06:27]: build needed for tests
Starting pkgProblemResolver with broken count: 0
Starting 2 pkgProblemResolver with broken count: 0
Done
autopkgtest: WARNING: virtualisation system does not offer root or writable testbed; unpacking dependencies to temporary dir, which will only work for some packages
Get:1 http://deb.debian.org/debian buster/main amd64 aspell-doc all 0.60.7~20110707-5 [259 kB]
Fetched 259 kB in 0s (0 B/s)
dpkg-buildpackage: info: source package testpkg
dpkg-buildpackage: info: source version 1
dpkg-buildpackage: info: source distribution UNRELEASED
dpkg-buildpackage: info: source changed by Martin Pitt <mpitt@debian.org>
dpkg-source --before-build real-tree
dpkg-buildpackage: info: host architecture amd64
dpkg-checkbuilddeps: error: Unmet build dependencies: aspell-doc
dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting
dpkg-buildpackage: warning: (Use -d flag to override.)
autopkgtest [00:06:30]: ERROR: erroneous package: rules build failed with exit code 3
Also skip the test entirely if aspell-doc is already installed and we are root: if we are running as root but aspell-doc was already installed, then dpkg wouldn't print "Unpacking aspell-doc" and the test will fail.
Edited by Simon McVittie