Skip to contentSkip to conversation

change the default behavior of bitbake-layers and oe-setup-builddir to rel paths

PATCH In review [email protected] 2 participants 3 messages Mar 24, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 change the default behavior of bitbake-layers and oe-setup-builddir to rel paths

From: Thomas Roos <[email protected]>

This patch will use the $TOPDIR variable to create layer entries in bblayers.conf. Instead of an absolute path this will create an relative path to $TOPDIR, which will allow to move the bblayers.conf to different paths without modification of it.

---
 bitbake/lib/bblayers/action.py | 4 +++-
 scripts/oe-setup-builddir      | 5 +++--
 2 files changed, 6 insertions(+), 3 deletions(-)
bitbake/lib/bblayers/action.py +3 -1
index 0d7fd6edd1..bd13e15a2f 100644
@@ -26,7 +26,7 @@ def plugin_init(plugins):
 class ActionPlugin(LayerPlugin):
     def do_add_layer(self, args):
         """Add one or more layers to bblayers.conf."""
-        layerdirs = [os.path.abspath(ldir) for ldir in args.layerdir]
+        layerdirs = [os.path.relpath(ldir, findTopdir()) for ldir in args.layerdir]
 
         for layerdir in layerdirs:
             if not os.path.exists(layerdir):
@@ -38,6 +38,8 @@ class ActionPlugin(LayerPlugin):
                 sys.stderr.write("Specified layer directory %s doesn't contain a conf/layer.conf file\n" % layerdir)
                 return 1
 
+        layerdirs = [os.path.join('${TOPDIR}', ldir) for ldir in args.layerdir]
+
         bblayers_conf = os.path.join(findTopdir(),'conf', 'bblayers.conf')
         if not os.path.exists(bblayers_conf):
             sys.stderr.write("Unable to find bblayers.conf\n")
scripts/oe-setup-builddir +3 -2
index 89ae30f609..65a77b76fd 100755
@@ -92,8 +92,9 @@ EOM
     # bitbake without the init script after the first run.
     # ##COREBASE## is deprecated as its meaning was inconsistent, but continue
     # to replace it for compatibility.
-    sed -e "s|##OEROOT##|$OEROOT|g" \
-        -e "s|##COREBASE##|$OEROOT|g" \
+    LAYERPATH='${TOPDIR}'/$(realpath --relative-to=$BUILDDIR $OEROOT)
+    sed -e "s|##OEROOT##|$LAYERPATH|"g \
+        -e "s|##COREBASE##|$LAYERPATH|"g \
         "$OECORELAYERCONF" > "$BUILDDIR/conf/bblayers.conf"
     SHOWYPDOC=yes
 fi
Signature · 14 lines
2.34.1




Amazon Web Services EMEA SARL
38 avenue John F. Kennedy, L-1855 Luxembourg
Sitz der Gesellschaft: L-1855 Luxemburg
eingetragen im Luxemburgischen Handelsregister unter R.C.S. B186284

Amazon Web Services EMEA SARL, Niederlassung Deutschland
Marcel-Breuer-Str. 12, D-80807 Muenchen
Sitz der Zweigniederlassung: Muenchen
eingetragen im Handelsregister des Amtsgerichts Muenchen unter HRB 242240, USt-ID DE317013094
#1 lore raw

Build directories are not meant to be relocatable, and will likely break in all kinds of ways if you try. Can you explain the use case?

Alex

Quoted 90 lines · Thomas Roos via lists.openembedded.org

From: Thomas Roos <[email protected]>

This patch will use the $TOPDIR variable to create layer entries in bblayers.conf.
Instead of an absolute path this will create an relative path to $TOPDIR, which will
allow to move the bblayers.conf to different paths without modification of it.

---
 bitbake/lib/bblayers/action.py | 4 +++-
 scripts/oe-setup-builddir      | 5 +++--
 2 files changed, 6 insertions(+), 3 deletions(-)
bitbake/lib/bblayers/action.py +1 -1
index 0d7fd6edd1..bd13e15a2f 100644
@@ -26,7 +26,7 @@ def plugin_init(plugins):
 class ActionPlugin(LayerPlugin):
     def do_add_layer(self, args):
         """Add one or more layers to bblayers.conf."""
-        layerdirs = [os.path.abspath(ldir) for ldir in args.layerdir]
+        layerdirs = [os.path.relpath(ldir, findTopdir()) for ldir in

args.layerdir]

for layerdir in layerdirs:
if not os.path.exists(layerdir):

