Add uprev_ebuilds script
This script allows us to generate manual uprev CLs the same way
PUpr creates them.
BUG=b:204223210
TEST=./tools/chromeos/uprev_ebuilds
Change-Id: I45f9f0f4d33f8782637455b578688fa9b504fe8e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3248905
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
diff --git a/tools/chromeos/uprev_ebuilds b/tools/chromeos/uprev_ebuilds
new file mode 100755
index 0000000..1eace90
--- /dev/null
+++ b/tools/chromeos/uprev_ebuilds
@@ -0,0 +1,43 @@
+#!/bin/sh
+# Copyright 2021 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+#
+# Uprev ebuild files of crosvm (and related packages) to the currently checked
+# out commit.
+# This uses the same process that PUpr is using when generating uprev CLs.
+
+cd $(dirname $0)
+
+CHROMITE_DIR=../../../../../chromite
+if ! [ -e "${CHROMITE_DIR}" ]; then
+ echo "Run from ChromeOS checkout."
+ exit 1
+fi
+
+IN=$(mktemp)
+OUT=$(mktemp)
+
+echo '{
+ "package_info": {
+ "category": "chromeos-base",
+ "package_name": "crosvm"
+ },
+ "versions": [
+ {
+ "repository": "dummy",
+ "ref": "dummy",
+ "revision": "dummy"
+ }
+ ]
+}' >> "${IN}"
+
+${CHROMITE_DIR}/bin/build_api \
+ --input-json "${IN}" \
+ --output-json "${OUT}" \
+ chromite.api.PackageService/UprevVersionedPackage
+
+cat "${OUT}"
+
+rm "${IN}"
+rm "${OUT}"