mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
container: Factor out loading an image tarball
This commit is contained in:
parent
6b51d56e9f
commit
20152fac13
1 changed files with 18 additions and 8 deletions
|
@ -227,16 +227,14 @@ class Container(IsolationProvider):
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def install() -> bool:
|
def get_expected_tag() -> str:
|
||||||
"""
|
"""Get the tag of the Dangerzone image tarball from the image-id.txt file."""
|
||||||
Make sure the podman container is installed. Linux only.
|
with open(get_resource_path("image-id.txt")) as f:
|
||||||
"""
|
return f.read.strip()
|
||||||
if Container.is_container_installed():
|
|
||||||
return True
|
|
||||||
|
|
||||||
# Load the container into podman
|
@staticmethod
|
||||||
|
def load_image_tarball() -> None:
|
||||||
log.info("Installing Dangerzone container image...")
|
log.info("Installing Dangerzone container image...")
|
||||||
|
|
||||||
p = subprocess.Popen(
|
p = subprocess.Popen(
|
||||||
[Container.get_runtime(), "load"],
|
[Container.get_runtime(), "load"],
|
||||||
stdin=subprocess.PIPE,
|
stdin=subprocess.PIPE,
|
||||||
|
@ -263,6 +261,18 @@ class Container(IsolationProvider):
|
||||||
f"Could not install container image: {error}"
|
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):
|
if not Container.is_container_installed(raise_on_error=True):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue