Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | METADATA_BRANCH ?= "${@base_detect_branch(d)}" |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 2 | METADATA_BRANCH[vardepvalue] = "${METADATA_BRANCH}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 3 | METADATA_REVISION ?= "${@base_detect_revision(d)}" |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 4 | METADATA_REVISION[vardepvalue] = "${METADATA_REVISION}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5 | |
| 6 | def base_detect_revision(d): |
| 7 | path = base_get_scmbasepath(d) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 8 | return base_get_metadata_git_revision(path, d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 9 | |
| 10 | def base_detect_branch(d): |
| 11 | path = base_get_scmbasepath(d) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 12 | return base_get_metadata_git_branch(path, d) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13 | |
| 14 | def base_get_scmbasepath(d): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 15 | return os.path.join(d.getVar('COREBASE'), 'meta') |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 16 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 17 | def base_get_metadata_svn_revision(path, d): |
| 18 | # This only works with older subversion. For newer versions |
| 19 | # this function will need to be fixed by someone interested |
| 20 | revision = "<unknown>" |
| 21 | try: |
| 22 | with open("%s/.svn/entries" % path) as f: |
| 23 | revision = f.readlines()[3].strip() |
| 24 | except (IOError, IndexError): |
| 25 | pass |
| 26 | return revision |
| 27 | |
| 28 | def base_get_metadata_git_branch(path, d): |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 29 | import bb.process |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 30 | |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 31 | try: |
| 32 | rev, _ = bb.process.run('git rev-parse --abbrev-ref HEAD', cwd=path) |
| 33 | except bb.process.ExecutionError: |
| 34 | rev = '<unknown>' |
| 35 | return rev.strip() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 36 | |
| 37 | def base_get_metadata_git_revision(path, d): |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 38 | import bb.process |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 39 | |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 40 | try: |
| 41 | rev, _ = bb.process.run('git rev-parse HEAD', cwd=path) |
| 42 | except bb.process.ExecutionError: |
| 43 | rev = '<unknown>' |
| 44 | return rev.strip() |