summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 0c173798d48d4f3d5cf7069f88d9fc202967c8b6 (plain)
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
53
54
55
56
57
58
59
60
61
# Maintainer: Tony Lambiris <tony@libpcap.net>

pkgname=virusgotal-git
pkgver=1.0.2.r5.g295d2dc
pkgrel=5
pkgdesc="VirusTotal zero dependency command line client."
arch=('x86_64')
url="https://github.com/moldabekov/virusgotal"
license=('MIT')
depends=()
makedepends=('go' 'git')
optdepends=()
provides=("${pkgname%-git}")
conflicts=("${pkgname%-git}")
source=("${pkgname}::git+${url}")
sha256sums=('SKIP')

pkgver() {
	cd "${srcdir}/${pkgname}"

	git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g;s/^v//g'
}

prepare() {
	cd "${srcdir}/${pkgname}"

	mkdir -p "${srcdir}/go/src/github.com/moldabekov"
	ln -sf "${srcdir}/${pkgname}" "${srcdir}/go/src/github.com/moldabekov/virusgotal"

	cd "${srcdir}/go/src/github.com/moldabekov/virusgotal"
	export GOPATH="${srcdir}/go" GOFLAGS="-modcacherw"

	if ! go get -v -t ./...; then
	test -f "go.mod" || go mod init

	sed -i -e '/.*kingpin.v2/c\\t"github.com/alecthomas/kingpin/v2"' main.go
	go mod tidy

	GO111MODULE=auto go get \
		github.com/alecthomas/kingpin/v2 \
		github.com/fatih/color \
		github.com/moldabekov/spinner
	fi
}

build() {
	cd "${srcdir}/go/src/github.com/moldabekov/virusgotal"

	mkdir -p build

	export GOPATH="${srcdir}/go" GOFLAGS="-modcacherw"
	go build -trimpath -ldflags "-s -w" \
		-o build/virusgotal
}

package() {
	cd "${srcdir}/go/src/github.com/moldabekov/virusgotal"

	install -Dm755 "build/virusgotal" "${pkgdir}/usr/bin/virusgotal"
	install -Dm644 "LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}