Finish converting googleapis and remoteapis into local_repository repos.

This finishes the fix for #6601.

local_repository, unlike new_local_repository, contains its own
WORKSPACE and correctly detects attemps to directly use the package,
instead of using the @repository name.

This has to be committed separately from the first half, because it is
outside of third_party.

Fixes #6601.
Closes #6646.

PiperOrigin-RevId: 221095131
diff --git a/BUILD b/BUILD
index caec40a..d5bdca7 100644
--- a/BUILD
+++ b/BUILD
@@ -68,6 +68,11 @@
 pkg_tar(
     name = "bazel-srcs",
     srcs = [":srcs"],
+    remap_paths = {
+        # Rewrite paths coming from local repositories back into third_party.
+        "../googleapis": "third_party/googleapis",
+        "../remoteapis": "third_party/remoteapis",
+    },
     strip_prefix = ".",
     # Public but bazel-only visibility.
     visibility = ["//:__subpackages__"],
diff --git a/WORKSPACE b/WORKSPACE
index 57be096..efbbe51 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -75,15 +75,13 @@
     path = "./third_party/protobuf/3.6.1/",
 )
 
-new_local_repository(
+local_repository(
     name = "googleapis",
-    build_file = "./third_party/googleapis/BUILD",
     path = "./third_party/googleapis/",
 )
 
-new_local_repository(
+local_repository(
     name = "remoteapis",
-    build_file = "./third_party/remoteapis/BUILD.bazel",
     path = "./third_party/remoteapis/",
 )