Patchwork [v3] log_srcrev.bbclass: add a bbclass for logging SRCREVs

login
register
mail settings
Submitter Constantin Musca
Date Feb. 26, 2013, 3:08 p.m.
Message ID <1361891289-6777-1-git-send-email-constantinx.musca@intel.com>
Download mbox | patch
Permalink /patch/45133/
State New
Headers show

Comments

Constantin Musca - Feb. 26, 2013, 3:08 p.m.
- add a task which creates a file for each package with the following
format:

${BB_FILENAME},${SRC_URI},${SRCREV},${FROM_AUTOREV}

[YOCTO #3041]

Signed-off-by: Constantin Musca <constantinx.musca@intel.com>
---
 meta/classes/log_srcrev.bbclass | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 meta/classes/log_srcrev.bbclass
Saul Wold - Feb. 27, 2013, 12:15 a.m.
On 02/26/2013 07:08 AM, Constantin Musca wrote:
> - add a task which creates a file for each package with the following
> format:
>
> ${BB_FILENAME},${SRC_URI},${SRCREV},${FROM_AUTOREV}
>
> [YOCTO #3041]
>
> Signed-off-by: Constantin Musca <constantinx.musca@intel.com>
> ---
>   meta/classes/log_srcrev.bbclass | 15 +++++++++++++++
>   1 file changed, 15 insertions(+)
>   create mode 100644 meta/classes/log_srcrev.bbclass
>
> diff --git a/meta/classes/log_srcrev.bbclass b/meta/classes/log_srcrev.bbclass
> new file mode 100644
> index 0000000..a04702c
> --- /dev/null
> +++ b/meta/classes/log_srcrev.bbclass
> @@ -0,0 +1,15 @@
> +python do_log_srcrev () {
> +    srcrev = d.getVar('SRCREV', True)
> +    if srcrev:
> +        bbfile = d.getVar('BB_FILENAME', True)
> +        src_uri = d.getVar('SRC_URI', True)
> +        from_autorev = 'yes' if d.getVar('SRCREV', False) == 'AUTOINC' else 'no'
> +
> +        srcrevfile = d.expand('${TMPDIR}/srcrevs/${MULTIMACH_TARGET_SYS}/${BP}')
> +        bb.utils.mkdirhier(os.path.dirname(srcrevfile))
> +
> +        with open(srcrevfile, 'w') as f:
> +            f.write(','.join([bbfile, src_uri, srcrev, from_autorev]))
> +}
> +
> +addtask do_log_srcrev after do_fetch
>

Otavio makes a good point, this might be something to consider putting 
it in to the RecipeInfo in buildhistory.bbclass and extend the 
write_pkghistory(), but maybe write the file with a different name 
latest_srcrev

Sau!

Patch

diff --git a/meta/classes/log_srcrev.bbclass b/meta/classes/log_srcrev.bbclass
new file mode 100644
index 0000000..a04702c
--- /dev/null
+++ b/meta/classes/log_srcrev.bbclass
@@ -0,0 +1,15 @@ 
+python do_log_srcrev () {
+    srcrev = d.getVar('SRCREV', True)
+    if srcrev:
+        bbfile = d.getVar('BB_FILENAME', True)
+        src_uri = d.getVar('SRC_URI', True)
+        from_autorev = 'yes' if d.getVar('SRCREV', False) == 'AUTOINC' else 'no'
+
+        srcrevfile = d.expand('${TMPDIR}/srcrevs/${MULTIMACH_TARGET_SYS}/${BP}')
+        bb.utils.mkdirhier(os.path.dirname(srcrevfile))
+
+        with open(srcrevfile, 'w') as f:
+            f.write(','.join([bbfile, src_uri, srcrev, from_autorev]))
+}
+
+addtask do_log_srcrev after do_fetch