Skip to content

Commit

Permalink
fix(installer): Fixes the same pkgbase being built multiple times
Browse files Browse the repository at this point in the history
When building a PKGBUILD pkgbase with multiple pkgnames,
installAURPackages() invokes buildPkg() multiple times for the same
pkgbase. This causes prepare() to be run multiple times for the same
pkgbase, since detection of already built packages happens after
prepare().

Additionally, detection of already built packages can fail if the split
debug packages are enabled and the package does not contain any
binaries, causing no -debug package to be created by makepkg even though
it is listed by makepkg --packagelist.

This commit fixes this by keeping track of the pkgdests built by
buildPkg() and avoiding rebuilds of the same pkgbase in the same yay
invocation.

Fixes Jguer#2340.

Signed-off-by: Ferdinand Bachmann <ferdinand.bachmann@yrlf.at>
  • Loading branch information
Ferdi265 committed Nov 18, 2024
1 parent f100c1d commit d9e17f9
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions pkg/sync/build/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,23 +219,33 @@ func (installer *Installer) installAURPackages(ctx context.Context,
return nil
}

builtPkgDests := make(map[string]map[string]string)
deps, exps := make([]string, 0, aurDepNames.Cardinality()), make([]string, 0, aurExpNames.Cardinality())
pkgArchives := make([]string, 0, len(exps)+len(deps))

for _, name := range all {
base := nameToBase[name]
dir := pkgBuildDirsByBase[base]

pkgdests, errMake := installer.buildPkg(ctx, dir, base,
installIncompatible, cmdArgs.ExistsArg("needed"), installer.origTargets.Contains(name))
if errMake != nil {
if !lastLayer {
return fmt.Errorf("%s - %w", gotext.Get("error making: %s", base), errMake)
pkgdests, ok := builtPkgDests[base]
if ok {
installer.log.Debugln("skipping built pkgbase", base, "package", name)
} else {
var errMake error
installer.log.Debugln("building pkgbase", base, "package", name)
pkgdests, errMake = installer.buildPkg(ctx, dir, base,
installIncompatible, cmdArgs.ExistsArg("needed"), installer.origTargets.Contains(name))
if errMake != nil {
if !lastLayer {
return fmt.Errorf("%s - %w", gotext.Get("error making: %s", base), errMake)
}

installer.failedAndIgnored[name] = errMake
installer.log.Errorln(gotext.Get("error making: %s", base), "-", errMake)
continue
}

installer.failedAndIgnored[name] = errMake
installer.log.Errorln(gotext.Get("error making: %s", base), "-", errMake)
continue
builtPkgDests[base] = pkgdests
}

if len(pkgdests) == 0 {
Expand Down

0 comments on commit d9e17f9

Please sign in to comment.