Skip to content

Commit

Permalink
[antlir][oss] buckify libcap (#253)
Browse files Browse the repository at this point in the history
Summary:

Don't require this to be installed on the system anymore

Test Plan: Export to PR

Differential Revision: D60903657
  • Loading branch information
vmagro authored and facebook-github-bot committed Aug 7, 2024
1 parent e615c50 commit 56236f7
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Install deps
run: |
sudo apt install \
cpio jq libcap-dev systemd-container
cpio jq systemd-container
- name: Disable watchman
run: |
Expand Down
2 changes: 1 addition & 1 deletion antlir/antlir2/libcap/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ rust_bindgen_library(
cpp_deps = [
internal_external(
fb = "third-party//libcap:cap",
oss = "//third-party/cxx/system:libcap",
oss = "//third-party/cxx/libcap:libcap",
),
],
generate = ("types", "functions", "vars"),
Expand Down
80 changes: 80 additions & 0 deletions third-party/cxx/libcap/BUCK
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
load("//antlir/bzl:build_defs.bzl", "buck_genrule", "cpp_binary", "cpp_library", "http_archive")

http_archive(
name = "src",
urls = [
"https://mirrors.edge.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.70.tar.gz",
],
sha1 = "fb56e148feb9e1ae7d45840b7cf3fca35cb769b7",
sha256 = "d3b777ed413c9fafface03b917e171854709b5e4be38dbfb9219aaf7dfd4eea6",
strip_prefix = "libcap-2.70/libcap",
sub_targets = [
"cap_alloc.c",
"cap_extint.c",
"cap_file.c",
"cap_flag.c",
"cap_proc.c",
"cap_test.c",
"cap_text.c",
"empty.c",
"execable.c",
"execable.h",
"libcap.h",
"_makenames.c",
"include/uapi/linux/capability.h",
"include/sys/capability.h",
"include/sys/securebits.h",
],
)

buck_genrule(
name = "cap_names.list.h",
srcs = [":src[include/uapi/linux/capability.h]"],
cmd = """
grep -E '^#define\\s+CAP_([^\\s]+)\\s+[0-9]+\\s*$$' include/uapi/linux/capability.h | sed -e 's/^#define\\s\\+/{"/' -e 's/\\s*$$/},/' -e 's/\\s\\+/",/' -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' > $OUT
""",
)

cpp_binary(
name = "_makenames",
srcs = [":src[_makenames.c]"],
headers = {
"cap_names.list.h": ":cap_names.list.h",
},
header_namespace = "",
)

buck_genrule(
name = "cap_names.h",
cmd = """
$(exe :_makenames) > $OUT
""",
)

cpp_library(
name = "libcap",
srcs = [
":src[cap_alloc.c]",
":src[cap_extint.c]",
":src[cap_file.c]",
":src[cap_flag.c]",
":src[cap_proc.c]",
":src[cap_test.c]",
":src[cap_text.c]",
":src[execable.c]",
],
exported_headers = {
"cap_names.h": ":cap_names.h",
"libcap.h": ":src[libcap.h]",
"sys/capability.h": ":src[include/sys/capability.h]",
"sys/securebits.h": ":src[include/sys/securebits.h]",
},
header_namespace = "",
preprocessor_flags = [
"-DLIBRARY_VERSION=\"libcap-2.70\"",
select({
"config//cpu:arm64": "-DSHARED_LOADER=\"/lib64/ld-linux-aarch64.so.1\"",
"config//cpu:x86_64": "-DSHARED_LOADER=\"/lib64/ld-linux-x86-64.so.2\"",
})
],
)
10 changes: 0 additions & 10 deletions third-party/cxx/system/BUCK

This file was deleted.

0 comments on commit 56236f7

Please sign in to comment.