Jguer / yay

Yet another Yogurt - An AUR Helper written in Go
GNU General Public License v3.0
11.23k stars 364 forks source link

fix(installer): Fixes the same pkgbase being built multiple times #2534

Closed Ferdi265 closed 3 days ago

Ferdi265 commented 4 days ago

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 PR fixes this by keeping track of the pkgdests built by buildPkg() and avoiding rebuilds of the same pkgbase in the same yay invocation.

Fixes #2340.

Ferdi265 commented 4 days ago

Just noticed this still has test failures locally, will fix those.

It appears I broke something related to installing built packages, marking this as a draft until that is fixed.

Broken tests as of d2837e1: ``` --- FAIL: TestIntegrationLocalInstall (0.00s) --- FAIL: TestIntegrationLocalInstallNeeded (0.00s) --- FAIL: TestIntegrationLocalInstallGenerateSRCINFO (0.00s) --- FAIL: TestIntegrationLocalInstallWithDepsProvides (0.00s) --- FAIL: TestIntegrationLocalInstallTwoSrcInfosWithDeps (0.00s) --- FAIL: TestSyncUpgradeAURPinnedSplitPackage (0.01s) --- FAIL: TestInstaller_KeepSrc (0.00s) --- FAIL: TestInstaller_KeepSrc/--keepsrc (0.00s) --- FAIL: TestInstaller_InstallNeeded (0.01s) --- FAIL: TestInstaller_InstallNeeded/not_installed_and_not_built (0.00s) --- FAIL: TestInstaller_InstallNeeded/not_installed_and_built (0.00s) --- FAIL: TestInstaller_InstallSplitPackage (0.01s) --- FAIL: TestInstaller_InstallSplitPackage/jellyfin (0.01s) --- FAIL: TestInstaller_InstallRebuild (0.01s) --- FAIL: TestInstaller_InstallRebuild/--norebuild(default)_when_built_and_not_installed (0.00s) --- FAIL: TestInstaller_InstallRebuild/--rebuild_when_built_and_not_installed (0.00s) --- FAIL: TestInstaller_InstallRebuild/--rebuild_when_built_and_installed (0.00s) --- FAIL: TestInstaller_InstallRebuild/--rebuild_when_built_and_installed_previously_as_dep (0.00s) --- FAIL: TestInstaller_CompileFailed (0.01s) --- FAIL: TestInstaller_CompileFailed/one_layer_--_fail_install (0.00s) --- FAIL: TestInstaller_InstallMixedSourcesAndLayers (0.01s) --- FAIL: TestInstaller_InstallMixedSourcesAndLayers/same_layer_--_different_sources (0.00s) --- FAIL: TestInstaller_InstallMixedSourcesAndLayers/different_layer_--_different_sources (0.00s) --- FAIL: TestInstaller_InstallMixedSourcesAndLayers/same_layer_--_aur (0.00s) --- FAIL: TestInstaller_InstallMixedSourcesAndLayers/different_layer_--_aur (0.00s) ```
Ferdi265 commented 4 days ago

Fixed accidently shadowing the pkgdests variable in d9e17f9. This caused installing built packages to be broken, which is now fixed.

Broken tests as of d9e17f9: ``` --- FAIL: TestIntegrationLocalInstall (0.00s) --- FAIL: TestIntegrationLocalInstallNeeded (0.00s) --- FAIL: TestIntegrationLocalInstallGenerateSRCINFO (0.00s) --- FAIL: TestSyncUpgradeAURPinnedSplitPackage (0.01s) --- FAIL: TestInstaller_InstallSplitPackage (0.00s) --- FAIL: TestInstaller_InstallSplitPackage/jellyfin (0.00s) ```
Ferdi265 commented 4 days ago

The test changes in 5064027 only update the list of expected commands for building split packages, since some redundant invocations of makepkg have been removed by the changes in this PR.

Broken tests as of 5064027: all green :+1:

Ferdi265 commented 4 days ago

Fixed another issue in a26822f: Previously, whether a pkgbase was built was considered part of installer.origTargets was dependent on the order of the packages. This wasn't as big of an issue before this PR since at least one of the buildPkg() invocations passed the correct value of isTarget to buildPkg(). d9e17f9 changed this to only a single invocation of buildPkg() per pkgbase, so now the isTarget argument has to be correct for the first (and only) invocation. Fixed this by tracking which pkgbases are part of installer.origTargets in handleLayer() and passing that to installAURPackages().

Jguer commented 3 days ago

:+1: let's get some feedback from yay-git