buildinstall: Allow customizing dracut arguments

JIRA: COMPOSE-3853
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2019-10-09 10:54:48 +02:00
parent 908a6a759d
commit c346492df4
6 changed files with 71 additions and 37 deletions

View File

@ -538,6 +538,10 @@ Options
* ``rootfs_size`` -- [*int*] (default empty)
* ``version`` -- [*str*] (default from ``release_version``) -- used as
``--version`` and ``--release`` argument on the lorax command line
* ``dracut_args`` -- [*[str]*] (default empty) override arguments for
dracut. Please note that if this option is used, lorax will not use any
other arguments, so you have to provide a full list and can not just
add something.
**lorax_extra_sources**
(*list*) -- a variant/arch mapping with urls for extra source repositories
added to Lorax command line. Either one repo or a list can be specified.

View File

@ -1205,6 +1205,7 @@ def make_schema():
'add_arch_template_var': {"$ref": "#/definitions/list_of_strings"},
"rootfs_size": {"type": "integer"},
"version": {"type": "string"},
"dracut_args": {"$ref": "#/definitions/list_of_strings"},
},
"additionalProperties": False,
}),

View File

@ -70,6 +70,7 @@ class BuildinstallPhase(PhaseBase):
add_arch_template = []
add_template_var = []
add_arch_template_var = []
dracut_args = []
rootfs_size = None
version = self.compose.conf["release_version"]
for data in get_arch_variant_data(self.compose.conf, 'lorax_options', arch, variant):
@ -85,6 +86,7 @@ class BuildinstallPhase(PhaseBase):
add_arch_template.extend(data.get('add_arch_template', []))
add_template_var.extend(data.get('add_template_var', []))
add_arch_template_var.extend(data.get('add_arch_template_var', []))
dracut_args.extend(data.get("dracut_args", []))
if "version" in data:
version = data["version"]
output_dir = os.path.join(output_dir, variant.uid)
@ -112,25 +114,28 @@ class BuildinstallPhase(PhaseBase):
repos.append(comps_repo)
lorax = LoraxWrapper()
lorax_cmd = lorax.get_lorax_cmd(self.compose.conf["release_name"],
version,
version,
repos,
output_dir,
variant=variant.uid,
buildinstallpackages=variant.buildinstallpackages,
is_final=self.compose.supported,
buildarch=buildarch,
volid=volid,
nomacboot=nomacboot,
bugurl=bugurl,
add_template=add_template,
add_arch_template=add_arch_template,
add_template_var=add_template_var,
add_arch_template_var=add_arch_template_var,
noupgrade=noupgrade,
rootfs_size=rootfs_size,
log_dir=log_dir)
lorax_cmd = lorax.get_lorax_cmd(
self.compose.conf["release_name"],
version,
version,
repos,
output_dir,
variant=variant.uid,
buildinstallpackages=variant.buildinstallpackages,
is_final=self.compose.supported,
buildarch=buildarch,
volid=volid,
nomacboot=nomacboot,
bugurl=bugurl,
add_template=add_template,
add_arch_template=add_arch_template,
add_template_var=add_template_var,
add_arch_template_var=add_arch_template_var,
noupgrade=noupgrade,
rootfs_size=rootfs_size,
log_dir=log_dir,
dracut_args=dracut_args,
)
return 'rm -rf %s && %s' % (shlex_quote(output_topdir),
' '.join([shlex_quote(x) for x in lorax_cmd]))

View File

@ -27,7 +27,8 @@ class LoraxWrapper(object):
add_template=None, add_arch_template=None,
add_template_var=None, add_arch_template_var=None,
rootfs_size=None,
log_dir=None):
log_dir=None,
dracut_args=None):
cmd = ["lorax"]
cmd.append("--product=%s" % product)
cmd.append("--version=%s" % version)
@ -71,6 +72,9 @@ class LoraxWrapper(object):
if rootfs_size is not None:
cmd.append('--rootfs-size=%s' % (rootfs_size))
for i in force_list(dracut_args or []):
cmd.append("--dracut-arg=%s" % i)
output_dir = os.path.abspath(output_dir)
cmd.append(output_dir)

View File

