summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 1254cf442fd5ec56ddad906b4beaa437ded71935 (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
# Maintainer: Owen Trigueros <owentrigueros@gmail.com>

pkgname=turtl-server-git
pkgver=r211.babccca
pkgrel=3
pkgdesc="The secure, collaborative notebook's server"
arch=('any')
url="https://turtlapp.com/"
license=('AGPL')
depends=('nodejs' 'postgresql')
makedepends=('git' 'npm')
provides=('turtl-server')
conflicts=('turtl-server')
install=$pkgname.install
source=("$pkgname::git+https://github.com/turtl/server.git"
        "turtl-server-git.install"
        "turtl.service"
        "turtl.sysusers")
        
md5sums=('SKIP'
         '95e7cdde22d846c34334b7f61aa0980c'  
         'ef593935d035ae7df448dbb18aaed70f'  
         'c6727740e7165fa825bc011ec5f50f78')

pkgver() {
	cd "$pkgname"
	printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() {
    cd "$srcdir"/"$pkgname"
    npm install
}

package() {
    cd "$srcdir"/"$pkgname"
    backup=('etc/webapps/turtl/config.yaml')

    # install service file and systemd-sysusers config
    install -Dm644 "$srcdir"/turtl.service  "$pkgdir"/usr/lib/systemd/system/turtl.service
    install -Dm644 "$srcdir"/turtl.sysusers "$pkgdir"/usr/lib/sysusers.d/turtl.conf
    
    # install server files
    find controllers/  -type f -exec install -Dm644 {} "$pkgdir"/usr/share/webapps/turtl/{} \;
    find helpers/      -type f -exec install -Dm644 {} "$pkgdir"/usr/share/webapps/turtl/{} \;
    find models/       -type f -exec install -Dm644 {} "$pkgdir"/usr/share/webapps/turtl/{} \;
    find scripts/      -type f -exec install -Dm755 {} "$pkgdir"/usr/share/webapps/turtl/{} \;
    find tools/        -type f -exec install -Dm644 {} "$pkgdir"/usr/share/webapps/turtl/{} \;
    find node_modules/ -type f -exec install -Dm644 {} "$pkgdir"/usr/share/webapps/turtl/{} \;
    install -Dm644 server.js "$pkgdir"/usr/share/webapps/turtl/server.js
    install -d "$pkgdir"/usr/share/webapps/turtl/plugins
    install -d "$pkgdir"/var/lib/turtl/public/uploads
    ln -s /var/lib/turtl/public "$pkgdir"/usr/share/webapps/turtl/public

    # install config file
    install -Dm644 config/config.yaml.default "$pkgdir"/etc/webapps/turtl/config.yaml
    mkdir -p "$pkgdir"/usr/share/webapps/turtl/config
    ln -s /etc/webapps/turtl/config.yaml "$pkgdir"/usr/share/webapps/turtl/config/config.yaml

    # remove references to $pkgdir and $srcdir
    find "$pkgdir" -name package.json -print0 | xargs -0 sed -i '/_where/d'

    # change 'loglevel' to 'info'
    sed -i "s/loglevel: 'debug'/loglevel: 'info'/" \
        "$pkgdir"/etc/webapps/turtl/config.yaml

    # change data dir
    sed -i "s/\/var\/www\/turtl\/server/\/usr\/share\/webapps\/turtl/g" \
        "$pkgdir"/etc/webapps/turtl/config.yaml
}