diff --git a/cmd/firmware-action/recipes/recipes.go b/cmd/firmware-action/recipes/recipes.go index c61599cc..6a90d22e 100644 --- a/cmd/firmware-action/recipes/recipes.go +++ b/cmd/firmware-action/recipes/recipes.go @@ -106,7 +106,15 @@ func Build( queueMutex.Unlock() return nil, nil } - _, err = dependencyForest.DescendantsFlow(target, nil, flowCallback) + + // Create a subgraph with target as the only root + // Having multiple roots will result in miscalculation inside DescendantsFlow channel size calculation + pruned, rootID, err := dependencyForest.GetDescendantsGraph(target) + if err != nil { + return nil, err + } + + _, err = pruned.DescendantsFlow(rootID, nil, flowCallback) if err != nil { return nil, err } diff --git a/cmd/firmware-action/recipes/recipes_test.go b/cmd/firmware-action/recipes/recipes_test.go index b72b87e1..be17b760 100644 --- a/cmd/firmware-action/recipes/recipes_test.go +++ b/cmd/firmware-action/recipes/recipes_test.go @@ -207,6 +207,43 @@ func TestBuild(t *testing.T) { recursive: false, config: testConfigDependencyHell, }, + { + name: "dependency clusterfuck - middle", + wantErr: nil, + target: "milk", + recursive: false, + config: testConfigDependencyHell, + }, + { + name: "two leaves and one root", + wantErr: nil, + target: "stitch", + recursive: false, + config: Config{ + Edk2: map[string]Edk2Opts{ + "edk2-build-a": {Depends: []string{}}, + "edk2-build-b": {Depends: []string{}}, + }, + FirmwareStitching: map[string]FirmwareStitchingOpts{ + "stitch": {Depends: []string{"edk2-build-a"}}, + }, + }, + }, + { + name: "one root and two leaves", + wantErr: nil, + target: "stitch-a", + recursive: false, + config: Config{ + Edk2: map[string]Edk2Opts{ + "edk2-build": {Depends: []string{}}, + }, + FirmwareStitching: map[string]FirmwareStitchingOpts{ + "stitch-a": {Depends: []string{"edk2-build"}}, + "stitch-b": {Depends: []string{"edk2-build"}}, + }, + }, + }, } const interactive = false