public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH] meta/image: leave BUILD_ID and VARIANT in /etc/os-release
@ 2018-06-28 15:05 Henning Schild
  2018-06-28 15:09 ` Henning Schild
  2018-07-02  9:15 ` Maxim Yu. Osipov
  0 siblings, 2 replies; 17+ messages in thread
From: Henning Schild @ 2018-06-28 15:05 UTC (permalink / raw)
  To: isar-users; +Cc: Henning Schild

This commit adds support for leaving a mark in the resulting image.
That should allow you to tell what code you used to create it. By
default "git describe" will be used on Isar itself to come up with a
BUILD_ID. And the DESCRIPTION of the image will become the VARIANT.

see
https://www.freedesktop.org/software/systemd/man/os-release.html

Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
 meta-isar/recipes-core/images/isar-image-base.bb |  2 ++
 meta/classes/image.bbclass                       | 27 ++++++++++++++++++++++++
 meta/classes/isar-bootstrap-helper.bbclass       | 26 +++++++++++++++++++++++
 3 files changed, 55 insertions(+)

diff --git a/meta-isar/recipes-core/images/isar-image-base.bb b/meta-isar/recipes-core/images/isar-image-base.bb
index 6cdc6b2..c72bfdb 100644
--- a/meta-isar/recipes-core/images/isar-image-base.bb
+++ b/meta-isar/recipes-core/images/isar-image-base.bb
@@ -24,6 +24,8 @@ IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge"
 
 WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}"
 
+ISAR_GIT_RELEASE_PATH ?= "${LAYERDIR_isar}"
+
 do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
                              ${IMAGE_ROOTFS}/isar-apt"
 
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 3bdcb2f..00040e5 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -34,6 +34,25 @@ def get_rootfs_size(d):
 
     return base_size + rootfs_extra * 1024
 
+# we assume that one git commit can describe the whole image, so you should be
+# using submodules, kas, or something like that
+# set ISAR_GIT_RELEASE_PATH to that one "most significant" layer
+# when not using git, override do_mark_rootfs
+def get_build_id(d):
+    import subprocess
+    if (len(d.getVar("BBLAYERS", True).strip().split(' ')) != 2 and
+        (d.getVar("ISAR_GIT_RELEASE_PATH", True) ==
+         d.getVar("LAYERDIR_isar", True))):
+        bb.warn('You are using external layers that will not be considered' +
+                ' in the build_id. Considder setting ISAR_GIT_RELEASE_PATH.')
+    base = ["git", "-C", d.getVar("ISAR_GIT_RELEASE_PATH", True)]
+    if (0 == subprocess.call(base + ["rev-parse"])):
+        v = subprocess.check_output(base +
+                                    ["describe", "--long", "--dirty",
+                                     "--always"], universal_newlines=True)
+        return v.rstrip()
+    return ""
+
 python set_image_size () {
     rootfs_size = get_rootfs_size(d)
     d.setVar('ROOTFS_SIZE', str(rootfs_size))
@@ -56,6 +75,14 @@ do_rootfs() {
 addtask rootfs before do_build after do_unpack
 do_rootfs[deptask] = "do_deploy_deb"
 
+do_mark_rootfs() {
+    update_etc_os_release \
+        --build-id "${@get_build_id(d)}" --variant "${DESCRIPTION}" \
+        "${IMAGE_ROOTFS}"
+}
+
+addtask mark_rootfs before do_copy_boot_files after do_rootfs
+
 do_copy_boot_files() {
     KERNEL_IMAGE=${@get_image_name(d, 'vmlinuz')[1]}
     if [ -n "${KERNEL_IMAGE}" ]; then
diff --git a/meta/classes/isar-bootstrap-helper.bbclass b/meta/classes/isar-bootstrap-helper.bbclass
index 3c10fc7..f375853 100644
--- a/meta/classes/isar-bootstrap-helper.bbclass
+++ b/meta/classes/isar-bootstrap-helper.bbclass
@@ -14,6 +14,32 @@ def reverse_bb_array(d, varname):
     array = reversed(array.split())
     return " ".join(i for i in array)
 
+update_etc_os_release() {
+    OS_RELEASE_BUILD_ID=""
+    OS_RELEASE_VARIANT=""
+    while true; do
+        case "$1" in
+	--build-id) OS_RELEASE_BUILD_ID=$2; shift ;;
+	--variant) OS_RELEASE_VARIANT=$2; shift ;;
+        -*) bbfatal "$0: invalid option specified: $1" ;;
+        *) break ;;
+        esac
+        shift
+    done
+    ROOTFSDIR="$1"
+
+    if [ -n "${OS_RELEASE_BUILD_ID}" ]; then
+        sudo sed -i '/^BUILD_ID=.*/d' ${ROOTFSDIR}/etc/os-release
+        echo "BUILD_ID=\"${OS_RELEASE_BUILD_ID}\"" | \
+            sudo tee -a ${ROOTFSDIR}/etc/os-release
+    fi
+    if [ -n "${OS_RELEASE_VARIANT}" ]; then
+        sudo sed -i '/^VARIANT=.*/d' ${ROOTFSDIR}/etc/os-release
+        echo "VARIANT=\"${OS_RELEASE_VARIANT}\"" | \
+            sudo tee -a ${ROOTFSDIR}/etc/os-release
+    fi
+}
+
 setup_root_file_system() {
     CLEAN=""
     FSTAB=""
-- 
2.16.4


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] meta/image: leave BUILD_ID and VARIANT in /etc/os-release
  2018-06-28 15:05 [PATCH] meta/image: leave BUILD_ID and VARIANT in /etc/os-release Henning Schild
@ 2018-06-28 15:09 ` Henning Schild
  2018-06-29 10:04   ` Maxim Yu. Osipov
  2018-07-02  9:15 ` Maxim Yu. Osipov
  1 sibling, 1 reply; 17+ messages in thread
From: Henning Schild @ 2018-06-28 15:09 UTC (permalink / raw)
  To: isar-users

Am Thu, 28 Jun 2018 17:05:21 +0200
schrieb Henning Schild <henning.schild@siemens.com>:

> This commit adds support for leaving a mark in the resulting image.
> That should allow you to tell what code you used to create it. By
> default "git describe" will be used on Isar itself to come up with a
> BUILD_ID. And the DESCRIPTION of the image will become the VARIANT.
> 
> see
> https://www.freedesktop.org/software/systemd/man/os-release.html
> 
> Signed-off-by: Henning Schild <henning.schild@siemens.com>
> ---
>  meta-isar/recipes-core/images/isar-image-base.bb |  2 ++
>  meta/classes/image.bbclass                       | 27
> ++++++++++++++++++++++++
> meta/classes/isar-bootstrap-helper.bbclass       | 26
> +++++++++++++++++++++++ 3 files changed, 55 insertions(+)
> 
> diff --git a/meta-isar/recipes-core/images/isar-image-base.bb
> b/meta-isar/recipes-core/images/isar-image-base.bb index
> 6cdc6b2..c72bfdb 100644 ---
> a/meta-isar/recipes-core/images/isar-image-base.bb +++
> b/meta-isar/recipes-core/images/isar-image-base.bb @@ -24,6 +24,8 @@
> IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge" 
>  WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}"
>  
> +ISAR_GIT_RELEASE_PATH ?= "${LAYERDIR_isar}"
> +
>  do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
>                               ${IMAGE_ROOTFS}/isar-apt"
>  
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index 3bdcb2f..00040e5 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -34,6 +34,25 @@ def get_rootfs_size(d):
>  
>      return base_size + rootfs_extra * 1024
>  
> +# we assume that one git commit can describe the whole image, so you
> should be +# using submodules, kas, or something like that
> +# set ISAR_GIT_RELEASE_PATH to that one "most significant" layer
> +# when not using git, override do_mark_rootfs
> +def get_build_id(d):
> +    import subprocess
> +    if (len(d.getVar("BBLAYERS", True).strip().split(' ')) != 2 and
> +        (d.getVar("ISAR_GIT_RELEASE_PATH", True) ==
> +         d.getVar("LAYERDIR_isar", True))):
> +        bb.warn('You are using external layers that will not be
> considered' +
> +                ' in the build_id. Considder setting
> ISAR_GIT_RELEASE_PATH.')
> +    base = ["git", "-C", d.getVar("ISAR_GIT_RELEASE_PATH", True)]
> +    if (0 == subprocess.call(base + ["rev-parse"])):
> +        v = subprocess.check_output(base +
> +                                    ["describe", "--long", "--dirty",
> +                                     "--always"],

Here i am not sure what arguments to use. That also depends on the
tagging of the project. We might want to make this configurable, since
the "most significant" layer might use different tagging. Opinions?

In that regard i realized that the tags on Isar are not consistent.
v0.3 seems to be the last annotated one.

Henning

> universal_newlines=True)
> +        return v.rstrip()
> +    return ""
> +
>  python set_image_size () {
>      rootfs_size = get_rootfs_size(d)
>      d.setVar('ROOTFS_SIZE', str(rootfs_size))
> @@ -56,6 +75,14 @@ do_rootfs() {
>  addtask rootfs before do_build after do_unpack
>  do_rootfs[deptask] = "do_deploy_deb"
>  
> +do_mark_rootfs() {
> +    update_etc_os_release \
> +        --build-id "${@get_build_id(d)}" --variant "${DESCRIPTION}" \
> +        "${IMAGE_ROOTFS}"
> +}
> +
> +addtask mark_rootfs before do_copy_boot_files after do_rootfs
> +
>  do_copy_boot_files() {
>      KERNEL_IMAGE=${@get_image_name(d, 'vmlinuz')[1]}
>      if [ -n "${KERNEL_IMAGE}" ]; then
> diff --git a/meta/classes/isar-bootstrap-helper.bbclass
> b/meta/classes/isar-bootstrap-helper.bbclass index 3c10fc7..f375853
> 100644 --- a/meta/classes/isar-bootstrap-helper.bbclass
> +++ b/meta/classes/isar-bootstrap-helper.bbclass
> @@ -14,6 +14,32 @@ def reverse_bb_array(d, varname):
>      array = reversed(array.split())
>      return " ".join(i for i in array)
>  
> +update_etc_os_release() {
> +    OS_RELEASE_BUILD_ID=""
> +    OS_RELEASE_VARIANT=""
> +    while true; do
> +        case "$1" in
> +	--build-id) OS_RELEASE_BUILD_ID=$2; shift ;;
> +	--variant) OS_RELEASE_VARIANT=$2; shift ;;
> +        -*) bbfatal "$0: invalid option specified: $1" ;;
> +        *) break ;;
> +        esac
> +        shift
> +    done
> +    ROOTFSDIR="$1"
> +
> +    if [ -n "${OS_RELEASE_BUILD_ID}" ]; then
> +        sudo sed -i '/^BUILD_ID=.*/d' ${ROOTFSDIR}/etc/os-release
> +        echo "BUILD_ID=\"${OS_RELEASE_BUILD_ID}\"" | \
> +            sudo tee -a ${ROOTFSDIR}/etc/os-release
> +    fi
> +    if [ -n "${OS_RELEASE_VARIANT}" ]; then
> +        sudo sed -i '/^VARIANT=.*/d' ${ROOTFSDIR}/etc/os-release
> +        echo "VARIANT=\"${OS_RELEASE_VARIANT}\"" | \
> +            sudo tee -a ${ROOTFSDIR}/etc/os-release
> +    fi
> +}
> +
>  setup_root_file_system() {
>      CLEAN=""
>      FSTAB=""


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] meta/image: leave BUILD_ID and VARIANT in /etc/os-release
  2018-06-28 15:09 ` Henning Schild
