summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 97956ca710209803169908cc032b40add13dcd34 (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
125
# Maintainer: Kainoa Kanter <kainoa@t1c.dev>
# Co-Matainer: Bjoern Franke <bjo+aur@schafweide.org>
# Original author of https://aur.archlinux.org/packages/misskey (which this is based off): <fabiscafe@mailbox.org>

pkgname=firefish-beta
_pkgname=firefish
pkgver=1.0.4beta31
pkgrel=5
pkgdesc='A fun, new way to experience social media'
url='https://joinfirefish.org'
arch=('x86_64')
license=('AGPL3' 'MIT')
depends=('nodejs' 'npm' 'postgresql' 'redis' 'pnpm' 'zip')
makedepends=('git' 'python' 'rust')
install='firefish.install'
optdepends=('ffmpeg: Media encode functionality'
            'nginx: Reverse-proxy')
source=("git+https://git.joinfirefish.org/firefish/firefish#tag=v1.0.4-beta31"
        "${_pkgname}.install"
        "${_pkgname}.service"
        "${_pkgname}.sh"
        "${_pkgname}.sysusers"
        "${_pkgname}.tmpfiles")
sha256sums=('SKIP'
            'd4e628de3827de4f3bca7924b22c20a6f1185062d4c8a697231b11d0f3b6cf1f'
            '95989ea41e7b6d4c3eac2244c23015da3e205352d19844404efc5eef801cdfb0'
            'e7a5c682f1f3ef1d21cd573ad520ee69664aa98afbb1427ae2b6f8cdb2a73928'
            'e81d9fca78fdff08b86302b56b060f8c8a5b4c8499d48a7b374c45509a7e1ffe'
            '676187c3c4cba5e574fa7e9ed782c22c235ee13f7282ad2a9f792272bd1bce41')

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-firefish-user|firefish|;
        s|  pass: example-firefish-pass|# pass: firefish|;
        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"
    rm -rf "${srcdir}/${_pkgname}/.cargo"
}


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"

    # firefish 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"
}