fix(shellyctl): align PKGBUILD with Arch Go package guidelines
- Add prepare() with GOPATH and go mod download for reproducible builds
- Remove redundant CLI flags from go build, rely on GOFLAGS export
- Add GOPATH="${srcdir}" to build() as recommended by guidelines
- Add check() function running go test
- Fix license file permissions from 0755 to 0644
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -15,6 +15,19 @@ source=(
|
||||
sha512sums=('2c19275204461c0449f4e638cbde8722a0387b147eaa77e2091d160b8c1233d061170ff3600293d116d1740166dacac3cc3ce79549f4558ed8adc5eb45efe224')
|
||||
b2sums=('a525fc326b8435c936798214911417cca29251062aa968753d0f2f68eee188e66bf5dca16489cb7fd51818389e931e3d9cdf67376968255ab008a602982845a0')
|
||||
|
||||
prepare() {
|
||||
cd "$pkgname-$pkgver"
|
||||
|
||||
export GONOSUMDB="${GONOSUMDB}"
|
||||
export GOPATH="${srcdir}"
|
||||
export GOPROXY="${GOPROXY}"
|
||||
|
||||
# INFO: Print all Go related environment variables for debugging purposes.
|
||||
env | sort | grep -E '^C?GO'
|
||||
|
||||
go mod download -modcacherw
|
||||
}
|
||||
|
||||
build() {
|
||||
cd "$pkgname-$pkgver"
|
||||
|
||||
@@ -23,16 +36,15 @@ build() {
|
||||
export CGO_CFLAGS="${CFLAGS}"
|
||||
export CGO_CXXFLAGS="${CXXFLAGS}"
|
||||
export CGO_LDFLAGS="${LDFLAGS}"
|
||||
export GOPATH="${srcdir}"
|
||||
export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw"
|
||||
|
||||
go build -v \
|
||||
-trimpath \
|
||||
-buildmode=pie \
|
||||
-mod=readonly \
|
||||
-modcacherw \
|
||||
-ldflags "-linkmode external -extldflags \"${LDFLAGS}\"" \
|
||||
-o $pkgname \
|
||||
.
|
||||
go build -o $pkgname .
|
||||
}
|
||||
|
||||
check() {
|
||||
cd "$pkgname-$pkgver"
|
||||
go test ./...
|
||||
}
|
||||
|
||||
package() {
|
||||
@@ -40,5 +52,5 @@ package() {
|
||||
install -D --mode 0755 --target-directory "$pkgdir/usr/bin" "$pkgname-$pkgver/$pkgname"
|
||||
|
||||
# license
|
||||
install -D --mode 0755 --target-directory "$pkgdir/usr/share/licenses/$pkgname" "$pkgname-$pkgver/LICENSE.md"
|
||||
install -D --mode 0644 --target-directory "$pkgdir/usr/share/licenses/$pkgname" "$pkgname-$pkgver/LICENSE.md"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user