summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 136f745dc06e50ad5d425470dae53fa098aab713 (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# Maintainer:
# Contributor: Digimezzo <raphael@digimezzo.com>

# options
#: ${_pkgtype:=git}

# basic info
_pkgname=knowte
pkgname="$_pkgname${_pkgtype:+-$_pkgtype}"
pkgver=3.0.0
pkgrel=1
pkgdesc="Cross platform note taking application"
url="https://github.com/digimezzo/knowte"
license=('GPL3')
arch=('x86_64')

# main package
_main_package() {
  makedepends=(
    'gendesk'
    'nvm'
  )

  if [ x"$pkgname" == x"$_pkgname" ] ; then
    _main_stable
  else
    _main_git
  fi

  source+=(
    "$_pkgname.sh"
  )
  sha256sums+=(
    '4fc173bf2c4c7f210e4a3fa1983ed6e502aa3bd2845b1947a472952189272b6f'
  )
}

# stable package
_main_stable() {
  _pkgsrc="$_pkgname-${pkgver%%.r*}"
  _pkgext="tar.gz"
  source+=(
    "$_pkgsrc.$_pkgext"::"$url/archive/refs/tags/v${pkgver%%.r*}.$_pkgext"
  )
  sha256sums+=(
    '32247fbec85fcd9340e35bcb0c2655e216899ac568e7dbe91844a873da280f64'
  )

  pkgver() {
    local _pkgver="${pkgver%%.r*}"
    echo "${_pkgver:?}"
  }
}

# git package
_main_git() {
  makedepends+=('git')

  provides+=("$_pkgname=${pkgver%%.r*}")
  conflicts+=("$_pkgname")

  _pkgsrc="$_pkgname"
  source+=("$_pkgsrc"::"git+$url.git")
  sha256sums+=('SKIP')

  pkgver() {
    cd "$_pkgsrc"
    git describe --long --tags --exclude='*[A-Za-z][A-Za-z]*' \
      | sed -E 's/^v//;s/([^-]*-g)/r\1/;s/-/./g'
  }
}

# common functions
prepare() {
  gendesk -q -f -n --categories "Utility" --pkgname="${_pkgname}" --pkgdesc="$pkgdesc" --name="Knowte" --exec="${_pkgname}"
}

_ensure_local_nvm() {
  export NVM_DIR="${srcdir:?}/nvm"
  source /usr/share/nvm/init-nvm.sh || [[ $? != 1 ]]
  nvm install 16
  nvm use 16
}

build() {
  _ensure_local_nvm

  export XDG_CACHE_HOME="${srcdir:?}/cache"
  export XDG_CONFIG_HOME="${srcdir:?}/config"

  cd "$_pkgsrc"
  npm install --force --no-audit --no-fund
  npm install --force --no-audit --no-fund querystring
  npm run electron:linux || true
}

package() {
  depends+=(
    'electron'
  )

  install -Dm755 "$_pkgname.sh" "${pkgdir:?}/usr/bin/$_pkgname" 

  install -Dm644 "$_pkgsrc/release/linux-unpacked/resources/app.asar" -t "${pkgdir:?}/usr/lib/$_pkgname/"

  install -Dm644 "$_pkgsrc/build/icon.png" "${pkgdir:?}/usr/share/pixmaps/$_pkgname.png"

  install -Dm644 "${srcdir:?}/$_pkgname.desktop" -t "${pkgdir:?}/usr/share/applications/"
}

# execute
_main_package