From: Jan Kiszka <jan.kiszka@siemens.com>
To: isar-users <isar-users@googlegroups.com>
Cc: Henning Schild <henning.schild@siemens.com>
Subject: [PATCH] meta/image: Rewrite get_build_id as shell function
Date: Mon, 23 Jul 2018 00:28:41 +0200 [thread overview]
Message-ID: <1572b44a-f1c5-1fef-8296-1b1d3a5f2f23@siemens.com> (raw)
This avoid warning the user multiple times because get_build_id gets
called each time the class is evaluated.
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}"
}
--
2.16.4
next reply other threads:[~2018-07-22 22:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-22 22:28 Jan Kiszka [this message]
2018-07-25 10:34 ` Maxim Yu. Osipov
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=1572b44a-f1c5-1fef-8296-1b1d3a5f2f23@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=henning.schild@siemens.com \
--cc=isar-users@googlegroups.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