Skip to content

Commit

Permalink
allow RpmPack customization in lib.virt when installing
Browse files Browse the repository at this point in the history
This is mostly useful for debugging, or experimenting - recently used
to prototype ansible-playbook in Anaconda's %post, for which one needs
to add a playbook into the RpmPack.

Signed-off-by: Jiri Jaburek <[email protected]>
  • Loading branch information
comps authored and mildas committed Apr 24, 2024
1 parent df46b41 commit ede8abf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/virt.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def __init__(self, tag=None, *, name=GUEST_NAME):
# if exists, all snapshot preparation processes were successful
self.snapshot_ready_path = f'{GUEST_IMG_DIR}/{name}.ready'

def install(self, location=None, kickstart=None, disk_format='raw'):
def install(self, location=None, kickstart=None, rpmpack=None, disk_format='raw'):
"""
Install a new guest, to a shut down state.
Expand All @@ -355,6 +355,9 @@ def install(self, location=None, kickstart=None, disk_format='raw'):
a Kickstart class instance.
To customize the instance (ie. add code before/after code added by
member functions), subclass Kickstart and set __init__() or assemble().
If custom 'rpmpack' is specified (RpmPack instance), it is used instead
of a self-made instance.
"""
util.log(f"installing guest {self.name}")

Expand Down Expand Up @@ -396,7 +399,7 @@ def install(self, location=None, kickstart=None, disk_format='raw'):
with contextlib.ExitStack() as stack:
# create a custom RPM to run guest setup scripts via RPM scriptlets
# and install it during Anaconda installation
pack = util.RpmPack()
pack = rpmpack or util.RpmPack()
pack.post.append(self.SETUP)
pack.requires += self.SETUP_REQUIRES
repo = stack.enter_context(pack.build_as_repo())
Expand Down

0 comments on commit ede8abf

Please sign in to comment.