@ 2018-06-29 10:04   ` Maxim Yu. Osipov
  2018-06-29 11:46     ` Henning Schild
  0 siblings, 1 reply; 17+ messages in thread
From: Maxim Yu. Osipov @ 2018-06-29 10:04 UTC (permalink / raw)
  To: Henning Schild, isar-users

Hi Henning,

On 06/28/2018 05:09 PM, Henning Schild wrote:
> Am Thu, 28 Jun 2018 17:05:21 +0200
> schrieb Henning Schild <henning.schild@siemens.com>:
> 
>> This commit adds support for leaving a mark in the resulting image.
>> That should allow you to tell what code you used to create it. By
>> default "git describe" will be used on Isar itself to come up with a
>> BUILD_ID. And the DESCRIPTION of the image will become the VARIANT.
>>
>> see
>> https://www.freedesktop.org/software/systemd/man/os-release.html
>>
>> Signed-off-by: Henning Schild <henning.schild@siemens.com>
>> ---
>>   meta-isar/recipes-core/images/isar-image-base.bb |  2 ++
>>   meta/classes/image.bbclass                       | 27
>> ++++++++++++++++++++++++
>> meta/classes/isar-bootstrap-helper.bbclass       | 26
>> +++++++++++++++++++++++ 3 files changed, 55 insertions(+)
>>
>> diff --git a/meta-isar/recipes-core/images/isar-image-base.bb
>> b/meta-isar/recipes-core/images/isar-image-base.bb index
>> 6cdc6b2..c72bfdb 100644 ---
>> a/meta-isar/recipes-core/images/isar-image-base.bb +++
>> b/meta-isar/recipes-core/images/isar-image-base.bb @@ -24,6 +24,8 @@
>> IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge"
>>   WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}"
>>   
>> +ISAR_GIT_RELEASE_PATH ?= "${LAYERDIR_isar}"
>> +
>>   do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
>>                                ${IMAGE_ROOTFS}/isar-apt"
>>   
>> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
>> index 3bdcb2f..00040e5 100644
>> --- a/meta/classes/image.bbclass
>> +++ b/meta/classes/image.bbclass
>> @@ -34,6 +34,25 @@ def get_rootfs_size(d):
>>   
>>       return base_size + rootfs_extra * 1024
>>   
>> +# we assume that one git commit can describe the whole image, so you
>> should be +# using submodules, kas, or something like that
>> +# set ISAR_GIT_RELEASE_PATH to that one "most significant" layer
>> +# when not using git, override do_mark_rootfs
>> +def get_build_id(d):
>> +    import subprocess
>> +    if (len(d.getVar("BBLAYERS", True).strip().split(' ')) != 2 and
>> +        (d.getVar("ISAR_GIT_RELEASE_PATH", True) ==
>> +         d.getVar("LAYERDIR_isar", True))):
>> +        bb.warn('You are using external layers that will not be
>> considered' +
>> +                ' in the build_id. Considder setting
>> ISAR_GIT_RELEASE_PATH.')
>> +    base = ["git", "-C", d.getVar("ISAR_GIT_RELEASE_PATH", True)]
>> +    if (0 == subprocess.call(base + ["rev-parse"])):
>> +        v = subprocess.check_output(base +
>> +                                    ["describe", "--long", "--dirty",
>> +                                     "--always"],
> 
> Here i am not sure what arguments to use. That also depends on the
> tagging of the project. We might want to make this configurable, since
> the "most significant" layer might use different tagging. Opinions?

In my opinion 'git describe --dirty --match "v[0-9].[0-9]*" would be enough.

It would be nice to add document describing versioning 
docs/VERSIONING.md. Something like that:

 >>>
ISAR Versioning

ISAR uses for release versioning unsigned, annotated tag
in format "v[0-9].[0-9]*".

The following procedure has to be followed for release versioning:

1) Update CHANGELOG.md in ISAR root directory.

2) Before creation of final release, prepare release candidate(s)
with the help of command 'git tag -a <release_candidate_tagname>', where
<release_candidate_tagname> has the format "v[0-9].[0-9]-rc[0-9]"

3) When final release is ready create annotated tag
with the help of command 'git tag -a <release_tagname>', where
<release_tagname> has the format "v[0-9].[0-9]"

BUILD_ID field in /etc/os-release keeps ISAR repository version
derived with the help of command 'git describe --dirty --match 
"v[0-9].[0-9]*'.

This command finds the most recent annotated tag that is reachable from 
a commit.
If the tag points to the commit, then only the tag is shown. Otherwise,
it suffixes the tag name with the number of additional commits on top of
the tagged object and the abbreviated object name of the most recent commit.
If the working tree is modified '-dirty' will be appended to the end of the
version string.

For example, BUILD_ID may have the values like
- "v3.0-rc2" for 3.0 release candidate 2
- "v3.0" for released 3.0 version
- "v3.0-112-g118cd4b" for developer's version,
meaning that 112 commits exist since recent release and the most
recent commit has abbreviated name 118cd4b.
- "v3.0-112-g118cd4b-dirty" for developer's version,
meaning that 112 commits exist since recent release, the most
recent commit has abbreviated name 118cd4b and the working tree
is modified.
 >>>

Is it OK?

> 
> In that regard i realized that the tags on Isar are not consistent.
> v0.3 seems to be the last annotated one.

Thank you for pointing this out - after applying your patch we will 
start to follow well defined versioning/release policy.

Kind regards,
Maxim.

> 
> Henning
> 
>> universal_newlines=True)
>> +        return v.rstrip()
>> +    return ""
>> +
>>   python set_image_size () {
>>       rootfs_size = get_rootfs_size(d)
>>       d.setVar('ROOTFS_SIZE', str(rootfs_size))
>> @@ -56,6 +75,14 @@ do_rootfs() {
>>   addtask rootfs before do_build after do_unpack
>>   do_rootfs[deptask] = "do_deploy_deb"
>>   
>> +do_mark_rootfs() {
>> +    update_etc_os_release \
>> +        --build-id "${@get_build_id(d)}" --variant "${DESCRIPTION}" \
>> +        "${IMAGE_ROOTFS}"
>> +}
>> +
>> +addtask mark_rootfs before do_copy_boot_files after do_rootfs
>> +
>>   do_copy_boot_files() {
>>       KERNEL_IMAGE=${@get_image_name(d, 'vmlinuz')[1]}
>>       if [ -n "${KERNEL_IMAGE}" ]; then
>> diff --git a/meta/classes/isar-bootstrap-helper.bbclass
>> b/meta/classes/isar-bootstrap-helper.bbclass index 3c10fc7..f375853
>> 100644 --- a/meta/classes/isar-bootstrap-helper.bbclass
>> +++ b/meta/classes/isar-bootstrap-helper.bbclass
>> @@ -14,6 +14,32 @@ def reverse_bb_array(d, varname):
>>       array = reversed(array.split())
>>       return " ".join(i for i in array)
>>   
>> +update_etc_os_release() {
>> +    OS_RELEASE_BUILD_ID=""
>> +    OS_RELEASE_VARIANT=""
>> +    while true; do
>> +        case "$1" in
>> +	--build-id) OS_RELEASE_BUILD_ID=$2; shift ;;
>> +	--variant) OS_RELEASE_VARIANT=$2; shift ;;
>> +        -*) bbfatal "$0: invalid option specified: $1" ;;
>> +        *) break ;;
>> +        esac
>> +        shift
>> +    done
>> +    ROOTFSDIR="$1"
>> +
>> +    if [ -n "${OS_RELEASE_BUILD_ID}" ]; then
>> +        sudo sed -i '/^BUILD_ID=.*/d' ${ROOTFSDIR}/etc/os-release
>> +        echo "BUILD_ID=\"${OS_RELEASE_BUILD_ID}\"" | \
>> +            sudo tee -a ${ROOTFSDIR}/etc/os-release
>> +    fi
>> +    if [ -n "${OS_RELEASE_VARIANT}" ]; then
>> +        sudo sed -i '/^VARIANT=.*/d' ${ROOTFSDIR}/etc/os-release
>> +        echo "VARIANT=\"${OS_RELEASE_VARIANT}\"" | \
>> +            sudo tee -a ${ROOTFSDIR}/etc/os-release
>> +    fi
>> +}
>> +
>>   setup_root_file_system() {
>>       CLEAN=""
>>       FSTAB=""
> 


-- 
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] 17+ messages in thread

* Re: [PATCH] meta/image: leave BUILD_ID and VARIANT in /etc/os-release
  2018-06-29 10:04   ` Maxim Yu. Osipov
@ 2018-06-29 11:46     ` Henning Schild
  0 siblings, 0 replies; 17+ messages in thread
From: Henning Schild @ 2018-06-29 11:46 UTC (permalink / raw)
  To: Maxim Yu. Osipov; +Cc: isar-users

Am Fri, 29 Jun 2018 12:04:25 +0200
schrieb "Maxim Yu. Osipov" <mosipov@ilbers.de>:

