From 646c414ce211e989e0c1147093a6efcdb3d542e8 Mon Sep 17 00:00:00 2001
From: Kevin Mihelich <kevin@archlinuxarm.org>
Date: Thu, 7 Jul 2022 03:46:38 +0000
Subject: [PATCH] extra/gn to 0.2042.2ecd43a1-2

---
 extra/gn/PKGBUILD    | 14 +++++++++++---
 extra/gn/repro.patch | 29 +++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 3 deletions(-)
 create mode 100644 extra/gn/repro.patch

diff --git a/extra/gn/PKGBUILD b/extra/gn/PKGBUILD
index 9066bc56d..eb6225e57 100644
--- a/extra/gn/PKGBUILD
+++ b/extra/gn/PKGBUILD
@@ -6,21 +6,29 @@
 pkgname=gn
 pkgver=0.2042.2ecd43a1
 _commit=2ecd43a10266bd091c98e6dcde507c64f6a0dad3
-pkgrel=1
+pkgrel=2
 pkgdesc="Meta-build system that generates build files for Ninja"
 arch=('x86_64')
 url="https://gn.googlesource.com/gn/"
 license=('BSD')
 depends=('gcc-libs')
 makedepends=('clang' 'ninja' 'python' 'git')
-source=(git+https://gn.googlesource.com/gn#commit=$_commit)
-sha256sums=('SKIP')
+source=(git+https://gn.googlesource.com/gn#commit=$_commit
+        repro.patch)
+sha256sums=('SKIP'
+            '4f87532d0785ded35a9452bb762635c36c8e2c8e5181c4b991dab258f895e27e')
 
 pkgver() {
   cd $pkgname
   echo 0.$(git rev-list --count initial-commit..).$(git rev-parse --short=8 HEAD)
 }
 
+prepare() {
+  cd $pkgname
+  # https://gn-review.googlesource.com/c/gn/+/14260
+  patch -Np1 -i ../repro.patch
+}
+
 build() {
   cd $pkgname
   # clang-13: error: argument unused during compilation: '-fstack-clash-protection' [-Werror,-Wunused-command-line-argument]
diff --git a/extra/gn/repro.patch b/extra/gn/repro.patch
new file mode 100644
index 000000000..a7ae9737d
--- /dev/null
+++ b/extra/gn/repro.patch
@@ -0,0 +1,29 @@
+From 102a161c76f8d4c8157390b7087ae6e65ec9d7cf Mon Sep 17 00:00:00 2001
+From: Evangelos Foutras <evangelos@foutrelis.com>
+Date: Thu, 7 Jul 2022 06:18:12 +0300
+Subject: [PATCH] build/gen.py: Make LAST_COMMIT_POSITION reproducible
+
+Abbreviated hashes can vary in length depending on the number of objects
+in the Git repository. This frequently breaks reproducibility for distro
+packages. Address this by adding --abbrev=12 to the 'git describe' call.
+
+Change-Id: I2fff11ff5a8e54e437a2186ea1f7c0ec17924437
+---
+ build/gen.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/build/gen.py b/build/gen.py
+index fe56186b..f877cc24 100755
+--- a/build/gen.py
++++ b/build/gen.py
+@@ -218,8 +218,8 @@ def main(argv):
+ def GenerateLastCommitPosition(host, header):
+   ROOT_TAG = 'initial-commit'
+   describe_output = subprocess.check_output(
+-      ['git', 'describe', 'HEAD', '--match', ROOT_TAG], shell=host.is_windows(),
+-      cwd=REPO_ROOT)
++      ['git', 'describe', 'HEAD', '--abbrev=12', '--match', ROOT_TAG],
++      shell=host.is_windows(), cwd=REPO_ROOT)
+   mo = re.match(ROOT_TAG + '-(\d+)-g([0-9a-f]+)', describe_output.decode())
+   if not mo:
+     raise ValueError(