Simplify building ios-deploy

This removes the usage of Homebrew from building ios-deploy, and
instead depends on a simple bash script.

BUG=https://github.com/flutter/flutter/issues/36019

Change-Id: If8170a9f32d6105bdc866aba0a7491bfb48e5b42
Reviewed-on: https://flutter-review.googlesource.com/c/recipes/+/17285
Reviewed-by: Keyong Han <keyonghan@google.com>
Commit-Queue: Christopher Fujino <fujino@google.com>
diff --git a/recipes/ios-usb-dependencies.expected/ios-deploy with git_ref.json b/recipes/ios-usb-dependencies.expected/ios-deploy with git_ref.json
new file mode 100644
index 0000000..6d72377
--- /dev/null
+++ b/recipes/ios-usb-dependencies.expected/ios-deploy with git_ref.json
@@ -0,0 +1,64 @@
+[
+  {
+    "cmd": [
+      "chmod",
+      "777",
+      "RECIPE[flutter::ios-usb-dependencies].resources/ios-deploy.sh"
+    ],
+    "name": "make RECIPE[flutter::ios-usb-dependencies].resources/ios-deploy.sh executable"
+  },
+  {
+    "cmd": [
+      "vpython",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0777",
+      "[START_DIR]/output"
+    ],
+    "infra_step": true,
+    "name": "mkdir [START_DIR]/output"
+  },
+  {
+    "cmd": [
+      "RECIPE[flutter::ios-usb-dependencies].resources/ios-deploy.sh",
+      "[START_DIR]/src",
+      "deadbeef",
+      "[START_DIR]/output"
+    ],
+    "name": "build ios-deploy"
+  },
+  {
+    "cmd": [
+      "python",
+      "-u",
+      "RECIPE_MODULE[flutter::zip]/resources/zip.py"
+    ],
+    "name": "zipping ios-deploy dir",
+    "stdin": "{\"entries\": [{\"path\": \"[START_DIR]/output\", \"type\": \"dir\"}], \"output\": \"[START_DIR]/ios-deploy.zip\", \"root\": \"[START_DIR]/output\"}"
+  },
+  {
+    "cmd": [
+      "python",
+      "-u",
+      "RECIPE_MODULE[depot_tools::gsutil]/resources/gsutil_smart_retry.py",
+      "--",
+      "RECIPE_REPO[depot_tools]/gsutil.py",
+      "----",
+      "cp",
+      "[START_DIR]/ios-deploy.zip",
+      "gs://flutter_infra_release/ios-usb-dependencies/unsigned/ios-deploy/deadbeef/ios-deploy.zip"
+    ],
+    "infra_step": true,
+    "name": "gsutil upload of ios-deploy.zip",
+    "~followup_annotations": [
+      "@@@STEP_LINK@ios-deploy.zip@https://storage.cloud.google.com/flutter_infra_release/ios-usb-dependencies/unsigned/ios-deploy/deadbeef/ios-deploy.zip@@@"
+    ]
+  },
+  {
+    "name": "$result"
+  }
+]
\ No newline at end of file
diff --git a/recipes/ios-usb-dependencies.expected/ios-deploy with gitiles.json b/recipes/ios-usb-dependencies.expected/ios-deploy with gitiles.json
new file mode 100644
index 0000000..6d72377
--- /dev/null
+++ b/recipes/ios-usb-dependencies.expected/ios-deploy with gitiles.json
@@ -0,0 +1,64 @@
+[
+  {
+    "cmd": [
+      "chmod",
+      "777",
+      "RECIPE[flutter::ios-usb-dependencies].resources/ios-deploy.sh"
+    ],
+    "name": "make RECIPE[flutter::ios-usb-dependencies].resources/ios-deploy.sh executable"
+  },
+  {
+    "cmd": [
+      "vpython",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
+      "ensure-directory",
+      "--mode",
+      "0777",
+      "[START_DIR]/output"
+    ],
+    "infra_step": true,
+    "name": "mkdir [START_DIR]/output"
+  },
+  {
+    "cmd": [
+      "RECIPE[flutter::ios-usb-dependencies].resources/ios-deploy.sh",
+      "[START_DIR]/src",
+      "deadbeef",
+      "[START_DIR]/output"
+    ],
+    "name": "build ios-deploy"
+  },
+  {
+    "cmd": [
+      "python",
+      "-u",
+      "RECIPE_MODULE[flutter::zip]/resources/zip.py"
+    ],
+    "name": "zipping ios-deploy dir",
+    "stdin": "{\"entries\": [{\"path\": \"[START_DIR]/output\", \"type\": \"dir\"}], \"output\": \"[START_DIR]/ios-deploy.zip\", \"root\": \"[START_DIR]/output\"}"
+  },
+  {
+    "cmd": [
+      "python",
+      "-u",
+      "RECIPE_MODULE[depot_tools::gsutil]/resources/gsutil_smart_retry.py",
+      "--",
+      "RECIPE_REPO[depot_tools]/gsutil.py",
+      "----",
+      "cp",
+      "[START_DIR]/ios-deploy.zip",
+      "gs://flutter_infra_release/ios-usb-dependencies/unsigned/ios-deploy/deadbeef/ios-deploy.zip"
+    ],
+    "infra_step": true,
+    "name": "gsutil upload of ios-deploy.zip",
+    "~followup_annotations": [
+      "@@@STEP_LINK@ios-deploy.zip@https://storage.cloud.google.com/flutter_infra_release/ios-usb-dependencies/unsigned/ios-deploy/deadbeef/ios-deploy.zip@@@"
+    ]
+  },
+  {
+    "name": "$result"
+  }
+]
\ No newline at end of file
diff --git a/recipes/ios-usb-dependencies.expected/ios-deploy-flutter.json b/recipes/ios-usb-dependencies.expected/ios-deploy-flutter.json
deleted file mode 100644
index 7ec4056..0000000
--- a/recipes/ios-usb-dependencies.expected/ios-deploy-flutter.json
+++ /dev/null
@@ -1,199 +0,0 @@
-[
-  {
-    "cmd": [
-      "vpython",
-      "-u",
-      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
-      "--json-output",
-      "/path/to/tmp/json",
-      "ensure-directory",
-      "--mode",
-      "0777",
-      "[START_DIR]/homebrew"
-    ],
-    "infra_step": true,
-    "name": "mkdir homebrew"
-  },
-  {
-    "cmd": [
-      "curl",
-      "-L",
-      "https://github.com/Homebrew/brew/tarball/master",
-      "-o",
-      "[START_DIR]/homebrew.tar.gz"
-    ],
-    "name": "get homebrew"
-  },
-  {
-    "cmd": [
-      "tar",
-      "zxf",
-      "[START_DIR]/homebrew.tar.gz",
-      "--strip",
-      "1",
-      "-C",
-      "[START_DIR]/homebrew"
-    ],
-    "name": "open tarball"
-  },
-  {
-    "cmd": [
-      "vpython",
-      "-u",
-      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
-      "--json-output",
-      "/path/to/tmp/json",
-      "ensure-directory",
-      "--mode",
-      "0777",
-      "[START_DIR]/output"
-    ],
-    "infra_step": true,
-    "name": "mkdir output"
-  },
-  {
-    "cmd": [
-      "vpython",
-      "-u",
-      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
-      "--json-output",
-      "/path/to/tmp/json",
-      "ensure-directory",
-      "--mode",
-      "0777",
-      "[START_DIR]/zips"
-    ],
-    "infra_step": true,
-    "name": "mkdir zips"
-  },
-  {
-    "cmd": [
-      "[START_DIR]/homebrew/bin/brew",
-      "tap",
-      "flutter/homebrew-flutter",
-      "https://flutter-mirrors.googlesource.com/homebrew-flutter"
-    ],
-    "name": "tap custom formulae"
-  },
-  {
-    "cmd": [
-      "[START_DIR]/homebrew/bin/brew",
-      "install",
-      "flutter/homebrew-flutter/ios-deploy-flutter",
-      "--HEAD"
-    ],
-    "name": "installing ios-deploy-flutter"
-  },
-  {
-    "cmd": [
-      "vpython",
-      "-u",
-      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
-      "--json-output",
-      "/path/to/tmp/json",
-      "ensure-directory",
-      "--mode",
-      "0777",
-      "[START_DIR]/output/ios-deploy-flutter"
-    ],
-    "infra_step": true,
-    "name": "mkdir package [START_DIR]/output/ios-deploy-flutter"
-  },
-  {
-    "cmd": [
-      "vpython",
-      "-u",
-      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
-      "--json-output",
-      "/path/to/tmp/json",
-      "copy",
-      "[START_DIR]/homebrew/opt/ios-deploy-flutter/bin/ios-deploy",
-      "[START_DIR]/output/ios-deploy-flutter"
-    ],
-    "infra_step": true,
-    "name": "copying bin/ios-deploy from package ios-deploy-flutter"
-  },
-  {
-    "cmd": [
-      "vpython",
-      "-u",
-      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
-      "--json-output",
-      "/path/to/tmp/json",
-      "copy",
-      "[START_DIR]/homebrew/opt/ios-deploy-flutter/LICENSE",
-      "[START_DIR]/output/ios-deploy-flutter"
-    ],
-    "infra_step": true,
-    "name": "copying LICENSE from package ios-deploy-flutter"
-  },
-  {
-    "cmd": [
-      "vpython",
-      "-u",
-      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
-      "--json-output",
-      "/path/to/tmp/json",
-      "copy",
-      "[START_DIR]/homebrew/opt/ios-deploy-flutter/LICENSE2",
-      "[START_DIR]/output/ios-deploy-flutter"
-    ],
-    "infra_step": true,
-    "name": "copying LICENSE2 from package ios-deploy-flutter"
-  },
-  {
-    "cmd": [
-      "python",
-      "-u",
-      "RECIPE_MODULE[flutter::zip]/resources/zip.py"
-    ],
-    "name": "zipping ios-deploy-flutter.zip",
-    "stdin": "{\"entries\": [{\"path\": \"[START_DIR]/output/ios-deploy-flutter\", \"type\": \"dir\"}], \"output\": \"[START_DIR]/zips/ios-deploy-flutter.zip\", \"root\": \"[START_DIR]/output/ios-deploy-flutter\"}"
-  },
-  {
-    "cmd": [
-      "echo",
-      "ios-usb-dependencies/unsigned/ios-deploy/2d72510e447ab60a9728aeea2362d8be2cbd7789/ios-deploy.zip"
-    ],
-    "name": "cloud path"
-  },
-  {
-    "cmd": [
-      "python",
-      "-u",
-      "RECIPE_MODULE[depot_tools::gsutil]/resources/gsutil_smart_retry.py",
-      "--",
-      "RECIPE_REPO[depot_tools]/gsutil.py",
-      "----",
-      "cp",
-      "[START_DIR]/zips/ios-deploy-flutter.zip",
-      "gs://flutter_infra/ios-usb-dependencies/unsigned/ios-deploy/2d72510e447ab60a9728aeea2362d8be2cbd7789/ios-deploy.zip"
-    ],
-    "infra_step": true,
-    "name": "gsutil upload of ios-deploy-flutter.zip",
-    "~followup_annotations": [
-      "@@@STEP_LINK@ios-deploy-flutter.zip@https://storage.cloud.google.com/flutter_infra/ios-usb-dependencies/unsigned/ios-deploy/2d72510e447ab60a9728aeea2362d8be2cbd7789/ios-deploy.zip@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "python",
-      "-u",
-      "RECIPE_MODULE[depot_tools::gsutil]/resources/gsutil_smart_retry.py",
-      "--",
-      "RECIPE_REPO[depot_tools]/gsutil.py",
-      "----",
-      "cp",
-      "[START_DIR]/zips/ios-deploy-flutter.zip",
-      "gs://flutter_infra_release/ios-usb-dependencies/unsigned/ios-deploy/2d72510e447ab60a9728aeea2362d8be2cbd7789/ios-deploy.zip"
-    ],
-    "infra_step": true,
-    "name": "gsutil upload of ios-deploy-flutter.zip (2)",
-    "~followup_annotations": [
-      "@@@STEP_LINK@ios-deploy-flutter.zip@https://storage.cloud.google.com/flutter_infra_release/ios-usb-dependencies/unsigned/ios-deploy/2d72510e447ab60a9728aeea2362d8be2cbd7789/ios-deploy.zip@@@"
-    ]
-  },
-  {
-    "name": "$result"
-  }
-]
\ No newline at end of file
diff --git a/recipes/ios-usb-dependencies.expected/libimobiledevice-flutter.json b/recipes/ios-usb-dependencies.expected/libimobiledevice-flutter.json
index 4d6e2e2..8e29a1a 100644
--- a/recipes/ios-usb-dependencies.expected/libimobiledevice-flutter.json
+++ b/recipes/ios-usb-dependencies.expected/libimobiledevice-flutter.json
@@ -223,28 +223,10 @@
       "----",
       "cp",
       "[START_DIR]/zips/libimobiledevice-flutter.zip",
