All of lore.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH] avoid encoding mtime in standalone scripts
@ 2022-12-05 16:28 Greg Thelen
  2022-12-06  6:14 ` Andrew Jones
  0 siblings, 1 reply; 2+ messages in thread
From: Greg Thelen @ 2022-12-05 16:28 UTC (permalink / raw)
  To: kvm; +Cc: 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.

Signed-off-by: Greg Thelen <gthelen@google.com>
---
 scripts/mkstandalone.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh
index 86c7e5498246..1e6d308b43f7 100755
--- a/scripts/mkstandalone.sh
+++ b/scripts/mkstandalone.sh
@@ -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"
-- 
2.39.0.rc0.267.gcb52ba06e7-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [kvm-unit-tests PATCH] avoid encoding mtime in standalone scripts
  2022-12-05 16:28 [kvm-unit-tests PATCH] avoid encoding mtime in standalone scripts Greg Thelen
@ 2022-12-06  6:14 ` Andrew Jones
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Jones @ 2022-12-06  6:14 UTC (permalink / raw)
  To: Greg Thelen; +Cc: kvm

On Mon, Dec 05, 2022 at 08:28:40AM -0800, Greg Thelen wrote:
> 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.
> 
> Signed-off-by: Greg Thelen <gthelen@google.com>
> ---
>  scripts/mkstandalone.sh | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh
> index 86c7e5498246..1e6d308b43f7 100755
> --- a/scripts/mkstandalone.sh
> +++ b/scripts/mkstandalone.sh
> @@ -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"
> -- 
> 2.39.0.rc0.267.gcb52ba06e7-goog
>

Reviewed-by: Andrew Jones <andrew.jones@linux.dev>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-12-06  6:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-05 16:28 [kvm-unit-tests PATCH] avoid encoding mtime in standalone scripts Greg Thelen
2022-12-06  6:14 ` Andrew Jones

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.