Skip to content

Commit fb38ac7

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 420720f commit fb38ac7

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
@@ -230,21 +230,58 @@ impl Solver {
230230
next_index,
231231
);
232232
solution_adds.push((pkg_request, package, {
233-
if located_build_ident_with_component.requires_build_from_source {
234-
PackageSource::BuildFromSource {
235-
recipe: repo
236-
.read_recipe(
237-
&located_build_ident_with_component.ident.to_version_ident(),
238-
)
239-
.await?,
233+
match located_build_ident_with_component.ident.build() {
234+
spk_schema::ident_build::Build::Source
235+
if located_build_ident_with_component.requires_build_from_source =>
236+
{
237+
PackageSource::BuildFromSource {
238+
recipe: repo
239+
.read_recipe(
240+
&located_build_ident_with_component.ident.to_version_ident(),
241+
)
242+
.await?,
243+
}
244+
}
245+
spk_schema::ident_build::Build::Source => {
246+
// Not building this from source but just adding the
247+
// source build to the Solution.
248+
PackageSource::Repository {
249+
repo: Arc::clone(repo),
250+
// XXX: Why is this needed?
251+
components: repo
252+
.read_components(located_build_ident_with_component.ident.target())
253+
.await?,
254+
}
240255
}
241-
} else {
242-
PackageSource::Repository {
243-
repo: Arc::clone(repo),
244-
// XXX: Why is this needed?
245-
components: repo
246-
.read_components(located_build_ident_with_component.ident.target())
247-
.await?,
256+
spk_schema::ident_build::Build::Embedded(embedded_source) => {
257+
match embedded_source {
258+
spk_schema::ident_build::EmbeddedSource::Package(
259+
embedded_source_package,
260+
) => {
261+
PackageSource::Embedded {
262+
parent: (**embedded_source_package).clone().try_into()?,
263+
// XXX: Why is this needed?
264+
components: repo
265+
.read_components(
266+
located_build_ident_with_component.ident.target(),
267+
)
268+
.await?
269+
.keys()
270+
.cloned()
271+
.collect(),
272+
}
273+
}
274+
spk_schema::ident_build::EmbeddedSource::Unknown => todo!(),
275+
}
276+
}
277+
spk_schema::ident_build::Build::BuildId(_build_id) => {
278+
PackageSource::Repository {
279+
repo: Arc::clone(repo),
280+
// XXX: Why is this needed?
281+
components: repo
282+
.read_components(located_build_ident_with_component.ident.target())
283+
.await?,
284+
}
248285
}
249286
}
250287
}));

0 commit comments

Comments
 (0)