summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2020-07-20 12:56:32 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-11-22 13:27:37 +0000
commit0d4dea01892734417264757ca5fd5a85874bb514 (patch)
tree9d194761b20e1527a4bd24fe13b930e68233c3fe /meta
parent9f46c1a1ad2efcebd8ddc34f3ef6be58706c126d (diff)
downloadpoky-0d4dea01892734417264757ca5fd5a85874bb514.tar.gz
lib/oe/reproducible: Fix error when no git HEAD
Fixes an error that occurs when attempting to get the timestamp of the latest commit when there is no HEAD in the git repository. The easiest way to trigger this condition is to use the 'subdir=' option when specifying a 'git://' SRC_URI. (From OE-Core rev: 02e42107e1c6145c215bfd74fe17fd8abc2db04f) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit a64caca5b5dbe4a76acd0b5709b2c3e75b245863) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oe/reproducible.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/meta/lib/oe/reproducible.py b/meta/lib/oe/reproducible.py
index f80a85ddef..f4f58dd952 100644
--- a/meta/lib/oe/reproducible.py
+++ b/meta/lib/oe/reproducible.py
@@ -47,14 +47,23 @@ def find_git_folder(d, sourcedir):
47 return None 47 return None
48 48
49def get_source_date_epoch_from_git(d, sourcedir): 49def get_source_date_epoch_from_git(d, sourcedir):
50 source_date_epoch = None 50 if not "git://" in d.getVar('SRC_URI'):
51 if "git://" in d.getVar('SRC_URI'): 51 return None
52 gitpath = find_git_folder(d, sourcedir) 52
53 if gitpath: 53 gitpath = find_git_folder(d, sourcedir)
54 import subprocess 54 if not gitpath:
55 source_date_epoch = int(subprocess.check_output(['git','log','-1','--pretty=%ct'], cwd=gitpath)) 55 return None
56 bb.debug(1, "git repository: %s" % gitpath) 56
57 return source_date_epoch 57 # Check that the repository has a valid HEAD; it may not if subdir is used
58 # in SRC_URI
59 p = subprocess.run(['git', 'rev-parse', 'HEAD'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=gitpath)
60 if p.returncode != 0:
61 bb.debug(1, "%s does not have a valid HEAD: %s" % (gitpath, p.stdout.decode('utf-8')))
62 return None
63
64 bb.debug(1, "git repository: %s" % gitpath)
65 p = subprocess.run(['git','log','-1','--pretty=%ct'], check=True, stdout=subprocess.PIPE, cwd=gitpath)
66 return int(p.stdout.decode('utf-8'))
58 67
59def get_source_date_epoch_from_youngest_file(d, sourcedir): 68def get_source_date_epoch_from_youngest_file(d, sourcedir):
60 if sourcedir == d.getVar('WORKDIR'): 69 if sourcedir == d.getVar('WORKDIR'):