* [PATCH] meta/image: Rewrite get_build_id as shell function
@ 2018-07-22 22:28 Jan Kiszka
2018-07-25 10:34 ` Maxim Yu. Osipov
0 siblings, 1 reply; 2+ messages in thread
From: Jan Kiszka @ 2018-07-22 22:28 UTC (permalink / raw)
To: isar-users; +Cc: Henning Schild
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] meta/image: Rewrite get_build_id as shell function
2018-07-22 22:28 [PATCH] meta/image: Rewrite get_build_id as shell function Jan Kiszka
@ 2018-07-25 10:34 ` Maxim Yu. Osipov
0 siblings, 0 replies; 2+ messages in thread
From: Maxim Yu. Osipov @ 2018-07-25 10:34 UTC (permalink / raw)
To: Jan Kiszka; +Cc: isar-users
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-07-25 10:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-22 22:28 [PATCH] meta/image: Rewrite get_build_id as shell function Jan Kiszka
2018-07-25 10:34 ` Maxim Yu. Osipov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox