summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 71a5e860f35c22f94f0a167b0edfb6a59264817b (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
# Maintainer: Alexander F Rødseth <xyproto@archlinux.org>

pkgname=algernon
pkgver=1.7
pkgrel=1
pkgdesc='Single executable web server with Lua, Markdown, QUIC and Pongo2 support'
arch=('x86_64' 'i686')
url='http://algernon.roboticoverlords.org/'
license=('MIT')
makedepends=('git' 'go' 'setconf')
optdepends=('redis: For using the Redis database backend'
            'mariadb: For using the MariaDB/MySQL database backend'
            'postgresql: For using the PostgreSQL database backend')
backup=('etc/algernon/serverconf.lua'
        'usr/lib/systemd/system/algernon.service')
source=('git+https://github.com/xyproto/algernon#commit=20a12302518e36b151b93ce5d3203ee267b2b4bb')
md5sums=('SKIP')
_gourl=github.com/xyproto/algernon

prepare() {
  cd "$pkgname"
  git submodule init
  git submodule update
  cd "$srcdir"

  export GOROOT=/usr/lib/go

  rm -rf build; mkdir -p build/go; cd build/go
  for f in "$GOROOT/"*; do ln -s "$f"; done
  rm pkg; mkdir pkg; cd pkg
  for f in "$GOROOT/pkg/"*; do ln -s "$f"; done

  export GOPATH="$srcdir/build"
  export GOROOT="$GOPATH/go"
  export DESTPATH="$GOPATH/src/$_gourl"

  # Make sure $DESTPATH is empty, but exists
  rm -rf "$DESTPATH"; mkdir -p "$DESTPATH"

  mv "$srcdir/$pkgname" "$(dirname $DESTPATH)"

  cd "$GOPATH/src/$_gourl"

  # Startup parameters
  setconf system/algernon_dev.service \
    ExecStart \
    "/usr/bin/algernon -e -a --domain --server --log /var/log/algernon.log --addr=:80 /srv/http"
  setconf system/algernon_dev.service Group=http
}

build() {
  cd "$GOPATH/src/$_gourl"

  go build -x
}

check() {
  cd "$GOPATH/src/$_gourl"

  go test
}

package() {
  cd "$GOPATH/src/$_gourl"

  install -Dm755 algernon "$pkgdir/usr/bin/algernon"
  install -Dm755 desktop/mdview "$pkgdir/usr/bin/mdview"
  install -Dm644 system/algernon_dev.service "$pkgdir/usr/lib/systemd/system/algernon.service"
  install -Dm644 system/logrotate "$pkgdir/etc/logrotate.d/algernon"
  install -Dm644 system/serverconf.lua "$pkgdir/etc/algernon/serverconf.lua"
  install -Dm644 desktop/algernon.desktop "$pkgdir/usr/share/applications/algernon.desktop"
  install -Dm644 desktop/markdown.png "$pkgdir/usr/share/pixmaps/markdown.png"
  install -d "$pkgdir/usr/share/doc/$pkgname/"
  cp -r samples "$pkgdir/usr/share/doc/algernon/samples"
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

# vim: ts=2 sw=2 et: