[tor-commits] [tor-browser-bundle/hardened-builds] Bug 19528: set MOZ_BUILD_DATE based on firefox version

gk at torproject.org gk at torproject.org
Fri Sep 9 13:14:33 UTC 2016


commit ac62d42011e18a5cf124d3265b3b62a931c17e9a
Author: Nicolas Vigier <boklm at torproject.org>
Date:   Fri Sep 9 14:07:39 2016 +0200

    Bug 19528: set MOZ_BUILD_DATE based on firefox version
    
    The MOZ_BUILD_DATE environment variable is used as the build id.
---
 gitian/build-helpers/get-moz-build-date       | 18 ++++++++++++++++++
 gitian/descriptors/linux/gitian-firefox.yml   |  3 ++-
 gitian/descriptors/mac/gitian-firefox.yml     |  3 ++-
 gitian/descriptors/windows/gitian-firefox.yml |  3 ++-
 tools/update-responses/update_responses       | 27 ++++++++++++++++++++++++++-
 5 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/gitian/build-helpers/get-moz-build-date b/gitian/build-helpers/get-moz-build-date
new file mode 100755
index 0000000..168a8c7
--- /dev/null
+++ b/gitian/build-helpers/get-moz-build-date
@@ -0,0 +1,18 @@
+#!/usr/bin/perl -w
+# Generate a MOZ_BUILD_DATE based on firefox version number
+
+use strict;
+
+my ($year) = split('-', `git show -s --format='%ci'`);
+
+die "missing argument" unless @ARGV;
+my $version = $ARGV[0];
+$version =~ s/\D+$//;
+my @v = split(/[\.ab]/, $version);
+push @v, '0' if @v < 4;
+push @v, '0' if @v < 4;
+my $day_of_month = int(($v[0] - 45) / 5);
+my $date = 101010101 + $year * 10000000000 + $day_of_month * 1000000
+           + $v[1] * 10000 + $v[2] * 100 + $v[3];
+$date += 100000000 unless $version =~ m/[ab]/;
+print "export MOZ_BUILD_DATE=$date\n";
diff --git a/gitian/descriptors/linux/gitian-firefox.yml b/gitian/descriptors/linux/gitian-firefox.yml
index f32ee40..89f68fa 100644
--- a/gitian/descriptors/linux/gitian-firefox.yml
+++ b/gitian/descriptors/linux/gitian-firefox.yml
@@ -32,6 +32,7 @@ remotes:
 files:
 - "binutils-linux64-utils.zip"
 - "gcc-linux64-utils.zip"
+- "get-moz-build-date"
 - "re-dzip.sh"
 - "dzip.sh"
 - "versions"
@@ -92,7 +93,7 @@ script: |
   # Self-Rando wrapper
   export PATH="$HOME/build/selfrando/Tools/TorBrowser/tc-wrapper/:$PATH"
   export SELFRANDO_skip_shuffle=
-  export MOZ_BUILD_DATE=$(date -d "$REFERENCE_DATETIME" +%Y%m%d%H%M%S)
+  eval $(~/build/get-moz-build-date $(cat browser/config/version.txt))
   make -f client.mk configure CONFIGURE_ARGS="--with-tor-browser-version=${TORBROWSER_VERSION} --enable-update-channel=${TORBROWSER_UPDATE_CHANNEL} --enable-bundled-fonts"
   find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
   # Without disabling LSan our build is blowing up:
diff --git a/gitian/descriptors/mac/gitian-firefox.yml b/gitian/descriptors/mac/gitian-firefox.yml
index 302f2a4..fea3139 100644
--- a/gitian/descriptors/mac/gitian-firefox.yml
+++ b/gitian/descriptors/mac/gitian-firefox.yml
@@ -17,6 +17,7 @@ files:
 - "gcc-linux64-precise-utils.zip"
 - "MacOSX10.7.sdk.tar.gz"
 - "x86_64-apple-darwin10.tar.xz"
+- "get-moz-build-date"
 - "re-dzip.sh"
 - "dzip.sh"
 - "fix-info-plist.py"
@@ -65,7 +66,7 @@ script: |
   find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
   rm -f configure
   rm -f js/src/configure
