summaryrefslogtreecommitdiff
path: root/vmdebootstrap
diff options
context:
space:
mode:
authorNeil Williams <codehelp@debian.org>2014-08-31 13:27:27 -0700
committerNeil Williams <codehelp@debian.org>2014-08-31 13:27:27 -0700
commit6e62b5502a892e4738137205cda39c61b1bf0eac (patch)
tree27a9a99cb2dabed61690f10e86a8eb51a4f1c8d4 /vmdebootstrap
parent7bdbcf07eac8f604b53d17444d004d4d6cbf2f4a (diff)
downloadvmdebootstrap-6e62b5502a892e4738137205cda39c61b1bf0eac.tar.gz
Add environment support to runcmd and pass noninteractive environment to second-stage as debootstrap does this automatically on native runs.
Diffstat (limited to 'vmdebootstrap')
-rwxr-xr-xvmdebootstrap31
1 files changed, 23 insertions, 8 deletions
diff --git a/vmdebootstrap b/vmdebootstrap
index 89739c5..694d1f6 100755
--- a/vmdebootstrap
+++ b/vmdebootstrap
@@ -199,11 +199,11 @@ class VmDebootstrap(cliapp.Application):
if self.settings['verbose']:
print msg
- def runcmd(self, argv, stdin='', ignore_fail=False, **kwargs):
- logging.debug('runcmd: %s %s' % (argv, kwargs))
+ def runcmd(self, argv, stdin='', ignore_fail=False, env=None, **kwargs):
+ logging.debug('runcmd: %s %s %s' % (argv, env, kwargs))
p = subprocess.Popen(argv, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
- **kwargs)
+ env=env, **kwargs)
out, err = p.communicate(stdin)
if p.returncode != 0:
msg = 'command failed: %s\n%s\n%s' % (argv, out, err)
@@ -304,8 +304,9 @@ class VmDebootstrap(cliapp.Application):
include.append('sudo')
args = ['debootstrap', '--arch=%s' % self.settings['arch']]
- args.append(
- '--include=%s' % ','.join(necessary_packages + include))
+ if self.settings['package'] and len(necessary_packages) > 0:
+ args.append(
+ '--include=%s' % ','.join(necessary_packages + include))
if self.settings['foreign']:
args.append('--foreign')
if self.settings['variant']:
@@ -316,13 +317,22 @@ class VmDebootstrap(cliapp.Application):
logging.debug(" ".join(args))
self.runcmd(args)
if self.settings['foreign']:
+ # set a noninteractive debconf environment for secondstage
+ env = {
+ "DEBIAN_FRONTEND": "noninteractive",
+ "DEBCONF_NONINTERACTIVE_SEEN": "true",
+ "LC_ALL": "C"
+ }
+ # add the mapping to the complete environment.
+ env.update(os.environ)
# First copy the binfmt handler over
self.message('Setting up binfmt handler')
shutil.copy(self.settings['foreign'], '%s/usr/bin/' % rootdir)
# Next, run the package install scripts etc.
self.message('Running debootstrap second stage')
self.runcmd(['chroot', rootdir,
- '/debootstrap/debootstrap', '--second-stage'])
+ '/debootstrap/debootstrap', '--second-stage'],
+ env=env)
def set_hostname(self, rootdir):
hostname = self.settings['hostname']
@@ -488,8 +498,13 @@ class VmDebootstrap(cliapp.Application):
return os.path.join('boot', basename)
raise cliapp.AppException('Cannot find match: %s' % pattern)
- kernel_image = find('vmlinuz-.*')
- initrd_image = find('initrd.img-.*')
+ try:
+ kernel_image = find('vmlinuz-.*')
+ initrd_image = find('initrd.img-.*')
+ except cliapp.AppException as e:
+ self.message("Unable to find kernel. Not installing extlinux.")
+ logging.debug("No kernel found. %s. Skipping install of extlinux." % e)
+ return
out = self.runcmd(['blkid', '-c', '/dev/null', '-o', 'value',
'-s', 'UUID', rootdev])