Skip to content

Commit b3310dc

Browse files
vmagrometa-codesync[bot]
authored andcommitted
[antlir2][packager] create separate build appliance for packaging use cases
Summary: This diff creates a separate build appliance for packaging rules that is independent of the target image OS. Changes: 1. Created a new `packager-appliance` layer and rule in `//antlir/antlir2/antlir2_packager/facebook/` that includes the `build-appliance-features` for packaging 2. Added `msdk.builder` for the packager-appliance for better performance 3. Updated the package rules attrs to use this new packager-appliance as the default `build_appliance` for packaging operations (internally) 4. Created `default_attrs_base` in attrs.bzl to separate attrs that don't include the packager-specific build_appliance 5. Updated `unprivileged_dir` to use `default_attrs_base` combined with `attrs_selected_by_cfg` (OS-specific build appliance) since it needs to build dot_meta layers 6. Removed the packager `build-appliance-features` from the layer build appliance features since packaging now uses its own appliance This allows packaging to be done with a consistent build appliance regardless of the target image OS, while still allowing users to customize it if needed. [Session trajectory link](https://www.internalfb.com/intern/devai/devmate/inspector/?id=a5c24bee-ebf3-45f5-a42c-adb356739e9e) Test Plan: Built the packager-appliance successfully: ``` buck2 build fbcode//antlir/antlir2/antlir2_packager/facebook:packager-appliance ``` Ran package tests that passed: ``` buck2 test fbcode//antlir/antlir2/test_images/package/unprivileged_dir/... buck2 test fbcode//antlir/antlir2/test_images/package/tar/... buck2 test fbcode//antlir/antlir2/test_images/package/cpio/... buck2 test fbcode//antlir/antlir2/test_images/package/ext3/... buck2 test fbcode//antlir/antlir2/test_images/package/ext4/... buck2 test fbcode//antlir/antlir2/test_images/package/rpm/... ``` (Some sendstream tests fail due to infrastructure issues with BTRFS ioctl permissions in Sandcastle, not related to these changes) Reviewed By: justintrudell Differential Revision: D94938828 fbshipit-source-id: e36dd3fbadc75f46f3d17dfbc8306c5cf8ced949
1 parent a7d7b60 commit b3310dc

File tree

4 files changed

+42
-8
lines changed

4 files changed

+42
-8
lines changed

antlir/antlir2/antlir2_packager/BUCK

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
load("//antlir/antlir2/bzl/feature:defs.bzl", "feature")
2+
load("//antlir/antlir2/bzl/image:defs.bzl", "image")
3+
load("//antlir/antlir2/bzl/package:defs.bzl", "package")
4+
load("//antlir/antlir2/facebook/images/build_appliance:defs.bzl", "build_appliance_from_dir")
25
load("//antlir/bzl:build_defs.bzl", "rust_binary")
36
load("//antlir/bzl:internal_external.bzl", "internal_external")
47

@@ -77,7 +80,7 @@ feature.new(
7780
}),
7881
":btrfs-progs",
7982
],
80-
visibility = ["//antlir/antlir2/build_appliance/..."],
83+
visibility = [],
8184
)
8285

8386
feature.new(
@@ -101,3 +104,25 @@ feature.new(
101104
),
102105
visibility = [],
103106
)
107+
108+
image.layer(
109+
name = "packager-appliance.layer",
110+
default_os = "centos9",
111+
features = [
112+
":build-appliance-features",
113+
],
114+
visibility = [],
115+
)
116+
117+
package.unprivileged_dir(
118+
name = "packager-appliance.dir",
119+
default_os = "centos9",
120+
layer = ":packager-appliance.layer",
121+
visibility = ["//antlir/antlir2/antlir2_packager/facebook/..."],
122+
)
123+
124+
build_appliance_from_dir(
125+
name = "packager-appliance",
126+
dir = ":packager-appliance.dir",
127+
visibility = ["PUBLIC"],
128+
)

