From 985fe814f019dae162f9410a6437bf0f3fcb9e09 Mon Sep 17 00:00:00 2001
From: Nicolas Vigier <boklm@torproject.org>
Date: Tue, 29 Nov 2022 11:59:52 +0100
Subject: [PATCH] Bug 40699: Fix input_files in projects/firefox-l10n/config

In input_files in projects/firefox-l10n/config we are doing this:

  my $locales = project_config($project, 'var/locales', $options);
  foreach my $locale (@$locales) {
    $locale = process_template($project, $locale, '.');

In this foreach loop, `$locale` is pointing to the real string from
`var/locales` and not a copy, and we are updating it with the output
from `process_template`. This means that the template will be processed
the first time the function is called (for example for a linux-x86_64
build) and the processed value from the first call reused on subsequent
calls (for example a macos build, where the `ja` locale is supposed to
be different).

This is what caused the reproducibility issue in
https://gitlab.torproject.org/tpo/applications/tor-browser-build/-/merge_requests/591#note_2857042

To fix that we just use a separate variable to store the processed
template.
---
 projects/firefox-l10n/config | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/projects/firefox-l10n/config b/projects/firefox-l10n/config
index 2a2e585be..d8800a3c5 100644
--- a/projects/firefox-l10n/config
+++ b/projects/firefox-l10n/config
@@ -24,8 +24,8 @@ steps:
       my $changesets_json = project_config('firefox', 'var/l10n-changesets', { %$options, origin_project => $project });
       my $d = decode_json $changesets_json;
       my $locales = project_config($project, 'var/locales', $options);
-      foreach my $locale (@$locales) {
-        $locale = process_template($project, $locale, '.');
+      foreach my $loc (@$locales) {
+        my $locale = process_template($project, $loc, '.');
         next unless my $revision = $d->{$locale}{revision};
         my $input_file = {
           name => $locale,
-- 
GitLab