summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 4382ce6c46bef42f961b252ec38d4064f1c96cfe (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
# Maintainer: Stephan Springer <buzo+arch@Lini.de>
# Contributor: Christian Pfeiffer <ChrisTX>
# Contributor: Giovanni Harting <539@idlegandalf.com>

pkgname=cryptpad
pkgver=4.6.0
pkgrel=1
pkgdesc="Realtime collaborative visual editor with zero knowlege server"
arch=('any')
url="https://github.com/xwiki-labs/cryptpad"
license=(AGPL3)
depends=(nodejs)
makedepends=(bower npm git)
optdepends=('nginx: HTTP server providing TLS'
            'certbot: Let’s Encrypt – automatically receive and install X.509 certificates to enable TLS'
            'certbot-nginx: Nginx plugin for Let’s Encrypt client')
backup=(etc/webapps/"$pkgname"/config.js
        etc/nginx/sites-available/"$pkgname".conf)
options=(!strip) # There are no ELF files, no need to strip anything.
source=("$pkgname-$pkgver.tar.gz::https://github.com/xwiki-labs/cryptpad/archive/$pkgver.tar.gz"
        "cryptpad.service"
        "cryptpad.sysusers"
        "cryptpad.tmpfiles")
sha256sums=('d723fec493b1254946015ce7d40b8cc3ca528d558bf434fd26742fbc5b5a1f12'
            '792da71f113aa15177a654e08a31dabd9be864ceb42f64d55cc46d18875c475b'
            '999a271d64b75c7c447fdb21486b27463c04679677e57ea9551a3b0429c618f6'
            '617ee2a7b3e81184dc82df8b800898092b1001fdbd57c3edc317512e3aee70a0')

build() {
    cd "$pkgname-$pkgver"
    export NODE_ENV=production
    npm install --cache "$srcdir"/npm-cache
    bower install -p --allow-root
}

package() {
    cd "$pkgname-$pkgver"

    # npm gives ownership of ALL FILES to build user
    # https://bugs.archlinux.org/task/63396
    chown -R root:root "$pkgdir"

    # remove unneeded man pages
    sed -i '/"man/d' www/bower_components/marked/package.json
    rm -r www/bower_components/marked/man

    # Remove references to $srcdir
    find . -type f -name package.json -print0 | xargs -0 sed -i '/_where/d'

    # Documentation
    install -t "$pkgdir/usr/share/doc/$pkgname" -Dm 644 docs/{ARCHITECTURE.md,example.nginx.conf} CHANGELOG.md

    # Cryptpad
    install -Dt "$pkgdir/usr/share/webapps/$pkgname" package.json server.js
    cp -rt "$pkgdir/usr/share/webapps/$pkgname" customize.dist lib node_modules scripts www
    rmdir "$pkgdir/usr/share/webapps/$pkgname/www/bower_components/codemirror/mode/rpm/changes"

    # Config
    sed -e "s|\(Path: '\)\./|\1/var/lib/cryptpad/|" \
        -e "s|'/var/lib/cryptpad/data/logs'|false|" \
        -e "s|logToStdout: false|logToStdout: true|" \
        -i config/config.example.js
    install -Dm 644 config/config.example.js "${pkgdir}/etc/webapps/$pkgname/config.js"

    # Nginx config
    sed -Ee "s|^( *root  *)/.*|\1/usr/share/webapps/$pkgname/www;|" \
        -e "s|/home/cryptpad/.acme.sh/|/etc/letsencrypt/live/|" \
        -i docs/example.nginx.conf
    install -Dm 644 docs/example.nginx.conf "${pkgdir}/etc/nginx/sites-available/$pkgname.conf"

    ln -s /etc/webapps/"$pkgname" "$pkgdir/usr/share/webapps/$pkgname/config"
    install -dm 750 "$pkgdir/var/lib/$pkgname"/{,blob,block,data{,store},logs}
    ln -s /var/lib/"$pkgname"/{blob,block,data{,store}} "$pkgdir/usr/share/webapps/$pkgname"

    # systemd
    install -Dm 644 "${srcdir}"/cryptpad.sysusers "${pkgdir}"/usr/lib/sysusers.d/cryptpad.conf
    install -Dm 644 "${srcdir}"/cryptpad.service "${pkgdir}"/usr/lib/systemd/system/cryptpad.service
    install -Dm 644 "${srcdir}"/cryptpad.tmpfiles "${pkgdir}"/usr/lib/tmpfiles.d/cryptpad.conf
}