Skip to content

Commit cf77b2c

Browse files
committed
superproductivity: optimize packaging process
1 parent f806f33 commit cf77b2c

6 files changed

Lines changed: 147 additions & 23 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Copyright Arch Linux Contributors
2+
3+
Permission to use, copy, modify, and/or distribute this software for
4+
any purpose with or without fee is hereby granted.
5+
6+
THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL
7+
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
8+
OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
9+
FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
10+
DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
11+
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
12+
OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Lines changed: 63 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,94 @@
1-
# Maintainer: Mahdi Sarikhani <mahdisarikhani@outlook.com>
1+
# Maintainer: DeepChirp <deepchirp@archlinuxcn.org>
2+
# Contributor: Mahdi Sarikhani <mahdisarikhani@outlook.com>
23
# Contributor: Anna <morganamilo@gmail.com>
34

45
pkgname=superproductivity
5-
_name=super-productivity
6+
_reponame=super-productivity
67
pkgver=18.1.3
8+
_electronversion=38
79
pkgrel=1
810
pkgdesc="An advanced todo list app with timeboxing and time tracking capabilities"
911
arch=('x86_64')
1012
url="https://super-productivity.com"
1113
license=('MIT')
12-
_electron=electron38
13-
depends=('bash' "${_electron}" 'gcc-libs' 'glibc' 'hicolor-icon-theme')
14-
makedepends=('nvm')
15-
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/johannesjo/super-productivity/archive/v${pkgver}.tar.gz"
14+
depends=('bash' "electron${_electronversion}" 'hicolor-icon-theme')
15+
makedepends=('nodejs-lts-jod' 'npm')
16+
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/johannesjo/${_reponame}/archive/v${pkgver}.tar.gz"
17+
"fix-wayland-icon.patch"
1618
"${pkgname}.desktop"
1719
"${pkgname}.sh")
1820
sha256sums=('15181b472547e34d893604c8d64a9e6a356cabe2624020be1e61f26d4b4aedb2'
19-
'a8945d93cacbe189b538da601b3f6ace0588c3b126236e763e8f2010005513bb'
20-
'f9ca69e16223b3dcfa0d8ae9dbbff231255482d85f0d72ddcc5033dac890741e')
21+
'7faa4450d82737b7b0b15a4ce82b79e1ab1fe3c79c88b4779919d64d454c9d1c'
22+
'232835a84d6a54a06c2114a01333dfbe3a29405abc3e598df64a784a99a919c6'
23+
'291f50480f5a61bc9c68db7d44cd0412071128706baa868a9cb854f8779a1980')
2124

2225
prepare() {
23-
source /usr/share/nvm/init-nvm.sh
24-
sed -i "s/@ELECTRON@/${_electron}/" "${pkgname}.sh"
26+
sed -e "
27+
s/@electronversion@/${_electronversion}/g
28+
s/@appname@/${pkgname}/g
29+
s/@runname@/app.asar/g
30+
s/@cfgdirname@/${_pkgname}/g
31+
s/@options@/env ELECTRON_OZONE_PLATFORM_HINT=auto/g
32+
" -i "${srcdir}/${pkgname}.sh"
2533

26-
cd "${_name}-${pkgver}"
34+
cd "${srcdir}/${_reponame}-${pkgver}"
35+
36+
# Fix the window title bar icon
37+
patch -Np1 -i "${srcdir}/fix-wayland-icon.patch"
38+
39+
export npm_config_cache="$srcdir/npm_cache"
2740
export ELECTRON_SKIP_BINARY_DOWNLOAD=1
28-
nvm install
29-
npm install
41+
export SYSTEM_ELECTRON_VERSION="$(electron${_electronversion} -v | sed 's/v//g')"
42+
43+
NODE_ENV=development npm ci
3044
}
3145

3246
build() {
33-
cd "${_name}-${pkgver}"
34-
npm run build
35-
npx electron-builder --linux --dir \
36-
-c.electronDist="/usr/lib/${_electron}" \
37-
-c.electronVersion="$(cat /usr/lib/${_electron}/version)"
47+
cd "${srcdir}/${_reponame}-${pkgver}"
48+
49+
export npm_config_cache="$srcdir/npm_cache"
50+
export ELECTRON_SKIP_BINARY_DOWNLOAD=1
51+
export SYSTEM_ELECTRON_VERSION="$(electron${_electronversion} -v | sed 's/v//g')"
52+
electronDist="/usr/lib/electron${_electronversion}"
53+
54+
npm run buildFrontend:prod:es6
55+
npm run electron:build
56+
57+
find .tmp/angular-dist -name '*.map' -type f -delete
58+
59+
pushd node_modules
60+
61+
# Mobile Native Bridge Plugin
62+
rm -rf @capacitor
63+
64+
find -name '*.map' -type f -print -delete
65+
find -name '*.c' -type f -print -delete
66+
find -name '*.h' -type f -print -delete
67+
find -name '*.ts' -type f -print -delete
68+
find -name '*.cts' -type f -print -delete
69+
find -name '*.md' -type f -print -delete
70+
find -name test.js -type f -print -delete
71+
72+
find -type d -name 'Tests' -prune -exec rm -rf {} +
73+
74+
find . -type d -empty -print -delete
75+
76+
popd
77+
78+
NODE_ENV=production npm exec -c "electron-builder --linux dir -c.electronDist=${electronDist} -c.electronVersion=${SYSTEM_ELECTRON_VERSION}"
3879
}
3980

