chiark / gitweb /
adt-run: Reset changes made to the apt configuration, on exit
authorTimo Juhani Lindfors <timo.lindfors@iki.fi>
Mon, 17 Oct 2011 20:50:26 +0000 (21:50 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 17 Oct 2011 20:50:26 +0000 (21:50 +0100)
After this change running
  adt-run --quiet --no-built-binaries hello_2.6-1.dsc --- adt-virt-null
  find /etc -name "*autopkgtest*"
does not print any files.

[ Ideally we would leave these config file settings somewhere where
  apt won't find them unless it's told to.  That way if adt-run crashes
  for any reason, we wouldn't be relying on this cleanup code, and we
  could remove it.

  However, when I tried to do this I found I couldn't get apt to
  reliably pick up all the files I needed using command line options.
  So this is an improvement for now.  -iwj ]

runner/adt-run

index 91102366944022390d887441def76ba4936354b2..310c39ae8f9aea32abd191c247c602873b874240 100755 (executable)
@@ -816,6 +816,14 @@ exec '''+shellquote_cmdl(cmdl)+' "$@"'+"\n"
        if rc:
                pstderr("\n" "warning: failed to restore"
                        " testbed apt cache, exit code %d" % rc)
+       what = 'aptconf-reset'
+       cmdl = ['rm','-f','/etc/apt/apt.conf.d/90autopkgtest',
+               '/etc/apt/sources.list.d/autopkgtest.list',
+               '/etc/apt/preferences.d/90autopkgtest']
+       rc = tb.execute(what, cmdl, kind='install')
+       if rc:
+               pstderr("\n" "warning: failed to reset changes"
+                       " made to testbed apt configuration, exit code %d" % rc)
        tb._need_reset_apt = False
  def close(tb):
        tb._debug('close, scratch=%s' % tb.scratch)