Skip to content

Commit 6384f33

Browse files
committed
Convert embedded packages properly from resolvo solve
When populating the Solution object, embedded packages need to be categorized properly or else when calculating the layers for the solution it ends up with an empty blob as one of the layers, which is an error. Handle source builds in resolvo solve When not building from source. Signed-off-by: J Robert Ray <[email protected]>
1 parent bf4da33 commit 6384f33

File tree

2 files changed

+52
-14
lines changed
  • crates
    • spk-cli/cmd-build/src/cmd_build_test
    • spk-solve/src/solvers/resolvo

2 files changed

+52
-14
lines changed

crates/spk-cli/cmd-build/src/cmd_build_test/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ build:
138138
#[rstest]
139139
#[case::cli("cli")]
140140
#[case::checks("checks")]
141+
#[case::resolvo("resolvo")]
141142
#[tokio::test]
142143
async fn test_build_with_circular_dependency_allow_with_validation(
143144
tmpdir: tempfile::TempDir,

crates/spk-solve/src/solvers/resolvo/mod.rs

Lines changed: 51 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -241,21 +241,58 @@ impl Solver {
241241
next_index,
242242
);
243243
solution_adds.push((pkg_request, package, {
244-
if located_build_ident_with_component.requires_build_from_source {
245-
PackageSource::BuildFromSource {
246-
recipe: repo
247-
.read_recipe(
248-
&located_build_ident_with_component.ident.to_version_ident(),
249-
)
250-
.await?,
244+
match located_build_ident_with_component.ident.build() {
245+
spk_schema::ident_build::Build::Source
246+
if located_build_ident_with_component.requires_build_from_source =>
247+
{
248+
PackageSource::BuildFromSource {
249+
recipe: repo
250+
.read_recipe(
251+
&located_build_ident_with_component.ident.to_version_ident(),
252+
)
253+
.await?,
254+
}
255+
}
256+
spk_schema::ident_build::Build::Source => {
257+
// Not building this from source but just adding the
258+
// source build to the Solution.
259+
PackageSource::Repository {
260+
repo: Arc::clone(repo),
261+
// XXX: Why is this needed?
262+
components: repo
263+
.read_components(located_build_ident_with_component.ident.target())
264+
.await?,
265+
}
251266
}
252-
} else {
253-
PackageSource::Repository {
254-
repo: Arc::clone(repo),
255-
// XXX: Why is this needed?
256-
components: repo
257-
.read_components(located_build_ident_with_component.ident.target())
258-
.await?,
267+
spk_schema::ident_build::Build::Embedded(embedded_source) => {
268+
match embedded_source {
269+
spk_schema::ident_build::EmbeddedSource::Package(
270+
embedded_source_package,
271+
) => {
272+
PackageSource::Embedded {
273+
parent: (**embedded_source_package).clone().try_into()?,
274+
// XXX: Why is this needed?
275+
components: repo
276+
.read_components(
277+
located_build_ident_with_component.ident.target(),
278+
)
279+
.await?
280+
.keys()
281+
.cloned()
282+
.collect(),
283+
}
284+
}
285+
spk_schema::ident_build::EmbeddedSource::Unknown => todo!(),
286+
}
287+
}
288+
spk_schema::ident_build::Build::BuildId(_build_id) => {
289+
PackageSource::Repository {
290+
repo: Arc::clone(repo),
291+
// XXX: Why is this needed?
292+
components: repo
293+
.read_components(located_build_ident_with_component.ident.target())
294+
.await?,
295+
}
259296
}
260297
}
261298
}));

0 commit comments

Comments
 (0)