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

_pkgname="memos"
pkgname="${_pkgname}-git"
pkgver=0.16.0.r65.g1b105db9
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" "nodejs")
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'
            'd529a5d48624848650268db4f0d1f2247507f7c8ee3541b52c235dd72861cfaede59d0752ae67776ca42b0fb3d5951db7b760a9fe7d47149c994d9cefb4af67f'
            '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"
    mkdir -p "$srcdir/bin"
    corepack enable --install-directory "$srcdir/bin"
    
    export PATH="$PATH:$srcdir/bin"
    pnpm install --store-dir=$srcdir/pnpm-store --frozen-lockfile
    pnpm type-gen
    pnpm build
    cp -r "dist" "$srcdir/$_pkgname/server/"

    # 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"
    CGO_ENABLED=0 go build -o 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"
}