summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 745346ae0f4c8bde54fd86e0eb1bb1b488359416 (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
# $Id$
# Maintainer: Philipp Marmet
# Contributor: Joe Julian

pkgname=mgmt
pkgver=0.0.26
pkgrel=2
epoch=1
pkgdesc='Next generation config management.'
arch=('x86_64' 'i686' 'armv6h' 'armv7h')
pkggopath='github.com/purpleidea/mgmt'
url="https://${pkggopath}"
license=('GPL3')
makedepends=('augeas' 'go' 'go-md2man' 'go-tools' 'libpcap' 'libvirt' 'rubygems' 'ragel')
depends=('augeas' 'libvirt')
# don't strip binaries! A sha1 is used to check binary consistency.
options=('!strip')
backup=("etc/${pkgname}/${pkgname}.conf")

source=("${pkgname}-${pkgver}.tar.gz"::"${url}/archive/refs/tags/${pkgver}.tar.gz"
        'mgmt.service')
sha256sums=('19d4cfb33c7c13b26b8088baac2d91471ac6839226d211b9cec85ddc575da392'
            'eeb4174a8556161b94f62808b4453ef91574797070ada53ffb90cb013aff9799')

prepare() {
    # extract tarball to path expected by go
    mkdir -p "${srcdir}/src/${pkggopath}"
    cd "${srcdir}/${pkgname}-${pkgver}"

    git submodule --quiet update --init --recursive
    git archive --prefix="${pkggopath}/" --format="tar" HEAD | tar xf - -C "${srcdir}/src"
    git submodule foreach 'git archive --prefix="${path}/" --format="tar" HEAD | tar xvf - -C "'${srcdir}'/src/'${pkggopath}'"'

    # fetch dependencies
    export GOPATH="${srcdir}"
    export PATH=${GOPATH}/bin:${PATH}
    cd "${srcdir}/src/${pkggopath}"
    msg2 'installing go dependencies'
    go install github.com/blynn/nex@latest
    go install golang.org/x/tools/cmd/goyacc@latest         # formerly `go tool yacc`
    go install golang.org/x/tools/cmd/stringer@latest       # for automatic stringer-ing
    go install golang.org/x/lint/golint@latest              # for `golint`-ing
    go install golang.org/x/tools/cmd/goimports@latest      # for fmt
    go install github.com/dvyukov/go-fuzz/go-fuzz@latest    # for fuzzing the mcl lang bits

}

build() {
    export GOPATH="${srcdir}"
    export PATH=${GOPATH}/bin:${PATH}:/usr/lib/go/pkg/tool/linux_amd64
    cd "${srcdir}/${pkgname}-${pkgver}"
    go mod tidy
    make VERSION="${pkgver}" SVERSION="${pkgver}" PROGRAM="${pkgname}"
}

package() {
    msg2 'installing files'
    install -Dm644 "mgmt.service" "${pkgdir}/usr/lib/systemd/system/mgmt.service"

    cd "${srcdir}/${pkgname}-${pkgver}"
    install -Dm755 "${pkgname}" "${pkgdir}/usr/bin/${pkgname}"
    install -Dm644 "misc/bashrc.sh" "${pkgdir}/usr/share/bash-completion/completions/${pkgname}"
    install -Dm644 "misc/example.conf" "${pkgdir}/etc/${pkgname}/${pkgname}.conf"
}