-      "gs://flutter_infra/ios-usb-dependencies/unsigned/libimobiledevice/2d72510e447ab60a9728aeea2362d8be2cbd7789/libimobiledevice.zip"
-    ],
-    "infra_step": true,
-    "name": "gsutil upload of libimobiledevice-flutter.zip",
-    "~followup_annotations": [
-      "@@@STEP_LINK@libimobiledevice-flutter.zip@https://storage.cloud.google.com/flutter_infra/ios-usb-dependencies/unsigned/libimobiledevice/2d72510e447ab60a9728aeea2362d8be2cbd7789/libimobiledevice.zip@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "python",
-      "-u",
-      "RECIPE_MODULE[depot_tools::gsutil]/resources/gsutil_smart_retry.py",
-      "--",
-      "RECIPE_REPO[depot_tools]/gsutil.py",
-      "----",
-      "cp",
-      "[START_DIR]/zips/libimobiledevice-flutter.zip",
       "gs://flutter_infra_release/ios-usb-dependencies/unsigned/libimobiledevice/2d72510e447ab60a9728aeea2362d8be2cbd7789/libimobiledevice.zip"
     ],
     "infra_step": true,
-    "name": "gsutil upload of libimobiledevice-flutter.zip (2)",
+    "name": "gsutil upload of libimobiledevice-flutter.zip",
     "~followup_annotations": [
       "@@@STEP_LINK@libimobiledevice-flutter.zip@https://storage.cloud.google.com/flutter_infra_release/ios-usb-dependencies/unsigned/libimobiledevice/2d72510e447ab60a9728aeea2362d8be2cbd7789/libimobiledevice.zip@@@"
     ]
