Patchwork [2/3] sstate.bbclass: fetch archive+siginfo in a single pstaging_fetch

login
register
mail settings
Submitter Christopher Larson
Date June 10, 2013, 8:46 p.m.
Message ID <694bdc11ba7066ca142d101c4dba08987fbfcb9c.1370896970.git.chris_larson@mentor.com>
Download mbox | patch
Permalink /patch/51427/
State Accepted
Commit 00c8834293b84a9fa1616de7aace639fc93a81e0
Headers show

Comments

Christopher Larson - June 10, 2013, 8:46 p.m.
From: Christopher Larson <chris_larson@mentor.com>

This avoids unnecessary duplication of setup. The only visible change in
behavior will be the case if siginfo exists and the archive does not, in which
case it'll redownload both, but this doesn't seem unresasonable to me,
particularly since the archive is downloaded first, making this case
particularly unlikely.

Signed-off-by: Christopher Larson <chris_larson@mentor.com>
---
 meta/classes/sstate.bbclass | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)
Otavio Salvador - June 10, 2013, 8:52 p.m.
On Mon, Jun 10, 2013 at 5:46 PM, Christopher Larson <kergoth@gmail.com>wrote:

> From: Christopher Larson <chris_larson@mentor.com>
>
> This avoids unnecessary duplication of setup. The only visible change in
> behavior will be the case if siginfo exists and the archive does not, in
> which
> case it'll redownload both, but this doesn't seem unresasonable to me,
> particularly since the archive is downloaded first, making this case
> particularly unlikely.
>
> Signed-off-by: Christopher Larson <chris_larson@mentor.com>
>

Reviewed-by: Otavio Salvador <otavio@ossystems.com.br>

Patch

diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
index 3aa4371..28dc312 100644
--- a/meta/classes/sstate.bbclass
+++ b/meta/classes/sstate.bbclass
@@ -224,8 +224,6 @@  def sstate_installpkg(ss, d):
 
     if not os.path.exists(sstatepkg):
         pstaging_fetch(sstatefetch, sstatepkg, d)
-    if not os.path.exists(sstatepkg + ".siginfo"):
-        pstaging_fetch(sstatefetch + ".siginfo", sstatepkg + ".siginfo", d)
 
     if not os.path.isfile(sstatepkg):
         bb.note("Staging package %s does not exist" % sstatepkg)
@@ -504,30 +502,30 @@  def pstaging_fetch(sstatefetch, sstatepkg, d):
     bb.data.update_data(localdata)
 
     dldir = localdata.expand("${SSTATE_DIR}")
-    srcuri = "file://" + sstatefetch
-
     bb.mkdirhier(dldir)
 
     localdata.delVar('MIRRORS')
     localdata.delVar('FILESPATH')
     localdata.setVar('DL_DIR', dldir)
     localdata.setVar('PREMIRRORS', mirrors)
-    localdata.setVar('SRC_URI', srcuri)
 
     # Try a fetch from the sstate mirror, if it fails just return and
     # we will build the package
-    try:
-        fetcher = bb.fetch2.Fetch([srcuri], localdata, cache=False)
-        fetcher.download()        
-
-        # Need to optimise this, if using file:// urls, the fetcher just changes the local path
-        # For now work around by symlinking
-        localpath = bb.data.expand(fetcher.localpath(srcuri), localdata)
-        if localpath != sstatepkg and os.path.exists(localpath) and not os.path.exists(sstatepkg):
-            os.symlink(localpath, sstatepkg)
-
-    except bb.fetch2.BBFetchException:
-        pass
+    for srcuri in ['file://{0}'.format(sstatefetch),
+                   'file://{0}.siginfo'.format(sstatefetch)]:
+        localdata.setVar('SRC_URI', srcuri)
+        try:
+            fetcher = bb.fetch2.Fetch([srcuri], localdata, cache=False)
+            fetcher.download()
+
+            # Need to optimise this, if using file:// urls, the fetcher just changes the local path
+            # For now work around by symlinking
+            localpath = bb.data.expand(fetcher.localpath(srcuri), localdata)
+            if localpath != sstatepkg and os.path.exists(localpath) and not os.path.exists(sstatepkg):
+                os.symlink(localpath, sstatepkg)
+
+        except bb.fetch2.BBFetchException:
+            break
 
 def sstate_setscene(d):
     shared_state = sstate_state_fromvars(d)