-  export MOZ_BUILD_DATE=$(date -d "$REFERENCE_DATETIME" +%Y%m%d%H%M%S)
+  eval $(~/build/get-moz-build-date $(cat browser/config/version.txt))
   make -f client.mk configure CONFIGURE_ARGS="--with-tor-browser-version=${TORBROWSER_VERSION} --enable-update-channel=${TORBROWSER_UPDATE_CHANNEL} --enable-bundled-fonts"
   find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
   make $MAKEOPTS -f client.mk build
diff --git a/gitian/descriptors/windows/gitian-firefox.yml b/gitian/descriptors/windows/gitian-firefox.yml
index 3261199..788b053 100644
--- a/gitian/descriptors/windows/gitian-firefox.yml
+++ b/gitian/descriptors/windows/gitian-firefox.yml
@@ -15,6 +15,7 @@ remotes:
 files:
 - "gcc-linux32-precise-utils.zip"
 - "mingw-w64-win32-utils.zip"
+- "get-moz-build-date"
 - "re-dzip.sh"
 - "dzip.sh"
 - "gcclibs-win32-utils.zip"
@@ -73,7 +74,7 @@ script: |
   find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
   rm -f configure
   rm -f js/src/configure
-  export MOZ_BUILD_DATE=$(date -d "$REFERENCE_DATETIME" +%Y%m%d%H%M%S)
+  eval $(~/build/get-moz-build-date $(cat browser/config/version.txt))
   make -f client.mk configure CONFIGURE_ARGS="--with-tor-browser-version=${TORBROWSER_VERSION} --enable-update-channel=${TORBROWSER_UPDATE_CHANNEL} --enable-bundled-fonts"
   find -type f -print0 | xargs -0 touch --date="$REFERENCE_DATETIME"
   #
diff --git a/tools/update-responses/update_responses b/tools/update-responses/update_responses
index faa1037..498132e 100755
--- a/tools/update-responses/update_responses
+++ b/tools/update-responses/update_responses
@@ -238,6 +238,30 @@ sub channel_to_version {
     return map { $config->{channels}{$_} } @channels;
 }
 
+sub get_buildinfos {
+    my ($config, $version) = @_;
+    return if exists $config->{versions}{$version}{buildID};
+    my $files = $config->{versions}{$version}{files};
+    foreach my $os (keys %$files) {
+        foreach my $lang (keys %{$files->{$os}}) {
+            next unless $files->{$os}{$lang}{complete};
+            my $tmpdir = File::Temp->newdir();
+            extract_mar(mar_filename($version, $os, $lang), "$tmpdir");
+            my $appfile = "$tmpdir/application.ini" if -f "$tmpdir/application.ini";
+            $appfile = "$tmpdir/Contents/Resources/application.ini"
+                                if -f "$tmpdir/Contents/Resources/application.ini";
+            exit_error "Could not find application.ini" unless $appfile;
+            foreach my $line (read_file("$tmpdir/application.ini")) {
+                if ($line =~ m/^BuildID=(.*)$/) {
+                    $config->{versions}{$version}{buildID} = $1;
+                    return;
+                }
+            }
+            exit_error "Could not extract buildID from application.ini";
+        }
+    }
+}
+
 sub get_response {
     my ($config, $version, $os, @patches) = @_;
     my $res;
@@ -257,7 +281,7 @@ sub get_response {
         displayVersion => $version,
         appVersion => $version,
         platformVersion => get_config($config, $version, $os, 'platformVersion'),
-        buildID => '20000101000000',
+        buildID => get_config($config, $version, $os, 'buildID'),
         detailsURL => get_config($config, $version, $os, 'detailsURL'),
         actions => 'showURL',
         openURL => get_config($config, $version, $os, 'detailsURL'),
@@ -281,6 +305,7 @@ sub write_responses {
     foreach my $channel (@channels) {
         my $version = $config->{channels}{$channel};
         get_version_files($config, $version);
+        get_buildinfos($config, $version);
         my $files = $config->{versions}{$version}{files};
         my $migrate_archs = $config->{versions}{$version}{migrate_archs} // {};
         foreach my $old_os (keys %$migrate_archs) {



More information about the tor-commits mailing list