summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: e977ea1c14664b07c8974f24c1ddad5483f62d9d (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
126
127
128
129
130
131
132
133
# Maintainer: Fabian Bornschein <fabiscafe@mailbox.org>

pkgname=misskey
pkgver=12.110.0
pkgrel=3
pkgdesc="🌎 An interplanetary microblogging platform 🚀 (Experimental)"
url="https://github.com/misskey-dev/misskey"
arch=("x86_64")
license=("AGPL3" "MIT")
depends=("nodejs-lts-gallium" "npm" "postgresql" "redis" "yarn")
makedepends=("git" "python")
install="misskey.install"
optdepends=("elasticsearch: Search functionality"
            "ffmpeg: Media de-encode functionality"
            "nginx: Reverse-proxy usage")
_commit="33c22b5f3efa4110c9b517c224c9fdfba7e6c64b" #tag/12.110.0
source=("git+https://github.com/misskey-dev/misskey.git#commit=${_commit}"
        "${pkgname}.install"
        "${pkgname}.service"
        "${pkgname}-db-upgrade.sh"
        "${pkgname}.sysusers"
        "${pkgname}.tmpfiles")
md5sums=('SKIP'
         '74797428d78ba89b328c7ef98fda2786'
         '9abc87cea2314b95334d4ad3b309e931'
         '482ab8e6ce416e4490459b4dd78cc158'
         'a3fe48c606eabebf818106648c0bf0d9'
         'c6f7dc5885f8db2329b3b1e3c2a67ef5')
sha256sums=('SKIP'
            '60cd6fb87a1ecde4db123cfa70ea308fb4559c3a0f5f84920af8473dcc9522a1'
            '5cd19f1798eb1852c47c7786021adede99d95ab83feb0802e7b1fba50a308517'
            '88d8c9853aa2ac070ff76c59d7ae4d61bbd5ae50b141794f50d91bc350954974'
            'a3ff9c1b77920ebbb0df8fb1affe9e8ef54d907bd4d16ed7c6076cbf52726df7'
            'c368b2ed2efbeca0e488f883defb2ccb7ed4661cc6832d2c396176206a794f34')

pkgver() {
    cd "${pkgname}"
    git describe --tags | sed 's/-/+/g'
}

prepare() {
    cd "${pkgname}"

    # Dependency handling
    git submodule update --init
    HOME="${srcdir}/${pkgname}" yarn install

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

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

build() {
    cd "${pkgname}"
    NODE_ENV=production HOME="${srcdir}/${pkgname}" yarn 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-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 -r "${srcdir}/${pkgname}/docs"
    rm -r "${srcdir}/${pkgname}/misskey-assets"
    rm -rf "${srcdir}/${pkgname}/.npm"
    rm -r "${srcdir}/${pkgname}/scripts"
    rm -r "${srcdir}/${pkgname}/.yarn"
}

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}/"
    rmdir "${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"

    # yarn, npm setup
    ln -s "/var/lib/${pkgname}/yarn" "${pkgdir}/usr/share/webapps/${pkgname}/.yarn"
    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"

    # db-update script
    install -dm755 "${pkgdir}/usr/lib/${pkgname}"
    install -Dm700 "${pkgname}-db-upgrade.sh" -t "${pkgdir}/usr/lib/${pkgname}"

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