commit ffd060c9f190af53af6b1f6a88ba4f024090f1d4
Author: aguestuser <aguestuser(a)torproject.org>
Date: Fri Feb 11 21:50:17 2022 -0500
Bug 40432: Inject commit hash into AC build.gradle files at build-time
context
- In a3a5306f, we added a patch to the android-components build
process that prevents gradle from invoking `git rev-parse` to obtain
the current build's commit hash (because `git` is absent in our build
containers and invoking it will abort the build), instead simply
inserting the dummy string "release build" where the hash would have occured
- However, having the git hash in build artifacts can be quite useful
for debugging later, so we'd like to preserve it, if we can.
changes
- Here, we inject the commit hash into the android-components
`build.gradle` files using `sed` and `c("abbrev")` as we will soon
also do in the fenix build process in 5912606f
---
projects/android-components/build | 7 ++++++-
projects/android-components/config | 1 -
projects/android-components/git.patch | 36 -----------------------------------
3 files changed, 6 insertions(+), 38 deletions(-)
diff --git a/projects/android-components/build b/projects/android-components/build
old mode 100644
new mode 100755
index 0500fbd..1199cb0
--- a/projects/android-components/build
+++ b/projects/android-components/build
@@ -35,7 +35,12 @@ EOF
tar -C /var/tmp/build -xf [% project %]-[% c('version') %].tar.gz
cd $builddir-[% c('version') %]
-patch -p1 < $rootdir/git.patch
+
+# Avoid call to `getGitHash()`, which will fail b/c it invokes git, which is absent in
+# the build container. Instead just inject the commit hash, which we know!
+sed -i 's/getGitHash()/\"[% c('abbrev') %]\"/' components/support/base/build.gradle
+sed -i 's/tag = getGitHash()/tag = \"[% c('abbrev') %]\"/' publish.gradle
+
[% IF c("var/fetch_gradle_dependencies") %]
# XXX: fetching deps for `assembleGeckoBeta -x lint` by using that same target
# results in some missing dependencies for yet unknown reasons. Thus, we use
diff --git a/projects/android-components/config b/projects/android-components/config
index 11b7413..5b390b2 100644
--- a/projects/android-components/config
+++ b/projects/android-components/config
@@ -45,7 +45,6 @@ input_files:
name: gradle-dependencies
exec: '[% INCLUDE "fetch-gradle-dependencies" %]'
enable: '[% !c("var/fetch_gradle_dependencies") %]'
- - filename: git.patch
- filename: mavenLocal.patch
enable: '[% !c("var/fetch_gradle_dependencies") %]'
- URL: '[% pc("glean", "var/glean_wheels_url/" _ c("var/glean_parser"), { error_if_undef => 1 }) %]'
diff --git a/projects/android-components/git.patch b/projects/android-components/git.patch
deleted file mode 100644
index 23cf1c5..0000000
--- a/projects/android-components/git.patch
+++ /dev/null
@@ -1,36 +0,0 @@
-From ad3f56a9e977b8c83643cfcf6f90b03176392c1f Mon Sep 17 00:00:00 2001
-From: Georg Koppen <gk(a)torproject.org>
-Date: Sun, 19 Apr 2020 17:59:16 +0000
-Subject: [PATCH 1/2] git patch
-
----
- components/support/base/build.gradle | 2 +-
- publish.gradle | 2 +-
- 2 files changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/components/support/base/build.gradle b/components/support/base/build.gradle
-index 3a0ae5002..cffb310d5 100644
---- a/components/support/base/build.gradle
-+++ b/components/support/base/build.gradle
-@@ -38,7 +38,7 @@ android {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
-
-- buildConfigField("String", "GIT_HASH", "\"" + getGitHash() + "\"")
-+ buildConfigField("String", "GIT_HASH", "\"release build\"")
- }
- }
-
-diff --git a/publish.gradle b/publish.gradle
-index 6bbd206d8..e27c00f67 100644
---- a/publish.gradle
-+++ b/publish.gradle
-@@ -66,7 +66,7 @@ ext.configurePublish = { groupIdArg, artifactIdArg, descriptionArg ->
- connection = libVcsUrl
- developerConnection = libVcsUrl
- url = libUrl
-- tag = getGitHash()
-+ tag = "release build"
- }
- }
- }