treewide: migrate more to bzlmod

This does migrate nearly everything to bzlmod and away from the "old"
WORKSPACE system. We do have to use some workarounds and there is no
good way to get the path to a repository. This definitively requires
some more love in future CLs but this should cover the basics. See
monogon-dev/monogon#343 for more information.

Change-Id: I0e188d8708b66fcdbdf0adc9143c93160e3395ae
Reviewed-on: https://review.monogon.dev/c/monogon/+/3357
Reviewed-by: Lorenz Brun <lorenz@monogon.tech>
Reviewed-by: Leopold Schabel <leo@monogon.tech>
Tested-by: Jenkins CI
diff --git a/third_party/edk2/external.bzl b/third_party/edk2/external.bzl
deleted file mode 100644
index 975769c..0000000
--- a/third_party/edk2/external.bzl
+++ /dev/null
@@ -1,29 +0,0 @@
-#  Copyright 2020 The Monogon Project Authors.
-#
-#  SPDX-License-Identifier: Apache-2.0
-#
-#  Licensed under the Apache License, Version 2.0 (the "License");
-#  you may not use this file except in compliance with the License.
-#  You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-#  Unless required by applicable law or agreed to in writing, software
-#  distributed under the License is distributed on an "AS IS" BASIS,
-#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#  See the License for the specific language governing permissions and
-#  limitations under the License.
-
-load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
-
-def edk2_external(name):
-    new_git_repository(
-        name = name,
-        build_file = "//third_party/edk2/external:BUILD.repo",
-        commit = "b24306f15daa2ff8510b06702114724b33895d3c",  # stable202202
-        recursive_init_submodules = True,
-        remote = "https://github.com/tianocore/edk2",
-        shallow_since = "1645456780 +0000",
-        patches = ["//third_party/edk2/patches:disable-werror.patch", "//third_party/edk2/patches:remove-brotli-build.patch"],
-        patch_args = ["-p1"],
-    )
diff --git a/third_party/edk2/external/BUILD.repo b/third_party/edk2/external/BUILD.repo
index 9faa930..acb27b8 100644
--- a/third_party/edk2/external/BUILD.repo
+++ b/third_party/edk2/external/BUILD.repo
@@ -16,13 +16,13 @@
         # The edk2 build does not like Bazel's default genrule environment.
         set +u
 
-        cd external/edk2
+        cd external/_main~_repo_rules~edk2
         . edksetup.sh
         make -C BaseTools/Source/C
         build -DTPM2_ENABLE -DSECURE_BOOT_ENABLE -t GCC5 -a X64 -b RELEASE -p $$PWD/OvmfPkg/OvmfPkgX64.dsc
     ) > /dev/null
 
-    cp external/edk2/Build/OvmfX64/RELEASE_GCC5/FV/{OVMF_CODE.fd,OVMF_VARS.fd} $(RULEDIR)
+    cp external/_main~_repo_rules~edk2/Build/OvmfX64/RELEASE_GCC5/FV/{OVMF_CODE.fd,OVMF_VARS.fd} $(RULEDIR)
     """,
     visibility = ["//visibility:public"],
 )