summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: d3ae5257c35e0993d11d4f1e5bcb3f7134a118ea (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
# Maintainer:
# Contributor: Lindasy Zhou <i@lin.moe>

_pkgname="memos"
pkgname="${_pkgname}-git"
pkgver=0.22.4.r62.gbb86482b
pkgrel=1
pkgdesc="A privacy-first, lightweight note-taking service. Easily capture and share your great thoughts."
url="https://github.com/usememos/${_pkgname}"
arch=("any")
license=('MIT')
makedepends=("go" "git" "npm")
provides=("$pkgname")
backup=('etc/memos.conf')
source=(
  "git+https://github.com/usememos/$_pkgname.git"
  "systemd.service"
  "sysusers.conf"
  "memos.conf"
  'tmpfiles.conf'
)
sha512sums=('SKIP'
            '9c37361974d8b3beecdd8b0bf8db929a4a882623ea7b23aa51bddf37790b66042cef593d6da89b34e7dde4a9a9a1e097ea31ec713b33fee6a699448fb300d4a2'
            '692dc4674b86b36c5464c78f493ace50091068f962d40130a32b4ed17517d77e33860333e870f5e80a5e17b6cbd5de45bf57e7de5ea7984bd4e36f95a8daf0fa'
            '251e01c4f5fc8aea209453d91da5dde91d58397668e34b78e52a31940e30a89be5601a6ea8cdebe791a96c9324733095de3567998b45ce1542578b1d9b7a5b76'
            'cf88b91a88825dcfda35f45461513b8a2e03b07890189fd1cf7b60aa4085c9e88d8338596b69a3d9c3e513e668093ab7cb246febbb7f6ac7796d37e1189db565')


pkgver(){
  cd "$srcdir/$_pkgname"
  git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}


build(){
    # build frontend
    cd "$srcdir/$_pkgname/web"
    npm install --frozen-lockfile
    npm run build
    rm -fr "$srcdir/$_pkgname/server/router/frontend/dist"
    cp -r "dist" "$srcdir/$_pkgname/server/router/frontend/dist"
    
    # build backend
    export CGO_CPPFLAGS="${CPPFLAGS}"
    export CGO_CFLAGS="${CFLAGS}"
    export CGO_CXXFLAGS="${CXXFLAGS}"
    export CGO_LDFLAGS="${LDFLAGS}"
    export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw"
    
    cd "$srcdir/$_pkgname"
    go build -o memos ./bin/memos/main.go
}

check(){
    cd "$srcdir/$_pkgname"
    go test ./...
}

package () {
  install -vDm644 systemd.service "$pkgdir/usr/lib/systemd/system/${_pkgname}.service"
  install -vDm644 sysusers.conf "$pkgdir/usr/lib/sysusers.d/${_pkgname}.conf"
  install -vDm644 tmpfiles.conf "$pkgdir/usr/lib/tmpfiles.d/${_pkgname}.conf"
  install -vDm644 memos.conf "$pkgdir/etc/memos.conf"

  cd "$_pkgname"
  install  -Dm755 "memos" "$pkgdir/usr/bin/memos"
  install -Dm0644 LICENSE "$pkgdir/usr/share/licenses/${_pkgname}/LICENSE"
}