1 From: Stanislaw Kardach <stanislaw.kardach@cavium.com>
2 Date: Thu, 25 Feb 2016 13:38:14 +0100
3 Subject: [PATCH] Use qemu-debootstrap for image creation
5 This commit adds qemu-debootstrap support and a command line argument
6 `target_arch` which can be used for choosing the architecture to build
7 the image for. The architecture detection from environment settings is
10 .../fuel_bootstrap_cli/fuel_bootstrap/commands/build.py | 8 ++++++++
11 .../fuel_bootstrap/utils/bootstrap_image.py | 3 ++-
13 fuel_agent/manager.py | 13 ++++++++++++-
14 fuel_agent/tests/test_build_utils.py | 4 ++--
15 fuel_agent/utils/build.py | 2 +-
16 specs/fuel-agent.spec | 2 ++
17 7 files changed, 29 insertions(+), 5 deletions(-)
19 diff --git a/contrib/fuel_bootstrap/fuel_bootstrap_cli/fuel_bootstrap/commands/build.py b/contrib/fuel_bootstrap/fuel_bootstrap_cli/fuel_bootstrap/commands/build.py
20 index b4e9a05..a22d319 100644
21 --- a/contrib/fuel_bootstrap/fuel_bootstrap_cli/fuel_bootstrap/commands/build.py
22 +++ b/contrib/fuel_bootstrap/fuel_bootstrap_cli/fuel_bootstrap/commands/build.py
23 @@ -171,6 +171,14 @@ class BuildCommand(command.Command):
24 " by ssh still rejected by default! This password actual"
25 " only for tty login!"),
27 + parser.add_argument(
30 + choices=['arm64', 'amd64'],
31 + help="Choose the target architecture for which image is built",
37 def take_action(self, parsed_args):
38 diff --git a/contrib/fuel_bootstrap/fuel_bootstrap_cli/fuel_bootstrap/utils/bootstrap_image.py b/contrib/fuel_bootstrap/fuel_bootstrap_cli/fuel_bootstrap/utils/bootstrap_image.py
39 index c09d421..a535075 100644
40 --- a/contrib/fuel_bootstrap/fuel_bootstrap_cli/fuel_bootstrap/utils/bootstrap_image.py
41 +++ b/contrib/fuel_bootstrap/fuel_bootstrap_cli/fuel_bootstrap/utils/bootstrap_image.py
42 @@ -161,7 +161,8 @@ def make_bootstrap(data):
44 LOG.info("Try to build image with data:\n%s", yaml.safe_dump(bootdata))
46 - opts = ['--data_driver', 'bootstrap_build_image']
47 + opts = ['--data_driver', 'bootstrap_build_image',
48 + '--target_arch', data['target_arch']]
49 if data.get('image_build_dir'):
50 opts.extend(['--image_build_dir', data['image_build_dir']])
52 diff --git a/debian/control b/debian/control
53 index d24450c..e843980 100644
56 @@ -37,6 +37,8 @@ Pre-Depends: dpkg (>= 1.15.6~)
65 diff --git a/fuel_agent/manager.py b/fuel_agent/manager.py
66 index df54f65..ba1ab78 100644
67 --- a/fuel_agent/manager.py
68 +++ b/fuel_agent/manager.py
69 @@ -19,6 +19,7 @@ import signal
72 from oslo_config import cfg
73 from oslo_log import log as logging
74 +from oslo_config import types
77 @@ -34,5 +35,7 @@ from fuel_agent.utils import md as mu
78 from fuel_agent.utils import utils
80 +ArchType = types.String(choices=['amd64', 'arm64'])
85 @@ -192,6 +195,13 @@ cli_opts = [
87 help='Directory where the image is supposed to be built',
93 + help='Architecture for which image will be built using '
99 @@ -724,7 +734,8 @@ class Manager(object):
100 LOG.debug('Preventing services from being get started')
101 bu.suppress_services_start(chroot)
102 LOG.debug('Installing base operating system using debootstrap')
103 - bu.run_debootstrap(uri=uri, suite=suite, chroot=chroot,
104 + bu.run_debootstrap(uri=uri, suite=suite, arch=CONF.target_arch,
106 attempts=CONF.fetch_packages_attempts,
107 proxies=proxies.proxies,
108 direct_repo_addr=proxies.direct_repo_addr_list)
109 diff --git a/fuel_agent/tests/test_build_utils.py b/fuel_agent/tests/test_build_utils.py
110 index 54f79f9..0ec466f 100644
111 --- a/fuel_agent/tests/test_build_utils.py
112 +++ b/fuel_agent/tests/test_build_utils.py
113 @@ -43,7 +43,7 @@ class BuildUtilsTestCase(unittest2.TestCase):
114 def test_run_debootstrap(self, mock_exec, mock_environ):
115 bu.run_debootstrap('uri', 'suite', 'chroot', 'arch', attempts=2)
116 mock_exec.assert_called_once_with(
117 - 'debootstrap', '--include={0}'
118 + 'qemu-debootstrap', '--include={0}'
119 .format(','.join(bu.ADDITIONAL_DEBOOTSTRAP_PACKAGES)),
120 '--verbose', '--no-check-gpg', '--arch=arch',
121 'suite', 'chroot', 'uri', attempts=2, env_variables={})
122 @@ -54,7 +54,7 @@ class BuildUtilsTestCase(unittest2.TestCase):
123 bu.run_debootstrap('uri', 'suite', 'chroot', 'arch', eatmydata=True,
125 mock_exec.assert_called_once_with(
126 - 'debootstrap', '--include={0}'
127 + 'qemu-debootstrap', '--include={0}'
128 .format(','.join(bu.ADDITIONAL_DEBOOTSTRAP_PACKAGES)),
129 '--verbose', '--no-check-gpg', '--arch=arch',
130 '--include=eatmydata', 'suite',
131 diff --git a/fuel_agent/utils/build.py b/fuel_agent/utils/build.py
132 index b1ecc0f..2950ad8 100644
133 --- a/fuel_agent/utils/build.py
134 +++ b/fuel_agent/utils/build.py
135 @@ -76,7 +76,7 @@ def run_debootstrap(uri, suite, chroot, arch='amd64', eatmydata=False,
136 env_vars['no_proxy'] = ','.join(direct_repo_addr)
137 LOG.debug('Setting no_proxy for: {0}'.format(env_vars['no_proxy']))
139 - cmds = ['debootstrap',
140 + cmds = ['qemu-debootstrap',
141 '--include={0}'.format(",".join(ADDITIONAL_DEBOOTSTRAP_PACKAGES)),
142 '--verbose', '--no-check-gpg',
143 '--arch={0}'.format(arch)]
144 diff --git a/specs/fuel-agent.spec b/specs/fuel-agent.spec
145 index 72cd6a1..18af4b9 100644
146 --- a/specs/fuel-agent.spec
147 +++ b/specs/fuel-agent.spec
148 @@ -50,6 +50,8 @@ Requires: xfsprogs
151 Requires: debootstrap
153 +Requires: qemu-user-static