> Hi Henning,
> 
> On 06/28/2018 05:09 PM, Henning Schild wrote:
> > Am Thu, 28 Jun 2018 17:05:21 +0200
> > schrieb Henning Schild <henning.schild@siemens.com>:
> >   
> >> This commit adds support for leaving a mark in the resulting image.
> >> That should allow you to tell what code you used to create it. By
> >> default "git describe" will be used on Isar itself to come up with
> >> a BUILD_ID. And the DESCRIPTION of the image will become the
> >> VARIANT.
> >>
> >> see
> >> https://www.freedesktop.org/software/systemd/man/os-release.html
> >>
> >> Signed-off-by: Henning Schild <henning.schild@siemens.com>
> >> ---
> >>   meta-isar/recipes-core/images/isar-image-base.bb |  2 ++
> >>   meta/classes/image.bbclass                       | 27
> >> ++++++++++++++++++++++++
> >> meta/classes/isar-bootstrap-helper.bbclass       | 26
> >> +++++++++++++++++++++++ 3 files changed, 55 insertions(+)
> >>
> >> diff --git a/meta-isar/recipes-core/images/isar-image-base.bb
> >> b/meta-isar/recipes-core/images/isar-image-base.bb index
> >> 6cdc6b2..c72bfdb 100644 ---
> >> a/meta-isar/recipes-core/images/isar-image-base.bb +++
> >> b/meta-isar/recipes-core/images/isar-image-base.bb @@ -24,6 +24,8
> >> @@ IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge"
> >>   WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}"
> >>   
> >> +ISAR_GIT_RELEASE_PATH ?= "${LAYERDIR_isar}"
> >> +
> >>   do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
> >>                                ${IMAGE_ROOTFS}/isar-apt"
> >>   
> >> diff --git a/meta/classes/image.bbclass
> >> b/meta/classes/image.bbclass index 3bdcb2f..00040e5 100644
> >> --- a/meta/classes/image.bbclass
> >> +++ b/meta/classes/image.bbclass
> >> @@ -34,6 +34,25 @@ def get_rootfs_size(d):
> >>   
> >>       return base_size + rootfs_extra * 1024
> >>   
> >> +# we assume that one git commit can describe the whole image, so
> >> you should be +# using submodules, kas, or something like that
> >> +# set ISAR_GIT_RELEASE_PATH to that one "most significant" layer
> >> +# when not using git, override do_mark_rootfs
> >> +def get_build_id(d):
> >> +    import subprocess
> >> +    if (len(d.getVar("BBLAYERS", True).strip().split(' ')) != 2
> >> and
> >> +        (d.getVar("ISAR_GIT_RELEASE_PATH", True) ==
> >> +         d.getVar("LAYERDIR_isar", True))):
> >> +        bb.warn('You are using external layers that will not be
> >> considered' +
> >> +                ' in the build_id. Considder setting
> >> ISAR_GIT_RELEASE_PATH.')
> >> +    base = ["git", "-C", d.getVar("ISAR_GIT_RELEASE_PATH", True)]
> >> +    if (0 == subprocess.call(base + ["rev-parse"])):
> >> +        v = subprocess.check_output(base +
> >> +                                    ["describe", "--long",
> >> "--dirty",
> >> +                                     "--always"],  
> > 
> > Here i am not sure what arguments to use. That also depends on the
> > tagging of the project. We might want to make this configurable,
> > since the "most significant" layer might use different tagging.
> > Opinions?  
> 
> In my opinion 'git describe --dirty --match "v[0-9].[0-9]*" would be
> enough.
> 
> It would be nice to add document describing versioning 
> docs/VERSIONING.md. Something like that:
> 
>  >>>  
> ISAR Versioning
> 
> ISAR uses for release versioning unsigned, annotated tag
> in format "v[0-9].[0-9]*".
> 
> The following procedure has to be followed for release versioning:
> 
> 1) Update CHANGELOG.md in ISAR root directory.
> 
> 2) Before creation of final release, prepare release candidate(s)
> with the help of command 'git tag -a <release_candidate_tagname>',
> where <release_candidate_tagname> has the format
> "v[0-9].[0-9]-rc[0-9]"
> 
> 3) When final release is ready create annotated tag
> with the help of command 'git tag -a <release_tagname>', where
> <release_tagname> has the format "v[0-9].[0-9]"
> 
> BUILD_ID field in /etc/os-release keeps ISAR repository version
> derived with the help of command 'git describe --dirty --match 
> "v[0-9].[0-9]*'.
> 
> This command finds the most recent annotated tag that is reachable
> from a commit.
> If the tag points to the commit, then only the tag is shown.
> Otherwise, it suffixes the tag name with the number of additional
> commits on top of the tagged object and the abbreviated object name
> of the most recent commit. If the working tree is modified '-dirty'
> will be appended to the end of the version string.
> 
> For example, BUILD_ID may have the values like
> - "v3.0-rc2" for 3.0 release candidate 2
> - "v3.0" for released 3.0 version
> - "v3.0-112-g118cd4b" for developer's version,
> meaning that 112 commits exist since recent release and the most
> recent commit has abbreviated name 118cd4b.
> - "v3.0-112-g118cd4b-dirty" for developer's version,
> meaning that 112 commits exist since recent release, the most
> recent commit has abbreviated name 118cd4b and the working tree
> is modified.
>  >>>  
> 
> Is it OK?

Thanks for citing half of the manpage ;). I think you can do whatever
you want. The point is that get_build_id should be generic enough to
also work for repos calling their tags completely differently, or not
using tags at all.
Think of a private layer-repo that happens to use Isar but has another
versioning policy. The BUILD_ID in the image should be the one of that
layer, set by ISAR_GIT_RELEASE_PATH.
People that do not use git at all override do_mark_rootfs, but for the
ones using git it would be nice if they would not have to.

Henning

> 
> > 
> > In that regard i realized that the tags on Isar are not consistent.
> > v0.3 seems to be the last annotated one.  
> 
> Thank you for pointing this out - after applying your patch we will 
> start to follow well defined versioning/release policy.
> 
> Kind regards,
> Maxim.
> 
> > 
> > Henning
> >   
> >> universal_newlines=True)
> >> +        return v.rstrip()
> >> +    return ""
> >> +
> >>   python set_image_size () {
> >>       rootfs_size = get_rootfs_size(d)
> >>       d.setVar('ROOTFS_SIZE', str(rootfs_size))
> >> @@ -56,6 +75,14 @@ do_rootfs() {
> >>   addtask rootfs before do_build after do_unpack
> >>   do_rootfs[deptask] = "do_deploy_deb"
> >>   
> >> +do_mark_rootfs() {
> >> +    update_etc_os_release \
> >> +        --build-id "${@get_build_id(d)}" --variant
> >> "${DESCRIPTION}" \
> >> +        "${IMAGE_ROOTFS}"
> >> +}
> >> +
> >> +addtask mark_rootfs before do_copy_boot_files after do_rootfs
> >> +
> >>   do_copy_boot_files() {
> >>       KERNEL_IMAGE=${@get_image_name(d, 'vmlinuz')[1]}
> >>       if [ -n "${KERNEL_IMAGE}" ]; then
> >> diff --git a/meta/classes/isar-bootstrap-helper.bbclass
> >> b/meta/classes/isar-bootstrap-helper.bbclass index 3c10fc7..f375853
> >> 100644 --- a/meta/classes/isar-bootstrap-helper.bbclass
> >> +++ b/meta/classes/isar-bootstrap-helper.bbclass
> >> @@ -14,6 +14,32 @@ def reverse_bb_array(d, varname):
> >>       array = reversed(array.split())
> >>       return " ".join(i for i in array)
> >>   
> >> +update_etc_os_release() {
> >> +    OS_RELEASE_BUILD_ID=""
> >> +    OS_RELEASE_VARIANT=""
> >> +    while true; do
> >> +        case "$1" in
> >> +	--build-id) OS_RELEASE_BUILD_ID=$2; shift ;;
> >> +	--variant) OS_RELEASE_VARIANT=$2; shift ;;
> >> +        -*) bbfatal "$0: invalid option specified: $1" ;;
> >> +        *) break ;;
> >> +        esac
> >> +        shift
> >> +    done
> >> +    ROOTFSDIR="$1"
> >> +
> >> +    if [ -n "${OS_RELEASE_BUILD_ID}" ]; then
> >> +        sudo sed -i '/^BUILD_ID=.*/d' ${ROOTFSDIR}/etc/os-release
> >> +        echo "BUILD_ID=\"${OS_RELEASE_BUILD_ID}\"" | \
> >> +            sudo tee -a ${ROOTFSDIR}/etc/os-release
> >> +    fi
> >> +    if [ -n "${OS_RELEASE_VARIANT}" ]; then
> >> +        sudo sed -i '/^VARIANT=.*/d' ${ROOTFSDIR}/etc/os-release
> >> +        echo "VARIANT=\"${OS_RELEASE_VARIANT}\"" | \
> >> +            sudo tee -a ${ROOTFSDIR}/etc/os-release
> >> +    fi
> >> +}
> >> +
> >>   setup_root_file_system() {
> >>       CLEAN=""
> >>       FSTAB=""  
> >   
> 
> 


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] meta/image: leave BUILD_ID and VARIANT in /etc/os-release
  2018-06-28 15:05 [PATCH] meta/image: leave BUILD_ID and VARIANT in /etc/os-release Henning Schild
  2018-06-28 15:09 ` Henning Schild
@ 2018-07-02  9:15 ` Maxim Yu. Osipov
  2018-07-02 18:19   ` [PATCH] meta/image: allow customization of git command we use fo BUILD_ID Henning Schild
  2018-07-03  7:39   ` [PATCH] meta/image: allow customization of " Henning Schild
  1 sibling, 2 replies; 17+ messages in thread
From: Maxim Yu. Osipov @ 2018-07-02  9:15 UTC (permalink / raw)
  To: Henning Schild, isar-users

On 06/28/2018 06:05 PM, Henning Schild wrote:
> This commit adds support for leaving a mark in the resulting image.
> That should allow you to tell what code you used to create it. By
> default "git describe" will be used on Isar itself to come up with a
> BUILD_ID. And the DESCRIPTION of the image will become the VARIANT.
> 
> see
> https://www.freedesktop.org/software/systemd/man/os-release.html

Applied to the 'next',

Thanks,
Maxim.

