All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] meta: save relative paths to qemuboot.conf and testdata.json
@ 2017-04-19 19:49 brian avery
  2017-04-19 19:49 ` [PATCH 1/3] meta: add search, replace strings to export2json brian avery
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: brian avery @ 2017-04-19 19:49 UTC (permalink / raw)
  To: openembedded-core

This patch set changes the behaviour to save relative paths instead of absolute paths into the qemuboot.conf and the testdata.json files.
A sed test verified that this seems to work without complication. If certain variables, need to be excluded from this relative path fix, that can be
done with subsequent patches.

This is to fix YOCTO #11375 https://bugzilla.yoctoproject.org/show_bug.cgi?id=11375

-brian

The following changes since commit 1423508b29fc557d8a1305f39c33de33e28d9003:

  bitbake: bitbake: Update version to 1.34.0 for stable release (2017-04-19 10:42:12 +0100)

are available in the git repository at:

  git://git.yoctoproject.org/poky-contrib bavery/poky/relpath_11375
  http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=bavery/poky/relpath_11375

brian avery (3):
  meta: add search,replace strings to export2json
  rootfs-postcommands.bbclass: save relative paths
  qemuboot.bbclass: save relative paths in conf file

 meta/classes/qemuboot.bbclass            | 7 +++++++
 meta/classes/rootfs-postcommands.bbclass | 8 +++++---
 meta/lib/oe/data.py                      | 6 ++++--
 3 files changed, 16 insertions(+), 5 deletions(-)

--
1.9.1


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

* [PATCH 1/3] meta: add search, replace strings to export2json
  2017-04-19 19:49 [PATCH 0/3] meta: save relative paths to qemuboot.conf and testdata.json brian avery
@ 2017-04-19 19:49 ` brian avery
  2017-04-19 19:49 ` [PATCH 2/3] rootfs-postcommands.bbclass: save relative paths brian avery
  2017-04-19 19:49 ` [PATCH 3/3] qemuboot.bbclass: save relative paths in conf file brian avery
  2 siblings, 0 replies; 4+ messages in thread
From: brian avery @ 2017-04-19 19:49 UTC (permalink / raw)
  To: openembedded-core

We want to be able to save relative paths so that we can relocate the
deploy dir images and kernels, yet still have qemu and testimage work
correctly.  This extends export2json with 2 named arguments so a
search/replace operation can be done to remove the leading path.

