mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
WIP: Remove non-reproducible parts
This commit is contained in:
parent
f72adcf7c3
commit
c77ec24ce9
2 changed files with 17 additions and 4 deletions
|
@ -11,6 +11,8 @@ RUN \
|
|||
apt-get update && \
|
||||
apt-get install -y --no-install-recommends python3-fitz libreoffice-nogui libreoffice-java-common python3 python3-magic default-jdk-headless fonts-noto-cjk && \
|
||||
: "Clean up for improving reproducibility (optional)" && \
|
||||
rm -rf /var/cache/fontconfig/ && \
|
||||
rm -rf /etc/ssl/certs/java/cacerts && \
|
||||
rm -rf /var/log/* /var/cache/ldconfig/aux-cache /var/lib/apt/lists/*
|
||||
|
||||
RUN mkdir -p /opt/dangerzone/dangerzone && \
|
||||
|
@ -18,7 +20,7 @@ RUN mkdir -p /opt/dangerzone/dangerzone && \
|
|||
addgroup --gid 1000 dangerzone && \
|
||||
adduser --uid 1000 --ingroup dangerzone --shell /bin/true --home /home/dangerzone dangerzone
|
||||
|
||||
COPY conversion /opt/dangerzone/dangerzone/conversion
|
||||
COPY conversion/doc_to_pixels.py conversion/common.py conversion/errors.py conversion/__init__.py /opt/dangerzone/dangerzone/conversion
|
||||
|
||||
###########################################
|
||||
# gVisor wrapper image
|
||||
|
|
|
@ -8,6 +8,15 @@ DEFAULT_DPI = 150 # Pixels per inch
|
|||
INT_BYTES = 2
|
||||
|
||||
|
||||
class CommandError(RuntimeError):
|
||||
|
||||
def __init__(self, msg, stdout, stderr):
|
||||
self.stdout = stdout
|
||||
self.stderr = stderr
|
||||
msg += f"\n====\nCommand output:\n{stdout}\n=====\nCommand stderr:\n{stderr}\n======"
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
def running_on_qubes() -> bool:
|
||||
# https://www.qubes-os.org/faq/#what-is-the-canonical-way-to-detect-qubes-vm
|
||||
return os.path.exists("/usr/share/qubes/marker-vm")
|
||||
|
@ -96,7 +105,7 @@ class DangerzoneConverter:
|
|||
Run a command using asyncio.subprocess, consume its standard streams, and return its
|
||||
output in bytes.
|
||||
|
||||
:raises RuntimeError: if the process returns a non-zero exit status
|
||||
:raises CommandError: if the process returns a non-zero exit status
|
||||
"""
|
||||
# Start the provided command, and return a handle. The command will run in the
|
||||
# background.
|
||||
|
@ -125,13 +134,15 @@ class DangerzoneConverter:
|
|||
# Wait until the command has finished. Then, verify that the command
|
||||
# has completed successfully. In any other case, raise an exception.
|
||||
ret = await proc.wait()
|
||||
if ret != 0:
|
||||
raise RuntimeError(error_message)
|
||||
|
||||
# Wait until the tasks that consume the command's standard streams have exited as
|
||||
# well, and return their output.
|
||||
stdout = await stdout_task
|
||||
stderr = await stderr_task
|
||||
|
||||
if ret != 0:
|
||||
raise CommandError(error_message, stdout, stderr)
|
||||
|
||||
return (stdout, stderr)
|
||||
|
||||
@abstractmethod
|
||||
|
|
Loading…
Reference in a new issue