> Signed-off-by: Henning Schild <henning.schild@siemens.com>
> ---
>   meta-isar/recipes-core/images/isar-image-base.bb |  2 ++
>   meta/classes/image.bbclass                       | 27 ++++++++++++++++++++++++
>   meta/classes/isar-bootstrap-helper.bbclass       | 26 +++++++++++++++++++++++
>   3 files changed, 55 insertions(+)
> 
> diff --git a/meta-isar/recipes-core/images/isar-image-base.bb b/meta-isar/recipes-core/images/isar-image-base.bb
> index 6cdc6b2..c72bfdb 100644
> --- a/meta-isar/recipes-core/images/isar-image-base.bb
> +++ b/meta-isar/recipes-core/images/isar-image-base.bb
> @@ -24,6 +24,8 @@ IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge"
>   
>   WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}"
>   
> +ISAR_GIT_RELEASE_PATH ?= "${LAYERDIR_isar}"
> +
>   do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
>                                ${IMAGE_ROOTFS}/isar-apt"
>   
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index 3bdcb2f..00040e5 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -34,6 +34,25 @@ def get_rootfs_size(d):
>   
>       return base_size + rootfs_extra * 1024
>   
> +# we assume that one git commit can describe the whole image, so you should be
> +# using submodules, kas, or something like that
> +# set ISAR_GIT_RELEASE_PATH to that one "most significant" layer
> +# when not using git, override do_mark_rootfs
> +def get_build_id(d):
> +    import subprocess
> +    if (len(d.getVar("BBLAYERS", True).strip().split(' ')) != 2 and
> +        (d.getVar("ISAR_GIT_RELEASE_PATH", True) ==
> +         d.getVar("LAYERDIR_isar", True))):
> +        bb.warn('You are using external layers that will not be considered' +
> +                ' in the build_id. Considder setting ISAR_GIT_RELEASE_PATH.')
> +    base = ["git", "-C", d.getVar("ISAR_GIT_RELEASE_PATH", True)]
> +    if (0 == subprocess.call(base + ["rev-parse"])):
> +        v = subprocess.check_output(base +
> +                                    ["describe", "--long", "--dirty",
> +                                     "--always"], universal_newlines=True)
> +        return v.rstrip()
> +    return ""
> +
>   python set_image_size () {
>       rootfs_size = get_rootfs_size(d)
>       d.setVar('ROOTFS_SIZE', str(rootfs_size))
> @@ -56,6 +75,14 @@ do_rootfs() {
>   addtask rootfs before do_build after do_unpack
>   do_rootfs[deptask] = "do_deploy_deb"
>   
> +do_mark_rootfs() {
> +    update_etc_os_release \
> +        --build-id "${@get_build_id(d)}" --variant "${DESCRIPTION}" \
> +        "${IMAGE_ROOTFS}"
> +}
> +
> +addtask mark_rootfs before do_copy_boot_files after do_rootfs
> +
>   do_copy_boot_files() {
>       KERNEL_IMAGE=${@get_image_name(d, 'vmlinuz')[1]}
>       if [ -n "${KERNEL_IMAGE}" ]; then
> diff --git a/meta/classes/isar-bootstrap-helper.bbclass b/meta/classes/isar-bootstrap-helper.bbclass
> index 3c10fc7..f375853 100644
> --- a/meta/classes/isar-bootstrap-helper.bbclass
> +++ b/meta/classes/isar-bootstrap-helper.bbclass
> @@ -14,6 +14,32 @@ def reverse_bb_array(d, varname):
>       array = reversed(array.split())
>       return " ".join(i for i in array)
>   
> +update_etc_os_release() {
> +    OS_RELEASE_BUILD_ID=""
> +    OS_RELEASE_VARIANT=""
> +    while true; do
> +        case "$1" in
> +	--build-id) OS_RELEASE_BUILD_ID=$2; shift ;;
> +	--variant) OS_RELEASE_VARIANT=$2; shift ;;
> +        -*) bbfatal "$0: invalid option specified: $1" ;;
> +        *) break ;;
> +        esac
> +        shift
> +    done
> +    ROOTFSDIR="$1"
> +
> +    if [ -n "${OS_RELEASE_BUILD_ID}" ]; then
> +        sudo sed -i '/^BUILD_ID=.*/d' ${ROOTFSDIR}/etc/os-release
> +        echo "BUILD_ID=\"${OS_RELEASE_BUILD_ID}\"" | \
> +            sudo tee -a ${ROOTFSDIR}/etc/os-release
> +    fi
> +    if [ -n "${OS_RELEASE_VARIANT}" ]; then
> +        sudo sed -i '/^VARIANT=.*/d' ${ROOTFSDIR}/etc/os-release
> +        echo "VARIANT=\"${OS_RELEASE_VARIANT}\"" | \
> +            sudo tee -a ${ROOTFSDIR}/etc/os-release
> +    fi
> +}
> +
>   setup_root_file_system() {
>       CLEAN=""
>       FSTAB=""
> 


-- 
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] 17+ messages in thread

* [PATCH] meta/image: allow customization of git command we use fo BUILD_ID
  2018-07-02  9:15 ` Maxim Yu. Osipov
@ 2018-07-02 18:19   ` Henning Schild
  2018-07-02 18:30     ` Henning Schild
  2018-07-03  7:50     ` Henning Schild
  2018-07-03  7:39   ` [PATCH] meta/image: allow customization of " Henning Schild
  1 sibling, 2 replies; 17+ messages in thread
From: Henning Schild @ 2018-07-02 18:19 UTC (permalink / raw)
  To: isar-users; +Cc: Maxim Yu . Osipov, Jan Kiszka, Henning Schild

One of the previous patches introduced the feature to leave some build
system information in the rootfs. The git command to derive that
information was kept pretty repository agnostic.

This patch makes the command Isar-specific and allows users to customize
the command to their needs if they use a different tagging scheme in
their repository.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
 meta-isar/recipes-core/images/isar-image-base.bb |  1 +
 meta/classes/image.bbclass                       | 13 +++++++------
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/meta-isar/recipes-core/images/isar-image-base.bb b/meta-isar/recipes-core/images/isar-image-base.bb
index c72bfdb..2ae1c01 100644
--- a/meta-isar/recipes-core/images/isar-image-base.bb
+++ b/meta-isar/recipes-core/images/isar-image-base.bb
@@ -25,6 +25,7 @@ IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge"
 WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}"
 
 ISAR_GIT_RELEASE_PATH ?= "${LAYERDIR_isar}"
+ISAR_GIT_RELEASE_CMD ?= "git -C ${ISAR_GIT_RELEASE_PATH} describe --tags --dirty --match 'v[0-9].[0-9]*'"
 
 do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
                              ${IMAGE_ROOTFS}/isar-apt"
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 7935b69..d60c6bb 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -36,7 +36,8 @@ def get_rootfs_size(d):
 
 # we assume that one git commit can describe the whole image, so you should be
 # using submodules, kas, or something like that
-# set ISAR_GIT_RELEASE_PATH to that one "most significant" layer
+# set ISAR_GIT_RELEASE_PATH to that one "most significant" layer and adjust
+# ISAR_GIT_RELEASE_ARGS according to your tagging
 # when not using git, override do_mark_rootfs
 def get_build_id(d):
     import subprocess
@@ -45,11 +46,11 @@ def get_build_id(d):
          d.getVar("LAYERDIR_isar", True))):
         bb.warn('You are using external layers that will not be considered' +
                 ' in the build_id. Considder setting ISAR_GIT_RELEASE_PATH.')
-    base = ["git", "-C", d.getVar("ISAR_GIT_RELEASE_PATH", True)]
-    if (0 == subprocess.call(base + ["rev-parse"])):
-        v = subprocess.check_output(base +
-                                    ["describe", "--long", "--dirty",
-                                     "--always"], universal_newlines=True)
+    if (0 == subprocess.call(["git", "-C",
+                              d.getVar("ISAR_GIT_RELEASE_PATH", True),
+                              "rev-parse"])):
+        cmd = d.getVar("ISAR_GIT_RELEASE_CMD", True)
+        v = subprocess.check_output(cmd, shell=True, universal_newlines=True)
         return v.rstrip()
     return ""
 
-- 
2.16.4


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] meta/image: allow customization of git command we use fo BUILD_ID
  2018-07-02 18:19   ` [PATCH] meta/image: allow customization of git command we use fo BUILD_ID Henning Schild
@ 2018-07-02 18:30     ` Henning Schild
  2018-07-03  7:50     ` Henning Schild
  1 sibling, 0 replies; 17+ messages in thread
From: Henning Schild @ 2018-07-02 18:30 UTC (permalink / raw)
  To: isar-users; +Cc: Maxim Yu . Osipov, Jan Kiszka

Hi,

in the previous one i wanted to start a discussion what the "correct"
git describe arguments would be. But there where not too many opinions
before it got merged.
I talked to Jan off list and he agreed that users should be able to
control it.
But now that i just saw the patch on the list i realize that this is
getting out of hand. I just introduced 2 variables and a new task, as
interface to the user. That seems to be overkill.

I will send an updated version, maybe of both patches.

Henning

Am Mon, 2 Jul 2018 20:19:57 +0200
schrieb Henning Schild <henning.schild@siemens.com>:

> One of the previous patches introduced the feature to leave some build
> system information in the rootfs. The git command to derive that
> information was kept pretty repository agnostic.
> 
> This patch makes the command Isar-specific and allows users to
> customize the command to their needs if they use a different tagging
> scheme in their repository.
> 
> Signed-off-by: Henning Schild <henning.schild@siemens.com>
> ---
>  meta-isar/recipes-core/images/isar-image-base.bb |  1 +
>  meta/classes/image.bbclass                       | 13 +++++++------
>  2 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/meta-isar/recipes-core/images/isar-image-base.bb
> b/meta-isar/recipes-core/images/isar-image-base.bb index
> c72bfdb..2ae1c01 100644 ---
> a/meta-isar/recipes-core/images/isar-image-base.bb +++
> b/meta-isar/recipes-core/images/isar-image-base.bb @@ -25,6 +25,7 @@
> IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge" WORKDIR =
> "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}" 
>  ISAR_GIT_RELEASE_PATH ?= "${LAYERDIR_isar}"
> +ISAR_GIT_RELEASE_CMD ?= "git -C ${ISAR_GIT_RELEASE_PATH} describe
> --tags --dirty --match 'v[0-9].[0-9]*'" 
>  do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
>                               ${IMAGE_ROOTFS}/isar-apt"
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index 7935b69..d60c6bb 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -36,7 +36,8 @@ def get_rootfs_size(d):
>  
>  # we assume that one git commit can describe the whole image, so you
> should be # using submodules, kas, or something like that
> -# set ISAR_GIT_RELEASE_PATH to that one "most significant" layer
> +# set ISAR_GIT_RELEASE_PATH to that one "most significant" layer and
> adjust +# ISAR_GIT_RELEASE_ARGS according to your tagging
>  # when not using git, override do_mark_rootfs
>  def get_build_id(d):
>      import subprocess
> @@ -45,11 +46,11 @@ def get_build_id(d):
>           d.getVar("LAYERDIR_isar", True))):
>          bb.warn('You are using external layers that will not be
> considered' + ' in the build_id. Considder setting
> ISAR_GIT_RELEASE_PATH.')
> -    base = ["git", "-C", d.getVar("ISAR_GIT_RELEASE_PATH", True)]
> -    if (0 == subprocess.call(base + ["rev-parse"])):
> -        v = subprocess.check_output(base +
> -                                    ["describe", "--long", "--dirty",
> -                                     "--always"],
> universal_newlines=True)
> +    if (0 == subprocess.call(["git", "-C",
> +                              d.getVar("ISAR_GIT_RELEASE_PATH",
> True),
> +                              "rev-parse"])):
> +        cmd = d.getVar("ISAR_GIT_RELEASE_CMD", True)
> +        v = subprocess.check_output(cmd, shell=True,
> universal_newlines=True) return v.rstrip()
>      return ""
>  


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH] meta/image: allow customization of command we use fo BUILD_ID
  2018-07-02  9:15 ` Maxim Yu. Osipov
  2018-07-02 18:19   ` [PATCH] meta/image: allow customization of git command we use fo BUILD_ID Henning Schild
