From 8dfe938c89615c7bf24283e5fbfd878e6bc6d791 Mon Sep 17 00:00:00 2001
From: Nicolas Vigier <boklm@torproject.org>
Date: Mon, 9 Jan 2017 19:01:33 +0100
Subject: [PATCH] Set firefox buildid based on version number

---
 projects/firefox/build              |  9 +++++++--
 projects/firefox/config             |  2 ++
 projects/firefox/get-moz-build-date | 11 ++---------
 rbm.conf                            |  1 -
 4 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/projects/firefox/build b/projects/firefox/build
index f2b3d8a3..67547f72 100644
--- a/projects/firefox/build
+++ b/projects/firefox/build
@@ -32,7 +32,12 @@ mkdir -p $distdir/Debug/Browser/browser/components
 cd /var/tmp/build/[% project %]-[% c("version") %]
 mv -f $rootdir/[% c('input_files_by_name/mozconfig') %] .mozconfig
 
-# TODO: run get-moz-build-date
+eval $(perl $rootdir/get-moz-build-date [% c("var/copyright_year") %] $(cat browser/config/version.txt))
+if [ -z $MOZ_BUILD_DATE ]
+then
+    echo "MOZ_BUILD_DATE is not set"
+    exit 1
+fi
 
 [% IF c("var/windows") %]
 # FIXME
@@ -75,7 +80,7 @@ rm -f $distdir/TorBrowser.app/Contents/MacOS/firefox-bin
 # Adjust the Info.plist file
 INFO_PLIST=$distdir/TorBrowser.app/Contents/Info.plist
 mv $INFO_PLIST tmp.plist
-python $rootdir/fix-info-plist.py '[% c("var/torbrowser_version") %]' '[% exec("git show -s --format=%ci").remove("-.*") %]' < tmp.plist > $INFO_PLIST
+python $rootdir/fix-info-plist.py '[% c("var/torbrowser_version") %]' '[% c("var/copyright_year") %]' < tmp.plist > $INFO_PLIST
 rm -f tmp.plist
 [% END %]
 
diff --git a/projects/firefox/config b/projects/firefox/config
index a24da5f7..0d1a4ac7 100644
--- a/projects/firefox/config
+++ b/projects/firefox/config
@@ -10,6 +10,7 @@ remote_docker: 1
 var:
   firefox_version: 45.6.0esr
   torbrowser_update_channel: alpha
+  copyright_year: '[% exec("git show -s --format=%ci").remove("-.*") %]'
   deps:
     - build-essential
     - unzip
@@ -70,6 +71,7 @@ input_files:
   - project: docker-image
   - name: '[% c("var/compiler") %]'
     project: '[% c("var/compiler") %]'
+  - filename: get-moz-build-date
   - filename: 'mozconfig-[% c("var/osname") %]'
     name: mozconfig
   - project: binutils
diff --git a/projects/firefox/get-moz-build-date b/projects/firefox/get-moz-build-date
index 3dae2325..fb7298a2 100755
--- a/projects/firefox/get-moz-build-date
+++ b/projects/firefox/get-moz-build-date
@@ -3,15 +3,8 @@
 
 use strict;
 
-my ($year) = split('-', `git show -s --format='%ci'`);
-if ($? != 0) {
-    print STDERR "Failed to get year from the git commit\n";
-    print "exit 1\n";
-    exit 1;
-}
-
-die "missing argument" unless @ARGV;
-my $version = $ARGV[0];
+die "wrong number of arguments" unless @ARGV == 2;
+my ($year, $version) = @ARGV;
 $version =~ s/\D+$//;
 my @v = split(/[\.ab]/, $version);
 push @v, '0' if @v < 4;
diff --git a/rbm.conf b/rbm.conf
index c6ffe40b..fb011be5 100644
--- a/rbm.conf
+++ b/rbm.conf
@@ -7,7 +7,6 @@ pkg_type: build
 
 var:
   torbrowser_version: '6.5n'
-  copyright_year: '2016'
   # By default, we sort the list of installed packages. This allows sharing
   # containers with identical list of packages, even if they are not listed
   # in the same order. In the cases where the installation order is
-- 
GitLab