diff --git a/recipes/ios-usb-dependencies.expected/libplist-flutter.json b/recipes/ios-usb-dependencies.expected/libplist-flutter.json
index 2ec00ff..5ebb10b 100644
--- a/recipes/ios-usb-dependencies.expected/libplist-flutter.json
+++ b/recipes/ios-usb-dependencies.expected/libplist-flutter.json
@@ -153,28 +153,10 @@
       "----",
       "cp",
       "[START_DIR]/zips/libplist-flutter.zip",
-      "gs://flutter_infra/ios-usb-dependencies/unsigned/libplist/2d72510e447ab60a9728aeea2362d8be2cbd7789/libplist.zip"
-    ],
-    "infra_step": true,
-    "name": "gsutil upload of libplist-flutter.zip",
-    "~followup_annotations": [
-      "@@@STEP_LINK@libplist-flutter.zip@https://storage.cloud.google.com/flutter_infra/ios-usb-dependencies/unsigned/libplist/2d72510e447ab60a9728aeea2362d8be2cbd7789/libplist.zip@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "python",
-      "-u",
-      "RECIPE_MODULE[depot_tools::gsutil]/resources/gsutil_smart_retry.py",
-      "--",
-      "RECIPE_REPO[depot_tools]/gsutil.py",
-      "----",
-      "cp",
-      "[START_DIR]/zips/libplist-flutter.zip",
       "gs://flutter_infra_release/ios-usb-dependencies/unsigned/libplist/2d72510e447ab60a9728aeea2362d8be2cbd7789/libplist.zip"
     ],
     "infra_step": true,