[YOCTO #11375]

Signed-off-by: brian avery <brian.avery@intel.com>
---
 meta/lib/oe/data.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/meta/lib/oe/data.py b/meta/lib/oe/data.py
index 80bba2b..b8901e6 100644
--- a/meta/lib/oe/data.py
+++ b/meta/lib/oe/data.py
@@ -17,7 +17,7 @@ def typed_value(key, d):
     except (TypeError, ValueError) as exc:
         bb.msg.fatal("Data", "%s: %s" % (key, str(exc)))
 
-def export2json(d, json_file, expand=True):
+def export2json(d, json_file, expand=True, searchString="",replaceString=""):
     data2export = {}
     keys2export = []
 
@@ -37,9 +37,11 @@ def export2json(d, json_file, expand=True):
 
     for key in keys2export:
         try:
-            data2export[key] = d.getVar(key, expand)
+            data2export[key] = d.getVar(key, expand).replace(searchString,replaceString)
         except bb.data_smart.ExpansionError:
             data2export[key] = ''
+        except AttributeError:
+            pass
 
     with open(json_file, "w") as f:
         json.dump(data2export, f, skipkeys=True, indent=4, sort_keys=True)
-- 
1.9.1



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

* [PATCH 2/3] rootfs-postcommands.bbclass: save relative paths
  2017-04-19 19:49 [PATCH 0/3] meta: save relative paths to qemuboot.conf and testdata.json brian avery
  2017-04-19 19:49 ` [PATCH 1/3] meta: add search, replace strings to export2json brian avery
@ 2017-04-19 19:49 ` brian avery
  2017-04-19 19:49 ` [PATCH 3/3] qemuboot.bbclass: save relative paths in conf file brian avery
  2 siblings, 0 replies; 4+ messages in thread
From: brian avery @ 2017-04-19 19:49 UTC (permalink / raw)
  To: openembedded-core

We pass the TOPDIR to do a search/replace in export2json so that we save
relative paths in the testdata.json file rather than absolute paths.
This is to allow the images and kernels to be relocated yet still allow
testimage to work.

[YOCTO #11375]

Signed-off-by: brian avery <brian.avery@intel.com>
---
 meta/classes/rootfs-postcommands.bbclass | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/meta/classes/rootfs-postcommands.bbclass b/meta/classes/rootfs-postcommands.bbclass
index c42829d..498174a 100644
--- a/meta/classes/rootfs-postcommands.bbclass
+++ b/meta/classes/rootfs-postcommands.bbclass
@@ -132,7 +132,7 @@ zap_empty_root_password () {
 	if [ -e ${IMAGE_ROOTFS}/etc/passwd ]; then
 		sed -i 's%^root::%root:*:%' ${IMAGE_ROOTFS}/etc/passwd
 	fi
-} 
+}
 
 #
 # allow dropbear/openssh to accept root logins and logins from accounts with an empty password string
@@ -243,7 +243,7 @@ python write_image_manifest () {
         os.symlink(os.path.basename(manifest_name), manifest_link)
 }
 
-# Can be use to create /etc/timestamp during image construction to give a reasonably 
+# Can be use to create /etc/timestamp during image construction to give a reasonably
 # sane default time setting
 rootfs_update_timestamp () {
 	date -u +%4Y%2m%2d%2H%2M%2S >${IMAGE_ROOTFS}/etc/timestamp
@@ -286,6 +286,7 @@ rootfs_sysroot_relativelinks () {
 	sysroot-relativelinks.py ${SDK_OUTPUT}/${SDKTARGETSYSROOT}
 }
 
+
 # Generated test data json file
 python write_image_test_data() {
     from oe.data import export2json
@@ -294,7 +295,8 @@ python write_image_test_data() {
     testdata_link = "%s/%s.testdata.json" % (d.getVar('DEPLOY_DIR_IMAGE'), d.getVar('IMAGE_LINK_NAME'))
 
     bb.utils.mkdirhier(os.path.dirname(testdata))
-    export2json(d, testdata)
+    searchString = "%s/"%(d.getVar("TOPDIR")).replace("//","/")
+    export2json(d, testdata,searchString=searchString,replaceString="")
 
     if os.path.lexists(testdata_link):
        os.remove(testdata_link)
-- 
1.9.1



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

* [PATCH 3/3] qemuboot.bbclass: save relative paths in conf file
  2017-04-19 19:49 [PATCH 0/3] meta: save relative paths to qemuboot.conf and testdata.json brian avery
  2017-04-19 19:49 ` [PATCH 1/3] meta: add search, replace strings to export2json brian avery
  2017-04-19 19:49 ` [PATCH 2/3] rootfs-postcommands.bbclass: save relative paths brian avery
@ 2017-04-19 19:49 ` brian avery
  2 siblings, 0 replies; 4+ messages in thread
From: brian avery @ 2017-04-19 19:49 UTC (permalink / raw)
  To: openembedded-core

This saves relative paths in the qemuboot.conf file instead of absolute
paths. This is to allow the images and kernels to be relocated and still
have the testimage and runqemu work.

[YOCTO #11375]

Signed-off-by: brian avery <brian.avery@intel.com>
---
 meta/classes/qemuboot.bbclass | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/meta/classes/qemuboot.bbclass b/meta/classes/qemuboot.bbclass
index cc5314e..86b3060 100644
--- a/meta/classes/qemuboot.bbclass
+++ b/meta/classes/qemuboot.bbclass
@@ -84,6 +84,7 @@ python do_write_qemuboot_conf() {
 
     qemuboot = "%s/%s.qemuboot.conf" % (d.getVar('IMGDEPLOYDIR'), d.getVar('IMAGE_NAME'))
     qemuboot_link = "%s/%s.qemuboot.conf" % (d.getVar('IMGDEPLOYDIR'), d.getVar('IMAGE_LINK_NAME'))
+    topdir="%s/"%(d.getVar('TOPDIR')).replace("//","/")
     cf = configparser.ConfigParser()
     cf.add_section('config_bsp')
     for k in qemuboot_vars(d):
@@ -94,6 +95,9 @@ python do_write_qemuboot_conf() {
                                'qemu-helper-native/1.0-r1/recipe-sysroot-native/usr/bin/')
         else:
             val = d.getVar(k)
+        # we only want to write out relative paths so that we can relocate images
+        # and still run them
+        val=val.replace(topdir,"")
         cf.set('config_bsp', k, '%s' % val)
 
     # QB_DEFAULT_KERNEL's value of KERNEL_IMAGETYPE is the name of a symlink
@@ -101,6 +105,9 @@ python do_write_qemuboot_conf() {
     # Read the link and replace it with the full filename of the target.
     kernel_link = os.path.join(d.getVar('DEPLOY_DIR_IMAGE'), d.getVar('QB_DEFAULT_KERNEL'))
     kernel = os.path.realpath(kernel_link)
+    # we only want to write out relative paths so that we can relocate images
+    # and still run them
+    kernel=kernel.replace(topdir,"")
     cf.set('config_bsp', 'QB_DEFAULT_KERNEL', kernel)
 
     bb.utils.mkdirhier(os.path.dirname(qemuboot))
-- 
1.9.1



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

end of thread, other threads:[~2017-04-19 19:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-19 19:49 [PATCH 0/3] meta: save relative paths to qemuboot.conf and testdata.json brian avery
2017-04-19 19:49 ` [PATCH 1/3] meta: add search, replace strings to export2json brian avery
2017-04-19 19:49 ` [PATCH 2/3] rootfs-postcommands.bbclass: save relative paths brian avery
2017-04-19 19:49 ` [PATCH 3/3] qemuboot.bbclass: save relative paths in conf file brian avery

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.