4081
package() {
41-
cd "${_name}-${pkgver}"
82+
cd "${srcdir}/${_reponame}-${pkgver}"
83+
4284
install -Dm644 .tmp/app-builds/linux-unpacked/resources/app.asar -t "${pkgdir}/usr/lib/${pkgname}"
4385
cp -r .tmp/app-builds/linux-unpacked/resources/app.asar.unpacked "${pkgdir}/usr/lib/${pkgname}"
86+
4487
install -Dm755 "${srcdir}/${pkgname}.sh" "${pkgdir}/usr/bin/${pkgname}"
4588
install -Dm644 "${srcdir}/${pkgname}.desktop" -t "${pkgdir}/usr/share/applications"
4689
for i in 16 32 48 64 128 256 512 1024; do
4790
install -Dm644 "build/icons/${i}x${i}.png" "${pkgdir}/usr/share/icons/hicolor/${i}x${i}/apps/${pkgname}.png"
4891
done
92+
4993
install -Dm644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
5094
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
[[annotations]]
2+
path = [
3+
"PKGBUILD",
4+
"README.md",
5+
"keys/**",
6+
".SRCINFO",
7+
".nvchecker.toml",
8+
"*.install",
9+
"*.sysusers",
10+
"*.tmpfiles",
11+
"*.logrotate",
12+
"*.pam",
13+
"*.service",
14+
"*.sh",
15+
"*.socket",
16+
"*.timer",
17+
"*.desktop",
18+
"*.hook",
19+
]
20+
SPDX-FileCopyrightText = "Arch Linux contributors"
21+
SPDX-License-Identifier = "0BSD"
22+
23+
[[annotations]]
24+
path = [
25+
"fix-wayland-icon.patch",
26+
]
27+
SPDX-FileCopyrightText = "Super Productivity contributors"
28+
SPDX-License-Identifier = "MIT"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/electron/main.ts b/electron/main.ts
2+
index c71cbfd..be026ae 100644
3+
--- a/electron/main.ts
4+
+++ b/electron/main.ts
5+
@@ -2,6 +2,8 @@ import { app } from 'electron';
6+
import { PROTOCOL_PREFIX } from './protocol-handler';
7+
import { startApp } from './start-app';
8+
9+
+(app as any).setDesktopName('superproductivity.desktop');
10+
+
11+
const IS_MAC = process.platform === 'darwin';
12+
13+
if (!IS_MAC) {

archlinuxcn/superproductivity/superproductivity.desktop

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
Type=Application
33
Name=Super Productivity
44
GenericName=ToDo List and Time Tracker
5+
GenericName[zh_CN]=待办事项与时间追踪
56
Comment=A todo list and time tracking app
7+
Comment[zh_CN]=一款待办事项与时间追踪应用
68
Icon=superproductivity
79
Exec=superproductivity %U
810
Terminal=false
911
Categories=Office;ProjectManagement;
10-
StartupWMClass=superProductivity
Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1-
#!/usr/bin/bash
2-
3-
exec @ELECTRON@ /usr/lib/superproductivity/app.asar "$@"
1+
#!/bin/bash
2+
set -o pipefail
3+
_APPDIR="/usr/lib/@appname@"
4+
_RUNNAME="${_APPDIR}/@runname@"
5+
_CFGDIR="@cfgdirname@/"
6+
_OPTIONS="@options@"
7+
export PATH="${_APPDIR}:${PATH}"
8+
export LD_LIBRARY_PATH="${_APPDIR}/swiftshader:${_APPDIR}/lib:${LD_LIBRARY_PATH}"
9+
export ELECTRON_IS_DEV=0
10+
export ELECTRON_FORCE_IS_PACKAGED=true
11+
export ELECTRON_DISABLE_SECURITY_WARNINGS=true
12+
export ELECTRON_OVERRIDE_DIST_PATH="/usr/bin/electron@electronversion@"
13+
export NODE_ENV=production
14+
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
15+
export _FLAGS_FILE="${XDG_CONFIG_HOME}/${_CFGDIR}@appname@-flags.conf"
16+
declare -a _USER_FLAGS
17+
if [[ -f "${_FLAGS_FILE}" ]]; then
18+
while read -r line; do
19+
if [[ ! "${line}" =~ ^[[:space:]]*#.* ]]; then
20+
_USER_FLAGS+=("${line}")
21+
fi
22+
done < "${_FLAGS_FILE}"
23+
fi
24+
cd "${_APPDIR}" || { echo "Failed to change directory to ${_APPDIR}"; exit 1; }
25+
if [[ "${EUID}" -ne 0 ]] || [[ "${ELECTRON_RUN_AS_NODE}" ]]; then
26+
exec electron@electronversion@ "${_RUNNAME}" ${_OPTIONS} "${_USER_FLAGS[@]}" "$@"
27+
else
28+
exec electron@electronversion@ "${_RUNNAME}" ${_OPTIONS} --no-sandbox "${_USER_FLAGS[@]}" "$@"
29+
fi

0 commit comments

Comments
 (0)