-    "name": "gsutil upload of libplist-flutter.zip (2)",
+    "name": "gsutil upload of libplist-flutter.zip",
     "~followup_annotations": [
       "@@@STEP_LINK@libplist-flutter.zip@https://storage.cloud.google.com/flutter_infra_release/ios-usb-dependencies/unsigned/libplist/2d72510e447ab60a9728aeea2362d8be2cbd7789/libplist.zip@@@"
     ]
diff --git a/recipes/ios-usb-dependencies.expected/openssl-flutter.json b/recipes/ios-usb-dependencies.expected/openssl-flutter.json
index 9542cb2..d7f8f50 100644
--- a/recipes/ios-usb-dependencies.expected/openssl-flutter.json
+++ b/recipes/ios-usb-dependencies.expected/openssl-flutter.json
@@ -167,28 +167,10 @@
       "----",
       "cp",
       "[START_DIR]/zips/openssl-flutter.zip",
-      "gs://flutter_infra/ios-usb-dependencies/unsigned/openssl/2d72510e447ab60a9728aeea2362d8be2cbd7789/openssl.zip"
-    ],
-    "infra_step": true,
-    "name": "gsutil upload of openssl-flutter.zip",
-    "~followup_annotations": [
-      "@@@STEP_LINK@openssl-flutter.zip@https://storage.cloud.google.com/flutter_infra/ios-usb-dependencies/unsigned/openssl/2d72510e447ab60a9728aeea2362d8be2cbd7789/openssl.zip@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "python",
-      "-u",
-      "RECIPE_MODULE[depot_tools::gsutil]/resources/gsutil_smart_retry.py",
-      "--",
-      "RECIPE_REPO[depot_tools]/gsutil.py",
-      "----",
-      "cp",
-      "[START_DIR]/zips/openssl-flutter.zip",
       "gs://flutter_infra_release/ios-usb-dependencies/unsigned/openssl/2d72510e447ab60a9728aeea2362d8be2cbd7789/openssl.zip"
     ],
     "infra_step": true,
