[yocto] Preventing a variable from being cached

Paul Knopf pauldotknopf at gmail.com
Thu Dec 7 12:30:13 PST 2017


Use a SRC_URI for another recip? Let me show you my recipe.

SUMMARY = "Puts a file in the image that contains the application version."
DESCRIPTION = "Puts a file in the image that contains the application
version."
LICENSE = "Proprietary"
LIC_FILES_CHKSUM =
"file://${COREBASE}/meta/files/common-licenses/Proprietary;md5=0557f9d92cf58f2ccdd50f62f8ac0b28"

inherit allarch deploy

DEPENDS += "jq-native"

# Want to store the git branch we are on, as well as the git SHA for the
current commit.
def get_git_position(d):
    import bb.process
    (output, error) = bb.process.run("git rev-parse --abbrev-ref HEAD")
    result = output.rstrip()
    (output, error) = bb.process.run("git rev-parse HEAD")
    result += "-"
    result += output.rstrip()
    return result
BUILD_GIT_POSITION := "${@get_git_position(d)}"

do_compile() {
    /usr/local/bin/gitversion "${LAYERROOT}" > ${S}/version.json
}

do_compile[vardeps] += "BUILD_GIT_POSITION"

do_install () {
    GIT_VERSION_OUTPUT=`cat ${S}/version.json`
    BUILD_GIT_COMMIT=`echo $GIT_VERSION_OUTPUT | jq '.Sha' --raw-output`
    BUILD_GIT_DIRTY=`test -n "git --git-dir "${LAYERROOT}/.git" --work-tree
"${LAYERROOT}" status --porcelain" && echo "+CHANGES" || true`
    BUILD_GIT_SEMVAR_VERSION=`echo $GIT_VERSION_OUTPUT | jq '.SemVer'
--raw-output`
    BUILD_GIT_INFORMATION_VERSION=`echo $GIT_VERSION_OUTPUT \
        | jq '.InformationalVersion' --raw-output \
        | sed -r -e 's,Branch\.,\.,' -e 's,\.Sha,,' -e
's,(\.[0-9a-fA-F]{8})[0-9a-fA-F]+$,\1,' `

install -d ${D}${sysconfdir}
    echo "BUILD_GIT_COMMIT:$BUILD_GIT_COMMIT" >
${D}${sysconfdir}/app-version
    echo "BUILD_GIT_DIRTY:$BUILD_GIT_DIRTY" >> ${D}${sysconfdir}/app-version
    echo "BUILD_GIT_SEMVAR_VERSION:$BUILD_GIT_SEMVAR_VERSION" >>
${D}${sysconfdir}/app-version
    echo "BUILD_GIT_INFORMATION_VERSION:$BUILD_GIT_INFORMATION_VERSION" >>
${D}${sysconfdir}/app-version
}

do_deploy() {
    install ${S}/version.json ${DEPLOYDIR}/version.json
}

addtask do_deploy after do_install

FILES_${PN} = "${sysconfdir}/*"

On Thu, Dec 7, 2017 at 3:28 PM, Alexander Kanavin <
alexander.kanavin at linux.intel.com> wrote:

> On 12/07/2017 10:22 PM, Paul Knopf wrote:
>
>> I have all my meta-layers and build conf files checked into a single
>> repository (submodules for layers). I want a recipe to look at the git
>> repository, and place a file in the build. I'd like this repository to read
>> the HEAD, and decide if it needs to be rebuilt (to put new file in image)
>> based off of HEAD/branch location.
>>
>
>
> Use the file: fetcher for the file in SRC_URI, and the fetcher will detect
> if the file has changed and trigger a rebuild accordingly.
>
> Alex
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/yocto/attachments/20171207/7060810e/attachment.html>


More information about the yocto mailing list