diff --git a/antlir/antlir2/antlir2/src/cmd/map.rs b/antlir/antlir2/antlir2/src/cmd/map.rs index de1131dce3..341ecaa17a 100644 --- a/antlir/antlir2/antlir2/src/cmd/map.rs +++ b/antlir/antlir2/antlir2/src/cmd/map.rs @@ -64,6 +64,9 @@ struct SetupArgs { output: PathBuf, #[clap(flatten)] dnf: super::DnfCompileishArgs, + #[cfg(facebook)] + #[clap(flatten)] + fbpkg: super::FbpkgCompileishArgs, } #[derive(Parser, Debug)] @@ -199,6 +202,8 @@ impl Map { root: subvol.path().to_owned(), external: compileish, dnf: self.setup.dnf, + #[cfg(facebook)] + fbpkg: self.setup.fbpkg, }, external, } @@ -216,6 +221,8 @@ impl Map { root: subvol.path().to_owned(), external: compileish, dnf: self.setup.dnf, + #[cfg(facebook)] + fbpkg: self.setup.fbpkg, }, external, } diff --git a/antlir/antlir2/antlir2/src/cmd/mod.rs b/antlir/antlir2/antlir2/src/cmd/mod.rs index f48c339b49..3b53c9e4a4 100644 --- a/antlir/antlir2/antlir2/src/cmd/mod.rs +++ b/antlir/antlir2/antlir2/src/cmd/mod.rs @@ -27,6 +27,10 @@ mod depgraph; mod map; mod plan; mod shell; +#[cfg(facebook)] +use antlir2_compile::facebook::FbpkgContext; +#[cfg(facebook)] +use antlir2_compile::facebook::ResolvedFbpkgInfoJsonFile; pub(crate) use compile::Compile; pub(crate) use depgraph::Depgraph; pub(crate) use map::Map; @@ -48,6 +52,9 @@ pub(self) struct Compileish { pub(crate) external: CompileishExternal, #[clap(flatten)] pub(crate) dnf: DnfCompileishArgs, + #[cfg(facebook)] + #[clap(flatten)] + pub(crate) fbpkg: FbpkgCompileishArgs, } #[derive(Parser, Debug)] @@ -63,6 +70,14 @@ pub(self) struct DnfCompileishArgs { pub(crate) excluded_rpms: Option>>, } +#[cfg(facebook)] +#[derive(Parser, Debug)] +pub(self) struct FbpkgCompileishArgs { + #[clap(long = "resolved-fbpkgs")] + /// Path to resolced fbpkgs json file + pub(crate) resolved_fbpkgs: Option, +} + #[derive(Parser, Debug)] /// Compile arguments that are _always_ passed from external sources (in other /// words, by buck2 actions) and are never generated by internal code in the @@ -96,6 +111,8 @@ impl Compileish { versionlock: dnf_versionlock, excluded_rpms: dnf_excluded_rpms, }, + #[cfg(facebook)] + fbpkg: FbpkgCompileishArgs { resolved_fbpkgs }, } = self; let mut v = vec![ Cow::Borrowed(OsStr::new("--label")), @@ -117,6 +134,11 @@ impl Compileish { v.push(Cow::Borrowed(OsStr::new("--dnf-excluded-rpms"))); v.push(Cow::Borrowed(excluded_rpms.path().as_os_str())); } + #[cfg(facebook)] + if let Some(resolved_fbpkgs) = resolved_fbpkgs { + v.push(Cow::Borrowed(OsStr::new("--resolved-fbpkgs"))); + v.push(Cow::Borrowed(resolved_fbpkgs.path().as_os_str())); + } for dep in image_dependencies { v.push(Cow::Borrowed(OsStr::new("--image-dependency"))); v.push(Cow::Borrowed(dep.as_os_str())); @@ -143,6 +165,8 @@ impl Compileish { .unwrap_or_default(), ), plan, + #[cfg(facebook)] + FbpkgContext::new(self.fbpkg.resolved_fbpkgs.clone()), ) .map_err(Error::Compile) } diff --git a/antlir/antlir2/antlir2_compile/src/lib.rs b/antlir/antlir2/antlir2_compile/src/lib.rs index 14defb8437..0a9e9b17dd 100644 --- a/antlir/antlir2/antlir2_compile/src/lib.rs +++ b/antlir/antlir2/antlir2_compile/src/lib.rs @@ -28,7 +28,7 @@ mod clone; mod ensure_dir_exists; mod extract; #[cfg(facebook)] -mod facebook; +pub mod facebook; mod genrule; mod install; pub mod plan; @@ -101,6 +101,9 @@ pub struct CompilerContext { dnf: DnfContext, /// Pre-computed plan for this compilation phase plan: Option, + #[cfg(facebook)] + /// Resolved fbpkgs from plan + fbpkg: facebook::FbpkgContext, } #[derive(Debug)] @@ -163,6 +166,7 @@ impl CompilerContext { root: PathBuf, dnf: DnfContext, plan: Option, + #[cfg(facebook)] fbpkg: facebook::FbpkgContext, ) -> Result { Ok(Self { label, @@ -170,6 +174,8 @@ impl CompilerContext { root, dnf, plan, + #[cfg(facebook)] + fbpkg, }) } diff --git a/antlir/antlir2/bzl/image/layer.bzl b/antlir/antlir2/bzl/image/layer.bzl index 0f96052c1d..efc310964f 100644 --- a/antlir/antlir2/bzl/image/layer.bzl +++ b/antlir/antlir2/bzl/image/layer.bzl @@ -3,6 +3,8 @@ # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. +# @lint-ignore-every BUCKFORMAT + load("//antlir/antlir2/bzl:build_phase.bzl", "BuildPhase", "build_phase") load("//antlir/antlir2/bzl:compat.bzl", "compat") load("//antlir/antlir2/bzl:lazy.bzl", "lazy") @@ -13,6 +15,7 @@ load("//antlir/antlir2/bzl/feature:defs.bzl", "feature") load("//antlir/bzl:build_defs.bzl", "alias") load("//antlir/bzl:constants.bzl", "REPO_CFG") load("//antlir/rpm/dnf2buck:repo.bzl", "RepoSetInfo") +# @oss-disable load("//antlir/bzl/build_defs.bzl", "config", "get_visibility") load(":depgraph.bzl", "build_depgraph") load(":mounts.bzl", "all_mounts", "nspawn_mount_args") @@ -92,6 +95,7 @@ def _impl(ctx: "context") -> ["provider"]: # expect it in starlark instead of a cli/json projection. all_features = list(ctx.attrs.features[FeatureInfo].features.traverse()) + # @oss-disable dnf_available_repos = (ctx.attrs.dnf_available_repos or flavor_info.dnf_info.default_repo_set)[RepoSetInfo] dnf_repodatas = repodata_only_local_repos(ctx, dnf_available_repos) dnf_versionlock = ctx.attrs.dnf_versionlock or flavor_info.dnf_info.default_versionlock @@ -211,16 +215,29 @@ def _impl(ctx: "context") -> ["provider"]: plan, flavor_info.dnf_info.reflink_flavor, ) + + # @oss-disable + # @oss-disable + # @oss-disable + # @oss-disable + # @oss-disable + # @oss-disable else: plan = None dnf_repos_dir = ctx.actions.symlinked_dir(identifier_prefix + "empty-dnf-repos", {}) + # @oss-disable + # @oss-disable logs["compile"] = ctx.actions.declare_output(identifier_prefix + "compile.log") + # @oss-disable + # @oss-disable + cmd, final_subvol = _map_image( build_appliance = build_appliance[LayerInfo], cmd = cmd_args( cmd_args(dnf_repos_dir, format = "--dnf-repos={}"), cmd_args(dnf_versionlock, format = "--dnf-versionlock={}") if dnf_versionlock else cmd_args(), + # @oss-disable "compile", compileish_args, cmd_args(plan, format = "--plan={}") if plan else cmd_args(), @@ -336,6 +353,12 @@ _layer = rule( impl = _impl, attrs = { "antlir_internal_build_appliance": attrs.bool(default = False, doc = "mark if this image is a build appliance and is allowed to not have a flavor"), + # @oss-disable + # @oss-disable + # @oss-disable + # @oss-disable + # @oss-disable + # @oss-disable "build_appliance": attrs.option( attrs.dep(providers = [LayerInfo]), default = None,