-    "name": "gsutil upload of openssl-flutter.zip (2)",
+    "name": "gsutil upload of openssl-flutter.zip",
     "~followup_annotations": [
       "@@@STEP_LINK@openssl-flutter.zip@https://storage.cloud.google.com/flutter_infra_release/ios-usb-dependencies/unsigned/openssl/2d72510e447ab60a9728aeea2362d8be2cbd7789/openssl.zip@@@"
     ]
diff --git a/recipes/ios-usb-dependencies.expected/usbmuxd-flutter.json b/recipes/ios-usb-dependencies.expected/usbmuxd-flutter.json
index e8a8271..ed382f7 100644
--- a/recipes/ios-usb-dependencies.expected/usbmuxd-flutter.json
+++ b/recipes/ios-usb-dependencies.expected/usbmuxd-flutter.json
@@ -167,28 +167,10 @@
       "----",
       "cp",
       "[START_DIR]/zips/usbmuxd-flutter.zip",
-      "gs://flutter_infra/ios-usb-dependencies/unsigned/usbmuxd/2d72510e447ab60a9728aeea2362d8be2cbd7789/usbmuxd.zip"
-    ],
-    "infra_step": true,
-    "name": "gsutil upload of usbmuxd-flutter.zip",
-    "~followup_annotations": [
-      "@@@STEP_LINK@usbmuxd-flutter.zip@https://storage.cloud.google.com/flutter_infra/ios-usb-dependencies/unsigned/usbmuxd/2d72510e447ab60a9728aeea2362d8be2cbd7789/usbmuxd.zip@@@"
-    ]
-  },
-  {
-    "cmd": [
-      "python",
-      "-u",
-      "RECIPE_MODULE[depot_tools::gsutil]/resources/gsutil_smart_retry.py",
-      "--",
-      "RECIPE_REPO[depot_tools]/gsutil.py",
-      "----",
-      "cp",
-      "[START_DIR]/zips/usbmuxd-flutter.zip",
       "gs://flutter_infra_release/ios-usb-dependencies/unsigned/usbmuxd/2d72510e447ab60a9728aeea2362d8be2cbd7789/usbmuxd.zip"
     ],
     "infra_step": true,
-    "name": "gsutil upload of usbmuxd-flutter.zip (2)",
+    "name": "gsutil upload of usbmuxd-flutter.zip",
     "~followup_annotations": [
       "@@@STEP_LINK@usbmuxd-flutter.zip@https://storage.cloud.google.com/flutter_infra_release/ios-usb-dependencies/unsigned/usbmuxd/2d72510e447ab60a9728aeea2362d8be2cbd7789/usbmuxd.zip@@@"
     ]
diff --git a/recipes/ios-usb-dependencies.py b/recipes/ios-usb-dependencies.py
index f9ce886..281f5ac 100644
--- a/recipes/ios-usb-dependencies.py
+++ b/recipes/ios-usb-dependencies.py
@@ -16,14 +16,12 @@
     'recipe_engine/path',
     'recipe_engine/platform',
     'recipe_engine/properties',
+    'recipe_engine/runtime',
     'recipe_engine/step',
     'recipe_engine/url',
 ]
 
