Brad Bishop | 0244915 | 2017-07-21 22:05:22 -0400 | [diff] [blame] | 1 | # WARNING! |
| 2 | # |
| 3 | # These modifications to os-release disable the bitbake parse |
| 4 | # cache (for the os-release recipe only). Before copying |
| 5 | # and pasting into another recipe ensure it is understood |
| 6 | # what that means! |
| 7 | |
Brad Bishop | a1e856b | 2015-11-19 22:06:41 -0600 | [diff] [blame] | 8 | def run_git(d, cmd): |
Brad Bishop | 6425ad2 | 2017-07-21 21:47:44 -0400 | [diff] [blame] | 9 | try: |
| 10 | oeroot = d.getVar('COREBASE', True) |
| 11 | return bb.process.run("git --work-tree %s --git-dir %s/.git %s" |
| 12 | % (oeroot, oeroot, cmd))[0].strip('\n') |
| 13 | except: |
| 14 | pass |
Brad Bishop | 7e3e11d | 2015-11-11 13:56:17 -0500 | [diff] [blame] | 15 | |
Brad Bishop | a1e856b | 2015-11-19 22:06:41 -0600 | [diff] [blame] | 16 | python() { |
Brad Bishop | 6425ad2 | 2017-07-21 21:47:44 -0400 | [diff] [blame] | 17 | version_id = run_git(d, 'describe --dirty --long') |
| 18 | if version_id: |
| 19 | d.setVar('VERSION_ID', version_id) |
| 20 | versionList = version_id.split('-') |
| 21 | version = versionList[0] + "-" + versionList[1] |
| 22 | d.setVar('VERSION', version) |
Brad Bishop | a1e856b | 2015-11-19 22:06:41 -0600 | [diff] [blame] | 23 | |
Brad Bishop | 6425ad2 | 2017-07-21 21:47:44 -0400 | [diff] [blame] | 24 | build_id = run_git(d, 'describe --abbrev=0') |
| 25 | if build_id: |
| 26 | d.setVar('BUILD_ID', build_id) |
Brad Bishop | a1e856b | 2015-11-19 22:06:41 -0600 | [diff] [blame] | 27 | } |
| 28 | |
Brad Bishop | 7e3e11d | 2015-11-11 13:56:17 -0500 | [diff] [blame] | 29 | OS_RELEASE_FIELDS_append = " BUILD_ID" |
Brad Bishop | 0244915 | 2017-07-21 22:05:22 -0400 | [diff] [blame] | 30 | |
| 31 | # Ensure the git commands run every time bitbake is invoked. |
| 32 | BB_DONT_CACHE = "1" |
Brad Bishop | e23b09a | 2017-07-24 20:24:28 -0400 | [diff] [blame] | 33 | |
| 34 | # Make os-release available to other recipes. |
| 35 | SYSROOT_DIRS_append = " ${sysconfdir}" |