@ 2018-07-03  7:39   ` Henning Schild
  2018-07-03  7:49     ` Henning Schild
                       ` (3 more replies)
  1 sibling, 4 replies; 17+ messages in thread
From: Henning Schild @ 2018-07-03  7:39 UTC (permalink / raw)
  To: isar-users; +Cc: Maxim Yu . Osipov, Jan Kiszka, Henning Schild

One of the previous patches introduced the feature to leave some build
system information in the rootfs. The git command to derive that
information was kept pretty repository agnostic.

This patch makes the command Isar-specific and allows users to customize
the command to their needs if they use a different tagging scheme in
their repository, or if they do not use git at all.

Signed-off-by: Henning Schild <henning.schild@siemens.com>
---
 meta-isar/recipes-core/images/isar-image-base.bb |  3 ++-
 meta/classes/image.bbclass                       | 27 ++++++++++++------------
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/meta-isar/recipes-core/images/isar-image-base.bb b/meta-isar/recipes-core/images/isar-image-base.bb
index c72bfdb..a24aa3e 100644
--- a/meta-isar/recipes-core/images/isar-image-base.bb
+++ b/meta-isar/recipes-core/images/isar-image-base.bb
@@ -24,7 +24,8 @@ IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge"
 
 WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}"
 
-ISAR_GIT_RELEASE_PATH ?= "${LAYERDIR_isar}"
+ISAR_RELEASE_CMD_DEFAULT = "git -C ${LAYERDIR_isar} describe --tags --dirty --match 'v[0-9].[0-9]*'"
+ISAR_RELEASE_CMD ?= "${ISAR_RELEASE_CMD_DEFAULT}"
 
 do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
                              ${IMAGE_ROOTFS}/isar-apt"
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index 7935b69..077c550 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -34,24 +34,25 @@ def get_rootfs_size(d):
 
     return base_size + rootfs_extra * 1024
 
-# we assume that one git commit can describe the whole image, so you should be
-# using submodules, kas, or something like that
-# set ISAR_GIT_RELEASE_PATH to that one "most significant" layer
-# when not using git, override do_mark_rootfs
+# here we call a command that should describe your whole build system,
+# 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_GIT_RELEASE_PATH", True) ==
-         d.getVar("LAYERDIR_isar", True))):
+        (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. Considder setting ISAR_GIT_RELEASE_PATH.')
-    base = ["git", "-C", d.getVar("ISAR_GIT_RELEASE_PATH", True)]
-    if (0 == subprocess.call(base + ["rev-parse"])):
-        v = subprocess.check_output(base +
-                                    ["describe", "--long", "--dirty",
-                                     "--always"], universal_newlines=True)
+                ' 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()
-    return ""
+    except subprocess.CalledProcessError as e:
+        bb.warn('\"%s\" returned %d, returning empty build_id' %
+                (e.cmd, e.returncode))
+        return ""
 
 python set_image_size () {
     rootfs_size = get_rootfs_size(d)
-- 
2.16.4


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] meta/image: allow customization of command we use fo BUILD_ID
  2018-07-03  7:39   ` [PATCH] meta/image: allow customization of " Henning Schild
@ 2018-07-03  7:49     ` Henning Schild
  2018-07-20 12:38     ` Henning Schild
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 17+ messages in thread
From: Henning Schild @ 2018-07-03  7:49 UTC (permalink / raw)
  To: isar-users; +Cc: Maxim Yu . Osipov, Jan Kiszka

Hi,

so this is what i came up with now. It allows the user to specify a
totally custom command, not even git-specific. The interface is one
variable ISAR_RELEASE_CMD and the task do_mark_rootfs.

Alternative commands could i.e. be
ISAR_RELEASE_CMD = "true" # to disable
or hg, svn, "echo 42" ...

If the command fails we always get the empty string. Here we could
discuss if "v${PV}" would make sense. In that case isar-image-base
should increment its PV on every Isar release.

Henning

Am Tue, 3 Jul 2018 09:39:28 +0200
schrieb Henning Schild <henning.schild@siemens.com>:

