blob: aa2a3fd44f7e457dc25426c31b13b65a3039fae2 (
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
|
# Maintainer: xeruf <27jf at pm dot me>
_electron_version=""
_pkgname=stretchly
pkgname=${_pkgname}-xeruf-git
pkgver=1386.c4b77ac
pkgrel=1
pkgdesc="The break reminder app with more restrictive menus"
arch=('i686' 'x86_64')
url="https://github.com/xeruf/${_pkgname}"
license=('BSD')
depends=('gtk3' 'libnotify' 'nss' 'libxss' 'libxtst' 'xdg-utils' 'at-spi2-atk' 'util-linux-libs' 'libsecret' 'libappindicator-gtk3' 'libxcrypt-compat' "electron$_electron_version")
makedepends=('git' 'nvm' 'jq' 'python')
provides=("$_pkgname")
source=("git+${url}.git")
conflicts=("$_pkgname" "${_pkgname}-bin")
sha256sums=('SKIP')
pkgver() {
cd "${srcdir}/${_pkgname}"
printf '%s.%s' "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}
_ensure_local_nvm() {
if type nvm &>/dev/null; then
nvm deactivate
nvm unload
fi
unset npm_config_prefix
export NVM_DIR=${srcdir}/.nvm
. /usr/share/nvm/init-nvm.sh
_node_version=$(jq -r '.engines.node' package.json)
}
prepare() {
cd "${srcdir}/${_pkgname}"
_ensure_local_nvm
# ` || false` is a workaround until this upstream fix is released:
# https://github.com/nvm-sh/nvm/pull/2698
nvm ls "$_node_version" &>/dev/null ||
nvm install "$_node_version" || false
}
build() {
cd "${srcdir}/${_pkgname}"
_ensure_local_nvm
nvm use "$_node_version"
npm install --no-save --no-audit --no-progress --no-fund
# electron-builder only generates /usr/share/* assets for target package
# types 'apk', 'deb', 'freebsd', 'p5p', 'pacman', 'rpm' and 'sh', so build a
# pacman package and unpack it
local _appname _appver _outfile _unpackdir=${srcdir}/${_pkgname}.unpacked
_appname=$(jq -r '.name' package.json)
_appver=$(jq -r '.version' package.json)
_outfile=dist/${_appname}-${_appver}.pacman
rm -rf "${_unpackdir}"
mkdir -p "${_unpackdir}"
local i686=ia32 x86_64=x64
# Add -c.asar=false to suppress creation of an app archive
./node_modules/.bin/electron-builder build \
--linux pacman \
--"${!CARCH}" \
-c.electronDist="/usr/lib/electron$_electron_version" \
-c.electronVersion="$(<"/usr/lib/electron$_electron_version/version")"
tar -C "${_unpackdir}" -xf "${_outfile}"
# Replace absolute path in desktop entry
sed -Ei "s/^(Exec=).*/\1\\/usr\\/bin\\/${_pkgname} %U/" \
"${_unpackdir}/usr/share/applications/${_pkgname}.desktop"
}
package() {
local _appname _appdir _appfile=
_appname=$(jq -r '.name' "${srcdir}/${_pkgname}/package.json")
_appdir=opt/${_appname}/resources/app
cd "${srcdir}/${_pkgname}.unpacked"
mv "usr" "${pkgdir}/"
install -d "${pkgdir}/usr/lib"
[[ -d $_appdir ]] || {
_appdir=${_appdir%/*}
_appfile=/app.asar
}
mv "$_appdir" "${pkgdir}/usr/lib/${_pkgname}"
install -Dm644 "${srcdir}/${_pkgname}/LICENSE" "${pkgdir}/usr/share/licenses/${_pkgname}/LICENSE"
install -Dm755 /dev/stdin "${pkgdir}/usr/bin/${_pkgname}" <<END
#!/bin/sh
exec /usr/lib/electron${_electron_version}/electron /usr/lib/$_pkgname$_appfile "\$@"
END
}
|