summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 6e9198a3250829d8dae4b23665bcd241464aad29 (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Maintainer: ThatOneCalculator <kainoa@t1c.dev>
# Co-Matainer: Bjoern Franke <bjo+aur@schafweide.org>
# Based on https://aur.archlinux.org/packages/misskey

pkgname=calckey
pkgver=13.1.4
pkgrel=7
pkgdesc='A fun, new way to experience social media'
url='https://calckey.org'
arch=('x86_64')
license=('AGPL3' 'MIT')
depends=('nodejs' 'npm' 'postgresql' 'redis' 'pnpm' 'zip')
makedepends=('git' 'python')
options=('debug')
install='calckey.install'
commit=b03e65584383ceafe2d85e08055e9ab249fbe765
optdepends=('ffmpeg: Media encode functionality'
            'nginx: Reverse-proxy')
source=("git+https://codeberg.org/calckey/calckey.git#commit=$commit"
        "${pkgname}.install"
        "${pkgname}.service"
        "${pkgname}.sh"
        "${pkgname}.sysusers"
        "${pkgname}.tmpfiles")
sha256sums=('SKIP'
            '9c97cf0b759ed9b79deb08044b688fe480ced068981f20636f0aa12e47752290'
            '64f805ff3d8a69eb03b0ab4359147f7ef39d94691b6c1e7b0529cdb7a53985d2'
            '5847f19482a6a0c50a1619ac303ce1e46bdd9b6aef7ddbfbe73caecab09f1876'
            '51252a058e84cf3772634aa7b02199cab8ddd08fefdfc5849836403780db6470'
            'b77fdf9138080924d8d4b008b6a075f513eecfad86efd1fc139bdc5e7a49f7cd')

prepare() {
    cd "${pkgname}"

    # Dependency handling
    git submodule update --init
    corepack enable --install-directory "${srcdir}/${pkgname}"
    HOME="${srcdir}/${pkgname}" pnpm install

    # Example configuration
    ## Change example configuration to reflect
    ## this packages purpose
    _example_file="${srcdir}/${pkgname}/.config/example.yml"

    sed -i \
        's|example-calckey-user|calckey|;
        s|  pass: example-calckey-pass|# pass: calckey|;
        s|#outgoingAddressFamily: ipv4|outgoingAddressFamily: dual|' \
        ${_example_file}
}

build() {
    cd "${pkgname}"
    corepack enable --install-directory "${srcdir}/${pkgname}"
    NODE_ENV=production HOME="${srcdir}/${pkgname}" pnpm run build

    # Cleanup
    find "${srcdir}/${pkgname}" \
        -depth \
        -type d \
        \( -iname '.git' \
        -o -iname '.github' \
        -o -iname '.vscode' \
        -o -iname 'darwin-arm64' \
        -o -iname 'darwin-x64' \
        -o -iname 'win32-ia32' \
        -o -iname 'win32-x64' \
        -o -iname 'linux-arm' \
        -o -iname 'linux-arm64' \) \
        -execdir rm -rf '{}' \;
    find "${srcdir}/${pkgname}" \
        -type f \
        \( -name '.git' \
        -o -name '.gitattributes' \
        -o -name '.gitignore' \
        -o -name '.gitmodules' \
        -o -name '.docker*' \
        -o -iname 'docker*' \
        -o -name '.editor*' \
        -o -name '.vsls.json' \
        -o -name 'darwin.js' \
        -o -name 'win32.js' \) \
        -not -name 'docker*.js' \
        -delete
    rm -r "${srcdir}/${pkgname}/cypress"
    rm -r "${srcdir}/${pkgname}/.cache"
    rm -rf "${srcdir}/${pkgname}/.npm"
    rm -rf "${srcdir}/${pkgname}/.local"
    rm -r "${srcdir}/${pkgname}/scripts"
}

package() {
    # systemd files
    install -Dm644 ${pkgname}.service -t "${pkgdir}"/usr/lib/systemd/system/
    install -Dm644 ${pkgname}.sysusers "${pkgdir}/usr/lib/sysusers.d/${pkgname}.conf"
    install -Dm644 ${pkgname}.tmpfiles "${pkgdir}/usr/lib/tmpfiles.d/${pkgname}.conf"

    install -dm755 "${pkgdir}/usr/share/webapps"
    mv "${srcdir}/${pkgname}" "${pkgdir}/usr/share/webapps/"

    # config setup
    install -dm755 "${pkgdir}/etc/webapps/${pkgname}"
    mv "${pkgdir}/usr/share/webapps/${pkgname}/.config/example.yml" -t \
        "${pkgdir}/etc/webapps/${pkgname}/"
    rm -r "${pkgdir}/usr/share/webapps/${pkgname}/.config"
    ln -s "/etc/webapps/${pkgname}" "${pkgdir}/usr/share/webapps/${pkgname}/.config"

    # cache setup
    ln -s "/var/cache/${pkgname}" "${pkgdir}/usr/share/webapps/${pkgname}/.cache"

    # pnpm, npm setup
    ln -s "/var/lib/${pkgname}/pnpm" "${pkgdir}/usr/share/webapps/${pkgname}/.pnpm"
    ln -s "/var/lib/${pkgname}/npm" "${pkgdir}/usr/share/webapps/${pkgname}/.npm"

    # files (upload, …)
    ln -s "/var/lib/${pkgname}/files" "${pkgdir}/usr/share/webapps/${pkgname}/files"

    # calckey helper script
    install -Dm755 "${pkgname}.sh" "${pkgdir}/usr/bin/${pkgname}"

    # license
    install -Dm644 "${pkgdir}/usr/share/webapps/${pkgname}/COPYING" \
        "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}