infra: Use CIPD autoconf

autoconf isn't installed on the Linux bot anymore. This CL installs
the CIPD autoconf instead.

No-Try: true
Bug: 462546993
Change-Id: I7dd72b35949ea983aa7f15d0ddb0b6d11bcde95a
Reviewed-on: https://gn-review.googlesource.com/c/gn/+/20400
Reviewed-by: Takuto Ikuta <tikuta@google.com>
Commit-Queue: Junji Watanabe <jwata@google.com>
diff --git a/infra/recipes/gn.expected/ci_linux.json b/infra/recipes/gn.expected/ci_linux.json
index 5a76c33..0a543df 100644
--- a/infra/recipes/gn.expected/ci_linux.json
+++ b/infra/recipes/gn.expected/ci_linux.json
@@ -241,8 +241,89 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "jemalloc.install infra/3pp/tools/autoconf",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
     "cmd": [
-      "autoconf"
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0777",
+      "[START_DIR]/cipd_tool/infra/3pp/tools/autoconf/79821582576f6f08410b2d2f2c0658c2be62aae6ca2df4ab28cc6b4d75002f20"
+    ],
+    "cwd": "[START_DIR]/jemalloc",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "gn:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "jemalloc.install infra/3pp/tools/autoconf.ensure package directory",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[START_DIR]/cipd_tool/infra/3pp/tools/autoconf/79821582576f6f08410b2d2f2c0658c2be62aae6ca2df4ab28cc6b4d75002f20",
+      "-ensure-file",
+      "infra/3pp/tools/autoconf/${platform} version:3@2.71.chromium.1",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "cwd": "[START_DIR]/jemalloc",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "gn:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "jemalloc.install infra/3pp/tools/autoconf.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@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:3@2.71.c\",@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"infra/3pp/tools/autoconf/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "[START_DIR]/cipd_tool/infra/3pp/tools/autoconf/79821582576f6f08410b2d2f2c0658c2be62aae6ca2df4ab28cc6b4d75002f20/autoconf"
     ],
     "cwd": "[START_DIR]/jemalloc",
     "infra_step": true,
diff --git a/infra/recipes/gn.expected/cipd_exists.json b/infra/recipes/gn.expected/cipd_exists.json
index 0c22ae2..8058614 100644
--- a/infra/recipes/gn.expected/cipd_exists.json
+++ b/infra/recipes/gn.expected/cipd_exists.json
@@ -241,8 +241,89 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "jemalloc.install infra/3pp/tools/autoconf",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
     "cmd": [
-      "autoconf"
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0777",
+      "[START_DIR]/cipd_tool/infra/3pp/tools/autoconf/79821582576f6f08410b2d2f2c0658c2be62aae6ca2df4ab28cc6b4d75002f20"
+    ],
+    "cwd": "[START_DIR]/jemalloc",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "infra-internal:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "jemalloc.install infra/3pp/tools/autoconf.ensure package directory",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[START_DIR]/cipd_tool/infra/3pp/tools/autoconf/79821582576f6f08410b2d2f2c0658c2be62aae6ca2df4ab28cc6b4d75002f20",
+      "-ensure-file",
+      "infra/3pp/tools/autoconf/${platform} version:3@2.71.chromium.1",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "cwd": "[START_DIR]/jemalloc",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "infra-internal:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "jemalloc.install infra/3pp/tools/autoconf.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@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:3@2.71.c\",@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"infra/3pp/tools/autoconf/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "[START_DIR]/cipd_tool/infra/3pp/tools/autoconf/79821582576f6f08410b2d2f2c0658c2be62aae6ca2df4ab28cc6b4d75002f20/autoconf"
     ],
     "cwd": "[START_DIR]/jemalloc",
     "infra_step": true,
diff --git a/infra/recipes/gn.expected/cipd_register.json b/infra/recipes/gn.expected/cipd_register.json
index 4303782..c7a8327 100644
--- a/infra/recipes/gn.expected/cipd_register.json
+++ b/infra/recipes/gn.expected/cipd_register.json
@@ -241,8 +241,89 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "jemalloc.install infra/3pp/tools/autoconf",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
     "cmd": [
-      "autoconf"
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0777",
+      "[START_DIR]/cipd_tool/infra/3pp/tools/autoconf/79821582576f6f08410b2d2f2c0658c2be62aae6ca2df4ab28cc6b4d75002f20"
+    ],
+    "cwd": "[START_DIR]/jemalloc",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "infra-internal:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "jemalloc.install infra/3pp/tools/autoconf.ensure package directory",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[START_DIR]/cipd_tool/infra/3pp/tools/autoconf/79821582576f6f08410b2d2f2c0658c2be62aae6ca2df4ab28cc6b4d75002f20",
+      "-ensure-file",
+      "infra/3pp/tools/autoconf/${platform} version:3@2.71.chromium.1",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "cwd": "[START_DIR]/jemalloc",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "infra-internal:ci"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "jemalloc.install infra/3pp/tools/autoconf.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@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:3@2.71.c\",@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"infra/3pp/tools/autoconf/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "[START_DIR]/cipd_tool/infra/3pp/tools/autoconf/79821582576f6f08410b2d2f2c0658c2be62aae6ca2df4ab28cc6b4d75002f20/autoconf"
     ],
     "cwd": "[START_DIR]/jemalloc",
     "infra_step": true,
