summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: cc9c13fed8bcd730158e91154c90f2abf7e51b36 (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
# Maintainer: Daniel Bermond <dbermond@archlinux.org>

pkgname=earthly-git
pkgver=0.6.15.r2.g07a81ee2
pkgrel=1
pkgdesc='A build automation tool that executes in containers (git version)'
arch=('x86_64')
url='https://earthly.dev/'
license=('MPL2')
depends=('docker')
makedepends=('git' 'go')
provides=('earthly')
conflicts=('earthly')
BUILDENV+=('!check')
source=('git+https://github.com/earthly/earthly.git')
sha256sums=('SKIP')

prepare() {
    mkdir -p earthly/build
}

pkgver() {
    git -C earthly describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g;s/^v//;s/\.rc/rc/'
}

build() {
    local _ldflags='-linkmode=external'
    _ldflags+=' -X main.DefaultBuildkitdImage=docker.io/earthly/buildkitd:latest'
    _ldflags+=' -X main.Version=latest'
    _ldflags+=" -X main.GitSha=$(git -C earthly rev-parse HEAD)"
    local _tags='dfrunmount,dfrunsecurity,dfsecrets,dfssh,dfrunnetwork,dfheredoc'
    export CGO_CPPFLAGS="$CPPFLAGS"
    export CGO_CFLAGS="$CFLAGS"
    export CGO_CXXFLAGS="$CXXFLAGS"
    export CGO_LDFLAGS="$LDFLAGS"
    export GOFLAGS='-buildmode=pie -trimpath -mod=readonly -modcacherw'
    cd earthly
    go build -tags "$_tags" -ldflags "$_ldflags" -o build ./cmd/...
}

check() {
    cd earthly
    go test ./...
}

package() {
    install -D -m755 earthly/build/earthly -t "${pkgdir}/usr/bin"
}