summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 35428b841631af617dc7a2e818544b95d0a3a87d (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
62
63
64
65
66
67
68
69
# Maintainer: fuero <fuerob@gmail.com>
_pkgname=ssh-tpm-agent
_repo_name="${_pkgname}.git"
pkgname="${_pkgname}-git"
# renovate: pkgName=https://github.com/Foxboron/ssh-tpm-agent depName=ssh-tpm-agent-git
pkgver=0.3.1.r9.f1be81b
pkgrel=1
pkgdesc='ssh-agent compatible agent using TPM backed keys'
arch=('x86_64')
url=https://github.com/Foxboron/ssh-tpm-agent
license=('MIT')
depends=('glibc')
makedepends=('go')
#source=("$url/archive/v$pkgver/${_pkgname}-$pkgver.tar.gz")
source=(
	"${_repo_name}::git+${url}"
)
b2sums=('SKIP')

pkgver() {
  cd "${srcdir}/${_repo_name}"
  (
    set -o pipefail
    git describe --long --tags 2> /dev/null | sed "s/^[A-Za-z\.\-]*//;s/\([^-]*-\)g/r\1/;s/-/./g" || 
    printf "r%s.%s\n" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" 
  )
}

_go_build() {
  go build -x -v \
	-buildmode=pie \
	-pkgdir=$(mktemp -d -p $(pwd)) \
	-ldflags "\
		  -linkmode=external \
		  -extldflags '${LDFLAGS}' \
		  -X main.commit=$(git rev-parse --short HEAD) \
		  -X main.date=$(date -u +%Y%m%d.%H%M%S) \
		  -X main.version=$(git describe --always --tags --abbrev=0).$(git rev-parse --short HEAD)\
	         " \
    -o "$1" \
    "$2"
}

build() {
  cd "${srcdir}/${_repo_name}"
  for i in agent keygen add hostkeys
  do
    _go_build "ssh-tpm-${i}.bin" "./cmd/ssh-tpm-${i}"
  done
}

check() {
  cd "${srcdir}/${_repo_name}"
  go test -v ./...
}

package () {
  cd "${srcdir}/${_repo_name}"
  for i in agent keygen add hostkeys
  do
    install -Dm 755 "ssh-tpm-${i}.bin" "${pkgdir}/usr/bin/ssh-tpm-${i}"
  done
  install -Dm 644 "LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

  for _file in *.md
  do
    install -Dm644 "${_file}" "${pkgdir}/usr/share/doc/${pkgname}/$(basename ${_file})"
  done
}