Skip to content

Commit

Permalink
support not touching partitions in lib.virt.Kickstart
Browse files Browse the repository at this point in the history
This fixes a bug where the translate_* functions would add their
own partitions, and class Kickstart would also append its own
'part / --size=1 --grow' line, breaking the kickstart.

Signed-off-by: Jiri Jaburek <[email protected]>
  • Loading branch information
comps authored and mildas committed Oct 8, 2024
1 parent fb4ee5f commit e8b299e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/virt.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,21 @@ class Kickstart:
]

def __init__(self, template=TEMPLATE, packages=PACKAGES, partitions=None):
"""
You can override 'template' / 'packages' with your own copy of
self.TEMPLATE and self.PACKAGES.
Partitions should be specified as a list of (mntpoint,size) tuples,
where None (default) uses one partition for the entire OS and an empty
list doesn't add any partitions.
"""
self.ks = template
self.appends = []
self.packages = packages
self.partitions = partitions

def assemble(self):
if self.partitions:
if self.partitions is not None:
partitions_block = '\n'.join(
(f'part {mountpoint} --size={size}' for mountpoint, size in self.partitions),
)
Expand Down Expand Up @@ -847,7 +855,7 @@ def translate_ssg_kickstart(ks_file):

# leave original %packages - Anaconda can handle multiple %packages sections
# just fine (when we later add ours during installation)
return Kickstart(template=ks_text)
return Kickstart(template=ks_text, partitions=[])


def translate_oscap_kickstart(lines, datastream):
Expand Down Expand Up @@ -891,7 +899,7 @@ def translate_oscap_kickstart(lines, datastream):

# leave original %packages - Anaconda can handle multiple %packages sections
# just fine (when we later add ours during installation)
return Kickstart(template=ks_text)
return Kickstart(template=ks_text, partitions=[])


#
Expand Down

0 comments on commit e8b299e

Please sign in to comment.