Patchwork log_srcrev.bbclass: add a bbclass for logging SRCREVs

login
register
mail settings
Submitter Constantin Musca
Date Feb. 22, 2013, 8:49 a.m.
Message ID <1361522961-5673-1-git-send-email-constantinx.musca@intel.com>
Download mbox | patch
Permalink /patch/45001/
State New
Headers show

Comments

Constantin Musca - Feb. 22, 2013, 8:49 a.m.
- add a task which creates a file for each package with the following
format:

BB_FILENAME: ${BB_FILENAME}
SRC_URI: ${SRC_URI}
SRCREV: ${SRCREV}
FROM AUTOREV: no/yes

[YOCTO #3041]

Signed-off-by: Constantin Musca <constantinx.musca@intel.com>
---
 meta/classes/log_srcrev.bbclass | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
 create mode 100644 meta/classes/log_srcrev.bbclass
Saul Wold - Feb. 26, 2013, 12:31 a.m.
On 02/22/2013 12:49 AM, Constantin Musca wrote:
> - add a task which creates a file for each package with the following
> format:
>
> BB_FILENAME: ${BB_FILENAME}
> SRC_URI: ${SRC_URI}
> SRCREV: ${SRCREV}
> FROM AUTOREV: no/yes
>
Would it be better to have the format more as a CSV

bbfilename,src_uri,srcrev,autorev?

This would make it easier to parse for scripts

Jerrod, you are the requester on this, do you have any comments on the 
format?


> [YOCTO #3041]
>
> Signed-off-by: Constantin Musca <constantinx.musca@intel.com>
> ---
>   meta/classes/log_srcrev.bbclass | 20 ++++++++++++++++++++
>   1 file changed, 20 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..b319e7b
> --- /dev/null
> +++ b/meta/classes/log_srcrev.bbclass
> @@ -0,0 +1,20 @@
> +SRCREV_LOGFILE ??= 'srcrev_log'
> +
> +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'
> +
> +        srcrevdir = d.expand('${TMPDIR}/srcrevs/${MULTIMACH_TARGET_SYS}/${PN}-${PV}/')
> +        srcrevfile = os.path.join(srcrevdir, d.getVar('SRCREV_LOGFILE', True))
> +        bb.utils.mkdirhier(os.path.dirname(srcrevfile))
> +
Do we really need the extra level of directory here?  Can the data be 
contained in a ${PN}-${PV} file instead?  Also this might be better to 
be ${BP} (base package & version).

You already have the mulitlib info in the ${MULTIMACH_TARGET_SYS} info.


Thanks
	Sau!


> +        with open(srcrevfile, 'w') as f:
> +            f.write("BB_FILENAME: %s\nSRC_URI: %s\nSRCREV: %s\nFROM AUTOREV: %s\n"
> +                    % (bbfile, src_uri, srcrev, from_autorev))
> +}
> +
> +addtask do_log_srcrev after do_fetch
> +do_log_srcrev[cleandirs] = "${TMPDIR}/srcrevs/${MULTIMACH_TARGET_SYS}/${PN}-${PV}/"
>

Patch

diff --git a/meta/classes/log_srcrev.bbclass b/meta/classes/log_srcrev.bbclass
new file mode 100644
index 0000000..b319e7b
--- /dev/null
+++ b/meta/classes/log_srcrev.bbclass
@@ -0,0 +1,20 @@ 
+SRCREV_LOGFILE ??= 'srcrev_log'
+
+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'
+
+        srcrevdir = d.expand('${TMPDIR}/srcrevs/${MULTIMACH_TARGET_SYS}/${PN}-${PV}/')
+        srcrevfile = os.path.join(srcrevdir, d.getVar('SRCREV_LOGFILE', True))
+        bb.utils.mkdirhier(os.path.dirname(srcrevfile))
+
+        with open(srcrevfile, 'w') as f:
+            f.write("BB_FILENAME: %s\nSRC_URI: %s\nSRCREV: %s\nFROM AUTOREV: %s\n"
+                    % (bbfile, src_uri, srcrev, from_autorev))
+}
+
+addtask do_log_srcrev after do_fetch
+do_log_srcrev[cleandirs] = "${TMPDIR}/srcrevs/${MULTIMACH_TARGET_SYS}/${PN}-${PV}/"