forked from BlackArch/blackarch-pkgbuilds
-
Notifications
You must be signed in to change notification settings - Fork 1
/
PKGBUILD-go
53 lines (44 loc) · 1.48 KB
/
PKGBUILD-go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.
pkgname=NAME
pkgver=VERSION
pkgrel=1
pkgdesc='Short description without using the package name itself.'
arch=('x86_64' 'aarch64')
groups=('blackarch' MORE_BLACKARCH_GROUPS_HERE)
url='URL pointing to download section of package'
license=('WHATEVER' OR 'custom:unknown')
depends=()
makedepends=('git' 'go')
source=("git+https://github.com/foo/$pkgname.git")
sha512sums=('')
pkgver() {
cd $pkgname
# use, if no version string provided neither in sources nor in git describe:
echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
# if tag exists, use this
git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}
build() {
cd $pkgname
# If you encounter the error: go mod download: no modules specified (see 'go help mod download')
# while building, then uncomment the following lines:
# GOPATH="$srcdir" go mod init go.mod
# GOPATH="$srcdir" go mod tidy
GOPATH="$srcdir" go mod download
GOPATH="$srcdir" go build \
-trimpath \
-buildmode=pie \
-mod=readonly \
-modcacherw \
-ldflags "-s -w" \
-o $pkgname .
}
package() {
cd $pkgname
install -Dm 755 $pkgname "$pkgdir/usr/bin/$pkgname"
install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
# Only install license if required according to
# https://wiki.archlinux.org/index.php/PKGBUILD#license
install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}