Skip to contentSkip to conversation

avoid encoding mtime in standalone scripts

PATCH In review Greg Thelen 2 participants 2 messages Dec 5, 2022 – Dec 6, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 avoid encoding mtime in standalone scripts

Reproducible builds aid in caching builds and tests. Ideally rebuilding the same source produces identical outputs.

The standalone kvm test scripts contain base64 encoded gzip compressed test binaries. Compression and encoding is done with
"gzip -c FILE | base64" which stores FILE's name and mtime in the compressed output.

Binaries are expanded with
base64 -d << 'BIN_EOF' | zcat > OUTPUT
This expansion pipeline ignores the gzip stored name and mtime.

Use "gzip -n" to avoid saving mtime in the output. This makes the standalone test scripts reproducible. Their contents are the same regardless of when they are built.

---
 scripts/mkstandalone.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/mkstandalone.sh +2 -1
index 86c7e5498246..1e6d308b43f7 100755
@@ -16,7 +16,8 @@ temp_file ()
 	echo "cleanup=\"\$$var \$cleanup\""
 	echo "base64 -d << 'BIN_EOF' | zcat > \$$var || exit 2"
 
-	gzip -c "$file" | base64
+	# For reproductible builds avoid saving $file mtime with -n
+	gzip -nc "$file" | base64
 
 	echo "BIN_EOF"
 	echo "chmod +x \$$var"
Signature · 1 line
2.39.0.rc0.267.gcb52ba06e7-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 38 lines · Greg Thelen

Reproducible builds aid in caching builds and tests. Ideally rebuilding the same source produces identical outputs.

The standalone kvm test scripts contain base64 encoded gzip compressed test binaries. Compression and encoding is done with
"gzip -c FILE | base64" which stores FILE's name and mtime in the compressed output.

Binaries are expanded with
base64 -d << 'BIN_EOF' | zcat > OUTPUT
This expansion pipeline ignores the gzip stored name and mtime.

Use "gzip -n" to avoid saving mtime in the output. This makes the standalone test scripts reproducible. Their contents are the same regardless of when they are built.

---
 scripts/mkstandalone.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/mkstandalone.sh +2 -1
index 86c7e5498246..1e6d308b43f7 100755
@@ -16,7 +16,8 @@ temp_file ()
 	echo "cleanup=\"\$$var \$cleanup\""
 	echo "base64 -d << 'BIN_EOF' | zcat > \$$var || exit 2"
 
-	gzip -c "$file" | base64
+	# For reproductible builds avoid saving $file mtime with -n
+	gzip -nc "$file" | base64
 
 	echo "BIN_EOF"
 	echo "chmod +x \$$var"
Signature · 1 line
2.39.0.rc0.267.gcb52ba06e7-goog