container: Factor out loading an image tarball

This commit is contained in:
Alex Pyrgiotis 2024-12-02 16:30:43 +02:00
parent 6b51d56e9f
commit 20152fac13
No known key found for this signature in database
GPG key ID: B6C15EBA0357C9AA

View file

@ -227,16 +227,14 @@ class Container(IsolationProvider):
)
@staticmethod
def install() -> bool:
"""
Make sure the podman container is installed. Linux only.
"""
if Container.is_container_installed():
return True
def get_expected_tag() -> str:
"""Get the tag of the Dangerzone image tarball from the image-id.txt file."""
with open(get_resource_path("image-id.txt")) as f:
return f.read.strip()
# Load the container into podman
@staticmethod
def load_image_tarball() -> None:
log.info("Installing Dangerzone container image...")
p = subprocess.Popen(
[Container.get_runtime(), "load"],
stdin=subprocess.PIPE,
@ -263,6 +261,18 @@ class Container(IsolationProvider):
f"Could not install container image: {error}"
)
log.info("Successfully installed container image from")
@staticmethod
def install() -> bool:
"""
Make sure the podman container is installed. Linux only.
"""
if Container.is_container_installed():
return True
Container.load_image_tarball()
if not Container.is_container_installed(raise_on_error=True):
return False