Source code for lwr.vm

# live-wrapper - Wrapper for vmdebootstrap for creating live images
# (C) Iain R. Learmonth 2015 <>
# See COPYING for terms of usage, modification and redistribution.
# lwr/ - vmdebootstrap helpers

The lwr.vm module provides helpers for calling vmdebootstrap as part of the
image creation process.

Directory listing of /live/

.. note::
    This module requires that the vmdebootstrap modules be available in the
    Python path.

import os
from vmdebootstrap.base import runcmd

# pylint: disable=superfluous-parens,missing-docstring,too-few-public-methods

[docs]class VMDebootstrap(object): def __init__(self, distribution, architecture, mirror=None, cdroot='/tmp/'): self.cdroot = cdroot # FIXME: The customise script needs to be specified in the command line # arguments, falling back to /usr/share/vmdebootstrap/hooks/ # if no script is specified and hooks/ does not exist in # the current directory. self.args = ["vmdebootstrap", "--sudo", "--lock-root-password", "--arch", architecture, "--enable-dhcp", "--configure-apt", "--verbose", "--log", "vmdebootstrap.log", "--squash=%s" % os.path.join(self.cdroot, 'live'), "--log-level", "debug"] self.args.extend(["--distribution", distribution]) self.args.extend(["--mirror", mirror]) # FIXME: apt-mirror is for what the booted image will use # this needs to be accessible over http://, not just file:// # FIXME: this should be declared in the command line args for lwr self.args.extend(["--apt-mirror", '']) # FIXME: Logging should happen here if os.path.exists(os.path.join(".", "hooks", "")): self.args.extend(["--customise", "hooks/"]) elif os.path.exists("/usr/share/live-wrapper/"): self.args.extend(["--customise", "/usr/share/live-wrapper/"]) else: raise cliapp.AppException("Could not locate")
[docs] def run(self): print(' '.join(self.args)) runcmd(self.args) # FIXME: may want to use a method which prints output in realtime print('vmdebootstrap complete')
[docs]def detect_kernels(cdroot): versions = [] filenames = os.listdir(os.path.join(cdroot, "live")) for filename in filenames: if filename[0:8] == "vmlinuz-": versions.append(filename[8:]) return versions