diff --git a/infra/recipes/gn.expected/cq_linux.json b/infra/recipes/gn.expected/cq_linux.json
index 035f993..0bab23d 100644
--- a/infra/recipes/gn.expected/cq_linux.json
+++ b/infra/recipes/gn.expected/cq_linux.json
@@ -292,8 +292,89 @@
     ]
   },
   {
+    "cmd": [],
+    "name": "jemalloc.install infra/3pp/tools/autoconf",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@1@@@"
+    ]
+  },
+  {
     "cmd": [
-      "autoconf"
+      "vpython3",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0777",
+      "[START_DIR]/cipd_tool/infra/3pp/tools/autoconf/79821582576f6f08410b2d2f2c0658c2be62aae6ca2df4ab28cc6b4d75002f20"
+    ],
+    "cwd": "[START_DIR]/jemalloc",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "gn:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "jemalloc.install infra/3pp/tools/autoconf.ensure package directory",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "cipd",
+      "ensure",
+      "-root",
+      "[START_DIR]/cipd_tool/infra/3pp/tools/autoconf/79821582576f6f08410b2d2f2c0658c2be62aae6ca2df4ab28cc6b4d75002f20",
+      "-ensure-file",
+      "infra/3pp/tools/autoconf/${platform} version:3@2.71.chromium.1",
+      "-max-threads",
+      "0",
+      "-json-output",
+      "/path/to/tmp/json"
+    ],
+    "cwd": "[START_DIR]/jemalloc",
+    "infra_step": true,
+    "luci_context": {
+      "realm": {
+        "name": "gn:try"
+      },
+      "resultdb": {
+        "current_invocation": {
+          "name": "invocations/build:8945511751514863184",
+          "update_token": "token"
+        },
+        "hostname": "rdbhost"
+      }
+    },
+    "name": "jemalloc.install infra/3pp/tools/autoconf.ensure_installed",
+    "~followup_annotations": [
+      "@@@STEP_NEST_LEVEL@2@@@",
+      "@@@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:3@2.71.c\",@@@",
+      "@@@STEP_LOG_LINE@json.output@        \"package\": \"infra/3pp/tools/autoconf/resolved-platform\"@@@",
+      "@@@STEP_LOG_LINE@json.output@      }@@@",
+      "@@@STEP_LOG_LINE@json.output@    ]@@@",
+      "@@@STEP_LOG_LINE@json.output@  }@@@",
+      "@@@STEP_LOG_LINE@json.output@}@@@",
+      "@@@STEP_LOG_END@json.output@@@"
+    ]
+  },
+  {
+    "cmd": [
+      "[START_DIR]/cipd_tool/infra/3pp/tools/autoconf/79821582576f6f08410b2d2f2c0658c2be62aae6ca2df4ab28cc6b4d75002f20/autoconf"
     ],
     "cwd": "[START_DIR]/jemalloc",
     "infra_step": true,
diff --git a/infra/recipes/gn.py b/infra/recipes/gn.py
index f4723bd..4ec9287 100644
--- a/infra/recipes/gn.py
+++ b/infra/recipes/gn.py
@@ -200,7 +200,13 @@
               'fetch',
               ['git', 'fetch', JEMALLOC_GIT_URL, 'refs/tags/' + JEMALLOC_TAG, '--depth=1'])
           api.step('checkout', ['git', 'checkout', 'FETCH_HEAD'])
-          api.step('autoconf', ['autoconf'])
+
+          # TODO: We can rely on pre-installed autoconf after the following
+          # change gets rolled out.
+          # https://gn-review.git.corp.google.com/c/gn/+/20200
+          autoconf_path = api.cipd.ensure_tool('infra/3pp/tools/autoconf/${platform}',
+                               "version:3@2.71.chromium.1")
+          api.step('autoconf', [autoconf_path])
 
         for platform in all_config_platforms:
           # Convert target architecture and os to jemalloc format.