Skip to contentSkip to conversation

better matching for refkit ci

PATCH Superseded Stephano Cetola 1 participant 2 messages Jul 5, 2017

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover better matching for refkit ci

Updates since V2:
match the first line and remove the variable name, rather than skipping the first line. Also, removed some backslashes and submitted the correct patch rather than resubmitting the old patch again.

fixes [YOCTO #11720]

Stephano Cetola (1):
ScrapeTargets.py: improve target search algorithm

 .../site-packages/autobuilder/buildsteps/ScrapeTargets.py     | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
Signature · 1 line
2.13.2
#1 lore raw

PATCH v3 1/1 ScrapeTargets.py: improve target search algorithm

When scraping the build targets from refkit-ci.inc, grep would only return the first line of the search result. By replacing grep with awk, we are now searching for multi-line variables, and should now scrape build targets even if they have line breaks between them.

[YOCTO #11720]

---
 .../site-packages/autobuilder/buildsteps/ScrapeTargets.py     | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
lib/python2.7/site-packages/autobuilder/buildsteps/ScrapeTargets.py +6 -5
index 80153fe85..8d1549636 100644
@@ -41,7 +41,9 @@ class ScrapeTargets(ShellCommand):
         workerdir = os.path.join(os.path.join(YOCTO_ABBASE, "yocto-worker"))
         buildername = self.getProperty("buildername")
         src = os.path.join(workerdir, buildername, "build", self.source)
-        self.command = "cat " + src + " | grep " + self.targetsvar
+        # find targetsvar then return lines up to a quote
+        self.command = ["awk",
+                '/%s/{flag=1;print;next}/"/{flag=0}flag' % self.targetsvar, src]
         ShellCommand.start(self)
 
     def commandComplete(self, cmd):
@@ -49,10 +51,9 @@ class ScrapeTargets(ShellCommand):
             return
 
         result = cmd.logs['stdio'].getText()
-        targets = result.replace(self.targetsvar, "")
-        targets = targets.strip()
-        targets = targets.replace('=', '')
-        targets = targets.strip('"')
+        targets = result.strip()
+        targets = targets.replace('%s="' % self.targetsvar, '')
+        targets = targets.replace('\\', '')
         self.setProperty("scraped_targets",
                          targets,
                          'Targets "%s" scraped from %s' % (targets,
Signature · 1 line
2.13.2