cros_install_debug_syms: handle file:// binhost
According to RFC1738, the URI for a file scheme can contain a location.
cros_generate_local_binhost use it and set it to localhost for binhost from
other boards.
PORTAGE_BINHOST is handled using urllib by portage. We should handle it with
urlparse to be compatible.
Also don't cache local binhost as they may change over time and it is
inexpensive to parse them again.
BUG=chromium:426494
TEST=`./build_packages --board=beaglebone_servo &&
./build_packages --board=beaglebone --reuse_pkgs_from_local_boards` works
TEST=`sudo -E /mnt/host/source/chromite/bin/cros_install_debug_syms
--board=beaglebone --all` does not create a cache entry for the local binhost.
Change-Id: I3c7507c38353864d1ebab8252ec682085de65dc4
Reviewed-on: https://chromium-review.googlesource.com/233300
Trybot-Ready: Bertrand Simonnet <bsimonnet@chromium.org>
Tested-by: Bertrand Simonnet <bsimonnet@chromium.org>
Reviewed-by: David James <davidjames@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Bertrand Simonnet <bsimonnet@chromium.org>
diff --git a/scripts/cros_install_debug_syms.py b/scripts/cros_install_debug_syms.py
index 8c6c710..d8d171d 100644
--- a/scripts/cros_install_debug_syms.py
+++ b/scripts/cros_install_debug_syms.py
@@ -20,6 +20,7 @@
import pickle
import sys
import tempfile
+import urlparse
from chromite.lib import binpkg
from chromite.lib import cache
@@ -180,17 +181,22 @@
key = binhost.split('://')[-1]
key = key.rstrip('/').split('/')
+ should_cache = True
+
if binhost_cache and binhost_cache.Lookup(key).Exists():
with open(binhost_cache.Lookup(key).path) as f:
return pickle.load(f)
pkgindex = binpkg.GrabRemotePackageIndex(binhost)
if pkgindex is None:
- binhost = binhost.replace('file://', '')
+ binhost = urlparse.urlsplit(binhost).path
if not os.path.isdir(binhost):
raise ValueError('unrecognized binhost format for %s. Supported formats: '
'http, gs or local path.' % binhost)
pkgindex = binpkg.GrabLocalPackageIndex(binhost)
+ # If the package index is local, do not cache as the package index may
+ # change later (for example when reusing packages from other board).
+ should_cache = False
symbols = {}
for p in pkgindex.packages:
@@ -198,7 +204,7 @@
path = p.get('PATH', os.path.join(binhost, p['CPV'] + '.tbz2'))
symbols[p['CPV']] = path.replace('.tbz2', '.debug.tbz2')
- if binhost_cache:
+ if binhost_cache and should_cache:
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
pickle.dump(symbols, temp_file)
temp_file.file.close()