summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 59d66ee1a8f132cda8e7b7193a9b5c0de9a80cd4 (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
70
71
72
73
74
75
# Maintainer: Giorgi Taba K'obakhidze <t@gtk.ge>
# Contributor: Simon Walker <s.r.walker101@googlemail.com>

# https://wiki.archlinux.org/title/VCS_package_guidelines
# https://wiki.archlinux.org/title/Go_package_guidelines
# https://developer.hashicorp.com/terraform/cli/config/config-file#implied-local-mirror-directories

pkgname=({terraform,opentofu}-provider-libvirt-git)
_pkgname="${pkgname%-git}"
pkgver=v0.7.6.r8.gd41792a
pkgrel=9
arch=("x86_64")
url="https://github.com/dmacvicar/${_pkgname}"
license=("Apache")
depends=("libvirt" "cdrtools")
makedepends=("git" "go")
checkdepends=("go")
source=("${_pkgname}::git+${url}")
sha256sums=('SKIP')

pkgver() {
    cd "${_pkgname}"
    git describe --long --tags --abbrev=7 | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
    cd "${_pkgname}"

    export CGO_CPPFLAGS="${CPPFLAGS}"
    export CGO_CFLAGS="${CFLAGS}"
    export CGO_CXXFLAGS="${CXXFLAGS}"
    export CGO_LDFLAGS="${LDFLAGS}"
    export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw"

    unset LDFLAGS
    make
}

check() {
    cd "${_pkgname}"
    make test
}

_package_common() {
    cd "${_pkgname}"

    install -Dm644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"

    install -Dm644 {CHANGELOG,README,docs/migration-13}.md -t "${pkgdir}/usr/share/doc/${pkgname}"
    cp -r website/docs "$pkgdir/usr/share/doc/${pkgname}"
}

package_terraform-provider-libvirt-git() {
    pkgdesc="Provision libvirt machines with terraform"
    provides=("${pkgname%-git}")
    conflicts=("${pkgname%-git}")

    _package_common

    _ver=${pkgver#v}; _ver=${_ver%."${pkgver#*.*.*.}"}
    install -Dm755 "${_pkgname}" \
        -t "${pkgdir}/usr/share/terraform/plugins/registry.terraform.io/dmacvicar/libvirt/${_ver}/linux_amd64"
}

package_opentofu-provider-libvirt-git() {
    pkgdesc="Provision libvirt machines with OpenTofu"
    provides=("${pkgname%-git}")
    conflicts=("${pkgname%-git}")

    _package_common

    _ver=${pkgver#v}; _ver=${_ver%."${pkgver#*.*.*.}"}
    install -Dm755 "${_pkgname}" \
        -t "${pkgdir}/usr/share/terraform/plugins/registry.opentofu.org/dmacvicar/libvirt/${_ver}/linux_amd64"
}