bitbake/lib/bblayers/action.py +1 -0
@@ -38,6 +38,8 @@ class ActionPlugin(LayerPlugin):
                 sys.stderr.write("Specified layer directory %s doesn't
 contain a conf/layer.conf file\n" % layerdir)
                 return 1
 
+        layerdirs = [os.path.join('${TOPDIR}', ldir) for ldir in

args.layerdir]

bitbake/lib/bblayers/action.py +1 -0
+
         bblayers_conf = os.path.join(findTopdir(),'conf', 'bblayers.conf')
         if not os.path.exists(bblayers_conf):
             sys.stderr.write("Unable to find bblayers.conf\n")
scripts/oe-setup-builddir +0 -0
index 89ae30f609..65a77b76fd 100755
@@ -92,8 +92,9 @@ EOM
     # bitbake without the init script after the first run.
     # ##COREBASE## is deprecated as its meaning was inconsistent, but

continue

     # to replace it for compatibility.
scripts/oe-setup-builddir +3 -3
-    sed -e "s|##OEROOT##|$OEROOT|g" \
-        -e "s|##COREBASE##|$OEROOT|g" \
+    LAYERPATH='${TOPDIR}'/$(realpath --relative-to=$BUILDDIR $OEROOT)
+    sed -e "s|##OEROOT##|$LAYERPATH|"g \
+        -e "s|##COREBASE##|$LAYERPATH|"g \
         "$OECORELAYERCONF" > "$BUILDDIR/conf/bblayers.conf"
     SHOWYPDOC=yes
 fi
--

2.34.1

Amazon Web Services EMEA SARL
38 avenue John F. Kennedy, L-1855 Luxembourg
Sitz der Gesellschaft: L-1855 Luxemburg
eingetragen im Luxemburgischen Handelsregister unter R.C.S. B186284

Amazon Web Services EMEA SARL, Niederlassung Deutschland Marcel-Breuer-Str. 12, D-80807 Muenchen
Sitz der Zweigniederlassung: Muenchen
eingetragen im Handelsregister des Amtsgerichts Muenchen unter HRB 242240, USt-ID DE317013094

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#179040):
https://lists.openembedded.org/g/openembedded-core/message/179040
Mute This Topic: https://lists.openembedded.org/mt/97825329/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw
In reply to [email protected]

Also, this will break build templates, as they can’t contain paths relative to build dirs.

Alex

Quoted 90 lines · Thomas Roos via lists.openembedded.org

From: Thomas Roos <[email protected]>

This patch will use the $TOPDIR variable to create layer entries in bblayers.conf.
Instead of an absolute path this will create an relative path to $TOPDIR, which will
allow to move the bblayers.conf to different paths without modification of it.

---
 bitbake/lib/bblayers/action.py | 4 +++-
 scripts/oe-setup-builddir      | 5 +++--
 2 files changed, 6 insertions(+), 3 deletions(-)
bitbake/lib/bblayers/action.py +1 -1
index 0d7fd6edd1..bd13e15a2f 100644
@@ -26,7 +26,7 @@ def plugin_init(plugins):
 class ActionPlugin(LayerPlugin):
     def do_add_layer(self, args):
         """Add one or more layers to bblayers.conf."""
-        layerdirs = [os.path.abspath(ldir) for ldir in args.layerdir]
+        layerdirs = [os.path.relpath(ldir, findTopdir()) for ldir in

args.layerdir]

for layerdir in layerdirs:
if not os.path.exists(layerdir):

bitbake/lib/bblayers/action.py +1 -0
@@ -38,6 +38,8 @@ class ActionPlugin(LayerPlugin):
                 sys.stderr.write("Specified layer directory %s doesn't
 contain a conf/layer.conf file\n" % layerdir)
                 return 1
 
+        layerdirs = [os.path.join('${TOPDIR}', ldir) for ldir in

args.layerdir]

bitbake/lib/bblayers/action.py +1 -0
+
         bblayers_conf = os.path.join(findTopdir(),'conf', 'bblayers.conf')
         if not os.path.exists(bblayers_conf):
             sys.stderr.write("Unable to find bblayers.conf\n")
scripts/oe-setup-builddir +0 -0
index 89ae30f609..65a77b76fd 100755
@@ -92,8 +92,9 @@ EOM
     # bitbake without the init script after the first run.
     # ##COREBASE## is deprecated as its meaning was inconsistent, but

continue

     # to replace it for compatibility.
scripts/oe-setup-builddir +3 -3
-    sed -e "s|##OEROOT##|$OEROOT|g" \
-        -e "s|##COREBASE##|$OEROOT|g" \
+    LAYERPATH='${TOPDIR}'/$(realpath --relative-to=$BUILDDIR $OEROOT)
+    sed -e "s|##OEROOT##|$LAYERPATH|"g \
+        -e "s|##COREBASE##|$LAYERPATH|"g \
         "$OECORELAYERCONF" > "$BUILDDIR/conf/bblayers.conf"
     SHOWYPDOC=yes
 fi
--

2.34.1

Amazon Web Services EMEA SARL
38 avenue John F. Kennedy, L-1855 Luxembourg
Sitz der Gesellschaft: L-1855 Luxemburg
eingetragen im Luxemburgischen Handelsregister unter R.C.S. B186284

Amazon Web Services EMEA SARL, Niederlassung Deutschland Marcel-Breuer-Str. 12, D-80807 Muenchen
Sitz der Zweigniederlassung: Muenchen
eingetragen im Handelsregister des Amtsgerichts Muenchen unter HRB 242240, USt-ID DE317013094

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#179040):
https://lists.openembedded.org/g/openembedded-core/message/179040
Mute This Topic: https://lists.openembedded.org/mt/97825329/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-