antlir/antlir2/build_appliance/BUCK

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ feature.new(
3333
subdirs_to_create = "out",
3434
),
3535
"//antlir/antlir2/package_managers/dnf/build_appliance:features",
36-
"//antlir/antlir2/antlir2_packager:build-appliance-features",
3736
],
3837
visibility = [
3938
"PUBLIC",

antlir/antlir2/bzl/package/attrs.bzl

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# LICENSE file in the root directory of this source tree.
55

66
load("//antlir/antlir2/bzl:platform.bzl", "arch_select")
7+
load("//antlir/antlir2/bzl:types.bzl", "BuildApplianceInfo")
78
load("//antlir/antlir2/bzl/image:cfg.bzl", "attrs_selected_by_cfg")
89
load("//antlir/antlir2/features:defs.bzl", "FeaturePluginInfo", "FeaturePluginPluginKind")
910
load(":cfg.bzl", "layer_attrs")
@@ -19,8 +20,8 @@ common_attrs = {
1920
),
2021
} | layer_attrs
2122

22-
# Attrs that are not expected for users to pass
23-
default_attrs = {
23+
# Base attrs that are not expected for users to pass (without build_appliance)
24+
default_attrs_base = {
2425
"_analyze_feature": attrs.exec_dep(default = "antlir//antlir/antlir2/antlir2_depgraph_if:analyze"),
2526
"_antlir2": attrs.exec_dep(default = "antlir//antlir/antlir2/antlir2:antlir2"),
2627
"_antlir2_packager": attrs.default_only(attrs.exec_dep(default = "antlir//antlir/antlir2/antlir2_packager:antlir2-packager")),
@@ -29,4 +30,13 @@ default_attrs = {
2930
"_target_arch": attrs.default_only(attrs.string(
3031
default = arch_select(aarch64 = "aarch64", x86_64 = "x86_64"),
3132
)),
32-
} | attrs_selected_by_cfg
33+
} | {k: v for k, v in attrs_selected_by_cfg.items() if k != "build_appliance"}
34+
35+
# Attrs that are not expected for users to pass (includes packager build_appliance)
36+
default_attrs = default_attrs_base | {
37+
"build_appliance": attrs.exec_dep(
38+
providers = [BuildApplianceInfo],
39+
default = "antlir//antlir/antlir2/antlir2_packager:packager-appliance",
40+
doc = "Build appliance for packaging. Defaults to a standard packager-appliance that is independent of the target image OS.",
41+
),
42+
}

antlir/antlir2/bzl/package/unprivileged_dir.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ load("//antlir/antlir2/bzl:types.bzl", "LayerInfo")
77
load("//antlir/antlir2/bzl/image:cfg.bzl", "attrs_selected_by_cfg")
88
load("//antlir/antlir2/features:defs.bzl", "FeaturePluginPluginKind")
99
load("//antlir/buck2/bzl:ensure_single_output.bzl", "ensure_single_output")
10-
load(":attrs.bzl", "common_attrs", "default_attrs")
10+
load(":attrs.bzl", "common_attrs", "default_attrs_base")
1111
load(":cfg.bzl", "package_cfg")
1212
load(":macro.bzl", "package_macro")
1313
load(":stamp_buildinfo.bzl", "stamp_buildinfo_rule")
@@ -83,7 +83,7 @@ _unprivileged_dir = rule(
8383
impl = _unprivileged_dir_impl,
8484
cfg = package_cfg,
8585
uses_plugins = [FeaturePluginPluginKind],
86-
attrs = default_attrs | common_attrs | _unprivileged_dir_attrs,
86+
attrs = default_attrs_base | common_attrs | _unprivileged_dir_attrs | attrs_selected_by_cfg,
8787
)
8888

8989
unprivileged_dir_anon = anon_rule(
@@ -92,7 +92,7 @@ unprivileged_dir_anon = anon_rule(
9292
"base64_encoded_path_mapping": lambda x: ensure_single_output(x[DefaultInfo].sub_targets["base64_encoded_path_mapping"]),
9393
"package": lambda x: ensure_single_output(x),
9494
},
95-
attrs = default_attrs | common_attrs | _unprivileged_dir_attrs,
95+
attrs = default_attrs_base | common_attrs | _unprivileged_dir_attrs | attrs_selected_by_cfg,
9696
)
9797

9898
unprivileged_dir = package_macro(_unprivileged_dir)

0 commit comments

Comments
 (0)