public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: "Maxim Yu. Osipov" <mosipov@ilbers.de>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: isar-users <isar-users@googlegroups.com>
Subject: Re: [PATCH] meta/image: Rewrite get_build_id as shell function
Date: Wed, 25 Jul 2018 13:34:29 +0300	[thread overview]
Message-ID: <b2ade7dc-10dc-8ad0-ee7e-d425f37e03df@ilbers.de> (raw)
In-Reply-To: <1572b44a-f1c5-1fef-8296-1b1d3a5f2f23@siemens.com>

On 07/23/2018 01:28 AM, Jan Kiszka wrote:
> This avoid warning the user multiple times because get_build_id gets
> called each time the class is evaluated.

Applied to the 'next',

Thanks,
Maxim.

> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
> 
> Builds on top of Henning's "meta/image: allow customization of command
> we use fo BUILD_ID"
> 
>   meta/classes/image.bbclass | 29 +++++++++++++----------------
>   1 file changed, 13 insertions(+), 16 deletions(-)
> 
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index 6f2a140..990aff3 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -38,21 +38,18 @@ def get_rootfs_size(d):
>   # this could be "git describe" or something similar.
>   # set ISAR_RELEASE_CMD to customize, or override do_mark_rootfs to do something
>   # completely different
> -def get_build_id(d):
> -    import subprocess
> -    if (len(d.getVar("BBLAYERS", True).strip().split(' ')) != 2 and
> -        (d.getVar("ISAR_RELEASE_CMD", True) ==
> -         d.getVar("ISAR_RELEASE_CMD_DEFAULT", True))):
> -        bb.warn('You are using external layers that will not be considered' +
> -                ' in the build_id. Consider changing ISAR_RELEASE_CMD.')
> -    cmd = d.getVar("ISAR_RELEASE_CMD", True)
> -    try:
> -        v = subprocess.check_output(cmd, shell=True, universal_newlines=True)
> -        return v.rstrip()
> -    except subprocess.CalledProcessError as e:
> -        bb.warn('\"%s\" returned %d, returning empty build_id' %
> -                (e.cmd, e.returncode))
> -        return ""
> +get_build_id() {
> +	if [ $(echo ${BBLAYERS} | wc -w) -ne 2 ] &&
> +	   [ "${ISAR_RELEASE_CMD}" = "${ISAR_RELEASE_CMD_DEFAULT}" ]; then
> +		bbwarn "You are using external layers that will not be" \
> +		       "considered in the build_id. Consider changing" \
> +		       "ISAR_RELEASE_CMD."
> +	fi
> +	if ! ${ISAR_RELEASE_CMD} 2>/dev/null; then
> +		bbwarn "\"${ISAR_RELEASE_CMD}\" failed, returning empty build_id."
> +		echo ""
> +	fi
> +}
>   
>   python set_image_size () {
>       rootfs_size = get_rootfs_size(d)
> @@ -78,7 +75,7 @@ do_rootfs[deptask] = "do_deploy_deb"
>   
>   do_mark_rootfs() {
>       update_etc_os_release \
> -        --build-id "${@get_build_id(d)}" --variant "${DESCRIPTION}" \
> +        --build-id $(get_build_id) --variant "${DESCRIPTION}" \
>           "${IMAGE_ROOTFS}"
>   }
>   
> 


-- 
Maxim Osipov
ilbers GmbH
Maria-Merian-Str. 8
85521 Ottobrunn
Germany
+49 (151) 6517 6917
mosipov@ilbers.de
http://ilbers.de/
Commercial register Munich, HRB 214197
General Manager: Baurzhan Ismagulov

      reply	other threads:[~2018-07-25 10:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-22 22:28 Jan Kiszka
2018-07-25 10:34 ` Maxim Yu. Osipov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b2ade7dc-10dc-8ad0-ee7e-d425f37e03df@ilbers.de \
    --to=mosipov@ilbers.de \
    --cc=isar-users@googlegroups.com \
    --cc=jan.kiszka@siemens.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox