Package: autopkgtest
Severity: wishlist
Version: 2.0.1
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu ubuntu-patch precise

Hello,

for testing build recipes I'd like to skip all the apt parts and run
adt-run as normal user. This currently fails because it always tries
to set up apt.

Attached patch skips the apt parts if running as non-root and prints a
warning. The second hunk is necessary because opts.user defaults to
'', not to None, and thus "opts.user is not None" is always True and
it always tries to call su (which doesn't work as normal user).

Thanks,

Martin

-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
--- /usr/bin/adt-run.orig	2011-11-09 08:18:48.101899155 +0100
+++ /usr/bin/adt-run	2011-11-09 08:47:09.653981505 +0100
@@ -838,6 +838,9 @@
 		tb._opened(pl)
 	tb.modified = False
  def prepare2(tb, deps_new):
+	if os.getuid() != 0:
+	    pstderr("warning: running as normal user, skipping binary package install")
+	    return
 	tb._debug('prepare2, deps_new=%s' % deps_new, 1)
 	binaries.publish()
 	tb._install_deps(deps_new)
@@ -1149,7 +1152,7 @@
 	rc = testbed.execute('testchmod-'+t.what, ['chmod','+x','--',tf])
 	if rc: bomb('failed to chmod +x %s' % tf)
 
-	if 'needs-root' not in t.restriction_names and opts.user is not None:
+	if 'needs-root' not in t.restriction_names and opts.user:
 		tfl = ['su',opts.user,'-c',tf]
 		tmpdir = '%s%s-tmpdir' % (testbed.scratch.read(True), t.what)
 		script = 'rm -rf -- "$1"; mkdir -- "$1"'

Attachment: signature.asc
Description: Digital signature

Reply via email to