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

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

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

	git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g;s/^v//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"

    export GOPATH="${srcdir}/go" GOFLAGS="-modcacherw"
    go get -v -t ./...
}

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

    mkdir -p build

    export CGO_ENABLED=0
    export GOPATH="${srcdir}/go" GOFLAGS="-modcacherw"
    go build \
		-trimpath -ldflags "-s -w" \
		-o ./build/ghwc ./cmd/ghwc
}

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

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