fix(installer): Fix the same pkgbase being built multiple times on error (#2561)

fix(installer): Fixes the same pkgbase being built multiple times on error

The previous fix commit ec837c8 failed to address the case where the
build fails, as packages are only added to builtPkgDests on a successful
build. This commit addresses this by adding the package to the map earlier.

Fixes #2560.
This commit is contained in:
Ferdinand Bachmann 2025-04-29 22:45:10 +02:00 committed by GitHub
parent ff176c0dd2
commit 95fc0938fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 4 deletions

View File

@ -240,6 +240,7 @@ func (installer *Installer) installAURPackages(ctx context.Context,
installer.log.Debugln("building pkgbase", base, "package", name)
pkgdests, errMake = installer.buildPkg(ctx, dir, base,
installIncompatible, cmdArgs.ExistsArg("needed"), aurOrigTargetBases.Contains(base))
builtPkgDests[base] = pkgdests
if errMake != nil {
if !lastLayer {
return fmt.Errorf("%s - %w", gotext.Get("error making: %s", base), errMake)
@ -249,8 +250,6 @@ func (installer *Installer) installAURPackages(ctx context.Context,
installer.log.Errorln(gotext.Get("error making: %s", base), "-", errMake)
continue
}
builtPkgDests[base] = pkgdests
}
if len(pkgdests) == 0 {

View File

@ -612,8 +612,18 @@ func TestInstaller_CompileFailed(t *testing.T) {
failed, err := installer.CompileFailedAndIgnored()
if tc.wantErrCompile {
require.Error(td, err)
assert.ErrorContains(td, err, "yay")
assert.Len(t, failed, len(tc.targets))
for key := range failed {
assert.ErrorContains(td, err, key)
}
uniqueBases := make(map[string]struct{})
for _, layer := range tc.targets {
for _, info := range layer {
if info.AURBase != nil {
uniqueBases[*info.AURBase] = struct{}{}
}
}
}
require.Len(td, failed, len(uniqueBases))
} else {
require.NoError(td, err)
}