treewide: replace libcap archive with bzlmod dependency
Change-Id: I571a5e58640e567cfa1c9a6d2c5bc90d99b8fc46
Reviewed-on: https://review.monogon.dev/c/monogon/+/4231
Tested-by: Jenkins CI
Reviewed-by: Jan Schär <jan@monogon.tech>
diff --git a/third_party/cap/BUILD.bazel b/third_party/cap/BUILD.bazel
deleted file mode 100644
index e69de29..0000000
--- a/third_party/cap/BUILD.bazel
+++ /dev/null
diff --git a/third_party/cap/cap.bzl b/third_party/cap/cap.bzl
deleted file mode 100644
index 5d93890..0000000
--- a/third_party/cap/cap.bzl
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright 2021 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("@io_bazel_rules_go//go:def.bzl", "go_binary")
-load("@rules_cc//cc:defs.bzl", "cc_library")
-
-cc_library(
- name = "cap",
- srcs = [
- "cap_alloc.c",
- "cap_extint.c",
- "cap_file.c",
- "cap_flag.c",
- "cap_proc.c",
- "cap_text.c",
- ] + glob(["include/sys/*.h"]), # UAPI is intentionally excluded as we want it from our own kernel headers
- hdrs = ["libcap.h", ":cap_names.h"],
- visibility = ["//visibility:public"],
- includes = [".", "include"],
-)
-
-go_binary(
- name = "makenames",
- srcs = ["makenames.go"],
-)
-
-genrule(
- name = "cap_names_hdr",
- srcs = [
- "include/uapi/linux/capability.h",
- ],
- outs = [
- "cap_names.h",
- ],
- cmd = "$(location :makenames) \"$(location include/uapi/linux/capability.h)\" \"$@\"",
- tools = [
- ":makenames",
- ],
-)
diff --git a/third_party/cap/patches/BUILD.bazel b/third_party/cap/patches/BUILD.bazel
deleted file mode 100644
index e69de29..0000000
--- a/third_party/cap/patches/BUILD.bazel
+++ /dev/null
diff --git a/third_party/cap/patches/add_go_codegen.patch b/third_party/cap/patches/add_go_codegen.patch
deleted file mode 100644
index 2572367..0000000
--- a/third_party/cap/patches/add_go_codegen.patch
+++ /dev/null
@@ -1,78 +0,0 @@
---- /dev/null
-+++ b/makenames.go
-@@ -0,0 +1,73 @@
-+// makenames replaces the built-in array generation consisting of Perl incantations being
-+// consumed by C code with a single implementation that's shorter anyways.
-+package main
-+
-+import (
-+ "io/ioutil"
-+ "log"
-+ "os"
-+ "regexp"
-+ "strconv"
-+ "strings"
-+ "text/template"
-+)
-+
-+type tmplParams struct {
-+ Bits int
-+ NameSize int
-+ Caps []string
-+}
-+
-+var capNamesTmpl = template.Must(template.New("cap_names").Parse(`/*
-+ * DO NOT EDIT: this file is generated automatically from
-+ *
-+ * <uapi/linux/capability.h>
-+ */
-+
-+#define __CAP_BITS {{ .Bits }}
-+#define __CAP_NAME_SIZE {{ .NameSize }}
-+
-+#ifdef LIBCAP_PLEASE_INCLUDE_ARRAY
-+#define LIBCAP_CAP_NAMES { \
-+{{ range $i, $name := .Caps }} /* {{ $i }} */ {{ if $name }}"{{ $name }}"{{else}}NULL, /* - presently unused */{{end}}, \
-+{{end}} }
-+#endif /* LIBCAP_PLEASE_INCLUDE_ARRAY */
-+
-+/* END OF FILE */
-+`))
-+
-+var capRe = regexp.MustCompile(`(?m)^#define[ \t](CAP[_A-Z]+)[ \t]+([0-9]+)\s+$`)
-+
-+func main() {
-+ sourceFile, err := ioutil.ReadFile(os.Args[1])
-+ if err != nil {
-+ log.Fatalln(err)
-+ }
-+
-+ matches := capRe.FindAllStringSubmatch(string(sourceFile), -1)
-+ out := tmplParams{
-+ Caps: make([]string, 1024),
-+ }
-+ for _, m := range matches {
-+ i, err := strconv.Atoi(m[2])
-+ if err != nil {
-+ log.Fatalln(err)
-+ }
-+ if i+1 > out.Bits {
-+ out.Bits = i + 1
-+ }
-+ if len(m[1])+1 > out.NameSize {
-+ out.NameSize = len(m[1]) + 1
-+ }
-+ out.Caps[i] = strings.ToLower(m[1])
-+ }
-+ out.Caps = out.Caps[:out.Bits]
-+ outFile, err := os.Create(os.Args[2])
-+ if err != nil {
-+ log.Fatalln(err)
-+ }
-+ if err := capNamesTmpl.ExecuteTemplate(outFile, "cap_names", &out); err != nil {
-+ log.Fatalln(err)
-+ }
-+ outFile.Close()
-+}
---
-2.25.1
diff --git a/third_party/chrony/chrony.bzl b/third_party/chrony/chrony.bzl
index afecf26..812d536 100644
--- a/third_party/chrony/chrony.bzl
+++ b/third_party/chrony/chrony.bzl
@@ -153,7 +153,7 @@
deps = [
":common",
"@seccomp//:seccomp",
- "@cap//:cap",
+ "@libcap//:libcap",
],
)