Jguer / yay

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

yay -Bi destroys the PKGBUILD when cleanbuilding #2449

Open Makrennel opened 5 months ago

Makrennel commented 5 months ago

Affected Version

yay v12.3.5 - libalpm v14.0.0

Describe the bug

When using yay -Bi ./ to build a local PKGBUILD in the current directory, if the user selects to cleanbuild all packages yay errors out saying that PKGBUILD does not exist and when you check the current directory the PKGBUILD will have disappeared.

Reproduction Steps

  1. Create a custom PKGBUILD in a local directory
  2. Change to that directory
  3. Run yay -Bi ./
  4. select "a" on Packages to cleanBuild?

Expected behavior

Do not destroy the PKGBUILD, and cleanbuild all the dependencies required for installation.

Output

yay -Bi ./
SRCINFO Explicit (1): illogical-impulse-pymc-aur-meta-1.0-1
  1 illogical-impulse-pymc-aur-meta          (Installed) (Build Files Exist)
==> Packages to cleanBuild?
==> [N]one [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)
==> a
:: Deleting (1/1): ./
HEAD is now at e5339a1 hyprlock: use xdg dir properly (#549)
Refusing to remove current working directory
Removing ./PKGBUILD
Removing ./.SRCINFO
  1 illogical-impulse-pymc-aur-meta          (Installed) (Build Files Exist)
==> Diffs to show?
==> [N]one [A]ll [Ab]ort [I]nstalled [No]tInstalled or (1 2 3, 1-3, ^4)
==> n
==> ERROR: PKGBUILD does not exist.
 -> error downloading sources: ./ 
    context: exit status 12 

:: (1/1) Parsing SRCINFO: illogical-impulse-pymc-aur-meta
 -> failed to parse illogical-impulse-pymc-aur-meta: Unable to read file: .SRCINFO: open .SRCINFO: no such file or directorygoroutine 1 [running]:
runtime/debug.Stack()
    runtime/debug/stack.go:24 +0x5e
main.main.func2()
    github.com/Jguer/yay/v12/main.go:125 +0x45
panic({0x636715ebf6c0?, 0xc000302100?})
    runtime/panic.go:770 +0x132
github.com/Jguer/yay/v12/pkg/sync/srcinfo.NewService({0x636715f400f0, 0xc00012c240}, 0xc000142200, 0xc000322000, {0x636715f3da78, 0xc0000f6480}, {0x636715f3ca50, 0xc00007f740}, 0xc00030c450)
    github.com/Jguer/yay/v12/pkg/sync/srcinfo/service.go:37 +0x1c7
github.com/Jguer/yay/v12/pkg/sync.(*OperationService).Run(0xc00030c240, {0x636715f3b850, 0x636716234c00}, 0xc000129420, 0xc00014dc50, {0xc000304028, 0x1, 0x1}, {0x636716234c00, 0x0, ...})
    github.com/Jguer/yay/v12/pkg/sync/sync.go:74 +0xdbf
main.installLocalPKGBUILD({0x636715f3b850, 0x636716234c00}, 0xc000129420, 0xc00014dc50, {0x636715f400f0, 0xc00012c240})
    github.com/Jguer/yay/v12/local_install.go:103 +0x94e
main.handleBuild({0x636715f3b850, 0x636716234c00}, 0xc000129420, {0x636715f400f0, 0xc00012c240}, 0xc00014dc50)
    github.com/Jguer/yay/v12/cmd.go:333 +0x113
main.handleCmd({0x636715f3b850, 0x636716234c00}, 0xc000129420, 0xc00014dc50, {0x636715f400f0, 0xc00012c240})
    github.com/Jguer/yay/v12/cmd.go:174 +0x36f
main.main()
    github.com/Jguer/yay/v12/main.go:131 +0x69f
jdholtz commented 4 months ago

Can you provide a public repo that you can reproduce this issue in by cloning and installing it manually? I tried with the cmatrix repo and I didn't run into this issue

Makrennel commented 4 months ago

Can you provide a public repo that you can reproduce this issue in by cloning and installing it manually? I tried with the cmatrix repo and I didn't run into this issue

Now that I look further into it, this appears to be primarily a problem with meta packages. Normal packages do not seem to have this issue, but for example base-devel does.

Also, it appears it will reset to the git HEAD branch if the directory is part of a git repository – if you run the command in a directory which is not in a git repository it will nuke the PKGBUILD from existence as mentioned.