> One of the previous patches introduced the feature to leave some build
> system information in the rootfs. The git command to derive that
> information was kept pretty repository agnostic.
> 
> This patch makes the command Isar-specific and allows users to
> customize the command to their needs if they use a different tagging
> scheme in their repository, or if they do not use git at all.
> 
> Signed-off-by: Henning Schild <henning.schild@siemens.com>
> ---
>  meta-isar/recipes-core/images/isar-image-base.bb |  3 ++-
>  meta/classes/image.bbclass                       | 27
> ++++++++++++------------ 2 files changed, 16 insertions(+), 14
> deletions(-)
> 
> diff --git a/meta-isar/recipes-core/images/isar-image-base.bb
> b/meta-isar/recipes-core/images/isar-image-base.bb index
> c72bfdb..a24aa3e 100644 ---
> a/meta-isar/recipes-core/images/isar-image-base.bb +++
> b/meta-isar/recipes-core/images/isar-image-base.bb @@ -24,7 +24,8 @@
> IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge" 
>  WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}"
>  
> -ISAR_GIT_RELEASE_PATH ?= "${LAYERDIR_isar}"
> +ISAR_RELEASE_CMD_DEFAULT = "git -C ${LAYERDIR_isar} describe --tags
> --dirty --match 'v[0-9].[0-9]*'" +ISAR_RELEASE_CMD ?=
> "${ISAR_RELEASE_CMD_DEFAULT}" 
>  do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
>                               ${IMAGE_ROOTFS}/isar-apt"
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index 7935b69..077c550 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -34,24 +34,25 @@ def get_rootfs_size(d):
>  
>      return base_size + rootfs_extra * 1024
>  
> -# we assume that one git commit can describe the whole image, so you
> should be -# using submodules, kas, or something like that
> -# set ISAR_GIT_RELEASE_PATH to that one "most significant" layer
> -# when not using git, override do_mark_rootfs
> +# here we call a command that should describe your whole build
> system, +# 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_GIT_RELEASE_PATH", True) ==
> -         d.getVar("LAYERDIR_isar", True))):
> +        (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. Considder setting
> ISAR_GIT_RELEASE_PATH.')
> -    base = ["git", "-C", d.getVar("ISAR_GIT_RELEASE_PATH", True)]
> -    if (0 == subprocess.call(base + ["rev-parse"])):
> -        v = subprocess.check_output(base +
> -                                    ["describe", "--long", "--dirty",
> -                                     "--always"],
> universal_newlines=True)
> +                ' 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()
> -    return ""
> +    except subprocess.CalledProcessError as e:
> +        bb.warn('\"%s\" returned %d, returning empty build_id' %
> +                (e.cmd, e.returncode))
> +        return ""
>  
>  python set_image_size () {
>      rootfs_size = get_rootfs_size(d)


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] meta/image: allow customization of git command we use fo BUILD_ID
  2018-07-02 18:19   ` [PATCH] meta/image: allow customization of git command we use fo BUILD_ID Henning Schild
  2018-07-02 18:30     ` Henning Schild
@ 2018-07-03  7:50     ` Henning Schild
  1 sibling, 0 replies; 17+ messages in thread
From: Henning Schild @ 2018-07-03  7:50 UTC (permalink / raw)
  To: isar-users; +Cc: Maxim Yu . Osipov, Jan Kiszka

obsolete, do not even look at that one. Sorry that the new one is
missing the v2 in the subject.

Henning

Am Mon, 2 Jul 2018 20:19:57 +0200
schrieb Henning Schild <henning.schild@siemens.com>:

> One of the previous patches introduced the feature to leave some build
> system information in the rootfs. The git command to derive that
> information was kept pretty repository agnostic.
> 
> This patch makes the command Isar-specific and allows users to
> customize the command to their needs if they use a different tagging
> scheme in their repository.
> 
> Signed-off-by: Henning Schild <henning.schild@siemens.com>
> ---
>  meta-isar/recipes-core/images/isar-image-base.bb |  1 +
>  meta/classes/image.bbclass                       | 13 +++++++------
>  2 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/meta-isar/recipes-core/images/isar-image-base.bb
> b/meta-isar/recipes-core/images/isar-image-base.bb index
> c72bfdb..2ae1c01 100644 ---
> a/meta-isar/recipes-core/images/isar-image-base.bb +++
> b/meta-isar/recipes-core/images/isar-image-base.bb @@ -25,6 +25,7 @@
> IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge" WORKDIR =
> "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}" 
>  ISAR_GIT_RELEASE_PATH ?= "${LAYERDIR_isar}"
> +ISAR_GIT_RELEASE_CMD ?= "git -C ${ISAR_GIT_RELEASE_PATH} describe
> --tags --dirty --match 'v[0-9].[0-9]*'" 
>  do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
>                               ${IMAGE_ROOTFS}/isar-apt"
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index 7935b69..d60c6bb 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -36,7 +36,8 @@ def get_rootfs_size(d):
>  
>  # we assume that one git commit can describe the whole image, so you
> should be # using submodules, kas, or something like that
> -# set ISAR_GIT_RELEASE_PATH to that one "most significant" layer
> +# set ISAR_GIT_RELEASE_PATH to that one "most significant" layer and
> adjust +# ISAR_GIT_RELEASE_ARGS according to your tagging
>  # when not using git, override do_mark_rootfs
>  def get_build_id(d):
>      import subprocess
> @@ -45,11 +46,11 @@ def get_build_id(d):
>           d.getVar("LAYERDIR_isar", True))):
>          bb.warn('You are using external layers that will not be
> considered' + ' in the build_id. Considder setting
> ISAR_GIT_RELEASE_PATH.')
> -    base = ["git", "-C", d.getVar("ISAR_GIT_RELEASE_PATH", True)]
> -    if (0 == subprocess.call(base + ["rev-parse"])):
> -        v = subprocess.check_output(base +
> -                                    ["describe", "--long", "--dirty",
> -                                     "--always"],
> universal_newlines=True)
> +    if (0 == subprocess.call(["git", "-C",
> +                              d.getVar("ISAR_GIT_RELEASE_PATH",
> True),
> +                              "rev-parse"])):
> +        cmd = d.getVar("ISAR_GIT_RELEASE_CMD", True)
> +        v = subprocess.check_output(cmd, shell=True,
> universal_newlines=True) return v.rstrip()
>      return ""
>  


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] meta/image: allow customization of command we use fo BUILD_ID
  2018-07-03  7:39   ` [PATCH] meta/image: allow customization of " Henning Schild
  2018-07-03  7:49     ` Henning Schild
@ 2018-07-20 12:38     ` Henning Schild
  2018-07-20 13:17       ` Maxim Yu. Osipov
  2018-07-23  6:38     ` Jan Kiszka
  2018-07-25 10:33     ` Maxim Yu. Osipov
  3 siblings, 1 reply; 17+ messages in thread
From: Henning Schild @ 2018-07-20 12:38 UTC (permalink / raw)
  To: isar-users; +Cc: Maxim Yu . Osipov, Jan Kiszka

Please have a look at this one. It fixes a commit that is currently
already in next.

Henning

Am Tue, 3 Jul 2018 09:39:28 +0200
schrieb Henning Schild <henning.schild@siemens.com>:

> One of the previous patches introduced the feature to leave some build
> system information in the rootfs. The git command to derive that
> information was kept pretty repository agnostic.
> 
> This patch makes the command Isar-specific and allows users to
> customize the command to their needs if they use a different tagging
> scheme in their repository, or if they do not use git at all.
> 
> Signed-off-by: Henning Schild <henning.schild@siemens.com>
> ---
>  meta-isar/recipes-core/images/isar-image-base.bb |  3 ++-
>  meta/classes/image.bbclass                       | 27
> ++++++++++++------------ 2 files changed, 16 insertions(+), 14
> deletions(-)
> 
> diff --git a/meta-isar/recipes-core/images/isar-image-base.bb
> b/meta-isar/recipes-core/images/isar-image-base.bb index
> c72bfdb..a24aa3e 100644 ---
> a/meta-isar/recipes-core/images/isar-image-base.bb +++
> b/meta-isar/recipes-core/images/isar-image-base.bb @@ -24,7 +24,8 @@
> IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge" 
>  WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}"
>  
> -ISAR_GIT_RELEASE_PATH ?= "${LAYERDIR_isar}"
> +ISAR_RELEASE_CMD_DEFAULT = "git -C ${LAYERDIR_isar} describe --tags
> --dirty --match 'v[0-9].[0-9]*'" +ISAR_RELEASE_CMD ?=
> "${ISAR_RELEASE_CMD_DEFAULT}" 
>  do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
>                               ${IMAGE_ROOTFS}/isar-apt"
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index 7935b69..077c550 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -34,24 +34,25 @@ def get_rootfs_size(d):
>  
>      return base_size + rootfs_extra * 1024
>  
> -# we assume that one git commit can describe the whole image, so you
> should be -# using submodules, kas, or something like that
> -# set ISAR_GIT_RELEASE_PATH to that one "most significant" layer
> -# when not using git, override do_mark_rootfs
> +# here we call a command that should describe your whole build
> system, +# 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_GIT_RELEASE_PATH", True) ==
> -         d.getVar("LAYERDIR_isar", True))):
> +        (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. Considder setting
> ISAR_GIT_RELEASE_PATH.')
> -    base = ["git", "-C", d.getVar("ISAR_GIT_RELEASE_PATH", True)]
> -    if (0 == subprocess.call(base + ["rev-parse"])):
> -        v = subprocess.check_output(base +
> -                                    ["describe", "--long", "--dirty",
> -                                     "--always"],
> universal_newlines=True)
> +                ' 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()
> -    return ""
> +    except subprocess.CalledProcessError as e:
> +        bb.warn('\"%s\" returned %d, returning empty build_id' %
> +                (e.cmd, e.returncode))
> +        return ""
>  
>  python set_image_size () {
>      rootfs_size = get_rootfs_size(d)


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] meta/image: allow customization of command we use fo BUILD_ID
  2018-07-20 12:38     ` Henning Schild
@ 2018-07-20 13:17       ` Maxim Yu. Osipov
  2018-07-20 13:44         ` Henning Schild
  0 siblings, 1 reply; 17+ messages in thread
From: Maxim Yu. Osipov @ 2018-07-20 13:17 UTC (permalink / raw)
  To: Henning Schild, isar-users; +Cc: Jan Kiszka

On 07/20/2018 03:38 PM, Henning Schild wrote:
> Please have a look at this one. It fixes a commit that is currently
> already in next.

Sorry, I was confused by your last email in this thread:

<-------
-------- Forwarded Message --------
Subject: Re: [PATCH] meta/image: allow customization of git command we 
use fo BUILD_ID
Date: Tue, 3 Jul 2018 09:50:09 +0200
From: Henning Schild <henning.schild@siemens.com>
To: isar-users@googlegroups.com
CC: Maxim Yu . Osipov <mosipov@ilbers.de>, Jan Kiszka 
<jan.kiszka@siemens.com>

obsolete, do not even look at that one. Sorry that the new one is
missing the v2 in the subject.

<---------

So, I'm testing your patch dated by Tue, 3 Jul 2018 09:39:28 +0200.

Maxim.

> Henning
> 
> Am Tue, 3 Jul 2018 09:39:28 +0200
> schrieb Henning Schild <henning.schild@siemens.com>:
> 
>> One of the previous patches introduced the feature to leave some build
>> system information in the rootfs. The git command to derive that
>> information was kept pretty repository agnostic.
>>
>> This patch makes the command Isar-specific and allows users to
>> customize the command to their needs if they use a different tagging
>> scheme in their repository, or if they do not use git at all.
>>
>> Signed-off-by: Henning Schild <henning.schild@siemens.com>
>> ---
>>   meta-isar/recipes-core/images/isar-image-base.bb |  3 ++-
>>   meta/classes/image.bbclass                       | 27
>> ++++++++++++------------ 2 files changed, 16 insertions(+), 14
>> deletions(-)
>>
>> diff --git a/meta-isar/recipes-core/images/isar-image-base.bb
>> b/meta-isar/recipes-core/images/isar-image-base.bb index
>> c72bfdb..a24aa3e 100644 ---
>> a/meta-isar/recipes-core/images/isar-image-base.bb +++
>> b/meta-isar/recipes-core/images/isar-image-base.bb @@ -24,7 +24,8 @@
>> IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge"
>>   WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}"
>>   
>> -ISAR_GIT_RELEASE_PATH ?= "${LAYERDIR_isar}"
>> +ISAR_RELEASE_CMD_DEFAULT = "git -C ${LAYERDIR_isar} describe --tags
>> --dirty --match 'v[0-9].[0-9]*'" +ISAR_RELEASE_CMD ?=
>> "${ISAR_RELEASE_CMD_DEFAULT}"
>>   do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
>>                                ${IMAGE_ROOTFS}/isar-apt"
>> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
>> index 7935b69..077c550 100644
>> --- a/meta/classes/image.bbclass
>> +++ b/meta/classes/image.bbclass
>> @@ -34,24 +34,25 @@ def get_rootfs_size(d):
>>   
>>       return base_size + rootfs_extra * 1024
>>   
>> -# we assume that one git commit can describe the whole image, so you
>> should be -# using submodules, kas, or something like that
>> -# set ISAR_GIT_RELEASE_PATH to that one "most significant" layer
>> -# when not using git, override do_mark_rootfs
>> +# here we call a command that should describe your whole build
>> system, +# 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_GIT_RELEASE_PATH", True) ==
>> -         d.getVar("LAYERDIR_isar", True))):
>> +        (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. Considder setting
>> ISAR_GIT_RELEASE_PATH.')
>> -    base = ["git", "-C", d.getVar("ISAR_GIT_RELEASE_PATH", True)]
>> -    if (0 == subprocess.call(base + ["rev-parse"])):
>> -        v = subprocess.check_output(base +
>> -                                    ["describe", "--long", "--dirty",
>> -                                     "--always"],
>> universal_newlines=True)
>> +                ' 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()
>> -    return ""
>> +    except subprocess.CalledProcessError as e:
>> +        bb.warn('\"%s\" returned %d, returning empty build_id' %
>> +                (e.cmd, e.returncode))
>> +        return ""
>>   
>>   python set_image_size () {
>>       rootfs_size = get_rootfs_size(d)
> 


-- 
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] 17+ messages in thread

* Re: [PATCH] meta/image: allow customization of command we use fo BUILD_ID
  2018-07-20 13:17       ` Maxim Yu. Osipov
@ 2018-07-20 13:44         ` Henning Schild
  0 siblings, 0 replies; 17+ messages in thread
From: Henning Schild @ 2018-07-20 13:44 UTC (permalink / raw)
  To: Maxim Yu. Osipov; +Cc: isar-users, Jan Kiszka

My bad, i forgot to version those patches ... twice.

Henning

Am Fri, 20 Jul 2018 16:17:01 +0300
schrieb "Maxim Yu. Osipov" <mosipov@ilbers.de>:

> On 07/20/2018 03:38 PM, Henning Schild wrote:
> > Please have a look at this one. It fixes a commit that is currently
> > already in next.  
> 
> Sorry, I was confused by your last email in this thread:
> 
> <-------
> -------- Forwarded Message --------
> Subject: Re: [PATCH] meta/image: allow customization of git command
> we use fo BUILD_ID
> Date: Tue, 3 Jul 2018 09:50:09 +0200
> From: Henning Schild <henning.schild@siemens.com>
> To: isar-users@googlegroups.com
> CC: Maxim Yu . Osipov <mosipov@ilbers.de>, Jan Kiszka 
> <jan.kiszka@siemens.com>
> 
> obsolete, do not even look at that one. Sorry that the new one is
> missing the v2 in the subject.
> 
> <---------
> 
> So, I'm testing your patch dated by Tue, 3 Jul 2018 09:39:28 +0200.
> 
> Maxim.
> 
> > Henning
> > 
> > Am Tue, 3 Jul 2018 09:39:28 +0200
> > schrieb Henning Schild <henning.schild@siemens.com>:
> >   
> >> One of the previous patches introduced the feature to leave some
> >> build system information in the rootfs. The git command to derive
> >> that information was kept pretty repository agnostic.
> >>
> >> This patch makes the command Isar-specific and allows users to
> >> customize the command to their needs if they use a different
> >> tagging scheme in their repository, or if they do not use git at
> >> all.
> >>
> >> Signed-off-by: Henning Schild <henning.schild@siemens.com>
> >> ---
> >>   meta-isar/recipes-core/images/isar-image-base.bb |  3 ++-
> >>   meta/classes/image.bbclass                       | 27
> >> ++++++++++++------------ 2 files changed, 16 insertions(+), 14
> >> deletions(-)
> >>
> >> diff --git a/meta-isar/recipes-core/images/isar-image-base.bb
> >> b/meta-isar/recipes-core/images/isar-image-base.bb index
> >> c72bfdb..a24aa3e 100644 ---
> >> a/meta-isar/recipes-core/images/isar-image-base.bb +++
> >> b/meta-isar/recipes-core/images/isar-image-base.bb @@ -24,7 +24,8
> >> @@ IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge"
> >>   WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}"
> >>   
> >> -ISAR_GIT_RELEASE_PATH ?= "${LAYERDIR_isar}"
> >> +ISAR_RELEASE_CMD_DEFAULT = "git -C ${LAYERDIR_isar} describe
> >> --tags --dirty --match 'v[0-9].[0-9]*'" +ISAR_RELEASE_CMD ?=
> >> "${ISAR_RELEASE_CMD_DEFAULT}"
> >>   do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
> >>                                ${IMAGE_ROOTFS}/isar-apt"
> >> diff --git a/meta/classes/image.bbclass
> >> b/meta/classes/image.bbclass index 7935b69..077c550 100644
> >> --- a/meta/classes/image.bbclass
> >> +++ b/meta/classes/image.bbclass
> >> @@ -34,24 +34,25 @@ def get_rootfs_size(d):
> >>   
> >>       return base_size + rootfs_extra * 1024
> >>   
> >> -# we assume that one git commit can describe the whole image, so
> >> you should be -# using submodules, kas, or something like that
> >> -# set ISAR_GIT_RELEASE_PATH to that one "most significant" layer
> >> -# when not using git, override do_mark_rootfs
> >> +# here we call a command that should describe your whole build
> >> system, +# 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_GIT_RELEASE_PATH", True) ==
> >> -         d.getVar("LAYERDIR_isar", True))):
> >> +        (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. Considder setting
> >> ISAR_GIT_RELEASE_PATH.')
> >> -    base = ["git", "-C", d.getVar("ISAR_GIT_RELEASE_PATH", True)]
> >> -    if (0 == subprocess.call(base + ["rev-parse"])):
> >> -        v = subprocess.check_output(base +
> >> -                                    ["describe", "--long",
> >> "--dirty",
> >> -                                     "--always"],
> >> universal_newlines=True)
> >> +                ' 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()
> >> -    return ""
> >> +    except subprocess.CalledProcessError as e:
> >> +        bb.warn('\"%s\" returned %d, returning empty build_id' %
> >> +                (e.cmd, e.returncode))
> >> +        return ""
> >>   
> >>   python set_image_size () {
> >>       rootfs_size = get_rootfs_size(d)  
> >   
> 
> 


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] meta/image: allow customization of command we use fo BUILD_ID
  2018-07-03  7:39   ` [PATCH] meta/image: allow customization of " Henning Schild
  2018-07-03  7:49     ` Henning Schild
  2018-07-20 12:38     ` Henning Schild
@ 2018-07-23  6:38     ` Jan Kiszka
  2018-07-23  6:40       ` Jan Kiszka
  2018-07-25 10:33     ` Maxim Yu. Osipov
  3 siblings, 1 reply; 17+ messages in thread
From: Jan Kiszka @ 2018-07-23  6:38 UTC (permalink / raw)
  To: Henning Schild, isar-users; +Cc: Maxim Yu . Osipov

On 2018-07-03 09:39, Henning Schild wrote:
> One of the previous patches introduced the feature to leave some build
> system information in the rootfs. The git command to derive that
> information was kept pretty repository agnostic.
> 
> This patch makes the command Isar-specific and allows users to customize
> the command to their needs if they use a different tagging scheme in
> their repository, or if they do not use git at all.
> 
> Signed-off-by: Henning Schild <henning.schild@siemens.com>
> ---
>   meta-isar/recipes-core/images/isar-image-base.bb |  3 ++-
>   meta/classes/image.bbclass                       | 27 ++++++++++++------------
>   2 files changed, 16 insertions(+), 14 deletions(-)
> 
> diff --git a/meta-isar/recipes-core/images/isar-image-base.bb b/meta-isar/recipes-core/images/isar-image-base.bb
> index c72bfdb..a24aa3e 100644
> --- a/meta-isar/recipes-core/images/isar-image-base.bb
> +++ b/meta-isar/recipes-core/images/isar-image-base.bb
> @@ -24,7 +24,8 @@ IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge"
>   
>   WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}"
>   
> -ISAR_GIT_RELEASE_PATH ?= "${LAYERDIR_isar}"
> +ISAR_RELEASE_CMD_DEFAULT = "git -C ${LAYERDIR_isar} describe --tags --dirty --match 'v[0-9].[0-9]*'"

