aboutsummarylogtreecommitdiffstats
path: root/PKGBUILD
blob: e533068957aa73bc4978066812241cb920f7a5ae (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
# Maintainer: Techcable <$USERNAME at techcable.net>

# This package is mirored on github at Techcable/archlinux-packages
# PRs and issues welcome

# This package uses precompiled jar files, see README.md for justification

pkgname=dis4irc
pkgver=1.6.2
pkgrel=1
pkgdesc="A modern Discord <-> IRC bridge"
arch=('any') # Java :)
url="https://github.com/zachbr/Dis4IRC"
license=('MIT')
# The downloaded jar is compiled with Java 11
depends=('java-runtime>=11')
# We put the config here
backup=('etc/dis4irc/config.hocon')
options=(!strip)
# We have to change the permissions on /etc/dis4irc/config.hocon
#
# to be writable by the `dis4irc` user, because Sponge's configurate
# modifies the config file
install=dis4irc.install
source=(
    # It's just a github release
    "https://github.com/zachbr/Dis4IRC/releases/download/v${pkgver}/Dis4IRC-${pkgver}.jar"
    # License is required for MIT per the official packaging guideliness
    "https://raw.githubusercontent.com/zachbr/Dis4IRC/v${pkgver}/LICENSE.md"
    # We create a dedcicated dis4irc user
    "dis4irc-sysusers.conf"
    # I wrote my own systemd file (kind of overkill huh)
    "dis4irc.service"
)
noextract=(
    # Jar is just a zip file, and we do *NOT* want it extracted
    "Dis4IRC-${pkgver}.jar"
)
sha256sums=('631bd64425a66561816d5deacb63cd8b0cc7ca089487f8dabb65584623b79a32'
            '3b0e019e48300b84a62273422b1deda67d548d38d5037fd94a0f2af54c96d4c8'
            'd8c07815db79c8e9e6d9dec5fe2bca2fe3d1ed11470f4eb232c0bce7c87e2a4d'
            'fe49b0c125e69433b91be596cd627424f464e609d39996693ae017889f2b31c4')

build() {
    # Default config file doesn't exist. We have to generate it

    # remove previous default config (autogenerated)
    rm -f "${srcdir}/default-config.hocon" 
    echo "============================="
    echo "  Generating Default Config  "
    echo "============================="
    echo "NOTE: Network connection & discord API calls should fail, but no other errors should occur"
    echo
    # Generate the configuration file by invoking the jar
    #
    # This will fail (without connecting to anything), but it will successfully generate the default config in the process.
    java -jar "$srcdir/Dis4IRC-${pkgver}.jar" --config "${srcdir}/default-config.hocon" "$pkgdir/" || true
}


package() {
    # Per the java packaging guidelines, we place jar files into /usr/share/java/dis4irc
    install -Dm644 "$srcdir/Dis4IRC-${pkgver}.jar" "$pkgdir/usr/share/java/dis4irc/Dis4IRC.jar"

    # We install the "default" config into /etc/dis4irc/config.hocon
    install -Dm644 "$srcdir/default-config.hocon" "$pkgdir/etc/dis4irc/config.hocon"

    install -Dm644 "$srcdir/dis4irc.service" "$pkgdir/usr/lib/systemd/system/dis4irc.service"
    install -Dm644 "$srcdir/dis4irc-sysusers.conf" "$pkgdir/usr/lib/sysusers.d/dis4irc.conf"
    install -Dm644 "$srcdir/LICENSE.md" "$pkgdir/usr/share/licenses/dis4irc/LICENSE.md"
}