summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a049512f32ffd4bac54ed575814623a12e69b861 (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
# Maintainer: Tony Lambiris <tony@libpcap.net>

pkgname=ghw-git
pkgver=v0.5.0.r1.g8b49aea
pkgrel=1
pkgdesc="Golang hardware discovery/inspection library"
arch=('x86_64')
url="https://github.com/jaypipes/ghw"
license=('Apache')
makedepends=('go>=1.10' 'git')
conflicts=('ghw')
provides=('ghw')
source=("${pkgname}::git+${url}")
sha256sums=('SKIP')

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

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

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

	install -m755 -d "${srcdir}/go/src/github.com/jaypipes/"
	ln -sf "${srcdir}/${pkgname}" "${srcdir}/go/src/github.com/jaypipes/ghw"

	cd "${srcdir}/go/src/github.com/jaypipes/ghw"

	GOROOT="/usr/lib/go" GOPATH="${srcdir}/go" \
	go get -v -d ./...
}

build() {
	cd "${srcdir}/go/src/github.com/jaypipes/ghw"

	mkdir -p build

	GOROOT="/usr/lib/go" GOPATH="${srcdir}/go" \
	go build \
		-ldflags "-s -w" \
		-gcflags="all=-trimpath=${GOPATH}/src" \
		-asmflags="all=-trimpath=${GOPATH}/src" \
		-o build/ghwc ./cmd/ghwc
}

package() {
	cd "${srcdir}/go/src/github.com/jaypipes/ghw"

	install -Dm755 "./build/ghwc" "${pkgdir}/usr/bin/ghwc"
}