-# TODO(godofredoc): Remove when flutter tool branches to stable.
-# https://github.com/flutter/flutter/issues/75363.
-OLD_BUCKET_NAME = 'flutter_infra'
-NEW_BUCKET_NAME = 'flutter_infra_release'
+BUCKET_NAME = 'flutter_infra_release'
 
 HOMEBREW_FLUTTER_PREFIX = ['flutter', 'homebrew-flutter']
 MIRROR_URL_PREFIX = 'https://flutter-mirrors.googlesource.com'
@@ -64,30 +62,18 @@
             'lib/libimobiledevice-1.0.6.dylib',
         ],
     },
-    'ios-deploy-flutter': {
-        'install_flags': ['--HEAD'],
-        'deliverables': [
-            'bin/ios-deploy',
-            'LICENSE',
-            'LICENSE2',
-        ],
-    },
 }
 
 
 def InstallHomebrew(api, homebrew_dir):
   homebrew_tar = api.path['start_dir'].join('homebrew.tar.gz')
   api.file.ensure_directory('mkdir homebrew', homebrew_dir)
-  api.step(
-      'get homebrew', [
-          'curl', '-L', 'https://github.com/Homebrew/brew/tarball/master', '-o',
-          homebrew_tar
-      ]
-  )
-  api.step(
-      'open tarball',
-      ['tar', 'zxf', homebrew_tar, '--strip', '1', '-C', homebrew_dir]
-  )
+  api.step('get homebrew', [
+      'curl', '-L', 'https://github.com/Homebrew/brew/tarball/master', '-o',
+      homebrew_tar
+  ])
+  api.step('open tarball',
+           ['tar', 'zxf', homebrew_tar, '--strip', '1', '-C', homebrew_dir])
 
 
 def GetBrewBin(api):
