It would be nice to somehow consolidate this new bbclass with
https://git.openembedded.org/meta-openembedded/tree/meta-oe/classes/gitpkgv.bbclass
https://git.openembedded.org/meta-openembedded/tree/meta-oe/classes/gitver.bbclass

and at least move the various git "wrapper" functions to lib/oe for better
reuse.

On Thu, Sep 22, 2022 at 2:24 PM Mikko Rapeli <[email protected]>
wrote:

> Output from git_describe() function can then be used in various places
> and from various git trees to create a user friend(lier) name to builds.
> Examples where this could be used is BUILD_ID, SDK_VERSION and
> IMAGE_VERSION_SUFFIX.
>
> Signed-off-by: Mikko Rapeli <[email protected]>
> ---
>  meta/classes/git-describe.bbclass | 24 ++++++++++++++++++++++++
>  1 file changed, 24 insertions(+)
>  create mode 100644 meta/classes/git-describe.bbclass
>
> diff --git a/meta/classes/git-describe.bbclass
> b/meta/classes/git-describe.bbclass
> new file mode 100644
> index 0000000000..3a2b06b3fd
> --- /dev/null
> +++ b/meta/classes/git-describe.bbclass
> @@ -0,0 +1,24 @@
> +# Defines a simple function which calls 'git describe --tags --always
> --dirty'
> +# on specified directory and returns the string.
> +#
> +# Can be used for example to easily generate a BUILD_ID in local.conf if
> +# TOPDIR build directory is under the main git tree for the project:
> +# INHERIT += "git-describe"
> +# BUILD_ID = "${@git_describe("${TOPDIR}/../meta-mylayer", d)}"
> +# # BUILD_ID to /etc/os-release
> +# OS_RELEASE_FIELDS:append:pn-os-release = " BUILD_ID"
> +# # Add os-release to all images
> +# IMAGE_INSTALL:append = " os-release"
> +# # BUILD_ID to image file name
> +# IMAGE_VERSION_SUFFIX = "-${BUILD_ID}"
> +# # BUILD_ID to SDK file names and paths
> +# SDK_VERSION = "${BUILD_ID}"
> +
> +def git_describe(p, d):
> +    import bb.process
> +    try:
> +        describe, _ = bb.process.run('git describe --tags --always
> --dirty', cwd=p)
> +    except bb.process.ExecutionError:
> +        describe = ''
> +    return describe.strip()
> +
> --
> 2.17.1
>
>
> 
>
>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#170980): 
https://lists.openembedded.org/g/openembedded-core/message/170980
Mute This Topic: https://lists.openembedded.org/mt/93847068/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to