diff --git a/providers/ec2/tasks/bootstrap.py b/common/tasks/bootstrap.py similarity index 100% rename from providers/ec2/tasks/bootstrap.py rename to common/tasks/bootstrap.py diff --git a/providers/ec2/__init__.py b/providers/ec2/__init__.py index a4e6954..5bd1c27 100644 --- a/providers/ec2/__init__.py +++ b/providers/ec2/__init__.py @@ -7,7 +7,7 @@ from tasks import ami from tasks import ebs from tasks import loopback from tasks import filesystem -from tasks import bootstrap +from common.tasks import bootstrap from tasks import locale from common.tasks import apt from tasks import boot diff --git a/providers/raw/__init__.py b/providers/raw/__init__.py index 7614d0e..c8ebc31 100644 --- a/providers/raw/__init__.py +++ b/providers/raw/__init__.py @@ -3,7 +3,7 @@ import logging from tasks import packages from tasks import host from tasks import filesystem -from tasks import bootstrap +from common.tasks import bootstrap from tasks import locale from common.tasks import apt from tasks import boot diff --git a/providers/raw/tasks/bootstrap.py b/providers/raw/tasks/bootstrap.py deleted file mode 100644 index 9b405b0..0000000 --- a/providers/raw/tasks/bootstrap.py +++ /dev/null @@ -1,58 +0,0 @@ -from base import Task -from common import phases -from common.exceptions import TaskError -import logging -log = logging.getLogger(__name__) - - -def get_bootstrap_args(info): - mirror = 'http://http.debian.net/debian' - if info.manifest.system['mirror']: - mirror = info.manifest.system['mirror'] - - executable = ['/usr/sbin/debootstrap'] - options = ['--arch=' + info.manifest.system['architecture']] - include, exclude = info.img_packages - if len(include) > 0: - options.append('--include=' + ','.join(include)) - if len(exclude) > 0: - options.append('--exclude=' + ','.join(exclude)) - arguments = [info.manifest.system['release'], info.root, mirror] - return executable, options, arguments - - -class MakeTarball(Task): - description = 'Creating bootstrap tarball' - phase = phases.os_installation - - def run(self, info): - from hashlib import sha1 - import os.path - executable, options, arguments = get_bootstrap_args(info) - # Filter info.root which points at /target/volume-id, we won't ever hit anything with that in there. - hash_args = [arg for arg in arguments if arg != info.root] - tarball_id = sha1(repr(frozenset(options + hash_args))).hexdigest()[0:8] - tarball_filename = 'debootstrap-{id}.tar'.format(id=tarball_id) - info.tarball = os.path.join(info.manifest.bootstrapper['tarball_dir'], tarball_filename) - if os.path.isfile(info.tarball): - log.debug('Found matching tarball, skipping download') - else: - from common.tools import log_call - status, out, err = log_call(executable + options + ['--make-tarball=' + info.tarball] + arguments) - if status != 1: - msg = 'debootstrap exited with status {status}, it should exit with status 1'.format(status=status) - raise TaskError(msg) - - -class Bootstrap(Task): - description = 'Installing Debian' - phase = phases.os_installation - after = [MakeTarball] - - def run(self, info): - executable, options, arguments = get_bootstrap_args(info) - if hasattr(info, 'tarball'): - options.extend(['--unpack-tarball=' + info.tarball]) - - from common.tools import log_check_call - log_check_call(executable + options + arguments)