@@ -95,12 +81,10 @@
 
 
 def TapCustomBrews(api):
-  api.step(
-      'tap custom formulae', [
-          str(GetBrewBin(api)), 'tap', '/'.join(HOMEBREW_FLUTTER_PREFIX),
-          '%s/homebrew-flutter' % MIRROR_URL_PREFIX
-      ]
-  )
+  api.step('tap custom formulae', [
+      str(GetBrewBin(api)), 'tap', '/'.join(HOMEBREW_FLUTTER_PREFIX),
+      '%s/homebrew-flutter' % MIRROR_URL_PREFIX
+  ])
 
 
 def GetLocalPath(api, package_name):
@@ -112,24 +96,24 @@
   commit_hash = GetCommitHash(api)
   short_name = package_name.replace('-flutter', '')
   return 'ios-usb-dependencies/unsigned/%s/%s/%s.zip' % (
-      short_name, commit_hash, short_name
-  )
+      short_name, commit_hash, short_name)
 
 
 def GetCommitHash(api):
-  return api.buildbucket.gitiles_commit.id
+  gitiles_commit = api.buildbucket.gitiles_commit.id
+  if gitiles_commit:
+    return gitiles_commit
+  return api.properties['git_ref']
 
 
 def InstallPackage(api, package, name):
   install_flags = package.get('install_flags', [])
   prefix = '/'.join(HOMEBREW_FLUTTER_PREFIX)
-  api.step(
-      'installing %s' % name, [
-          str(GetBrewBin(api)),
-          'install',
-          '/'.join([prefix, name]),
-      ] + install_flags
-  )
+  api.step('installing %s' % name, [
+      str(GetBrewBin(api)),
+      'install',
+      '/'.join([prefix, name]),
+  ] + install_flags)
 
 
 def CopyDeliverable(api, deliverable, name, output_path):
@@ -149,58 +133,88 @@
   api.step('cloud path', ['echo', cloud_path])
   api.gsutil.upload(
       output_path,
-      OLD_BUCKET_NAME,
+      BUCKET_NAME,
       cloud_path,
       link_name=file_name,
       name='upload of %s' % file_name,
   )
+
+
+def BuildIosDeploy(api):
+  build_script = api.resource('ios-deploy.sh')
+  api.step('make %s executable' % build_script, ['chmod', '777', build_script])
+
+  work_dir = api.path['start_dir']
+  src_dir = work_dir.join('src')
+  out_dir = work_dir.join('output')
+  api.file.ensure_directory('mkdir %s' % out_dir, out_dir)
+  zip_file = work_dir.join('ios-deploy.zip')
+  commit_hash = GetCommitHash(api)
+  api.step('build ios-deploy', [build_script, src_dir, commit_hash, out_dir])
+  api.zip.directory('zipping ios-deploy dir', out_dir, zip_file)
+  version_namespace = 'led' if api.runtime.is_experimental else commit_hash
+  remote_path = 'ios-usb-dependencies/unsigned/ios-deploy/%s/ios-deploy.zip' % version_namespace
   api.gsutil.upload(
-      output_path,
-      NEW_BUCKET_NAME,
-      cloud_path,
-      link_name=file_name,
-      name='upload of %s' % file_name,
+      zip_file,
+      BUCKET_NAME,
+      remote_path,
+      link_name='ios-deploy.zip',
+      name='upload of ios-deploy.zip',
   )
 
 
 def RunSteps(api):
