Skip to contentSkip to conversation

toaster: localhostbectrl Don't descend into directories for cached_layers

PATCH In review Michael Wood 2 participants 2 messages Oct 8, 2015 – Oct 9, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 toaster: localhostbectrl Don't descend into directories for cached_layers

As toaster makes use of clones of itself we have a mechanism to just clone the current checkout and use that as a basis for the git clone for the layers inside. For instance in poky if we're running in that directory we don't ever want to change the current checkout so we make a copy of ourselves to do this work in. This step is cached_layers and previously traversed through directories inside the current checkout to find any pre-existing checkouts. This was ending up traversing too many directories down so remove the traverse and only deal with the current directory.

[YOCTO #8463]

---
 .../toaster/bldcontrol/localhostbecontroller.py    | 29 ++++++++++++----------
 1 file changed, 16 insertions(+), 13 deletions(-)
bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +16 -13
index 3ee68ae..b5cf559 100644
@@ -218,23 +218,26 @@ class LocalhostBEController(BuildEnvironmentController):
         logger.debug("localhostbecontroller, our git repos are %s" % pformat(gitrepos))
 
 
-        # 2. find checked-out git repos in the sourcedir directory that may help faster cloning
+        # 2. Note for future use if the current source directory is a
+        # checked-out git repos that could match a layer's vcs_url and therefore
+        # be used to speed up cloning (rather than fetching it again).
 
         cached_layers = {}
-        for ldir in os.listdir(self.be.sourcedir):
-            fldir = os.path.join(self.be.sourcedir, ldir)
-            if os.path.isdir(fldir):
+
+        try:
+            for remotes in self._shellcmd("git remote -v", self.be.sourcedir).split("\n"):
                 try:
-                    for line in self._shellcmd("git remote -v", fldir).split("\n"):
-                        try:
-                            remote = line.split("\t")[1].split(" ")[0]
-                            if remote not in cached_layers:
-                                cached_layers[remote] = fldir
-                        except IndexError:
-                            pass
-                except ShellCmdException:
-                    # ignore any errors in collecting git remotes
+                    remote = remotes.split("\t")[1].split(" ")[0]
+                    if remote not in cached_layers:
+                        cached_layers[remote] = self.be.sourcedir
+                except IndexError:
                     pass
+        except ShellCmdException:
+            # ignore any errors in collecting git remotes this is an optional
+            # step
+            pass
+
+        logger.info("Using pre-checked out source for layer %s", cached_layers)
 
         layerlist = []
 
Signature · 1 line
2.1.4
#1 lore raw
Quoted 10 lines · Michael Wood

As toaster makes use of clones of itself we have a mechanism to just clone the current checkout and use that as a basis for the git clone for the layers inside. For instance in poky if we're running in that directory we don't ever want to change the current checkout so we make a copy of ourselves to do this work in. This step is cached_layers and previously traversed through directories inside the current checkout to find any pre-existing checkouts. This was ending up traversing too many directories down so remove the traverse and only deal with the current directory.

Submitted upstream, added to toaster-next.

Elliot

Quoted 71 lines

[YOCTO #8463]

---
 .../toaster/bldcontrol/localhostbecontroller.py    | 29
++++++++++++----------
 1 file changed, 16 insertions(+), 13 deletions(-)
bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +0 -0
index 3ee68ae..b5cf559 100644
@@ -218,23 +218,26 @@ class

LocalhostBEController(BuildEnvironmentController):
logger.debug("localhostbecontroller, our git repos are %s" %
pformat(gitrepos))

- # 2. find checked-out git repos in the sourcedir directory that
may help faster cloning

bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +2 -0
+        # 2. Note for future use if the current source directory is a
+        # checked-out git repos that could match a layer's vcs_url and

therefore

bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +4 -3
+        # be used to speed up cloning (rather than fetching it again).
 
         cached_layers = {}
-        for ldir in os.listdir(self.be.sourcedir):
-            fldir = os.path.join(self.be.sourcedir, ldir)
-            if os.path.isdir(fldir):
+
+        try:
+            for remotes in self._shellcmd("git remote -v",

self.be.sourcedir).split("\n"):
try:
- for line in self._shellcmd("git remote -v",
fldir).split("\n"):

bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +6 -8
-                        try:
-                            remote = line.split("\t")[1].split(" ")[0]
-                            if remote not in cached_layers:
-                                cached_layers[remote] = fldir
-                        except IndexError:
-                            pass
-                except ShellCmdException:
-                    # ignore any errors in collecting git remotes
+                    remote = remotes.split("\t")[1].split(" ")[0]
+                    if remote not in cached_layers:
+                        cached_layers[remote] = self.be.sourcedir
+                except IndexError:
                     pass
+        except ShellCmdException:
+            # ignore any errors in collecting git remotes this is an

optional

bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +4 -0
+            # step
+            pass
+
+        logger.info("Using pre-checked out source for layer %s",

cached_layers)

         layerlist = []

--
2.1.4

--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster

Signature · 3 lines
Elliot Smith
Software Engineer
Intel Open Source Technology Centre