Skip to content

Commit

Permalink
fix(pkg): fix gcc version from builder images setter.
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
  • Loading branch information
FedeDP authored and EXONER4TED committed Mar 24, 2023
1 parent 197a3a9 commit ee18ba2
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions pkg/driverbuilder/builder/builders.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,31 +185,31 @@ func (b *Build) setGCCVersion(builder Builder, kr kernelrelease.KernelRelease) {
image, ok := b.Images.findImage(b.TargetType, targetGCC)
if ok {
b.GCCVersion = image.GCCVersion.String()
}

// Step 2:
// Build the list of "proposed" GCC versions,
// that is, the list of available gccs from images
// for each builder image
proposedGCCs := make([]semver.Version, 0)
for _, img := range b.Images {
proposedGCCs = append(proposedGCCs, img.GCCVersion)
logger.WithField("image", img.Name).
WithField("targetGCC", targetGCC.String()).
Debug("proposedGCC=", img.GCCVersion.String())
}
} else {
// Step 2:
// Build the list of "proposed" GCC versions,
// that is, the list of available gccs from images
// for each builder image
proposedGCCs := make([]semver.Version, 0)
for _, img := range b.Images {
proposedGCCs = append(proposedGCCs, img.GCCVersion)
logger.WithField("image", img.Name).
WithField("targetGCC", targetGCC.String()).
Debug("proposedGCC=", img.GCCVersion.String())
}

// Now, sort versions and fetch
// the nearest gcc, that is also < targetGCC
semver.Sort(proposedGCCs)
lastGCC := proposedGCCs[0]
for _, gcc := range proposedGCCs {
if gcc.GT(targetGCC) {
break
// Now, sort versions and fetch
// the nearest gcc, that is also < targetGCC
semver.Sort(proposedGCCs)
lastGCC := proposedGCCs[0]
for _, gcc := range proposedGCCs {
if gcc.GT(targetGCC) {
break
}
lastGCC = gcc
}
lastGCC = gcc
b.GCCVersion = lastGCC.String()
}
b.GCCVersion = lastGCC.String()
logger.WithField("targetGCC", targetGCC.String()).
Debug("foundGCC=", b.GCCVersion)
}
Expand Down

0 comments on commit ee18ba2

Please sign in to comment.