cros deploy: simplify _GetPackagesPaths implementation
The |pkgs| variable passed into _GetPackagesPaths contain only cpvs*, so
simplify its implementation based on that.
*pkgs comes from pkg_scanner.Run(..), which supposed to return the cpvs
string (see cs/chromeos_public/chromite/cli/deploy.py?rcl=c08d404a452b5d55b99fb665ace0435ba4d6e198&l=679)
BUG=chromium:920140
TEST=unittest, run `cros deploy` locally
Change-Id: I93784b88f3d79436829270dec7dc1af4a3397ea0
Reviewed-on: https://chromium-review.googlesource.com/1484191
Commit-Ready: Ned Nguyen <nednguyen@google.com>
Tested-by: Ned Nguyen <nednguyen@google.com>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/cli/deploy.py b/cli/deploy.py
index 1090f66..533ebce 100644
--- a/cli/deploy.py
+++ b/cli/deploy.py
@@ -838,30 +838,16 @@
def _GetPackagesPaths(pkgs, strip, sysroot):
"""Returns paths to binary |pkgs|.
- Each package argument may be specified as a filename, in which case it is
- returned as-is, or it may be a CPV value, in which case it is stripped (if
- instructed) and a path to it is returned.
-
Args:
- pkgs: List of package arguments.
+ pkgs: List of package CPVs string.
strip: Whether or not to run strip_package for CPV packages.
sysroot: The sysroot path.
Returns:
List of paths corresponding to |pkgs|.
"""
- indexes = []
- cpvs = []
- for i, pkg in enumerate(pkgs):
- if not os.path.isfile(pkg):
- indexes.append(i)
- cpvs.append(portage_util.SplitCPV(pkg))
-
- cpv_paths = cpvs and _GetPackagesByCPV(cpvs, strip, sysroot)
- paths = list(pkgs)
- for i, cpv_path in zip(indexes, cpv_paths):
- paths[i] = cpv_path
- return paths
+ cpvs = [portage_util.SplitCPV(p) for p in pkgs]
+ return _GetPackagesByCPV(cpvs, strip, sysroot)
def _Unmerge(device, pkg, root):