summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: b2bae44f5de0fccdd16a7b295ad209885096e385 (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
# Maintainer: Mahdi Sarikhani <mahdisarikhani@outlook.com>
# Contributor: Michael Asher <michael at we solve everything dot com>
# Contributor: Stephen304

pkgname=crowdsec
pkgver=1.8.1
pkgrel=1
pkgdesc="The open-source and collaborative security suite"
arch=('aarch64' 'x86_64')
url="https://www.crowdsec.net"
license=('MIT')
depends=('bash' 'glibc' 'libgcc' 'libstdc++' 're2')
makedepends=('git' 'go')
backup=(etc/crowdsec/{acquis,config,console,profiles,simulation}.yaml
        etc/crowdsec/{local_api_credentials,online_api_credentials}.yaml
        etc/crowdsec/console/context.yaml
        etc/crowdsec/notifications/{email,file,http,sentinel,slack,splunk}.yaml)
install=crowdsec.install
source=("git+https://github.com/crowdsecurity/crowdsec.git#tag=v${pkgver}")
sha256sums=('7f3560edfb060b85d34c649c01b3666d0e853d1c2ce6f38ecb1e4cc38a277a04')

prepare() {
    cd "${pkgname}"
    sed -i 's|/usr/local/|/usr/|' config/{crowdsec.service,config.yaml}
    sed -i 's|/libexec/|/lib/|' debian/crowdsec-hubupdate.service
}

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"
    make BUILD_VERSION="v${pkgver}" build
}

package() {
    cd "${pkgname}"
    install -Dm755 cmd/crowdsec/crowdsec cmd/crowdsec-cli/cscli -t "${pkgdir}/usr/bin"
    install -Dm600 config/detect.yaml -t "${pkgdir}/var/lib/${pkgname}/data"
    install -Dm644 config/{acquis,console,profiles,simulation}.yaml -t "${pkgdir}/etc/${pkgname}"
    install -Dm600 config/{config,local_api_credentials,online_api_credentials}.yaml -t "${pkgdir}/etc/${pkgname}"
    install -Dm644 config/context.yaml -t "${pkgdir}/etc/${pkgname}/console"
    install -Dm644 config/patterns/* -t "${pkgdir}/etc/${pkgname}/patterns"
    install -Dm755 debian/hubupdate.sh -t "${pkgdir}/usr/lib/${pkgname}"
    install -Dm644 debian/crowdsec.service -t "${pkgdir}/usr/lib/systemd/system"
    install -Dm644 debian/crowdsec-hubupdate.{service,timer} -t "${pkgdir}/usr/lib/systemd/system"
    install -Dm644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"

    for i in email file http sentinel slack splunk; do
        install -Dm551 "cmd/notification-${i}/notification-${i}" -t "${pkgdir}/usr/lib/${pkgname}/plugins"
        install -Dm600 "cmd/notification-${i}/${i}.yaml" -t "${pkgdir}/etc/${pkgname}/notifications"
    done

    install -d "${pkgdir}/etc/${pkgname}/"{acquis.d,hub}

    cmd/crowdsec-cli/cscli completion bash | install -Dm644 /dev/stdin "${pkgdir}/usr/share/bash-completion/completions/cscli"
    cmd/crowdsec-cli/cscli completion fish | install -Dm644 /dev/stdin "${pkgdir}/usr/share/fish/vendor_completions.d/cscli.fish"
    cmd/crowdsec-cli/cscli completion zsh | install -Dm644 /dev/stdin "${pkgdir}/usr/share/zsh/site-functions/_cscli"
}