aboutsummaryrefslogtreecommitdiff
path: root/tests/docker
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2020-04-22 12:19:43 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2020-06-10 12:09:31 -0400
commitaf509738f8e4400c26d321abeac924efb04fbfa0 (patch)
tree8e63fabbd613b12d3d4a3e8ec7f68b09a3d31d28 /tests/docker
parentdfae62845961556935c6b8ccbb4285d4688c42b4 (diff)
downloadqemu-af509738f8e4400c26d321abeac924efb04fbfa0.zip
qemu-af509738f8e4400c26d321abeac924efb04fbfa0.tar.gz
qemu-af509738f8e4400c26d321abeac924efb04fbfa0.tar.bz2
docker.py/build: support binary files in --extra-files
Read the --extra-files in binary mode to avoid encoding errors. Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tests/docker')
-rwxr-xr-xtests/docker/docker.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/docker/docker.py b/tests/docker/docker.py
index d96ccc9..e630aae 100755
--- a/tests/docker/docker.py
+++ b/tests/docker/docker.py
@@ -56,15 +56,19 @@ class EngineEnum(enum.IntEnum):
USE_ENGINE = EngineEnum.AUTO
+def _bytes_checksum(bytes):
+ """Calculate a digest string unique to the text content"""
+ return hashlib.sha1(bytes).hexdigest()
+
def _text_checksum(text):
"""Calculate a digest string unique to the text content"""
- return hashlib.sha1(text.encode('utf-8')).hexdigest()
+ return _bytes_checksum(text.encode('utf-8'))
def _read_dockerfile(path):
return open(path, 'rt', encoding='utf-8').read()
def _file_checksum(filename):
- return _text_checksum(_read_dockerfile(filename))
+ return _bytes_checksum(open(filename, 'rb').read())
def _guess_engine_command():