summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 4da713332f8321fa96060fa2048aeed495c1b17f (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Maintainer: Jason Ozias <jason.g.ozias@gmail.com>

pkgname=bartos
pkgver=1.5.11
pkgrel=1
pkgdesc="Barto central job scheduling server"
arch=('x86_64')
url="https://github.com/rustyhorde/barto"
license=('MIT' 'Apache-2.0')
depends=()
optdepends=('mariadb: local database server'
            'logrotate: periodic cleanup of rotated log files'
            'xz: xz compression of rotated log files')
makedepends=('cargo')
install=bartos.install
source=("$pkgname-$pkgver.tar.gz::https://github.com/rustyhorde/barto/archive/v$pkgver.tar.gz")
sha256sums=('b3d451d59ace506adda572bfbcd93fe9da019cbbbd9e75a79d8c0de8517551dc')

prepare() {
    cd "barto-$pkgver"
    export RUSTUP_TOOLCHAIN=stable
    cargo fetch --locked --target x86_64-unknown-linux-gnu
}

build() {
    cd "barto-$pkgver"
    export RUSTUP_TOOLCHAIN=stable
    export CARGO_TARGET_DIR=target
    export VERGEN_IDEMPOTENT=1
    export SQLX_OFFLINE=true
    cargo build --release --locked --bin bartos
    cargo xtask dist bartos
}

package() {
    cd "barto-$pkgver"

    # Binary
    install -Dm755 "target/release/bartos" "$pkgdir/usr/bin/bartos"

    # Launcher script (reads systemd credentials, exports as env vars)
    install -Dm755 "dist/bartos/bartos-launcher" "$pkgdir/usr/lib/bartos/bartos-launcher"

    # Secrets init helper
    install -Dm755 "packaging/nfpm/scripts/bartos-secrets-init" "$pkgdir/usr/bin/bartos-secrets-init"

    # Migration helper
    install -Dm755 "packaging/nfpm/scripts/barto-migrate" "$pkgdir/usr/bin/barto-migrate"

    # Database migrations
    install -dm755 "$pkgdir/usr/share/bartos/migrations"
    install -m644 migrations/*.sql "$pkgdir/usr/share/bartos/migrations/"

    # Man page
    install -Dm644 "dist/bartos/bartos.1" "$pkgdir/usr/share/man/man1/bartos.1"

    # Shell completions
    install -Dm644 "dist/bartos/bartos.bash" \
        "$pkgdir/usr/share/bash-completion/completions/bartos"
    install -Dm644 "dist/bartos/_bartos" \
        "$pkgdir/usr/share/zsh/site-functions/_bartos"
    install -Dm644 "dist/bartos/bartos.fish" \
        "$pkgdir/usr/share/fish/vendor_completions.d/bartos.fish"

    # Systemd service
    install -Dm644 "dist/bartos/bartos.service" \
        "$pkgdir/usr/lib/systemd/system/bartos.service"

    # Log rotation helper script
    install -Dm755 "dist/bartos/bartos-logrotate" \
        "$pkgdir/usr/lib/bartos/bartos-logrotate"

    # Systemd timer for log rotation
    install -Dm644 "dist/bartos/bartos-logrotate.service" \
        "$pkgdir/usr/lib/systemd/system/bartos-logrotate.service"
    install -Dm644 "dist/bartos/bartos-logrotate.timer" \
        "$pkgdir/usr/lib/systemd/system/bartos-logrotate.timer"

    # Example config
    install -Dm644 "packaging/arch/bartos/examples/bartos.toml.example" \
        "$pkgdir/usr/share/doc/$pkgname/examples/bartos.toml.example"

    # Documentation
    install -Dm644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"

    # Licenses
    install -Dm644 LICENSE-MIT    "$pkgdir/usr/share/licenses/$pkgname/LICENSE-MIT"
    install -Dm644 LICENSE-APACHE "$pkgdir/usr/share/licenses/$pkgname/LICENSE-APACHE"
}