-  work_dir = api.path['start_dir']
-  homebrew_dir = work_dir.join('homebrew')
-  InstallHomebrew(api, homebrew_dir)
+  with api.osx_sdk('ios'):
+    package_name = api.properties['package_name']
+    if package_name == 'ios-deploy-flutter':
+      BuildIosDeploy(api)
+    else:
+      work_dir = api.path['start_dir']
+      package = INSTALL_PKGS[package_name]
 
-  output_dir = work_dir.join('output')
-  api.file.ensure_directory('mkdir output', output_dir)
+      homebrew_dir = work_dir.join('homebrew')
+      InstallHomebrew(api, homebrew_dir)
 
-  zip_out_dir = work_dir.join('zips')
-  api.file.ensure_directory('mkdir zips', zip_out_dir)
+      output_dir = work_dir.join('output')
+      api.file.ensure_directory('mkdir output', output_dir)
 
-  TapCustomBrews(api)
+      zip_out_dir = work_dir.join('zips')
+      api.file.ensure_directory('mkdir zips', zip_out_dir)
 
-  package_name = api.properties['package_name']
-  package = INSTALL_PKGS[package_name]
+      TapCustomBrews(api)
 
-  with api.osx_sdk('mac'):
-    InstallPackage(api, package, package_name)
+      InstallPackage(api, package, package_name)
 
-  package_out_dir = output_dir.join(package_name)
-  api.file.ensure_directory(
-      'mkdir package %s' % package_out_dir, package_out_dir
-  )
+      package_out_dir = output_dir.join(package_name)
+      api.file.ensure_directory('mkdir package %s' % package_out_dir,
+                                package_out_dir)
 
-  if len(package['deliverables']) > 0:
-    for deliverable in package['deliverables']:
-      CopyDeliverable(api, deliverable, package_name, package_out_dir)
+      if len(package['deliverables']) > 0:
+        for deliverable in package['deliverables']:
+          CopyDeliverable(api, deliverable, package_name, package_out_dir)
 
-    ZipAndUploadDeliverables(api, package_name, package_out_dir, zip_out_dir)
+        ZipAndUploadDeliverables(api, package_name, package_out_dir,
+                                 zip_out_dir)
 
 
 def GenTests(api):
+  yield api.test(
+      'ios-deploy with git_ref',
+      api.properties(
+          package_name='ios-deploy-flutter',
+          git_ref='deadbeef',
+      ),
+  )
+  yield api.test(
+      'ios-deploy with gitiles',
+      api.properties(
+          package_name='ios-deploy-flutter',
+      ),
+      api.buildbucket.ci_build(revision='deadbeef'),
+  )
   for package_name in INSTALL_PKGS:
     yield api.test(
         package_name,
         api.properties(package_name=package_name),
         api.buildbucket.ci_build(git_ref='refs/heads/master'),
     )
-
-
-# vim: ts=2 sw=2
diff --git a/recipes/ios-usb-dependencies.resources/ios-deploy.sh b/recipes/ios-usb-dependencies.resources/ios-deploy.sh
new file mode 100755
index 0000000..aa83da8
--- /dev/null
+++ b/recipes/ios-usb-dependencies.resources/ios-deploy.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+
+set -exo pipefail
+
+if [ -z "$3" ]; then
+  echo -e "Usage: ios-deploy.sh \$SRC_DIR \$REVISION \$OUTPUT_DIR " 1>&2
+  exit 1
+fi
+
+set -u
+
+SRC_DIR="$1"
+REVISION="$2"
+OUTPUT_DIR="$3"
+REMOTE_URL="https://flutter-mirrors.googlesource.com/ios-deploy"
+
+git clone "$REMOTE_URL" "$SRC_DIR"
+cd "$SRC_DIR"
+git checkout "$REVISION"
+
+xcodebuild -configuration Release SYMROOT=build -arch x86_64
+
+xcodebuild test \
+  -scheme ios-deploy-tests -configuration Release SYMROOT=build -arch x86_64
+
+cp LICENSE LICENSE2 ./build/Release/ios-deploy "$OUTPUT_DIR"