Remove ensure tool dep from tar.
This also fixes the an issue with gsutil binary path.
Change-Id: Ic92b3c04820deeeb0d4b4de10a38c5ef61f60b2f
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/51900
Reviewed-by: Keyong Han <keyonghan@google.com>
Commit-Queue: Godofredo Contreras <godofredoc@google.com>
diff --git a/recipe_modules/gsutil/api.py b/recipe_modules/gsutil/api.py
index 2d9604b..7a76670 100644
--- a/recipe_modules/gsutil/api.py
+++ b/recipe_modules/gsutil/api.py
@@ -4,15 +4,15 @@
from recipe_engine import recipe_api
-
GSUTIL_VERSION = 'version:2@5.19'
+
class GSUtilApi(recipe_api.RecipeApi):
"""GSUtilApi provides support for GSUtil."""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
- self._initialized = False
+ self._tool_path = None
@recipe_api.non_step
def join(self, *parts):
@@ -268,12 +268,11 @@
@property
def _gsutil_tool(self):
- if not self._initialized:
- self.m.cipd.ensure_tool(
+ if not self._tool_path:
+ self._tool_path = self.m.cipd.ensure_tool(
'infra/3pp/tools/gsutil/${platform}', GSUTIL_VERSION
)
- self._initialized = True
- return self._initialized
+ return self._tool_path
def _run(self, *args, **kwargs):
"""Return a step to run arbitrary gsutil command."""
diff --git a/recipe_modules/gsutil/tests/full.expected/basic.json b/recipe_modules/gsutil/tests/full.expected/basic.json
index 62e79da..bce7a1c 100644
--- a/recipe_modules/gsutil/tests/full.expected/basic.json
+++ b/recipe_modules/gsutil/tests/full.expected/basic.json
@@ -77,7 +77,7 @@
},
{
"cmd": [
- "True",
+ "[START_DIR]/cipd_tool/infra/3pp/tools/gsutil/version%3A2%405.19/gsutil",
"-h",
"Cache-Control:no-cache",
"-h",
@@ -117,7 +117,7 @@
},
{
"cmd": [
- "True",
+ "[START_DIR]/cipd_tool/infra/3pp/tools/gsutil/version%3A2%405.19/gsutil",
"-h",
"Custom-Time:2012-05-14T12:53:23.000000Z",
"-o",
@@ -151,7 +151,7 @@
},
{
"cmd": [
- "True",
+ "[START_DIR]/cipd_tool/infra/3pp/tools/gsutil/version%3A2%405.19/gsutil",
"-h",
"Custom-Time:2012-05-14T12:53:24.500000Z",
"-o",
@@ -185,7 +185,7 @@
},
{
"cmd": [
- "True",
+ "[START_DIR]/cipd_tool/infra/3pp/tools/gsutil/version%3A2%405.19/gsutil",
"-h",
"Custom-Time:2012-05-14T12:53:26.000000Z",
"-o",
@@ -215,7 +215,7 @@
},
{
"cmd": [
- "True",
+ "[START_DIR]/cipd_tool/infra/3pp/tools/gsutil/version%3A2%405.19/gsutil",
"-o",
"GSUtil:software_update_check_period=0",
"cp",
@@ -243,7 +243,7 @@
},
{
"cmd": [
- "True",
+ "[START_DIR]/cipd_tool/infra/3pp/tools/gsutil/version%3A2%405.19/gsutil",
"-o",
"GSUtil:software_update_check_period=0",
"cp",
diff --git a/recipe_modules/gsutil/tests/full.expected/retry_on_failure.json b/recipe_modules/gsutil/tests/full.expected/retry_on_failure.json
index 075ec96..2561207 100644
--- a/recipe_modules/gsutil/tests/full.expected/retry_on_failure.json
+++ b/recipe_modules/gsutil/tests/full.expected/retry_on_failure.json
@@ -195,7 +195,7 @@
{
"cmd": [
"[START_DIR]\\cipd_tool\\path\\to\\cpython3\\version%3Apinned-version\\bin\\python3.exe",
- "True",
+ "[START_DIR]\\cipd_tool\\infra\\3pp\\tools\\gsutil\\version%3A2%405.19\\gsutil",
"-h",
"Cache-Control:no-cache",
"-h",
@@ -236,7 +236,7 @@
{
"cmd": [
"[START_DIR]\\cipd_tool\\path\\to\\cpython3\\version%3Apinned-version\\bin\\python3.exe",
- "True",
+ "[START_DIR]\\cipd_tool\\infra\\3pp\\tools\\gsutil\\version%3A2%405.19\\gsutil",
"-h",
"Custom-Time:2012-05-14T12:53:23.000000Z",
"-o",
@@ -271,7 +271,7 @@
{
"cmd": [
"[START_DIR]\\cipd_tool\\path\\to\\cpython3\\version%3Apinned-version\\bin\\python3.exe",
- "True",
+ "[START_DIR]\\cipd_tool\\infra\\3pp\\tools\\gsutil\\version%3A2%405.19\\gsutil",
"-h",
"Custom-Time:2012-05-14T12:53:24.500000Z",
"-o",
@@ -306,7 +306,7 @@
{
"cmd": [
"[START_DIR]\\cipd_tool\\path\\to\\cpython3\\version%3Apinned-version\\bin\\python3.exe",
- "True",
+ "[START_DIR]\\cipd_tool\\infra\\3pp\\tools\\gsutil\\version%3A2%405.19\\gsutil",
"-h",
"Custom-Time:2012-05-14T12:53:24.500000Z",
"-o",
@@ -341,7 +341,7 @@
{
"cmd": [
"[START_DIR]\\cipd_tool\\path\\to\\cpython3\\version%3Apinned-version\\bin\\python3.exe",
- "True",
+ "[START_DIR]\\cipd_tool\\infra\\3pp\\tools\\gsutil\\version%3A2%405.19\\gsutil",
"-h",
"Custom-Time:2012-05-14T12:53:26.000000Z",
"-o",
@@ -372,7 +372,7 @@
{
"cmd": [
"[START_DIR]\\cipd_tool\\path\\to\\cpython3\\version%3Apinned-version\\bin\\python3.exe",
- "True",
+ "[START_DIR]\\cipd_tool\\infra\\3pp\\tools\\gsutil\\version%3A2%405.19\\gsutil",
"-o",
"GSUtil:software_update_check_period=0",
"cp",
@@ -401,7 +401,7 @@
{
"cmd": [
"[START_DIR]\\cipd_tool\\path\\to\\cpython3\\version%3Apinned-version\\bin\\python3.exe",
- "True",
+ "[START_DIR]\\cipd_tool\\infra\\3pp\\tools\\gsutil\\version%3A2%405.19\\gsutil",
"-o",
"GSUtil:software_update_check_period=0",
"cp",
diff --git a/recipe_modules/tar/__init__.py b/recipe_modules/tar/__init__.py
index 4174dac..1933777 100644
--- a/recipe_modules/tar/__init__.py
+++ b/recipe_modules/tar/__init__.py
@@ -3,7 +3,7 @@
# found in the LICENSE file.
DEPS = [
- "fuchsia/ensure_tool",
+ "recipe_engine/cipd",
"recipe_engine/context",
"recipe_engine/path",
"recipe_engine/step",
diff --git a/recipe_modules/tar/api.py b/recipe_modules/tar/api.py
index f64f332..eb9d393 100644
--- a/recipe_modules/tar/api.py
+++ b/recipe_modules/tar/api.py
@@ -4,12 +4,18 @@
from recipe_engine import recipe_api
+TAR_VERSION = 'git_revision:6462ccda48c8f33dce4c80c2f1533263277d4da9'
+
class TarApi(recipe_api.RecipeApi):
"""Provides steps to tar and untar files."""
COMPRESSION_OPTS = ["gzip", "bzip2", "xz", "lzma"]
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ self._tool_path = None
+
def __call__(self, step_name, cmd):
full_cmd = [self._bsdtar_path] + list(cmd)
return self.m.step(step_name, full_cmd)
@@ -17,7 +23,11 @@
@property
def _bsdtar_path(self):
"""Ensures that bsdtar is installed."""
- return self.m.ensure_tool("bsdtar", self.resource("tool_manifest.json"))
+ if not self._tool_path:
+ self._tool_path = self.m.cipd.ensure_tool(
+ 'fuchsia/tools/bsdtar/${platform}', TAR_VERSION
+ )
+ return self._tool_path
def create(self, path, compression=None):
"""Returns TarArchive object that can be used to compress a set of files.
diff --git a/recipe_modules/tar/tests/full.expected/linux.json b/recipe_modules/tar/tests/full.expected/linux.json
index 20844c7..7421198 100644
--- a/recipe_modules/tar/tests/full.expected/linux.json
+++ b/recipe_modules/tar/tests/full.expected/linux.json
@@ -37,36 +37,7 @@
},
{
"cmd": [],
- "name": "ensure bsdtar"
- },
- {
- "cmd": [
- "vpython3",
- "-u",
- "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
- "--json-output",
- "/path/to/tmp/json",
- "copy",
- "RECIPE_MODULE[flutter::tar]/resources/tool_manifest.json",
- "/path/to/tmp/json"
- ],
- "infra_step": true,
- "name": "ensure bsdtar.read manifest",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@",
- "@@@STEP_LOG_LINE@tool_manifest.json@{@@@",
- "@@@STEP_LOG_LINE@tool_manifest.json@ \"path\": \"path/to/bsdtar\",@@@",
- "@@@STEP_LOG_LINE@tool_manifest.json@ \"version\": \"version:pinned-version\"@@@",
- "@@@STEP_LOG_LINE@tool_manifest.json@}@@@",
- "@@@STEP_LOG_END@tool_manifest.json@@@"
- ]
- },
- {
- "cmd": [],
- "name": "ensure bsdtar.install path/to/bsdtar",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
+ "name": "install fuchsia/tools/bsdtar"
},
{
"cmd": [
@@ -78,12 +49,12 @@
"ensure-directory",
"--mode",
"0777",
- "[START_DIR]/cipd_tool/path/to/bsdtar/version%3Apinned-version"
+ "[START_DIR]/cipd_tool/fuchsia/tools/bsdtar/git_revision%3A6462ccda48c8f33dce4c80c2f1533263277d4da9"
],
"infra_step": true,
- "name": "ensure bsdtar.install path/to/bsdtar.ensure package directory",
+ "name": "install fuchsia/tools/bsdtar.ensure package directory",
"~followup_annotations": [
- "@@@STEP_NEST_LEVEL@2@@@"
+ "@@@STEP_NEST_LEVEL@1@@@"
]
},
{
@@ -91,24 +62,24 @@
"cipd",
"ensure",
"-root",
- "[START_DIR]/cipd_tool/path/to/bsdtar/version%3Apinned-version",
+ "[START_DIR]/cipd_tool/fuchsia/tools/bsdtar/git_revision%3A6462ccda48c8f33dce4c80c2f1533263277d4da9",
"-ensure-file",
- "path/to/bsdtar version:pinned-version",
+ "fuchsia/tools/bsdtar/${platform} git_revision:6462ccda48c8f33dce4c80c2f1533263277d4da9",
"-max-threads",
"0",
"-json-output",
"/path/to/tmp/json"
],
"infra_step": true,
- "name": "ensure bsdtar.install path/to/bsdtar.ensure_installed",
+ "name": "install fuchsia/tools/bsdtar.ensure_installed",
"~followup_annotations": [
- "@@@STEP_NEST_LEVEL@2@@@",
+ "@@@STEP_NEST_LEVEL@1@@@",
"@@@STEP_LOG_LINE@json.output@{@@@",
"@@@STEP_LOG_LINE@json.output@ \"result\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"\": [@@@",
"@@@STEP_LOG_LINE@json.output@ {@@@",
- "@@@STEP_LOG_LINE@json.output@ \"instance_id\": \"resolved-instance_id-of-version:pinned-v\",@@@",
- "@@@STEP_LOG_LINE@json.output@ \"package\": \"path/to/bsdtar\"@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"instance_id\": \"resolved-instance_id-of-git_revision:646\",@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"package\": \"fuchsia/tools/bsdtar/resolved-platform\"@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ ]@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
@@ -118,7 +89,7 @@
},
{
"cmd": [
- "[START_DIR]/cipd_tool/path/to/bsdtar/version%3Apinned-version/bsdtar",
+ "[START_DIR]/cipd_tool/fuchsia/tools/bsdtar/git_revision%3A6462ccda48c8f33dce4c80c2f1533263277d4da9/bsdtar",
"--create",
"-f",
"[CLEANUP]/tar-example_tmp_1/more.tar.gz",
@@ -142,7 +113,7 @@
},
{
"cmd": [
- "[START_DIR]/cipd_tool/path/to/bsdtar/version%3Apinned-version/bsdtar",
+ "[START_DIR]/cipd_tool/fuchsia/tools/bsdtar/git_revision%3A6462ccda48c8f33dce4c80c2f1533263277d4da9/bsdtar",
"--extract",
"--verbose",
"-f",
diff --git a/recipe_modules/tar/tests/full.expected/mac.json b/recipe_modules/tar/tests/full.expected/mac.json
index 20844c7..7421198 100644
--- a/recipe_modules/tar/tests/full.expected/mac.json
+++ b/recipe_modules/tar/tests/full.expected/mac.json
@@ -37,36 +37,7 @@
},
{
"cmd": [],
- "name": "ensure bsdtar"
- },
- {
- "cmd": [
- "vpython3",
- "-u",
- "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
- "--json-output",
- "/path/to/tmp/json",
- "copy",
- "RECIPE_MODULE[flutter::tar]/resources/tool_manifest.json",
- "/path/to/tmp/json"
- ],
- "infra_step": true,
- "name": "ensure bsdtar.read manifest",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@",
- "@@@STEP_LOG_LINE@tool_manifest.json@{@@@",
- "@@@STEP_LOG_LINE@tool_manifest.json@ \"path\": \"path/to/bsdtar\",@@@",
- "@@@STEP_LOG_LINE@tool_manifest.json@ \"version\": \"version:pinned-version\"@@@",
- "@@@STEP_LOG_LINE@tool_manifest.json@}@@@",
- "@@@STEP_LOG_END@tool_manifest.json@@@"
- ]
- },
- {
- "cmd": [],
- "name": "ensure bsdtar.install path/to/bsdtar",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
+ "name": "install fuchsia/tools/bsdtar"
},
{
"cmd": [
@@ -78,12 +49,12 @@
"ensure-directory",
"--mode",
"0777",
- "[START_DIR]/cipd_tool/path/to/bsdtar/version%3Apinned-version"
+ "[START_DIR]/cipd_tool/fuchsia/tools/bsdtar/git_revision%3A6462ccda48c8f33dce4c80c2f1533263277d4da9"
],
"infra_step": true,
- "name": "ensure bsdtar.install path/to/bsdtar.ensure package directory",
+ "name": "install fuchsia/tools/bsdtar.ensure package directory",
"~followup_annotations": [
- "@@@STEP_NEST_LEVEL@2@@@"
+ "@@@STEP_NEST_LEVEL@1@@@"
]
},
{
@@ -91,24 +62,24 @@
"cipd",
"ensure",
"-root",
- "[START_DIR]/cipd_tool/path/to/bsdtar/version%3Apinned-version",
+ "[START_DIR]/cipd_tool/fuchsia/tools/bsdtar/git_revision%3A6462ccda48c8f33dce4c80c2f1533263277d4da9",
"-ensure-file",
- "path/to/bsdtar version:pinned-version",
+ "fuchsia/tools/bsdtar/${platform} git_revision:6462ccda48c8f33dce4c80c2f1533263277d4da9",
"-max-threads",
"0",
"-json-output",
"/path/to/tmp/json"
],
"infra_step": true,
- "name": "ensure bsdtar.install path/to/bsdtar.ensure_installed",
+ "name": "install fuchsia/tools/bsdtar.ensure_installed",
"~followup_annotations": [
- "@@@STEP_NEST_LEVEL@2@@@",
+ "@@@STEP_NEST_LEVEL@1@@@",
"@@@STEP_LOG_LINE@json.output@{@@@",
"@@@STEP_LOG_LINE@json.output@ \"result\": {@@@",
"@@@STEP_LOG_LINE@json.output@ \"\": [@@@",
"@@@STEP_LOG_LINE@json.output@ {@@@",
- "@@@STEP_LOG_LINE@json.output@ \"instance_id\": \"resolved-instance_id-of-version:pinned-v\",@@@",
- "@@@STEP_LOG_LINE@json.output@ \"package\": \"path/to/bsdtar\"@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"instance_id\": \"resolved-instance_id-of-git_revision:646\",@@@",
+ "@@@STEP_LOG_LINE@json.output@ \"package\": \"fuchsia/tools/bsdtar/resolved-platform\"@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
"@@@STEP_LOG_LINE@json.output@ ]@@@",
"@@@STEP_LOG_LINE@json.output@ }@@@",
@@ -118,7 +89,7 @@
},
{
"cmd": [
- "[START_DIR]/cipd_tool/path/to/bsdtar/version%3Apinned-version/bsdtar",
+ "[START_DIR]/cipd_tool/fuchsia/tools/bsdtar/git_revision%3A6462ccda48c8f33dce4c80c2f1533263277d4da9/bsdtar",
"--create",
"-f",
"[CLEANUP]/tar-example_tmp_1/more.tar.gz",
@@ -142,7 +113,7 @@
},
{
"cmd": [
- "[START_DIR]/cipd_tool/path/to/bsdtar/version%3Apinned-version/bsdtar",
+ "[START_DIR]/cipd_tool/fuchsia/tools/bsdtar/git_revision%3A6462ccda48c8f33dce4c80c2f1533263277d4da9/bsdtar",
"--extract",
"--verbose",
"-f",