@ -124,7 +124,8 @@ class TestBuildinstallPhase(PungiTestCase):
add_template=[], add_arch_template=[],
add_template_var=[], add_arch_template_var=[],
rootfs_size=None,
log_dir=self.topdir + '/logs/x86_64/buildinstall-Server-logs'),
log_dir=self.topdir + "/logs/x86_64/buildinstall-Server-logs",
dracut_args=[]),
mock.call('Test', '1', '1',
[self.topdir + "/work/amd64/repo/p1",
self.topdir + "/work/amd64/repo/p2",
@ -136,7 +137,8 @@ class TestBuildinstallPhase(PungiTestCase):
add_template=[], add_arch_template=[],
add_template_var=[], add_arch_template_var=[],
rootfs_size=None,
log_dir=self.topdir + '/logs/amd64/buildinstall-Server-logs'),
log_dir=self.topdir + "/logs/amd64/buildinstall-Server-logs",
dracut_args=[]),
mock.call('Test', '1', '1',
[self.topdir + "/work/amd64/repo/p1",
self.topdir + "/work/amd64/repo/p2",
@ -148,7 +150,8 @@ class TestBuildinstallPhase(PungiTestCase):
add_template=[], add_arch_template=[],
add_template_var=[], add_arch_template_var=[],
rootfs_size=None,
log_dir=self.topdir + '/logs/amd64/buildinstall-Client-logs')])
log_dir=self.topdir + "/logs/amd64/buildinstall-Client-logs",
dracut_args=[])])
six.assertCountEqual(
self,
get_volid.mock_calls,
@ -195,7 +198,8 @@ class TestBuildinstallPhase(PungiTestCase):
add_template=[], add_arch_template=[],
add_template_var=[], add_arch_template_var=[],
rootfs_size=None,
log_dir=self.topdir + '/logs/amd64/buildinstall-Client-logs')],
log_dir=self.topdir + "/logs/amd64/buildinstall-Client-logs",
dracut_args=[])],
any_order=True)
self.assertEqual(
get_volid.mock_calls,
@ -261,6 +265,7 @@ class TestBuildinstallPhase(PungiTestCase):
'add_arch_template_var': ['quux=2'],
"rootfs_size": 3,
"version": "1.2.3",
"dracut_args": ["--xz", "--install", "/.buildstamp"],
},
'amd64': {'noupgrade': False}
}),
@ -303,7 +308,8 @@ class TestBuildinstallPhase(PungiTestCase):
add_template_var=['baz=1'], add_arch_template_var=['quux=2'],
bugurl='http://example.com',
rootfs_size=3,
log_dir=self.topdir + '/logs/x86_64/buildinstall-Server-logs'),
log_dir=self.topdir + "/logs/x86_64/buildinstall-Server-logs",
dracut_args=["--xz", "--install", "/.buildstamp"]),
mock.call('Test', '1', '1',
[self.topdir + "/work/amd64/repo/p1",
self.topdir + '/work/amd64/comps_repo_Server'],
@ -314,7 +320,8 @@ class TestBuildinstallPhase(PungiTestCase):
add_template=[], add_arch_template=[],
add_template_var=[], add_arch_template_var=[],
rootfs_size=None,
log_dir=self.topdir + '/logs/amd64/buildinstall-Server-logs'),
log_dir=self.topdir + "/logs/amd64/buildinstall-Server-logs",
dracut_args=[]),
mock.call('Test', '1', '1',
[self.topdir + "/work/amd64/repo/p1",
self.topdir + '/work/amd64/comps_repo_Client'],
@ -325,7 +332,8 @@ class TestBuildinstallPhase(PungiTestCase):
add_template=[], add_arch_template=[],
add_template_var=[], add_arch_template_var=[],
rootfs_size=None,
log_dir=self.topdir + '/logs/amd64/buildinstall-Client-logs')])
log_dir=self.topdir + "/logs/amd64/buildinstall-Client-logs",
dracut_args=[])])
six.assertCountEqual(
self,
get_volid.mock_calls,
@ -383,7 +391,8 @@ class TestBuildinstallPhase(PungiTestCase):
add_template=[], add_arch_template=[],
add_template_var=[], add_arch_template_var=[],
rootfs_size=None,
log_dir=self.topdir + '/logs/x86_64/buildinstall-Server-logs'),
log_dir=self.topdir + "/logs/x86_64/buildinstall-Server-logs",
dracut_args=[]),
mock.call('Test', '1', '1',
[self.topdir + "/work/amd64/repo/p1",
self.topdir + '/work/amd64/comps_repo_Server'],
@ -394,7 +403,8 @@ class TestBuildinstallPhase(PungiTestCase):
add_template=[], add_arch_template=[],
add_template_var=[], add_arch_template_var=[],
rootfs_size=None,
log_dir=self.topdir + '/logs/amd64/buildinstall-Server-logs'),
log_dir=self.topdir + "/logs/amd64/buildinstall-Server-logs",
dracut_args=[]),
mock.call('Test', '1', '1',
[self.topdir + "/work/amd64/repo/p1",
self.topdir + '/work/amd64/comps_repo_Client'],
@ -405,7 +415,8 @@ class TestBuildinstallPhase(PungiTestCase):
add_template=[], add_arch_template=[],
add_template_var=[], add_arch_template_var=[],
rootfs_size=None,
log_dir=self.topdir + '/logs/amd64/buildinstall-Client-logs')])
log_dir=self.topdir + "/logs/amd64/buildinstall-Client-logs",
dracut_args=[])])
six.assertCountEqual(
self,
get_volid.mock_calls,
@ -463,7 +474,8 @@ class TestBuildinstallPhase(PungiTestCase):
add_template_var=[], add_arch_template_var=[],
bugurl=None,
rootfs_size=None,
log_dir=buildinstall_topdir + '/x86_64/Server/logs'),
log_dir=buildinstall_topdir + "/x86_64/Server/logs",
dracut_args=[]),
mock.call('Test', '1', '1',
["http://localhost/work/amd64/repo/p1",
'http://localhost/work/amd64/comps_repo_Server'],
@ -474,7 +486,8 @@ class TestBuildinstallPhase(PungiTestCase):
add_template=[], add_arch_template=[],
add_template_var=[], add_arch_template_var=[],
rootfs_size=None,
log_dir=buildinstall_topdir + '/amd64/Server/logs'),
log_dir=buildinstall_topdir + "/amd64/Server/logs",
dracut_args=[]),
mock.call('Test', '1', '1',
["http://localhost/work/amd64/repo/p1",
'http://localhost/work/amd64/comps_repo_Client'],
@ -485,7 +498,8 @@ class TestBuildinstallPhase(PungiTestCase):
add_template=[], add_arch_template=[],
add_template_var=[], add_arch_template_var=[],
rootfs_size=None,
log_dir=buildinstall_topdir + '/amd64/Client/logs')])
log_dir=buildinstall_topdir + "/amd64/Client/logs",
dracut_args=[])])
six.assertCountEqual(
self,
get_volid.mock_calls,
@ -535,7 +549,8 @@ class TestBuildinstallPhase(PungiTestCase):
add_template_var=[], add_arch_template_var=[],
bugurl=None,
rootfs_size=None,
log_dir=self.topdir + '/logs/x86_64/buildinstall-Server-logs'),
log_dir=self.topdir + "/logs/x86_64/buildinstall-Server-logs",
dracut_args=[]),
mock.call('Test', '1', '1',
[self.topdir + "/work/amd64/repo/p1",
self.topdir + '/work/amd64/comps_repo_Server'],
@ -546,7 +561,8 @@ class TestBuildinstallPhase(PungiTestCase):
add_template=[], add_arch_template=[],
add_template_var=[], add_arch_template_var=[],
rootfs_size=None,
log_dir=self.topdir + '/logs/amd64/buildinstall-Server-logs'),
log_dir=self.topdir + "/logs/amd64/buildinstall-Server-logs",
dracut_args=[]),
mock.call('Test', '1', '1',
[self.topdir + "/work/amd64/repo/p1",
"http://example.com/repo2",
@ -559,7 +575,8 @@ class TestBuildinstallPhase(PungiTestCase):
add_template=[], add_arch_template=[],
add_template_var=[], add_arch_template_var=[],
rootfs_size=None,
log_dir=self.topdir + '/logs/amd64/buildinstall-Client-logs')])
log_dir=self.topdir + "/logs/amd64/buildinstall-Client-logs",
dracut_args=[])])
@mock.patch(

View File

@ -46,7 +46,8 @@ class LoraxWrapperTest(unittest.TestCase):
add_arch_template=['ta1', 'ta2'],
add_template_var=['v1', 'v2'],
add_arch_template_var=['va1', 'va2'],
log_dir='/tmp')
log_dir="/tmp",
dracut_args=["--foo", "bar"])
self.assertEqual(cmd[0], 'lorax')
six.assertCountEqual(
@ -64,5 +65,7 @@ class LoraxWrapperTest(unittest.TestCase):
"--add-template-var=v1", "--add-template-var=v2",
"--add-arch-template-var=va1", "--add-arch-template-var=va2",
"--logfile=/tmp/lorax.log",
"--dracut-arg=--foo",
"--dracut-arg=bar",
"/mnt/output_dir"],
)