yay 是一个用于 Arch Linux 用户仓库(AUR)的包管理器。它的全称是 "Yet Another Yaourt",是一款用 Go 语言编写的 AUR 助手工具。yay 可以简化从 AUR 安装、更新和管理软件包的过程,同时支持官方 Arch 仓库的包管理。其功能包括搜索、安装、升级和删除 AUR 包,自动处理依赖关系,并提供与 pacman 类似的用户体验。
通常来说,安装 yay 需要通过终端执行:
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
Bash如果一切顺利,yay 最终会被编译为软件包并通过 pacman 自动安装。
但是在中国大陆,使用这种方式会遇到各种网络问题。
go build -trimpath -mod=readonly -modcacherw -ldflags '-X "main.yayVersion=12.3.5" -X "main.localePath=/usr/share/locale/" -linkmode=external -compressdwarf=false' -buildmode=pie -o yay
go: downloading github.com/Jguer/votar v1.0.0
go: downloading github.com/Jguer/go-alpm/v2 v2.2.2
go: downloading github.com/Morganamilo/go-srcinfo v1.0.0
go: downloading github.com/deckarep/golang-set/v2 v2.6.0
go: downloading github.com/leonelquinteros/gotext v1.5.2
go: downloading golang.org/x/sys v0.18.0
go: downloading github.com/Jguer/aur v1.2.3
go: downloading github.com/Morganamilo/go-pacmanconf v0.0.0-20210502114700-cff030e927a5
go: downloading golang.org/x/term v0.18.0
go: downloading github.com/adrg/strutil v0.3.1
go: downloading github.com/hashicorp/go-multierror v1.1.1
clean.go:8:2: github.com/Jguer/aur@v1.2.3: Get "https://proxy.golang.org/github.com/%21jguer/aur/@v/v1.2.3.zip": dial tcp 142.251.42.241:443: i/o timeout
cmd.go:11:2: github.com/Jguer/go-alpm/v2@v2.2.2: Get "https://proxy.golang.org/github.com/%21jguer/go-alpm/v2/@v/v2.2.2.zip": dial tcp 142.251.42.241:443: i/o timeout
vote.go:8:2: github.com/Jguer/votar@v1.0.0: Get "https://proxy.golang.org/github.com/%21jguer/votar/@v/v1.0.0.zip": dial tcp 142.251.42.241:443: i/o timeout
pkg/text/errors.go:3:8: github.com/leonelquinteros/gotext@v1.5.2: Get "https://proxy.golang.org/github.com/leonelquinteros/gotext/@v/v1.5.2.zip": dial tcp 142.251.42.241:443: i/o timeout
pkg/db/ialpm/alpm.go:11:2: github.com/Morganamilo/go-pacmanconf@v0.0.0-20210502114700-cff030e927a5: Get "https://proxy.golang.org/github.com/%21morganamilo/go-pacmanconf/@v/v0.0.0-20210502114700-cff030e927a5.zip": dial tcp 142.251.42.241:443: i/o timeout
pkg/intrange/intrange.go:8:2: github.com/deckarep/golang-set/v2@v2.6.0: Get "https://proxy.golang.org/github.com/deckarep/golang-set/v2/@v/v2.6.0.zip": dial tcp 142.251.42.241:443: i/o timeout
pkg/query/metric.go:7:2: github.com/adrg/strutil@v0.3.1: Get "https://proxy.golang.org/github.com/adrg/strutil/@v/v0.3.1.zip": dial tcp 142.251.42.241:443: i/o timeout
pkg/query/query_builder.go:13:2: github.com/adrg/strutil@v0.3.1: Get "https://proxy.golang.org/github.com/adrg/strutil/@v/v0.3.1.zip": dial tcp 142.251.42.241:443: i/o timeout
pkg/query/source.go:7:2: github.com/hashicorp/go-multierror@v1.1.1: Get "https://proxy.golang.org/github.com/hashicorp/go-multierror/@v/v1.1.1.zip": dial tcp 142.251.42.241:443: i/o timeout
pkg/dep/dep_graph.go:10:2: github.com/Morganamilo/go-srcinfo@v1.0.0: Get "https://proxy.golang.org/github.com/%21morganamilo/go-srcinfo/@v/v1.0.0.zip": dial tcp 142.251.42.241:443: i/o timeout
pkg/runtime/runtime.go:20:2: github.com/Jguer/aur@v1.2.3: Get "https://proxy.golang.org/github.com/%21jguer/aur/@v/v1.2.3.zip": dial tcp 142.251.42.241:443: i/o timeout
pkg/runtime/runtime.go:21:2: github.com/Jguer/aur@v1.2.3: Get "https://proxy.golang.org/github.com/%21jguer/aur/@v/v1.2.3.zip": dial tcp 142.251.42.241:443: i/o timeout
pkg/runtime/pacman.go:10:2: golang.org/x/term@v0.18.0: Get "https://proxy.golang.org/golang.org/x/term/@v/v0.18.0.zip": dial tcp 142.251.42.241:443: i/o timeout
print.go:16:2: golang.org/x/sys@v0.18.0: Get "https://proxy.golang.org/golang.org/x/sys/@v/v0.18.0.zip": dial tcp 142.251.42.241:443: i/o timeout
make: *** [Makefile:114:yay] 错误 1
==> 错误: 在 build() 中发生一个错误。
正在放弃...
Plaintext通过直接设置 GoProxy(go env -w GOPROXY=https://goproxy.cn,direct
……)不会对 makepkg 生效,这时候我们需要打开文件夹下的 PKGBUILD 文件,找到 build()
函数,在其多条 export 语句下添加:
build() {
export GOPATH="$srcdir"/gopath
export CGO_CPPFLAGS="${CPPFLAGS}"
export CGO_CFLAGS="${CFLAGS}"
export CGO_CXXFLAGS="${CXXFLAGS}"
export CGO_LDFLAGS="${LDFLAGS}"
export CGO_ENABLED=1
export GO111MODULE=on
export GOPROXY=https://goproxy.cn
cd "$srcdir/$pkgname-$pkgver"
make VERSION=$pkgver DESTDIR="$pkgdir" PREFIX="/usr" build
}
Bash成功解决问题。
感谢!
搞定,多谢
感谢,解决了
非常感谢!