Vagrant Cascadian:
> Well, I've been debugging why u-boot stopped building reprodicbly, and
> it appears to be that the recent fix that really switches armhf to build
> with it_CH.UTF-8 locale actually breaks u-boot reproducibility.
> 
> So, just for comparison, I also tested with other locales, including
> some with non-latin "alphabets" and other countries just to vary as much
> as possible, and the following all built reproducibly with each other:
> 
>   C
>   el_GR.UTF-8
>   ru_RU.UTF-8
>   ar_EG.UTF-8
>   zh_CN.UTF-8
>   es_ES.UTF-8
>   fr_CH.UTF-8
>   et_EE.UTF-8
>   ja_JP.UTF-8
>   ko_KR.UTF-8
>   en_US.UTF-8
> 
> And these locales built reproducibly with each other:
> 
>   it_CH.UTF-8
>   it_IT.UTF-8
> 
> 
> Haven't really figured out *what* the actual issue is, but figured I'd
> share my confusion.
> 
> 
> With this as evidence, there appear to be two kinds of locales, Italian,
> and not-Italian. At least when it comes to u-boot. :)

@all:

We found out the reason is [0] because:

  $ LANG=C ld --version | head -n 1
  GNU ld (GNU Binutils for Debian) 2.26

  $ LANG=fr_CH.UTF-8 ld --version | head -n 1
  GNU ld (GNU Binutils for Debian) 2.26

  $ LANG=it_CH.UTF-8 ld --version | head -n 1
  ld di GNU (GNU Binutils for Debian) 2.26


While debugging this I noticed that this Makefile resets LC_ALL [1]. So this
variation was only detected because we also set LANG. So I think we
should set all LC_* variables.

[0]: https://sources.debian.net/src/u-boot/2016.07~rc1%2Bdfsg1-1/Makefile/#L1274
[1]: https://sources.debian.net/src/u-boot/2016.07~rc1%2Bdfsg1-1/Makefile/#L22


@vagrantc:

I found the additional issue with dra7xx_evm. This target uses another
image format which embeds timestamps which aren't set to
SOURCE_DATE_EPOCH [2]. See attached patch to fix this (might need some
cleanup before upstreaming).

[2]: 
https://sources.debian.net/src/u-boot/2016.07~rc1%2Bdfsg1-1/tools/fit_image.c/#L55


HW42
--- a/tools/default_image.c
+++ b/tools/default_image.c
@@ -88,7 +88,6 @@ static void image_set_header(void *ptr,
 				struct image_tool_params *params)
 {
 	uint32_t checksum;
-	char *source_date_epoch;
 	time_t time;
 
 	image_header_t * hdr = (image_header_t *)ptr;
@@ -98,18 +97,7 @@ static void image_set_header(void *ptr,
 				sizeof(image_header_t)),
 			sbuf->st_size - sizeof(image_header_t));
 
-	source_date_epoch = getenv("SOURCE_DATE_EPOCH");
-	if (source_date_epoch != NULL) {
-		time = (time_t) strtol(source_date_epoch, NULL, 10);
-
-		if (gmtime(&time) == NULL) {
-			fprintf(stderr, "%s: SOURCE_DATE_EPOCH is not valid\n",
-				__func__);
-			time = 0;
-		}
-	} else {
-		time = sbuf->st_mtime;
-	}
+	time = imagetool_get_source_date(params, sbuf->st_mtime);
 
 	/* Build new header */
 	image_set_magic(hdr, IH_MAGIC);
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -51,8 +51,10 @@ static int fit_add_file_data(struct imag
 	}
 
 	/* for first image creation, add a timestamp at offset 0 i.e., root  */
-	if (params->datafile)
-		ret = fit_set_timestamp(ptr, 0, sbuf.st_mtime);
+	if (params->datafile) {
+		time_t time = imagetool_get_source_date(params, sbuf.st_mtime);
+		ret = fit_set_timestamp(ptr, 0, time);
+	}
 
 	if (!ret) {
 		ret = fit_add_verification_data(params->keydir, dest_blob, ptr,
--- a/tools/imagetool.c
+++ b/tools/imagetool.c
@@ -115,3 +115,22 @@ int imagetool_get_filesize(struct image_
 
 	return sbuf.st_size;
 }
+
+time_t imagetool_get_source_date(struct image_tool_params *params, time_t fallback)
+{
+	char *source_date_epoch = getenv("SOURCE_DATE_EPOCH");
+
+	if (source_date_epoch == NULL) {
+		return fallback;
+	}
+
+	time_t time = (time_t) strtol(source_date_epoch, NULL, 10);
+
+	if (gmtime(&time) == NULL) {
+		fprintf(stderr, "%s: SOURCE_DATE_EPOCH is not valid\n",
+				params->cmdname);
+		time = 0;
+	}
+
+	return time;
+}
--- a/tools/imagetool.h
+++ b/tools/imagetool.h
@@ -205,6 +205,20 @@ int imagetool_save_subimage(
  */
 int imagetool_get_filesize(struct image_tool_params *params, const char *fname);
 
+/**
+ * imagetool_get_source_date() - Get timestamp for build output.
+ *
+ * Gets a timestamp for embedding it in a build output. If set
+ * SOURCE_DATE_EPOCH is used. Else the given fallback value is returned. Prints
+ * an error message if SOURCE_DATE_EPOCH contains an invalid value and returns
+ * 0.
+ *
+ * @params:	mkimage parameters
+ * @fallback:	timestamp to use if SOURCE_DATE_EPOCH isn't set
+ * @return timestamp based on SOURCE_DATE_EPOCH
+ */
+time_t imagetool_get_source_date(struct image_tool_params *params, time_t fallback);
+
 /*
  * There is a c file associated with supported image type low level code
  * for ex. default_image.c, fit_image.c

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Reproducible-builds mailing list
Reproducible-builds@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/reproducible-builds

Reply via email to