summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 22e341807e2afa8c23632b07c4326936a2cc5b52 (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
80
81
82
83
84
85
86
87
88
89
90
91
# Maintainer: Seann Moser <you@example.com>
pkgname=ymn-git
pkgver=0.1.14.r0.g1bbad76
pkgrel=1
pkgdesc="Yomuna visual novel transcript and flashcard tool"
arch=('x86_64')
url="https://github.com/DarlingGoose/ymn"
license=('custom')
depends=(
  'ffmpeg'
  'glibc'
  'gst-plugins-base-libs'
  'gstreamer'
  'libx11'
  'libxkbcommon'
  'mesa'
  'mpv'
  'wayland'
  'wine'
)
makedepends=('git' 'go' 'pkgconf')
optdepends=(
  'steam: Steam/Proton launch flows'
  'tesseract: legacy OCR workflow'
  'grim: Wayland screenshot capture for legacy OCR workflow'
  'slurp: Wayland region selection for legacy OCR workflow'
  'ollama: local translation backend'
)
provides=('ymn')
conflicts=('ymn')
source=(
  'ymn::git+https://github.com/DarlingGoose/ymn.git#branch=main'
  'ymn.desktop'
  'icon.svg'
)
sha256sums=(
  'SKIP'
  'df60b7525f82e0cd8f1910eb2dff2b3d5892c04d9d6f1d30bc28c2b7d24d6468'
  '77ab34aacd3b216c2c8a243c7a49903a675e0731010d3d421d08a4d200bf8314'
)

pkgver() {
  cd ymn

  local tag commits
  tag="$(git tag --sort=-v:refname --merged HEAD | head -n1)"
  commits="$(git rev-list --count "${tag}..HEAD")"

  printf '%s.r%s.g%s\n' "${tag#v}" "${commits}" "$(git rev-parse --short HEAD)"
}


prepare() {
  cd ymn

  export GOPATH="$srcdir/gopath"
  export GOCACHE="$srcdir/go-build"
  export GOMODCACHE="$srcdir/gopath/pkg/mod"
  export GOFLAGS="-modcacherw"

  go mod vendor
}

build() {
  cd ymn

  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOPATH="$srcdir/gopath"
  export GOCACHE="$srcdir/go-build"
  export GOMODCACHE="$srcdir/gopath/pkg/mod"
  export GOFLAGS="-buildmode=pie -trimpath -mod=vendor -modcacherw"

  mkdir -p build

  go build \
    -ldflags "-linkmode external" \
    -o build/ymn \
    .
}

package() {
  cd ymn

  install -Dm755 build/ymn "$pkgdir/usr/bin/ymn"
  install -Dm644 "$srcdir/ymn.desktop" "$pkgdir/usr/share/applications/ymn.desktop"
  install -Dm644 "$srcdir/icon.svg" "$pkgdir/usr/share/icons/hicolor/scalable/apps/ymn.svg"
  install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}