Skip to content

Commit df3fc28

Browse files
authored
[ABLD-278] Use bazel built libacl. (#44079)
Cutover from omnibus libacl to bazel - Call libacl install directly from openscap.rb. When openscap is built with Bazel, we'll just depend on it as a dependency. - Remove omnibus step for libacl - Adjust build flags to match what configure/make would produce. ### Testing: - Compare 3 things - build with with configure/make, - pull libacl.so from an old CI image, - build with bazel and look at libacl.so The sizes are close enough for comfort. They vary a bit because in the new build we are not double building some util functions, so we get a little space back. Similar compare for the public header files. Make sure that our new ones match previous agent builds. Co-authored-by: tony.aiuto <tony.aiuto@datadoghq.com>
1 parent 7e486ae commit df3fc28

File tree

3 files changed

+56
-81
lines changed

3 files changed

+56
-81
lines changed

deps/acl/overlay/overlay.BUILD.bazel

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
# libacl
1+
"""libacl"""
22

33
load("@@//bazel/rules:so_symlink.bzl", "so_symlink")
44
load("@@//compliance/rules:ship_source_offer.bzl", "ship_source_offer")
5-
load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
65
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
76
load("@package_metadata//rules:package_metadata.bzl", "package_metadata")
87
load("@rules_cc//cc:defs.bzl", "cc_library", "cc_shared_library")
98
load("@rules_license//rules:license.bzl", "license")
109
load("@rules_pkg//pkg:install.bzl", "pkg_install")
11-
load("@rules_pkg//pkg:mappings.bzl", "pkg_files")
10+
load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix")
1211

1312
package(default_package_metadata = [":package_metadata", ":ship_source_offer"])
1413

15-
_VERSION = "2.3.1"
14+
VERSION = "2.3.1"
1615

17-
# This is going to change in the future. Debate the syntax in https://github.com/bazel-contrib/supply-chain/issues/124
18-
PURL = "pkg:https/download.savannah.nongnu.org/acl@{version}?url=https://download.savannah.nongnu.org/releases/acl/attr-%{version}.tar.xz".format(
19-
version = _VERSION,
16+
PURL = "pkg:generic/acl@{version}?download_url=https://download.savannah.nongnu.org/releases/acl/acl-{version}.tar.xz".format(
17+
version = VERSION,
2018
)
2119

2220
package_metadata(
@@ -39,33 +37,39 @@ license(
3937

4038
# TODO: We will have to adjust this when we put a dependency on it.
4139
# It is possible that some of the other files in include are public.
42-
_PUBLIC_HEADERS = [
43-
":include/sys/acl.h",
44-
":include/acl/libacl.h",
40+
PUBLIC_HEADERS = [
41+
":fixed/include/sys/acl.h",
42+
":fixed/include/acl/libacl.h",
4543
]
4644

47-
# The code sometimes includes "include/acl.h" as <sys/acl.h>
48-
copy_file(
49-
name = "sys_acl_h",
50-
src = "include/acl.h",
51-
out = "include/sys/acl.h",
52-
)
45+
# There are two things going on here
46+
# 1. The public headers in the source are not in their installed locations.
47+
# src = "include/acl.h" => "include/sys/acl.h"
48+
# src = "include/libacl.h", => "include/acl/libacl.h"
49+
# 2. In the (internal) source headers, external methods are marked EXPORT.
50+
# However, the public version should use extern instead. Configure/make
51+
# did the rename while copying, so we do the same.
5352

54-
# There is both a libacl/libacl.h and an include/libacl.h
55-
# libacl/libacl.h is internal to the library build.
56-
# include/libacl.h is the public one, which they self refernce as
57-
# <sys/libacl.h>
58-
copy_file(
59-
name = "sys_libacl_h",
60-
src = "include/libacl.h",
61-
out = "include/acl/libacl.h",
53+
genrule(
54+
name = "fixed_headers",
55+
srcs = [
56+
":include/acl.h",
57+
":include/libacl.h",
58+
],
59+
outs = [
60+
"fixed/include/sys/acl.h",
61+
"fixed/include/acl/libacl.h",
62+
],
63+
cmd = ";".join([
64+
"sed 's/EXPORT/extern/g' $(location :include/acl.h) > $(location fixed/include/sys/acl.h)",
65+
"sed 's/EXPORT/extern/g' $(location :include/libacl.h) > $(location fixed/include/acl/libacl.h)",
66+
]),
6267
)
6368

6469
cc_library(
6570
name = "libacl",
6671
srcs = [
67-
":sys_acl_h",
68-
":sys_libacl_h",
72+
":fixed_headers",
6973
"include/acl_ea.h",
7074
"include/acl.h",
7175
"include/config.h",
@@ -133,14 +137,15 @@ cc_library(
133137
"libmisc/unquote.c",
134138
"libmisc/walk_tree.c",
135139
],
136-
hdrs = _PUBLIC_HEADERS,
140+
hdrs = PUBLIC_HEADERS,
137141
includes = [
138142
"include",
143+
"fixed/include",
139144
],
140145
copts = [
141146
"-fPIC",
142-
# TODO: Does this need speed or size?
143-
# "-O2",
147+
"-O2",
148+
"-g",
144149
"-Ilibacl",
145150
],
146151
local_defines = [
@@ -173,12 +178,14 @@ so_symlink(
173178
src = ":acl",
174179
libname = "libacl",
175180
version = "1.1.2301",
181+
prefix = "embedded",
176182
)
177183

178184
pkg_files(
179185
name = "hdr_files",
180-
srcs = _PUBLIC_HEADERS,
181-
prefix = "include/acl/",
186+
srcs = [":fixed_headers"],
187+
strip_prefix = strip_prefix.from_pkg("fixed"),
188+
prefix = "embedded",
182189
)
183190

184191
expand_template(
@@ -190,22 +197,29 @@ expand_template(
190197
"@exec_prefix@": "${prefix}",
191198
"@libdir@": "${prefix}/lib",
192199
"@includedir@": "${prefix}/include",
193-
"@PACKAGE_VERSION@": _VERSION,
200+
"@PACKAGE_VERSION@": VERSION,
194201
},
195202
template = "libacl.pc.in",
196203
)
197204

198205
pkg_files(
199206
name = "pc_file",
200207
srcs = [":gen_pkgconfig"],
201-
prefix = "lib/pkgconfig",
208+
prefix = "embedded/lib/pkgconfig",
202209
)
203210

204-
pkg_install(
205-
name = "install",
211+
pkg_filegroup(
212+
name = "all_files",
206213
srcs = [
207214
":hdr_files",
208215
":lib_files",
209216
":pc_file",
210217
],
211218
)
219+
220+
pkg_install(
221+
name = "install",
222+
srcs = [
223+
":all_files",
224+
],
225+
)

omnibus/config/software/libacl.rb

Lines changed: 0 additions & 45 deletions
This file was deleted.

omnibus/config/software/openscap.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@
1515

1616
source url: "https://github.com/OpenSCAP/openscap/releases/download/#{version}/openscap-#{version}.tar.gz"
1717

18+
build do
19+
command_on_repo_root "bazelisk run -- @acl//:install --destdir='#{install_dir}'"
20+
command_on_repo_root "bazelisk run -- //bazel/rules:replace_prefix --prefix '#{install_dir}/embedded'" \
21+
" #{install_dir}/embedded/lib/pkgconfig/libacl.pc" \
22+
" #{install_dir}/embedded/lib/libacl.so"
23+
end
24+
1825
dependency 'attr'
1926
dependency 'bzip2'
2027
dependency 'curl'
2128
dependency 'dbus'
22-
dependency 'libacl'
2329
dependency 'libgcrypt'
2430
dependency 'libselinux'
2531
dependency 'libsepol'

0 commit comments

Comments
 (0)