# Maintainer: Tobias Reisinger <tobias@msrg.cc>
pkgname=emgauwa-core-testing
pkgver=0.3.0
pkgrel=1
epoch=
pkgdesc=""
arch=('x86_64' 'armv6h'  'armv7h' 'aarch64')
url="https://git.serguzim.me/emgauwa/core"
license=('unknown')
groups=()
depends=('glibc' 'sqlite')
makedepends=('make' 'cmake' 'gcc' 'vim')
conflicts=('emgauwa-core')
backup=('etc/emgauwa/core.ini')
source=("https://git.serguzim.me/emgauwa/core/archive/testing-v$pkgver.tar.gz"
        "core.ini"
        "emgauwa-core-testing.service"
        "emgauwa-core-testing.sysusers"
        "emgauwa-core-testing.tmpfiles")
sha256sums=('6fb8f24faf4dc60b83bcae88fa63b1a71888b954f6ac57729b86878e9f250f43'
            '210c8a05bae65e5f19c0c168b0f8c63d064706a9e7885a22a57ca7b04ea4e00f'
            'c781f4d50da8e158551a47a8549981dad05faaf2d632c4fde8b36b48474ab0ec'
            'b9cde58b9e9b0605ca4a1eddd78067c55aa3c8d40f80cde0a25c4da9f6f95798'
            '76f7d12b56efbdb06eb14ac758da2daa4ca9f2c6449a0103db6aeab22ed93cd8')

prepare() {
    cd "core"
    mkdir -p "build"
}

build() {
    cd "core/build" || exit 1
    cmake ..
    make
}

package() {
    install -Dm755 "core/build/core"            "${pkgdir}/usr/bin/emgauwa-core"

    install -Dm600 "core.ini"                   "${pkgdir}/etc/emgauwa/core.ini"
    install -Dm644 "${pkgname}.service"         "${pkgdir}/usr/lib/systemd/system/${pkgname}.service"
    install -Dm644 "${pkgname}.tmpfiles"        "${pkgdir}/usr/lib/tmpfiles.d/${pkgname}.conf"
    install -Dm644 "${pkgname}.sysusers"        "${pkgdir}/usr/lib/sysusers.d/${pkgname}.conf"
    
    install -Ddm750                             "${pkgdir}/var/lib/emgauwa"
    install -Ddm750                             "${pkgdir}/var/lib/emgauwa/core"
}