mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
Allow setting the compression level of the image
There are times where we may want to build the container image for testing, but compression takes too much time. If we don't plan to use this image for production builds, we can specify instead a compression level that is so low, that the image will be compressed instantly. In this commit, we allow the user to specify the Gzip compression level, and even set it to 0. The default will always be 9, so that we don't make a mistake during release.
This commit is contained in:
parent
a31f3370d0
commit
be8e2aa36b
1 changed files with 12 additions and 1 deletions
|
@ -28,6 +28,13 @@ def main():
|
||||||
action="store_true",
|
action="store_true",
|
||||||
help="Do not save the container image as a tarball in share/container.tar.gz",
|
help="Do not save the container image as a tarball in share/container.tar.gz",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--compress-level",
|
||||||
|
type=int,
|
||||||
|
choices=range(0, 10),
|
||||||
|
default=9,
|
||||||
|
help="The Gzip compression level, from 0 (lowest) to 9 (highest, default)",
|
||||||
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
print("Exporting container pip dependencies")
|
print("Exporting container pip dependencies")
|
||||||
|
@ -71,7 +78,11 @@ def main():
|
||||||
|
|
||||||
print("Compressing container image")
|
print("Compressing container image")
|
||||||
chunk_size = 4 << 20
|
chunk_size = 4 << 20
|
||||||
with gzip.open("share/container.tar.gz", "wb") as gzip_f:
|
with gzip.open(
|
||||||
|
"share/container.tar.gz",
|
||||||
|
"wb",
|
||||||
|
compresslevel=args.compress_level,
|
||||||
|
) as gzip_f:
|
||||||
while True:
|
while True:
|
||||||
chunk = cmd.stdout.read(chunk_size)
|
chunk = cmd.stdout.read(chunk_size)
|
||||||
if len(chunk) > 0:
|
if len(chunk) > 0:
|
||||||
|
|
Loading…
Reference in a new issue