Figure out how we're building Bazel and make the code work with it
Change-Id: Iac0abca9e34ebf9d8f41f6f5a5803f54ca2b8beb
diff --git a/doc/make_bazel_package.sh b/doc/make_bazel_package.sh
new file mode 100755
index 0000000..1c10df0
--- /dev/null
+++ b/doc/make_bazel_package.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+# This script builds a Debian package from a Bazel source tree with the
+# correct version.
+# The only argument is the path to a Bazel source tree.
+
+set -e
+set -u
+
+BAZEL_SOURCE="$1"
+
+VERSION="$(date +%Y%m%d%H%M)+$(GIT_DIR="${BAZEL_SOURCE}/.git" git rev-parse --short HEAD)"
+DEB="bazel_${VERSION}.deb"
+
+"${BAZEL_SOURCE}/compile.sh" compile
+(
+cd "${BAZEL_SOURCE}"
+./output/bazel build //scripts/packages:bazel-debian --embed_label="${VERSION}"
+)
+
+cp "${BAZEL_SOURCE}/bazel-bin/scripts/packages/bazel-debian.deb" "${DEB}"
+
+echo "Output is at ${DEB}"