1ff075f6eSBrad Bishop# WARNING!
2ff075f6eSBrad Bishop#
3ff075f6eSBrad Bishop# These modifications to os-release disable the bitbake parse
4ff075f6eSBrad Bishop# cache (for the os-release recipe only).  Before copying
5ff075f6eSBrad Bishop# and pasting into another recipe ensure it is understood
6ff075f6eSBrad Bishop# what that means!
7ff075f6eSBrad Bishop
8460ca240SPatrick WilliamsOS_RELEASE_ROOTPATH ?= "${COREBASE}"
9ff075f6eSBrad Bishopdef run_git(d, cmd):
10ff075f6eSBrad Bishop    try:
11460ca240SPatrick Williams        oeroot = d.getVar('OS_RELEASE_ROOTPATH', True)
12bc442de0SPatrick Williams        return bb.process.run(("export PSEUDO_DISABLED=1; " +
13bc442de0SPatrick Williams                               "git --work-tree %s --git-dir %s/.git %s")
14ff075f6eSBrad Bishop            % (oeroot, oeroot, cmd))[0].strip('\n')
15bc442de0SPatrick Williams    except Exception as e:
16bc442de0SPatrick Williams        bb.warn("Unexpected exception from 'git' call: %s" % e)
17ff075f6eSBrad Bishop        pass
1824d05d0bSPatrick Williams# DISTRO_VERSION can be overridden by a bbappend or config, so it must be a
1924d05d0bSPatrick Williams# weak override.  But, when a variable is weakly overridden the definition
2024d05d0bSPatrick Williams# and not the contents are used in the task-hash (for sstate reuse).  We need
2124d05d0bSPatrick Williams# a strong variable in the vardeps chain for do_compile so that we get the
2224d05d0bSPatrick Williams# contents of the 'git describe --dirty' call.  Create a strong/immediate
2324d05d0bSPatrick Williams# indirection via PHOSPHOR_OS_RELEASE_DISTRO_VERSION.
2424d05d0bSPatrick WilliamsPHOSPHOR_OS_RELEASE_DISTRO_VERSION := "${@run_git(d, 'describe --dirty')}"
2524d05d0bSPatrick WilliamsDISTRO_VERSION ??= "${PHOSPHOR_OS_RELEASE_DISTRO_VERSION}"
26*bde7dbefSAdriana KobylakEXTENDED_VERSION ??= "${PHOSPHOR_OS_RELEASE_DISTRO_VERSION}"
2746d9de31SPatrick WilliamsVERSION = "${@'-'.join(d.getVar('VERSION_ID').split('-')[0:2])}"
2846d9de31SPatrick WilliamsOPENBMC_TARGET_MACHINE = "${MACHINE}"
2912fc939cSPatrick WilliamsOS_RELEASE_FIELDS:append = " BUILD_ID OPENBMC_TARGET_MACHINE EXTENDED_VERSION"
30ff075f6eSBrad Bishop# Ensure the git commands run every time bitbake is invoked.
31ff075f6eSBrad BishopBB_DONT_CACHE = "1"
32ff075f6eSBrad Bishop# Make os-release available to other recipes.
3312fc939cSPatrick WilliamsSYSROOT_DIRS:append = " ${sysconfdir}"
34