Skip to content

Commit a23098a

Browse files
committed
Build ACL from source
The PR provides patch for building ACL from release.
1 parent 498a4b2 commit a23098a

7 files changed

Lines changed: 321 additions & 26 deletions

File tree

MODULE.bazel

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,6 @@ register_toolchains(
136136

137137
deb = use_repo_rule("@download_utils//download/deb:defs.bzl", "download_deb")
138138

139-
deb(
140-
name = "acl-deb",
141-
build = "//third_party/acl:acl.BUILD",
142-
urls = ["https://archive.ubuntu.com/ubuntu/pool/main/a/acl/libacl1-dev_2.2.52-3build1_amd64.deb"],
143-
visibility = ["//visibility:public"],
144-
)
145-
146-
deb(
147-
name = "acl-deb-aarch64",
148-
build = "//third_party/acl:acl.BUILD",
149-
urls = ["https://ports.ubuntu.com/ubuntu-ports/pool/main/a/acl/libacl1-dev_2.2.52-3build1_arm64.deb"],
150-
visibility = ["//visibility:public"],
151-
)
152-
153139
deb(
154140
name = "valgrind-deb",
155141
build = "//third_party/valgrind:valgrind.BUILD",
@@ -183,6 +169,26 @@ deb(
183169
visibility = ["//visibility:public"],
184170
)
185171

172+
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
173+
174+
http_archive(
175+
name = "bazel_attr",
176+
build_file = "//third_party/attr:attr.BUILD",
177+
patch_args = ["-p1"],
178+
patches = ["//third_party/attr:attr.patch"],
179+
strip_prefix = "attr-2.5.2",
180+
urls = ["https://download.savannah.gnu.org/releases/attr/attr-2.5.2.tar.gz"],
181+
)
182+
183+
http_archive(
184+
name = "bazel_acl",
185+
build_file = "//third_party/acl:acl.BUILD",
186+
patch_args = ["-p1"],
187+
patches = ["//third_party/acl:acl.patch"],
188+
strip_prefix = "acl-2.3.2",
189+
urls = ["https://download.savannah.gnu.org/releases/acl/acl-2.3.2.tar.gz"],
190+
)
191+
186192
bazel_dep(name = "flatbuffers", version = "25.12.19")
187193
bazel_dep(name = "nlohmann_json", version = "3.11.3")
188194
bazel_dep(name = "bazel_skylib", version = "1.9.0")

third_party/acl/BUILD

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313

1414
alias(
1515
name = "acl",
16-
actual = select({
17-
"@platforms//cpu:aarch64": "@acl-deb-aarch64//:acl",
18-
"//conditions:default": "@acl-deb//:acl",
19-
}),
16+
actual = "@bazel_acl//:acl",
2017
visibility = ["//:__subpackages__"],
2118
)

third_party/acl/acl.BUILD

Lines changed: 68 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# *******************************************************************************
2-
# Copyright (c) 2025 Contributors to the Eclipse Foundation
2+
# Copyright (c) 2026 Contributors to the Eclipse Foundation
33
#
44
# See the NOTICE file(s) distributed with this work for additional
55
# information regarding copyright ownership.
@@ -11,18 +11,78 @@
1111
# SPDX-License-Identifier: Apache-2.0
1212
# *******************************************************************************
1313

14+
""" Bazel BUILD file for the ACL library.
15+
"""
16+
1417
load("@rules_cc//cc:defs.bzl", "cc_library")
1518

1619
cc_library(
17-
name = "acl",
18-
srcs = select({
19-
"@platforms//cpu:aarch64": ["usr/lib/libacl.a"],
20-
"@platforms//cpu:x86_64": ["usr/lib/libacl.a"],
20+
name = "config",
21+
hdrs = select({
22+
"@platforms//os:linux": ["bazel/configs/linux/config.h"],
23+
}),
24+
strip_include_prefix = select({
25+
"@platforms//os:linux": "bazel/configs/linux",
2126
}),
27+
)
28+
29+
cc_library(
30+
name = "acl_h",
31+
hdrs = ["include/acl.h"],
32+
copts = [
33+
'-DEXPORT=__attribute__((visibility("default"))) extern',
34+
],
35+
include_prefix = "sys",
36+
includes = ["include"],
37+
strip_include_prefix = "include",
38+
)
39+
40+
cc_library(
41+
name = "libacl_h",
42+
hdrs = ["include/libacl.h"],
43+
include_prefix = "acl",
44+
includes = ["include"],
45+
strip_include_prefix = "include",
46+
)
47+
48+
cc_library(
49+
name = "includes",
2250
hdrs = [
23-
"usr/include/acl/libacl.h",
24-
"usr/include/sys/acl.h",
51+
"include/acl_ea.h",
52+
"include/misc.h",
53+
"include/walk_tree.h",
54+
],
55+
includes = ["include"],
56+
)
57+
58+
cc_library(
59+
name = "acl",
60+
srcs = glob(["libacl/*c"]) + [
61+
"libmisc/high_water_alloc.c",
62+
"libmisc/next_line.c",
63+
"libmisc/quote.c",
64+
"libmisc/uid_gid_lookup.c",
65+
"libmisc/unquote.c",
66+
"libmisc/walk_tree.c",
2567
],
26-
includes = ["usr/include/"],
68+
hdrs = glob(["libacl/*h"]),
69+
copts = [
70+
"-include libacl/perm_copy.h",
71+
"-include",
72+
"config.h",
73+
"-Wno-error=missing-prototypes",
74+
"-Wno-error=cast-qual",
75+
"-Wno-error=int-conversion",
76+
"-Wno-error=implicit-function-declaration",
77+
],
78+
includes = ["libacl"],
79+
linkstatic = True,
2780
visibility = ["//visibility:public"],
81+
deps = [
82+
":acl_h",
83+
":config",
84+
":includes",
85+
":libacl_h",
86+
"@bazel_attr//:attr",
87+
],
2888
)

third_party/acl/acl.patch

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
diff --git a/bazel/configs/linux/config.h b/bazel/configs/linux/config.h
2+
new file mode 100644
3+
index 0000000..e7c5ff6
4+
--- /dev/null
5+
+++ b/bazel/configs/linux/config.h
6+
@@ -0,0 +1,41 @@
7+
+#ifndef ACL_CONFIG_H
8+
+#define ACL_CONFIG_H
9+
+
10+
+#define HAVE_CONFIG_H 1
11+
+
12+
+#define PACKAGE "acl"
13+
+#define PACKAGE_NAME "acl"
14+
+#define PACKAGE_VERSION "2.3.2"
15+
+#define VERSION "2.3.2"
16+
+
17+
+/* Headers */
18+
+#define HAVE_ERRNO_H 1
19+
+#define HAVE_FCNTL_H 1
20+
+#define HAVE_LIMITS_H 1
21+
+#define HAVE_STDARG_H 1
22+
+#define HAVE_STDDEF_H 1
23+
+#define HAVE_STDINT_H 1
24+
+#define HAVE_STDLIB_H 1
25+
+#define HAVE_STRING_H 1
26+
+#define HAVE_SYS_ACL_H 1
27+
+#define HAVE_SYS_STAT_H 1
28+
+#define HAVE_SYS_TYPES_H 1
29+
+#define HAVE_UNISTD_H 1
30+
+
31+
+/* Functions */
32+
+#define HAVE_FCHMOD 1
33+
+#define HAVE_FCHOWN 1
34+
+#define HAVE_GETXATTR 1
35+
+#define HAVE_FGETXATTR 1
36+
+#define HAVE_SETXATTR 1
37+
+#define HAVE_FSETXATTR 1
38+
+#define HAVE_LISTXATTR 1
39+
+#define HAVE_FLISTXATTR 1
40+
+#define HAVE_REMOVEXATTR 1
41+
+#define HAVE_FREMOVEXATTR 1
42+
+
43+
+/* Linux behavior */
44+
+#define HAVE_VISIBILITY_ATTRIBUTE 1
45+
+#define EXPORT __attribute__ ((visibility ("default"))) extern
46+
+
47+
+#endif /* ACL_CONFIG_H */
48+
diff --git a/include/acl.h b/include/acl.h
49+
index 710bf31..4edc471 100644
50+
--- a/include/acl.h
51+
+++ b/include/acl.h
52+
@@ -21,6 +21,7 @@
53+
#define __SYS_ACL_H
54+
55+
#include <sys/types.h>
56+
+#include "config.h"
57+
58+
#ifdef __cplusplus
59+
extern "C" {
60+
diff --git a/libacl/acl_get_fd.c b/libacl/acl_get_fd.c
61+
index 089ec79..ff930ca 100644
62+
--- a/libacl/acl_get_fd.c
63+
+++ b/libacl/acl_get_fd.c
64+
@@ -24,6 +24,7 @@
65+
#include <unistd.h>
66+
#include <stdio.h>
67+
#include <sys/xattr.h>
68+
+#include <alloca.h>
69+
#include "libacl.h"
70+
#include "__acl_from_xattr.h"
71+
72+
diff --git a/libacl/acl_get_file.c b/libacl/acl_get_file.c
73+
index 4a86d1a..f062bf2 100644
74+
--- a/libacl/acl_get_file.c
75+
+++ b/libacl/acl_get_file.c
76+
@@ -19,6 +19,7 @@
77+
*/
78+
79+
#include "config.h"
80+
+#include <alloca.h>
81+
#include <sys/types.h>
82+
#include <sys/stat.h>
83+
#include <unistd.h>

third_party/attr/BUILD

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
14+
alias(
15+
name = "attr",
16+
actual = "@bazel_attr//:attr",
17+
visibility = ["//:__subpackages__"],
18+
)

third_party/attr/attr.BUILD

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2026 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
14+
""" The BUILD file for the bazel_attr module. This module provides a C library for
15+
extended attributes (xattr) on Linux. It includes a configuration header and
16+
the source files for the library. The library is built as a static library and
17+
is visible to other modules. The configuration header is selected based on the
18+
platform, and the library depends on the platforms and rules_cc modules.
19+
"""
20+
21+
load("@rules_cc//cc:defs.bzl", "cc_library")
22+
23+
cc_library(
24+
name = "config",
25+
hdrs = select({
26+
"@platforms//os:linux": ["bazel/configs/linux/config.h"],
27+
}),
28+
strip_include_prefix = select({
29+
"@platforms//os:linux": "bazel/configs/linux",
30+
}),
31+
)
32+
33+
cc_library(
34+
name = "attr_h",
35+
hdrs = [
36+
"include/attributes.h",
37+
"include/libattr.h",
38+
],
39+
include_prefix = "attr",
40+
includes = ["include"],
41+
strip_include_prefix = "include",
42+
)
43+
44+
cc_library(
45+
name = "includes",
46+
hdrs = [
47+
"include/error_context.h",
48+
"include/misc.h",
49+
"include/nls.h",
50+
"include/walk_tree.h",
51+
],
52+
includes = ["include"],
53+
)
54+
55+
cc_library(
56+
name = "attr",
57+
srcs = [
58+
"libattr/libattr.c",
59+
],
60+
hdrs = [
61+
"libattr/libattr.h",
62+
],
63+
copts = [
64+
"-DSYSCONFDIR=\\\"$(location :xattr.conf)\\\"",
65+
"-Wno-error=cast-qual",
66+
"-Wno-error=missing-prototypes",
67+
],
68+
data = [":xattr.conf"],
69+
includes = ["libattr"],
70+
linkstatic = True,
71+
visibility = ["//visibility:public"],
72+
deps = [
73+
":attr_h",
74+
":config",
75+
":includes",
76+
],
77+
)

third_party/attr/attr.patch

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
diff --git a/bazel/configs/linux/config.h b/bazel/configs/linux/config.h
2+
new file mode 100644
3+
index 0000000..a0dac0e
4+
--- /dev/null
5+
+++ b/bazel/configs/linux/config.h
6+
@@ -0,0 +1,47 @@
7+
+
8+
+
9+
+#ifndef ATTR_CONFIG_H
10+
+#define ATTR_CONFIG_H
11+
+
12+
+#define HAVE_CONFIG_H 1
13+
+
14+
+#define PACKAGE "attr"
15+
+#define PACKAGE_NAME "attr"
16+
+#define PACKAGE_VERSION "2.5.2"
17+
+#define VERSION "2.5.2"
18+
+
19+
+/* Headers */
20+
+#define HAVE_ERRNO_H 1
21+
+#define HAVE_FCNTL_H 1
22+
+#define HAVE_LIMITS_H 1
23+
+#define HAVE_STDDEF_H 1
24+
+#define HAVE_STDINT_H 1
25+
+#define HAVE_STDLIB_H 1
26+
+#define HAVE_STRING_H 1
27+
+#define HAVE_SYS_STAT_H 1
28+
+#define HAVE_SYS_TYPES_H 1
29+
+#define HAVE_SYS_XATTR_H 1
30+
+#define HAVE_UNISTD_H 1
31+
+
32+
+/* Functions */
33+
+#define HAVE_GETXATTR 1
34+
+#define HAVE_LGETXATTR 1
35+
+#define HAVE_FGETXATTR 1
36+
+
37+
+#define HAVE_SETXATTR 1
38+
+#define HAVE_LSETXATTR 1
39+
+#define HAVE_FSETXATTR 1
40+
+
41+
+#define HAVE_LISTXATTR 1
42+
+#define HAVE_LLISTXATTR 1
43+
+#define HAVE_FLISTXATTR 1
44+
+
45+
+#define HAVE_REMOVEXATTR 1
46+
+#define HAVE_LREMOVEXATTR 1
47+
+#define HAVE_FREMOVEXATTR 1
48+
+
49+
+/* Linux behavior */
50+
+#define HAVE_VISIBILITY_ATTRIBUTE 1
51+
+#define EXPORT __attribute__ ((visibility ("default"))) extern
52+
+
53+
+#endif /* ATTR_CONFIG_H */
54+
\ No newline at end of file

0 commit comments

Comments
 (0)