blob: bb0c89d65667cacc8548aa94fe6c4bb9db5532d5 (
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
# Maintainer:
# Contributor: Digimezzo <raphael@digimezzo.com>
# options
#: ${_pkgtype:=git}
# basic info
_pkgname=knowte
pkgname="$_pkgname${_pkgtype:+-$_pkgtype}"
pkgver=3.0.0
pkgrel=2
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
}
# 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() {
cat <<'EOF' > "$_pkgname.sh"
#!/usr/bin/env sh
set -e
APPDIR="/usr/lib/knowte"
XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
_ELECTRON=/usr/bin/electron
_ASAR="${APPDIR}/app.asar"
_FLAGS_FILE="$XDG_CONFIG_HOME/logseq-flags.conf"
if [ -r "$_FLAGS_FILE" ]; then
_USER_FLAGS="$(cat "$_FLAGS_FILE")"
fi
if [[ $EUID -ne 0 ]] || [[ $ELECTRON_RUN_AS_NODE ]]; then
exec ${_ELECTRON} ${_ASAR} $_USER_FLAGS "$@"
else
exec ${_ELECTRON} ${_ASAR} --no-sandbox $_USER_FLAGS "$@"
fi
EOF
local _gendesk_options=(
-q -f -n
--pkgname="$_pkgname"
--pkgdesc="$pkgdesc"
--name="Knowte"
--exec="$_pkgname %u"
--icon="$_pkgname"
--terminal=false
--categories="Utility"
#--mimetypes=""
--startupnotify=true
--custom="StartupWMClass=Knowte"
)
gendesk "${_gendesk_options[@]}"
}
_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
|