import logging
import os
import re
-import time
import shutil
import subprocess
import tempfile
class VmDebootstrap(cliapp.Application):
def add_settings(self):
- default_arch = self.runcmd(
- ["dpkg", "--print-architecture"],
- ignore_fail=False).strip()
+ default_arch = subprocess.check_output(
+ ["dpkg", "--print-architecture"]).strip()
self.settings.boolean(['verbose'], 'report what is going on')
self.settings.string(['image'], 'put created disk image in FILE',
self.runcmd(args)
if self.settings['foreign']:
# 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')
def customize(self, rootdir):
script = self.settings['customize']
- if script:
- self.message('Running customize script %s' % script)
- with open('/dev/tty', 'w') as tty:
- cliapp.runcmd([script, rootdir], stdout=tty, stderr=tty)
+ if not script:
+ return
+ if not os.path.exists(script):
+ example = os.path.join("/usr/share/vmdebootstrap/examples/", script)
+ if not os.path.exists(example):
+ self.message("Unable to find %s" % script)
+ return
+ script = example
+ self.message('Running customize script %s' % script)
+ with open('/dev/tty', 'w') as tty:
+ cliapp.runcmd([script, rootdir], stdout=tty, stderr=tty)
def create_tarball(self, rootdir):
# Create a tarball of the disk's contents