chiark / gitweb /
Update python version to 2.6
[autopkgtest.git] / virt-subproc / adt-virt-chroot
index e5651e195eaac0f8f393109d3de630317743ba81..e5fa2e3924f7ae915cc2f09d255e9720867f1776 100755 (executable)
@@ -1,9 +1,9 @@
-#!/usr/bin/python2.4
+#!/usr/bin/python2.6
 #
 # adt-virt-chroot is part of autopkgtest
 # autopkgtest is a tool for testing Debian binary packages
 #
-# autopkgtest is Copyright (C) 2006 Canonical Ltd.
+# autopkgtest is Copyright (C) 2006-2007 Canonical Ltd.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 
 import sys
 import os
-
-try: our_base = os.environ['AUTOPKGTEST_BASE']
-except KeyError: our_base = '/usr/share/autopkgtest';
-sys.path.insert(1, our_base+'/python')
-
 import string
 from optparse import OptionParser
+
+try: our_base = os.environ['AUTOPKGTEST_BASE']+'/lib'
+except KeyError: our_base = '/usr/share/autopkgtest/python';
+sys.path.insert(1, our_base)
+
 import VirtSubproc as vsp
+capabilities = []
 
 def parse_args():
        global down, debuglevel
 
-       usage = "%prog [options] =<dchroot>|/path/to/chroot"
+       usage = "%prog [<options>] =<dchroot>|/path/to/chroot"
        parser = OptionParser(usage=usage)
        pa = parser.add_option
        pe = parser.error
@@ -51,29 +52,47 @@ def parse_args():
 
        chroot_arg = args[0]
        if not chroot_arg: pe("chroot specification may not be empty")
-       if chroot_arg == '=': down = ['dchroot','-q']
-       elif chroot_arg == '=': down = ['dchroot','-q']
-       elif chroot_arg[0] == '=': down = ['dchroot','-q','-c',chroot_arg[1:]]
-       elif chroot_arg[0] == '/': down = ['chroot',chroot_arg,'--']
-       else: pe("chroot spec must be =[DCHROOT] or /PATH/TO/CHROOT")
+       if chroot_arg == '=':
+               down = ['dchroot','-q','--']
+       elif chroot_arg == '=':
+               down = ['dchroot','-q','--']
+       elif chroot_arg[0] == '=':
+               down = ['dchroot','-q','-c',chroot_arg[1:],'--']
+       elif chroot_arg[0] == '/':
+               down = ['chroot',chroot_arg]
+       else:
+               pe("chroot spec must be =[DCHROOT] or /PATH/TO/CHROOT")
 
-       if opts.gain_root != None: down = opts.gain_root.split() + down
+       if down[0] == 'chroot':
+               vsp.downkind = 'auxverb'
+       elif down[0] == 'dchroot':
+               vsp.downkind = 'shstring'
+       else:
+               print >>sys.stderr, 'down[0]=%s' % `down[0]`
+               assert(False)
+
+       if opts.gain_root != None:
+               down = opts.gain_root.split() + down
+
+       if opts.gain_root or os.getuid()==0:
+               capabilities.append('root-on-testbed')
 
-       vsp.debug("down = %s" % string.join(down))
        vsp.down = down
 
 def hook_open():
-       global downtmp
-       vsp.execute('true', downp=True)
-       downtmp = vsp.execute('mktemp -t -d', downp=True, outp=True)
-       return downtmp
+       pass
 
-def hook_stop():
-       vsp.execute('rm -rf --', c[1:2])
-       os.mkdir(c[1])
+def hook_downtmp():
+       return vsp.downtmp_mktemp()
 
 def hook_cleanup():
-       vsp.execute('rm -rf --', [downtmp], downp=True)
+       vsp.downtmp_remove()
+
+def hook_forked_inchild():
+       pass
+
+def hook_capabilities():
+       return capabilities
 
 parse_args()
 vsp.main()