kokoro: Allow presubmits to use the real build path

Currently the kokoro presubmits use a cut down version of the
container build that skips building the cros versions of debian
packages. This has caused the presubmits to break since the cros
version of apitrace started requiring a later version of libwaffle
then is supplied in the debian repos.

This change, along with a corresponding change to the internal
configs, will make the presubmit flow the same as the normal build,
except that it will skip uploading the results to GCS and won't sign
anything.

The presubmits will cover all combinations of OS versions and
archetectures both to ensure full coverage and because this step takes
<1/3 of the total build time, so reducing it has fairly marginal
gains.

BUG=none
TEST=untestable!

Change-Id: I098d0396effd75be3830d866431c1630627a976e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/containers/cros-container-guest-tools/+/2176817
Tested-by: Fergus Dall <sidereal@google.com>
Reviewed-by: Nicholas Verne <nverne@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
diff --git a/kokoro/apt_signer.cfg b/kokoro/apt_signer.cfg
index 9b9c1ab..dc0b649 100644
--- a/kokoro/apt_signer.cfg
+++ b/kokoro/apt_signer.cfg
@@ -10,5 +10,6 @@
   define_artifacts {
     regex: "git/cros-container-guest-tools/apt_signed/**"
     strip_prefix: "git/cros-container-guest-tools"
+    fail_if_no_artifacts: false
   }
 }
diff --git a/kokoro/apt_signer.sh b/kokoro/apt_signer.sh
index 13a77a6..bd98273 100755
--- a/kokoro/apt_signer.sh
+++ b/kokoro/apt_signer.sh
@@ -36,4 +36,5 @@
                                           {} \;
 }
 
+skip_in_presubmit
 main "$@"
diff --git a/kokoro/common.sh b/kokoro/common.sh
index a7ee2a1..b2664f6 100644
--- a/kokoro/common.sh
+++ b/kokoro/common.sh
@@ -22,3 +22,10 @@
         exit 1
     fi
 }
+
+skip_in_presubmit() {
+  if [ -e "${KOKORO_ARTIFACTS_DIR}"/running_presubmits ]; then
+    echo "Skipping because this is a presubmit job"
+    exit 0
+  fi
+}
diff --git a/kokoro/guest_tools.cfg b/kokoro/guest_tools.cfg
index 1e9b966..6db41e6 100644
--- a/kokoro/guest_tools.cfg
+++ b/kokoro/guest_tools.cfg
@@ -4,12 +4,11 @@
 
 # Format: //devtools/kokoro/config/proto/build.proto
 
-build_file: "cros-container-guest-tools/kokoro/guest_tools.sh"
+build_file: "cros-container-guest-tools/kokoro/presubmit.sh"
 
 action {
   define_artifacts {
-    regex: "git/cros-container-guest-tools/guest_debs/**"
-    strip_prefix: "git/cros-container-guest-tools/guest_debs"
+    regex: "running_presubmits"
     fail_if_no_artifacts: true
   }
 }
diff --git a/kokoro/presubmit.cfg b/kokoro/presubmit.cfg
new file mode 100644
index 0000000..6db41e6
--- /dev/null
+++ b/kokoro/presubmit.cfg
@@ -0,0 +1,14 @@
+# Copyright 2018 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.
+
+# Format: //devtools/kokoro/config/proto/build.proto
+
+build_file: "cros-container-guest-tools/kokoro/presubmit.sh"
+
+action {
+  define_artifacts {
+    regex: "running_presubmits"
+    fail_if_no_artifacts: true
+  }
+}
diff --git a/kokoro/guest_tools.sh b/kokoro/presubmit.sh
similarity index 62%
rename from kokoro/guest_tools.sh
rename to kokoro/presubmit.sh
index e0993a5..6877070 100755
--- a/kokoro/guest_tools.sh
+++ b/kokoro/presubmit.sh
@@ -6,12 +6,13 @@
 set -ex
 
 . "$(dirname "$0")/common.sh" || exit 1
-. "$(dirname "$0")/common_build.sh" || exit 1
 
 main() {
     require_kokoro_artifacts
 
-    build_guest_tools
+    # This is used in other scripts to skip things like apt signing that
+    # shouldn't be done to unsubmitted code.
+    touch ${KOKORO_ARTIFACTS_DIR}/running_presubmits
 }
 
 main "$@"
diff --git a/kokoro/publish_apt_staging.cfg b/kokoro/publish_apt_staging.cfg
index de56d7c..cc95b5d 100644
--- a/kokoro/publish_apt_staging.cfg
+++ b/kokoro/publish_apt_staging.cfg
@@ -10,6 +10,7 @@
   define_artifacts {
     regex: "git/cros-container-guest-tools/apt/**"
     strip_prefix: "git/cros-container-guest-tools/apt"
+    fail_if_no_artifacts: false
   }
 }
 
diff --git a/kokoro/publish_apt_staging.sh b/kokoro/publish_apt_staging.sh
index 4925dac..c9bccdf 100755
--- a/kokoro/publish_apt_staging.sh
+++ b/kokoro/publish_apt_staging.sh
@@ -21,4 +21,5 @@
     cp -r "${KOKORO_GFILE_DIR}"/apt_signed/* "${result_dir}"
 }
 
+skip_in_presubmit
 main "$@"
diff --git a/kokoro/publish_lxd_staging.cfg b/kokoro/publish_lxd_staging.cfg
index e1ba2b0..686ce83 100644
--- a/kokoro/publish_lxd_staging.cfg
+++ b/kokoro/publish_lxd_staging.cfg
@@ -10,6 +10,7 @@
   define_artifacts {
     regex: "git/cros-container-guest-tools/simplestreams/**"
     strip_prefix: "git/cros-container-guest-tools/simplestreams"
+    fail_if_no_artifacts: false
   }
 }
 
diff --git a/kokoro/publish_lxd_staging.sh b/kokoro/publish_lxd_staging.sh
index 312e779..d723562 100755
--- a/kokoro/publish_lxd_staging.sh
+++ b/kokoro/publish_lxd_staging.sh
@@ -21,4 +21,5 @@
                                            "${result_dir}"
 }
 
+skip_in_presubmit
 main "$@"
diff --git a/lxd/build_debian_container.sh b/lxd/build_debian_container.sh
index b25c970..2e96fbf 100755
--- a/lxd/build_debian_container.sh
+++ b/lxd/build_debian_container.sh
@@ -135,32 +135,6 @@
     touch "${dummy_path}"/lib/swrast_dri.so
     touch "${dummy_path}"/lib/virtio_gpu_dri.so
 
-    # If doing presubmit, only run tests.
-    if [[ $job_name = *"presubmit"* ]]; then
-        build_container "amd64" \
-                        "${src_root}" \
-                        "${results_dir}" \
-                        "${apt_dir}" \
-                        false \
-                        stretch \
-                        "${job_name}"
-        build_container "amd64" \
-                        "${src_root}" \
-                        "${results_dir}" \
-                        "${apt_dir}" \
-                        true \
-                        stretch \
-                        "${job_name}"
-        build_container "amd64" \
-                        "${src_root}" \
-                        "${results_dir}" \
-                        "${apt_dir}" \
-                        true \
-                        buster \
-                        "${job_name}"
-        exit 0
-    fi
-
     # Build the normal and test images for each arch.
     for arch in amd64 arm64; do
         for release in stretch buster; do