I think we should keep ISAR_GIT_RELEASE_PATH as overridable API 
variable. Many project will use the default pattern and just deviate in 
the layer name.

Jan

> +ISAR_RELEASE_CMD ?= "${ISAR_RELEASE_CMD_DEFAULT}"
>   
>   do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
>                                ${IMAGE_ROOTFS}/isar-apt"
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index 7935b69..077c550 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -34,24 +34,25 @@ def get_rootfs_size(d):
>   
>       return base_size + rootfs_extra * 1024
>   
> -# we assume that one git commit can describe the whole image, so you should be
> -# using submodules, kas, or something like that
> -# set ISAR_GIT_RELEASE_PATH to that one "most significant" layer
> -# when not using git, override do_mark_rootfs
> +# here we call a command that should describe your whole build system,
> +# 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_GIT_RELEASE_PATH", True) ==
> -         d.getVar("LAYERDIR_isar", True))):
> +        (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. Considder setting ISAR_GIT_RELEASE_PATH.')
> -    base = ["git", "-C", d.getVar("ISAR_GIT_RELEASE_PATH", True)]
> -    if (0 == subprocess.call(base + ["rev-parse"])):
> -        v = subprocess.check_output(base +
> -                                    ["describe", "--long", "--dirty",
> -                                     "--always"], universal_newlines=True)
> +                ' 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()
> -    return ""
> +    except subprocess.CalledProcessError as e:
> +        bb.warn('\"%s\" returned %d, returning empty build_id' %
> +                (e.cmd, e.returncode))
> +        return ""
>   
>   python set_image_size () {
>       rootfs_size = get_rootfs_size(d)
> 


-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] meta/image: allow customization of command we use fo BUILD_ID
  2018-07-23  6:38     ` Jan Kiszka
@ 2018-07-23  6:40       ` Jan Kiszka
  2018-07-23  7:34         ` Henning Schild
  0 siblings, 1 reply; 17+ messages in thread
From: Jan Kiszka @ 2018-07-23  6:40 UTC (permalink / raw)
  To: Henning Schild, isar-users; +Cc: Maxim Yu . Osipov

On 2018-07-23 08:38, Jan Kiszka wrote:
> On 2018-07-03 09:39, Henning Schild wrote:
>> One of the previous patches introduced the feature to leave some build
>> system information in the rootfs. The git command to derive that
>> information was kept pretty repository agnostic.
>>
>> This patch makes the command Isar-specific and allows users to customize
>> the command to their needs if they use a different tagging scheme in
>> their repository, or if they do not use git at all.
>>
>> Signed-off-by: Henning Schild <henning.schild@siemens.com>
>> ---
>>   meta-isar/recipes-core/images/isar-image-base.bb |  3 ++-
>>   meta/classes/image.bbclass                       | 27 
>> ++++++++++++------------
>>   2 files changed, 16 insertions(+), 14 deletions(-)
>>
>> diff --git a/meta-isar/recipes-core/images/isar-image-base.bb 
>> b/meta-isar/recipes-core/images/isar-image-base.bb
>> index c72bfdb..a24aa3e 100644
>> --- a/meta-isar/recipes-core/images/isar-image-base.bb
>> +++ b/meta-isar/recipes-core/images/isar-image-base.bb
>> @@ -24,7 +24,8 @@ IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge"
>>   WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}"
>> -ISAR_GIT_RELEASE_PATH ?= "${LAYERDIR_isar}"
>> +ISAR_RELEASE_CMD_DEFAULT = "git -C ${LAYERDIR_isar} describe --tags 
>> --dirty --match 'v[0-9].[0-9]*'"
> 
> I think we should keep ISAR_GIT_RELEASE_PATH as overridable API 
> variable. Many project will use the default pattern and just deviate in 
> the layer name.
> 

Just to clarify: We should have *both* ISAR_GIT_RELEASE_PATH and 
ISAR_RELEASE_CMD as API. The former for the common customizations, the 
latter for deviating tag schemes or different version control systems.

Jan

>> +ISAR_RELEASE_CMD ?= "${ISAR_RELEASE_CMD_DEFAULT}"
>>   do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
>>                                ${IMAGE_ROOTFS}/isar-apt"
>> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
>> index 7935b69..077c550 100644
>> --- a/meta/classes/image.bbclass
>> +++ b/meta/classes/image.bbclass
>> @@ -34,24 +34,25 @@ def get_rootfs_size(d):
>>       return base_size + rootfs_extra * 1024
>> -# we assume that one git commit can describe the whole image, so you 
>> should be
>> -# using submodules, kas, or something like that
>> -# set ISAR_GIT_RELEASE_PATH to that one "most significant" layer
>> -# when not using git, override do_mark_rootfs
>> +# here we call a command that should describe your whole build system,
>> +# 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_GIT_RELEASE_PATH", True) ==
>> -         d.getVar("LAYERDIR_isar", True))):
>> +        (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. Considder setting 
>> ISAR_GIT_RELEASE_PATH.')
>> -    base = ["git", "-C", d.getVar("ISAR_GIT_RELEASE_PATH", True)]
>> -    if (0 == subprocess.call(base + ["rev-parse"])):
>> -        v = subprocess.check_output(base +
>> -                                    ["describe", "--long", "--dirty",
>> -                                     "--always"], 
>> universal_newlines=True)
>> +                ' 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()
>> -    return ""
>> +    except subprocess.CalledProcessError as e:
>> +        bb.warn('\"%s\" returned %d, returning empty build_id' %
>> +                (e.cmd, e.returncode))
>> +        return ""
>>   python set_image_size () {
>>       rootfs_size = get_rootfs_size(d)
>>
> 
> 


-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] meta/image: allow customization of command we use fo BUILD_ID
  2018-07-23  6:40       ` Jan Kiszka
@ 2018-07-23  7:34         ` Henning Schild
  0 siblings, 0 replies; 17+ messages in thread
From: Henning Schild @ 2018-07-23  7:34 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: isar-users, Maxim Yu . Osipov

Am Mon, 23 Jul 2018 08:40:50 +0200
schrieb Jan Kiszka <jan.kiszka@siemens.com>:

> On 2018-07-23 08:38, Jan Kiszka wrote:
> > On 2018-07-03 09:39, Henning Schild wrote:  
> >> One of the previous patches introduced the feature to leave some
> >> build system information in the rootfs. The git command to derive
> >> that information was kept pretty repository agnostic.
> >>
> >> This patch makes the command Isar-specific and allows users to
> >> customize the command to their needs if they use a different
> >> tagging scheme in their repository, or if they do not use git at
> >> all.
> >>
> >> Signed-off-by: Henning Schild <henning.schild@siemens.com>
> >> ---
> >>   meta-isar/recipes-core/images/isar-image-base.bb |  3 ++-
> >>   meta/classes/image.bbclass                       | 27 
> >> ++++++++++++------------
> >>   2 files changed, 16 insertions(+), 14 deletions(-)
> >>
> >> diff --git a/meta-isar/recipes-core/images/isar-image-base.bb 
> >> b/meta-isar/recipes-core/images/isar-image-base.bb
> >> index c72bfdb..a24aa3e 100644
> >> --- a/meta-isar/recipes-core/images/isar-image-base.bb
> >> +++ b/meta-isar/recipes-core/images/isar-image-base.bb
> >> @@ -24,7 +24,8 @@ IMAGE_TRANSIENT_PACKAGES +=
> >> "isar-cfg-localepurge" WORKDIR =
> >> "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}"
> >> -ISAR_GIT_RELEASE_PATH ?= "${LAYERDIR_isar}"
> >> +ISAR_RELEASE_CMD_DEFAULT = "git -C ${LAYERDIR_isar} describe
> >> --tags --dirty --match 'v[0-9].[0-9]*'"  
> > 
> > I think we should keep ISAR_GIT_RELEASE_PATH as overridable API 
> > variable. Many project will use the default pattern and just
> > deviate in the layer name.
> >   
> 
> Just to clarify: We should have *both* ISAR_GIT_RELEASE_PATH and 
> ISAR_RELEASE_CMD as API. The former for the common customizations,
> the latter for deviating tag schemes or different version control
> systems.

I think that would introduce too many knobs to turn. The CMD instead of
the default git is not just there to abstract away from git. It also
takes care of its arguments, like matching a tag.
While it is more than likely that people will use git, i am not sure
the args will match for everyone.

If you still want that variable back, i will send an update.

Henning 

> Jan
> 
> >> +ISAR_RELEASE_CMD ?= "${ISAR_RELEASE_CMD_DEFAULT}"
> >>   do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
> >>                                ${IMAGE_ROOTFS}/isar-apt"
> >> diff --git a/meta/classes/image.bbclass
> >> b/meta/classes/image.bbclass index 7935b69..077c550 100644
> >> --- a/meta/classes/image.bbclass
> >> +++ b/meta/classes/image.bbclass
> >> @@ -34,24 +34,25 @@ def get_rootfs_size(d):
> >>       return base_size + rootfs_extra * 1024
> >> -# we assume that one git commit can describe the whole image, so
> >> you should be
> >> -# using submodules, kas, or something like that
> >> -# set ISAR_GIT_RELEASE_PATH to that one "most significant" layer
> >> -# when not using git, override do_mark_rootfs
> >> +# here we call a command that should describe your whole build
> >> system, +# 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_GIT_RELEASE_PATH", True) ==
> >> -         d.getVar("LAYERDIR_isar", True))):
> >> +        (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. Considder setting 
> >> ISAR_GIT_RELEASE_PATH.')
> >> -    base = ["git", "-C", d.getVar("ISAR_GIT_RELEASE_PATH", True)]
> >> -    if (0 == subprocess.call(base + ["rev-parse"])):
> >> -        v = subprocess.check_output(base +
> >> -                                    ["describe", "--long",
> >> "--dirty",
> >> -                                     "--always"], 
> >> universal_newlines=True)
> >> +                ' 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()
> >> -    return ""
> >> +    except subprocess.CalledProcessError as e:
> >> +        bb.warn('\"%s\" returned %d, returning empty build_id' %
> >> +                (e.cmd, e.returncode))
> >> +        return ""
> >>   python set_image_size () {
> >>       rootfs_size = get_rootfs_size(d)
> >>  
> > 
> >   
> 
> 


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] meta/image: allow customization of command we use fo BUILD_ID
  2018-07-03  7:39   ` [PATCH] meta/image: allow customization of " Henning Schild
                       ` (2 preceding siblings ...)
  2018-07-23  6:38     ` Jan Kiszka
@ 2018-07-25 10:33     ` Maxim Yu. Osipov
  3 siblings, 0 replies; 17+ messages in thread
From: Maxim Yu. Osipov @ 2018-07-25 10:33 UTC (permalink / raw)
  To: Henning Schild; +Cc: isar-users

On 07/03/2018 10:39 AM, Henning Schild wrote:
> One of the previous patches introduced the feature to leave some build
> system information in the rootfs. The git command to derive that
> information was kept pretty repository agnostic.
> 
> This patch makes the command Isar-specific and allows users to customize
> the command to their needs if they use a different tagging scheme in
> their repository, or if they do not use git at all.

Applied to the 'next',

Thanks,
Maxim.

> Signed-off-by: Henning Schild <henning.schild@siemens.com>
> ---
>   meta-isar/recipes-core/images/isar-image-base.bb |  3 ++-
>   meta/classes/image.bbclass                       | 27 ++++++++++++------------
>   2 files changed, 16 insertions(+), 14 deletions(-)
> 
> diff --git a/meta-isar/recipes-core/images/isar-image-base.bb b/meta-isar/recipes-core/images/isar-image-base.bb
> index c72bfdb..a24aa3e 100644
> --- a/meta-isar/recipes-core/images/isar-image-base.bb
> +++ b/meta-isar/recipes-core/images/isar-image-base.bb
> @@ -24,7 +24,8 @@ IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge"
>   
>   WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}"
>   
> -ISAR_GIT_RELEASE_PATH ?= "${LAYERDIR_isar}"
> +ISAR_RELEASE_CMD_DEFAULT = "git -C ${LAYERDIR_isar} describe --tags --dirty --match 'v[0-9].[0-9]*'"
> +ISAR_RELEASE_CMD ?= "${ISAR_RELEASE_CMD_DEFAULT}"
>   
>   do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
>                                ${IMAGE_ROOTFS}/isar-apt"
> diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
> index 7935b69..077c550 100644
> --- a/meta/classes/image.bbclass
> +++ b/meta/classes/image.bbclass
> @@ -34,24 +34,25 @@ def get_rootfs_size(d):
>   
>       return base_size + rootfs_extra * 1024
>   
> -# we assume that one git commit can describe the whole image, so you should be
> -# using submodules, kas, or something like that
> -# set ISAR_GIT_RELEASE_PATH to that one "most significant" layer
> -# when not using git, override do_mark_rootfs
> +# here we call a command that should describe your whole build system,
> +# 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_GIT_RELEASE_PATH", True) ==
> -         d.getVar("LAYERDIR_isar", True))):
> +        (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. Considder setting ISAR_GIT_RELEASE_PATH.')
> -    base = ["git", "-C", d.getVar("ISAR_GIT_RELEASE_PATH", True)]
> -    if (0 == subprocess.call(base + ["rev-parse"])):
> -        v = subprocess.check_output(base +
> -                                    ["describe", "--long", "--dirty",
> -                                     "--always"], universal_newlines=True)
> +                ' 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()
> -    return ""
> +    except subprocess.CalledProcessError as e:
> +        bb.warn('\"%s\" returned %d, returning empty build_id' %
> +                (e.cmd, e.returncode))
> +        return ""
>   
>   python set_image_size () {
>       rootfs_size = get_rootfs_size(d)
> 


-- 
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] 17+ messages in thread

end of thread, other threads:[~2018-07-25 10:33 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-28 15:05 [PATCH] meta/image: leave BUILD_ID and VARIANT in /etc/os-release Henning Schild
2018-06-28 15:09 ` Henning Schild
2018-06-29 10:04   ` Maxim Yu. Osipov
2018-06-29 11:46     ` Henning Schild
2018-07-02  9:15 ` Maxim Yu. Osipov
2018-07-02 18:19   ` [PATCH] meta/image: allow customization of git command we use fo BUILD_ID Henning Schild
2018-07-02 18:30     ` Henning Schild
2018-07-03  7:50     ` Henning Schild
2018-07-03  7:39   ` [PATCH] meta/image: allow customization of " Henning Schild
2018-07-03  7:49     ` Henning Schild
2018-07-20 12:38     ` Henning Schild
2018-07-20 13:17       ` Maxim Yu. Osipov
2018-07-20 13:44         ` Henning Schild
2018-07-23  6:38     ` Jan Kiszka
2018-07-23  6:40       ` Jan Kiszka
2018-07-23  7:34         ` Henning Schild
2018-07-25 10:33     ` 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