From cfaabe618f1df3fd927657b57a3fe92714e85f94 Mon Sep 17 00:00:00 2001 From: Luke Yang Date: Wed, 21 Feb 2024 10:55:49 -0500 Subject: [PATCH] stages/org.osbuild.gzip: add compression level option Allow compression level to be specified instead of defaulting to 1. This is needed for CoreOS Assembler. --- stages/org.osbuild.gzip | 10 +++++++++- test/data/stages/gzip/b.json | 3 ++- test/data/stages/gzip/b.mpp.yaml | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/stages/org.osbuild.gzip b/stages/org.osbuild.gzip index 66b1e678..60b71c5c 100755 --- a/stages/org.osbuild.gzip +++ b/stages/org.osbuild.gzip @@ -30,6 +30,13 @@ SCHEMA_2 = r""" "filename": { "description": "Filename to use for the compressed file", "type": "string" + }, + "level": { + "description": "Compression level", + "type": "integer", + "minimum": 1, + "maximum": 9, + "default": 1 } } } @@ -48,13 +55,14 @@ def parse_input(inputs): def main(inputs, output, options): filename = options["filename"].lstrip("/") + level = options.get("level", 1) source = parse_input(inputs) target = os.path.join(output, filename) with open(target, "w", encoding="utf8") as f: cmd = [ - "gzip", "--no-name", "--stdout", "-1", source + "gzip", "--no-name", "--stdout", f"-{level}", source ] subprocess.run( diff --git a/test/data/stages/gzip/b.json b/test/data/stages/gzip/b.json index bb0d968f..fdb0a8ba 100644 --- a/test/data/stages/gzip/b.json +++ b/test/data/stages/gzip/b.json @@ -883,7 +883,8 @@ } }, "options": { - "filename": "compressed.gz" + "filename": "compressed.gz", + "level": 9 } } ] diff --git a/test/data/stages/gzip/b.mpp.yaml b/test/data/stages/gzip/b.mpp.yaml index 9af0b4cc..7e7501c1 100644 --- a/test/data/stages/gzip/b.mpp.yaml +++ b/test/data/stages/gzip/b.mpp.yaml @@ -25,3 +25,4 @@ pipelines: sha256:f950375066d74787f31cbd8f9f91c71819357cad243fb9d4a0d9ef4fa76709e0: {} options: filename: compressed.gz + level: 9