Skip to contentSkip to conversation

rootfs-postcommaneds: put image testdata under sstate control

PATCH Superseded André Draszik 2 participants 8 messages Mar 9, 2018 – Aug 20, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rootfs-postcommaneds: put image testdata under sstate control

From: André Draszik <[email protected]>

The testdata.json is being written to DEPLOY_DIR_IMAGE directly, thus bypassing sstate, which results in an ever growing list of files.

Write them to IMGDEPLOYDIR instead, so as to benefit from the automatic management via sstate.

---
 meta/classes/rootfs-postcommands.bbclass | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
meta/classes/rootfs-postcommands.bbclass +8 -7
index a4e627fef8..01eee350b8 100644
@@ -303,17 +303,18 @@ rootfs_sysroot_relativelinks () {
 python write_image_test_data() {
     from oe.data import export2json
 
-    testdata = "%s/%s.testdata.json" % (d.getVar('DEPLOY_DIR_IMAGE'), d.getVar('IMAGE_NAME'))
-    testdata_link = "%s/%s.testdata.json" % (d.getVar('DEPLOY_DIR_IMAGE'), d.getVar('IMAGE_LINK_NAME'))
+    deploy_dir = d.getVar('IMGDEPLOYDIR')
+    link_name = d.getVar('IMAGE_LINK_NAME')
+    testdata_name = os.path.join(deploy_dir, "%s.testdata.json" % d.getVar('IMAGE_NAME'))
 
-    bb.utils.mkdirhier(os.path.dirname(testdata))
     searchString = "%s/"%(d.getVar("TOPDIR")).replace("//","/")
-    export2json(d, testdata,searchString=searchString,replaceString="")
+    export2json(d, testdata_name, searchString=searchString, replaceString="")
 
-    if testdata_link != testdata:
+    if os.path.exists(testdata_name):
+        testdata_link = os.path.join(deploy_dir, "%s.testdata.json" % link_name)
         if os.path.lexists(testdata_link):
-           os.remove(testdata_link)
-        os.symlink(os.path.basename(testdata), testdata_link)
+            os.remove(testdata_link)
+        os.symlink(os.path.basename(testdata_name), testdata_link)
 }
 write_image_test_data[vardepsexclude] += "TOPDIR"
 
Signature · 1 line
2.16.2
#1 lore raw

PATCH v2 1/1 rootfs-postcommands: put image testdata under sstate control

From: André Draszik <[email protected]>

The testdata.json is being written to DEPLOY_DIR_IMAGE directly, thus bypassing sstate, which results in an ever growing list of files.

Write them to IMGDEPLOYDIR instead, so as to benefit from the automatic management via sstate.

---
v2: fix typo in subject line

---
 meta/classes/rootfs-postcommands.bbclass | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
meta/classes/rootfs-postcommands.bbclass +8 -7
index a4e627fef8..01eee350b8 100644
@@ -303,17 +303,18 @@ rootfs_sysroot_relativelinks () {
 python write_image_test_data() {
     from oe.data import export2json
 
-    testdata = "%s/%s.testdata.json" % (d.getVar('DEPLOY_DIR_IMAGE'), d.getVar('IMAGE_NAME'))
-    testdata_link = "%s/%s.testdata.json" % (d.getVar('DEPLOY_DIR_IMAGE'), d.getVar('IMAGE_LINK_NAME'))
+    deploy_dir = d.getVar('IMGDEPLOYDIR')
+    link_name = d.getVar('IMAGE_LINK_NAME')
+    testdata_name = os.path.join(deploy_dir, "%s.testdata.json" % d.getVar('IMAGE_NAME'))
 
-    bb.utils.mkdirhier(os.path.dirname(testdata))
     searchString = "%s/"%(d.getVar("TOPDIR")).replace("//","/")
-    export2json(d, testdata,searchString=searchString,replaceString="")
+    export2json(d, testdata_name, searchString=searchString, replaceString="")
 
-    if testdata_link != testdata:
+    if os.path.exists(testdata_name):
+        testdata_link = os.path.join(deploy_dir, "%s.testdata.json" % link_name)
         if os.path.lexists(testdata_link):
-           os.remove(testdata_link)
-        os.symlink(os.path.basename(testdata), testdata_link)
+            os.remove(testdata_link)
+        os.symlink(os.path.basename(testdata_name), testdata_link)
 }
 write_image_test_data[vardepsexclude] += "TOPDIR"
 
Signature · 1 line
2.16.2
#2 lore raw

Re: [PATCH v2] rootfs-postcommands: put image testdata under sstate control

ping

Quoted 53 lines · André Draszik

From: André Draszik <[email protected]>

The testdata.json is being written to DEPLOY_DIR_IMAGE directly, thus bypassing sstate, which results in an ever growing list of files.

Write them to IMGDEPLOYDIR instead, so as to benefit from the automatic management via sstate.

---
v2: fix typo in subject line

---
 meta/classes/rootfs-postcommands.bbclass | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
meta/classes/rootfs-postcommands.bbclass +8 -7
index a4e627fef8..01eee350b8 100644
@@ -303,17 +303,18 @@ rootfs_sysroot_relativelinks () {
 python write_image_test_data() {
     from oe.data import export2json
 
-    testdata = "%s/%s.testdata.json" % (d.getVar('DEPLOY_DIR_IMAGE'),
 d.getVar('IMAGE_NAME'))
-    testdata_link = "%s/%s.testdata.json" %
 (d.getVar('DEPLOY_DIR_IMAGE'), d.getVar('IMAGE_LINK_NAME'))
+    deploy_dir = d.getVar('IMGDEPLOYDIR')
+    link_name = d.getVar('IMAGE_LINK_NAME')
+    testdata_name = os.path.join(deploy_dir, "%s.testdata.json" %
 d.getVar('IMAGE_NAME'))
 
-    bb.utils.mkdirhier(os.path.dirname(testdata))
     searchString = "%s/"%(d.getVar("TOPDIR")).replace("//","/")
-    export2json(d, testdata,searchString=searchString,replaceString="")
+    export2json(d, testdata_name, searchString=searchString,
 replaceString="")
 
-    if testdata_link != testdata:
+    if os.path.exists(testdata_name):
+        testdata_link = os.path.join(deploy_dir, "%s.testdata.json" %
 link_name)
         if os.path.lexists(testdata_link):
-           os.remove(testdata_link)
-        os.symlink(os.path.basename(testdata), testdata_link)
+            os.remove(testdata_link)
+        os.symlink(os.path.basename(testdata_name), testdata_link)
 }
 write_image_test_data[vardepsexclude] += "TOPDIR"
#3 lore raw

Re: [PATCH v2] rootfs-postcommands: put image testdata under sstate control

Is there anything wrong with this?

Quoted 56 lines · André Draszik

ping

Quoted 53 lines · André Draszik

From: André Draszik <[email protected]>

The testdata.json is being written to DEPLOY_DIR_IMAGE directly, thus bypassing sstate, which results in an ever growing list of files.

Write them to IMGDEPLOYDIR instead, so as to benefit from the automatic management via sstate.

---
v2: fix typo in subject line

---
 meta/classes/rootfs-postcommands.bbclass | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
meta/classes/rootfs-postcommands.bbclass +8 -7
index a4e627fef8..01eee350b8 100644
@@ -303,17 +303,18 @@ rootfs_sysroot_relativelinks () {
 python write_image_test_data() {
     from oe.data import export2json
 
-    testdata = "%s/%s.testdata.json" % (d.getVar('DEPLOY_DIR_IMAGE'),
 d.getVar('IMAGE_NAME'))
-    testdata_link = "%s/%s.testdata.json" %
 (d.getVar('DEPLOY_DIR_IMAGE'), d.getVar('IMAGE_LINK_NAME'))
+    deploy_dir = d.getVar('IMGDEPLOYDIR')
+    link_name = d.getVar('IMAGE_LINK_NAME')
+    testdata_name = os.path.join(deploy_dir, "%s.testdata.json" %
 d.getVar('IMAGE_NAME'))
 
-    bb.utils.mkdirhier(os.path.dirname(testdata))
     searchString = "%s/"%(d.getVar("TOPDIR")).replace("//","/")
-    export2json(d, testdata,searchString=searchString,replaceString="")
+    export2json(d, testdata_name, searchString=searchString,
 replaceString="")
 
-    if testdata_link != testdata:
+    if os.path.exists(testdata_name):
+        testdata_link = os.path.join(deploy_dir, "%s.testdata.json" %
 link_name)
         if os.path.lexists(testdata_link):
-           os.remove(testdata_link)
-        os.symlink(os.path.basename(testdata), testdata_link)
+            os.remove(testdata_link)
+        os.symlink(os.path.basename(testdata_name), testdata_link)
 }
 write_image_test_data[vardepsexclude] += "TOPDIR"
#4 lore raw

Re: [PATCH v2] rootfs-postcommands: put image testdata under sstate control

Hi,

I've also noticed this problem. The growing testdata.json files also bothered me a little bit.

I think the only small flaw with your patch is you deleted the following check.

if testdata_link != testdata:

Checking the values of IMAGE_NAME and IMAGE_LINK_NAME in bitbake.conf, such check seems not necessary. But these values could be overridden. How about still keeping such check?

Best Regards,
Chen Qi

Quoted 59 lines · André Draszik

Is there anything wrong with this?

Quoted 56 lines · André Draszik

ping

Quoted 53 lines · André Draszik

From: André Draszik <[email protected]>

The testdata.json is being written to DEPLOY_DIR_IMAGE directly, thus bypassing sstate, which results in an ever growing list of files.

Write them to IMGDEPLOYDIR instead, so as to benefit from the automatic management via sstate.

---
v2: fix typo in subject line

---
  meta/classes/rootfs-postcommands.bbclass | 15 ++++++++-------
  1 file changed, 8 insertions(+), 7 deletions(-)
meta/classes/rootfs-postcommands.bbclass +8 -7
index a4e627fef8..01eee350b8 100644
@@ -303,17 +303,18 @@ rootfs_sysroot_relativelinks () {
  python write_image_test_data() {
      from oe.data import export2json
 
-    testdata = "%s/%s.testdata.json" % (d.getVar('DEPLOY_DIR_IMAGE'),
 d.getVar('IMAGE_NAME'))
-    testdata_link = "%s/%s.testdata.json" %
 (d.getVar('DEPLOY_DIR_IMAGE'), d.getVar('IMAGE_LINK_NAME'))
+    deploy_dir = d.getVar('IMGDEPLOYDIR')
+    link_name = d.getVar('IMAGE_LINK_NAME')
+    testdata_name = os.path.join(deploy_dir, "%s.testdata.json" %
 d.getVar('IMAGE_NAME'))
 
-    bb.utils.mkdirhier(os.path.dirname(testdata))
      searchString = "%s/"%(d.getVar("TOPDIR")).replace("//","/")
-    export2json(d, testdata,searchString=searchString,replaceString="")
+    export2json(d, testdata_name, searchString=searchString,
 replaceString="")
 
-    if testdata_link != testdata:
+    if os.path.exists(testdata_name):
+        testdata_link = os.path.join(deploy_dir, "%s.testdata.json" %
 link_name)
          if os.path.lexists(testdata_link):
-           os.remove(testdata_link)
-        os.symlink(os.path.basename(testdata), testdata_link)
+            os.remove(testdata_link)
+        os.symlink(os.path.basename(testdata_name), testdata_link)
  }
  write_image_test_data[vardepsexclude] += "TOPDIR"
#5 lore raw

Re: [PATCH v2] rootfs-postcommands: put image testdata under sstate control

Hi,

Quoted 5 lines · ChenQi

Hi,

I've also noticed this problem. The growing testdata.json files also bothered me a little bit.

Quoted 8 lines

I think the only small flaw with your patch is you deleted the following check.

if testdata_link != testdata:

Checking the values of IMAGE_NAME and IMAGE_LINK_NAME in bitbake.conf, such check seems not necessary.
But these values could be overridden. How about still keeping such check?

I made this fragment identical to all other uses of IMAGE_LINK_NAME and IMAGE_LINK within this class. None of the other uses have such a test, so it doesn't seem to make sense to have this check in write_image_test_data() either.

Cheers,
Andre'

#6 lore raw

Re: [PATCH v2] rootfs-postcommands: put image testdata under sstate control

In reply to André Draszik

ping

Quoted 60 lines · André Draszik

Is there anything wrong with this?

Quoted 57 lines · André Draszik

ping

Quoted 54 lines · André Draszik

From: André Draszik <[email protected]>

The testdata.json is being written to DEPLOY_DIR_IMAGE directly, thus bypassing sstate, which results in an ever growing list of files.

Write them to IMGDEPLOYDIR instead, so as to benefit from the automatic management via sstate.

---
v2: fix typo in subject line

---
 meta/classes/rootfs-postcommands.bbclass | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
meta/classes/rootfs-postcommands.bbclass +6 -5
index a4e627fef8..01eee350b8 100644
@@ -303,17 +303,18 @@ rootfs_sysroot_relativelinks () {
 python write_image_test_data() {
     from oe.data import export2json
 
-    testdata = "%s/%s.testdata.json" % (d.getVar('DEPLOY_DIR_IMAGE'),
 d.getVar('IMAGE_NAME'))
-    testdata_link = "%s/%s.testdata.json" %
 (d.getVar('DEPLOY_DIR_IMAGE'), d.getVar('IMAGE_LINK_NAME'))
+    deploy_dir = d.getVar('IMGDEPLOYDIR')
+    link_name = d.getVar('IMAGE_LINK_NAME')
+    testdata_name = os.path.join(deploy_dir, "%s.testdata.json" %
 d.getVar('IMAGE_NAME'))
 
-    bb.utils.mkdirhier(os.path.dirname(testdata))
     searchString = "%s/"%(d.getVar("TOPDIR")).replace("//","/")
-    export2json(d,
 testdata,searchString=searchString,replaceString="")
+    export2json(d, testdata_name, searchString=searchString,
 replaceString="")
 
-    if testdata_link != testdata:
+    if os.path.exists(testdata_name):
+        testdata_link = os.path.join(deploy_dir, "%s.testdata.json" %
 link_name)

if os.path.lexists(testdata_link):

meta/classes/rootfs-postcommands.bbclass +2 -2
-           os.remove(testdata_link)
-        os.symlink(os.path.basename(testdata), testdata_link)
+            os.remove(testdata_link)
+        os.symlink(os.path.basename(testdata_name), testdata_link)
 }
 write_image_test_data[vardepsexclude] += "TOPDIR"
#7 lore raw

PATCH v3 1/1 rootfs-postcommands: put image testdata under sstate control

In reply to André Draszik

From: André Draszik <[email protected]>

The testdata.json is being written to DEPLOY_DIR_IMAGE directly, thus bypassing sstate, which results in an ever growing list of files.

Write them to IMGDEPLOYDIR instead, so as to benefit from the automatic management via sstate.

---
v3: rebased
v2: fix typo in subject line

---
 meta/classes/rootfs-postcommands.bbclass | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
meta/classes/rootfs-postcommands.bbclass +8 -7
index ca690a6e59..e816824f28 100644
@@ -316,17 +316,18 @@ rootfs_sysroot_relativelinks () {
 python write_image_test_data() {
     from oe.data import export2json
 
-    testdata = "%s/%s.testdata.json" % (d.getVar('DEPLOY_DIR_IMAGE'), d.getVar('IMAGE_NAME'))
-    testdata_link = "%s/%s.testdata.json" % (d.getVar('DEPLOY_DIR_IMAGE'), d.getVar('IMAGE_LINK_NAME'))
+    deploy_dir = d.getVar('IMGDEPLOYDIR')
+    link_name = d.getVar('IMAGE_LINK_NAME')
+    testdata_name = os.path.join(deploy_dir, "%s.testdata.json" % d.getVar('IMAGE_NAME'))
 
-    bb.utils.mkdirhier(os.path.dirname(testdata))
     searchString = "%s/"%(d.getVar("TOPDIR")).replace("//","/")
-    export2json(d, testdata,searchString=searchString,replaceString="")
+    export2json(d, testdata_name, searchString=searchString, replaceString="")
 
-    if testdata_link != testdata:
+    if os.path.exists(testdata_name):
+        testdata_link = os.path.join(deploy_dir, "%s.testdata.json" % link_name)
         if os.path.lexists(testdata_link):
-           os.remove(testdata_link)
-        os.symlink(os.path.basename(testdata), testdata_link)
+            os.remove(testdata_link)
+        os.symlink(os.path.basename(testdata_name), testdata_link)
 }
 write_image_test_data[vardepsexclude] += "TOPDIR"
 
Signature · 1 line
2.18.0