summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 5ae1b01e9cf4ddfa4f8fb75b440b94af6c6010eb (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
# Maintainer: Fabian Bornschein <fabiscafe@mailbox.org>

pkgname=misskey
pkgver=12.108.1
pkgrel=2
pkgdesc="🌎 An interplanetary microblogging platform 🚀 (Experimental)"
url="https://github.com/misskey-dev/misskey"
options=("!strip")
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: something something"
            "nginx: reverse-proxy usage")
_commit="2cd2d6522e096bfbca244010e30241828d13a3cb" #tag/12.108.1
source=("git+https://github.com/misskey-dev/misskey.git#commit=${_commit}"
        "${pkgname}.install"
        "${pkgname}.service"
        "${pkgname}.sysusers"
        "${pkgname}.tmpfiles")
md5sums=('SKIP'
         'aa0312f32fe331cd7a2e471902dad1f4'
         '9abc87cea2314b95334d4ad3b309e931'
         'a3fe48c606eabebf818106648c0bf0d9'
         'c6f7dc5885f8db2329b3b1e3c2a67ef5')
sha256sums=('SKIP'
            'd860082dbc90b0e7ecadcb1bfeeeb11dae6f24544d4746883e4a2bfafd052284'
            '5cd19f1798eb1852c47c7786021adede99d95ab83feb0802e7b1fba50a308517'
            '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' \) \
        -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' \) \
        -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" 
    
    # license
    install -Dm644 "${pkgdir}/usr/share/webapps/${pkgname}/COPYING" \
        "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}