user/trilium: new aport

This commit is contained in:
Antoine Martin 2023-05-03 01:33:58 -04:00
parent 1fc4159ed2
commit c566f00f03
7 changed files with 205 additions and 0 deletions

117
user/trilium/APKBUILD Normal file
View file

@ -0,0 +1,117 @@
# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>
pkgname="trilium"
pkgver=0.59.4
pkgrel=0
pkgdesc="A hierarchical note taking application with focus on building large personal knowledge bases."
arch="x86_64'"
url="https://github.com/zadam/trilium"
license="AGPL-3.0"
depends="electron"
makedepends="
npm
nodejs
"
subpackages="$pkgname-server $pkgname-dumpdb"
source="$pkgname-$pkgver.tar.gz::https://github.com/zadam/trilium/archive/refs/tags/v$pkgver.tar.gz
copy-trilium.sh.patch
config-sample.ini.patch
trilium.sh
trilium-server.sh
trilium-dumpdb.sh
trilium.desktop
"
prepare() {
default_prepare
sed -i "s|@electronversion@|$_electron_version|" ../trilium.sh
}
_trilium_desktop_src_dir=./dist/trilium-linux-x64-src
_trilium_server_src_dir=./dist/trilium-linux-server-x64-src
build() {
export npm_config_cache="$srcdir/npm_cache"
export ELECTRON_SKIP_BINARY_DOWNLOAD=1
npm install --build-from-source
# Building trilium (desktop)
./bin/copy-trilium.sh $_trilium_desktop_src_dir
rm -rf $_trilium_desktop_src_dir/dump-db
rm -r $_trilium_desktop_src_dir/src/public/app-dist/*.mobile.*
npx electron-builder --linux --x64 --dir \
--project=$_trilium_desktop_src_dir \
-c.electronDist=/usr/lib/electron$_electron_version \
-c.electronVersion=$(electron$_electron_version --version | tail -c +2)
# Building trilium-server
grep -v electron package.json > package-server.json
mv package-server.json package.json
./bin/copy-trilium.sh $_trilium_server_src_dir
rm -rf $_trilium_server_src_dir/dump-db
mkdir $_trilium_server_src_dir/node_modules/better-sqlite3/build/Release
cp ./node_modules/better-sqlite3/build/Release/better_sqlite3.node $_trilium_server_src_dir/node_modules/better-sqlite3/build/Release/better_sqlite3.node
rm -r $_trilium_server_src_dir/webpack*
rm -r $_trilium_server_src_dir/electron.js
# Building trilium-dumpdb
cd dump-db
npm install
cp -f ../node_modules/better-sqlite3/build/Release/better_sqlite3.node node_modules/better-sqlite3/build/Release/better_sqlite3.node
}
package() {
install -vDm644 $_trilium_desktop_src_dir/dist/linux-unpacked/resources/app.asar -t "${pkgdir}/usr/lib/${pkgname}"
install -vDm644 $_trilium_desktop_src_dir/package.json -t "${pkgdir}/usr/lib/${pkgname}"
install -vDm644 bin/tpl/anonymize-database.sql -t "${pkgdir}/usr/lib/${pkgname}"
for i in 16 32 64 128 256 512; do
install -vDm644 images/app-icons/png/${i}x${i}.png "${pkgdir}/usr/share/icons/hicolor/${i}x${i}/apps/${pkgname}.png"
done
install -vDm755 "${srcdir}/${pkgname}.sh" "${pkgdir}/usr/bin/trilium"
install -vDm644 "${srcdir}"/${pkgname}.desktop -t "${pkgdir}"/usr/share/applications
}
server() {
pkgdesc="A hierarchical note taking application with focus on building large personal knowledge bases - Server version"
depends="nodejs"
install -vd "${pkgdir}/usr/share/webapps/${pkgname}"
cp -vr $_trilium_server_src_dir/. -t "${pkgdir}/usr/share/webapps/${pkgname}"
chmod -v 755 "${pkgdir}/usr/share/webapps/${pkgname}/src/www"
install -vDm644 $_trilium_server_src_dir/package.json -t "${pkgdir}/usr/share/webapps/${pkgname}"
install -vDm644 bin/tpl/anonymize-database.sql -t "${pkgdir}/usr/share/webapps/${pkgname}"
install -vDm755 "${srcdir}/${pkgname}.sh" "${pkgdir}/usr/bin/trilium-server"
# TODO: setup openrc
# install -vDm644 "${srcdir}"/${pkgname}.service -t "${pkgdir}/usr/lib/systemd/system"
}
dumpdb() {
pkgdesc="An emergency tool to extract notes from the database where they're stored to plain files on the filesystem"
depends="nodejs"
install -vd "${pkgdir}/usr/lib/${pkgname}"
cp -vr dump-db/. -t "${pkgdir}/usr/lib/${pkgname}"
chmod -v 755 "${pkgdir}/usr/lib/${pkgname}/dump-db.js"
install -vDm755 "${srcdir}/${pkgname}.sh" "${pkgdir}/usr/bin/trilium-dumpdb"
}
sha512sums="
96a4788574f66a830515eb8fe11bdc87e1083f04c3f409d095cdde2515c008c2ba32a0554d7e5cda4602c2b20861e5b442e022f3c1be4fd3397c0f9e4d24eae2 trilium-0.59.4.tar.gz
90ed115b3c7664d958f8426ac55253d46e770ebbfc4b7443581943df7e85211d709948e7ca41d698b28d4510c3e4c50244726ce49d44e1fa530fbf8129e42c5a copy-trilium.sh.patch
48fcb6931b632280a16b14744ee64804de1b399b0682076fdf1fa5669f691a53371532363020d8c7fb3704ea7bd633903cab1b92018f88a7170e6c2e213cd149 config-sample.ini.patch
6b03a7cce3836966d00e282d012cce944b8b56e29200fa06e64563a95e4edde591c0018715639a5e2acdbfd11a73ccb8283fbad19efc7dff218e8398c7e12d30 trilium.sh
14a97f1fab392dd9a55440712bf3f2976de20e9c09789392984313455af77d9900445bd06cf2c3a3879a94cab893e83bd4093060f9214b2c201af89d7f62f663 trilium-server.sh
e1fa62cdc2ecde41f5c5336bca3dd2d2b9e65de1a3162ef4ed336aaa7660c2b1c23793df7cdbd09e8b020890de0ba2d58c8704d2d1f0916da1212167c4820c0f trilium-dumpdb.sh
d0c051a0412f17f0373ead660ae6ddfefe5e8f8e2104a0ffc52d9af94c57c1274a2dc8d2317516dafa0fa85263250633acb56556318f21a663105dd7fce9b36f trilium.desktop
"

View file

@ -0,0 +1,13 @@
diff --git a/config-sample.ini.orig b/config-sample.ini
index 0e8da03..046b970 100644
--- a/config-sample.ini.orig
+++ b/config-sample.ini
@@ -9,7 +9,7 @@ noAuthentication=false
noBackup=false
# Disable automatically generating desktop icon
-# noDesktopIcon=true
+noDesktopIcon=true
[Network]
# host setting is relevant only for web deployments - set the host on which the server will listen

View file

@ -0,0 +1,33 @@
diff --git a/./bin/copy-trilium.sh.orig b/./bin/copy-trilium.sh
index ae460ff..95015ca 100755
--- a/./bin/copy-trilium.sh.orig
+++ b/./bin/copy-trilium.sh
@@ -5,12 +5,12 @@ if [[ $# -eq 0 ]] ; then
exit 1
fi
-n exec 16.19.1 npm run webpack
+npm run webpack
DIR=$1
rm -rf $DIR
-mkdir $DIR
+mkdir -p $DIR
echo "Copying Trilium to build directory $DIR"
@@ -27,11 +27,11 @@ cp -r electron.js $DIR/
cp webpack-* $DIR/
# run in subshell (so we return to original dir)
-(cd $DIR && n exec 16.19.1 npm install --only=prod)
+(cd $DIR && npm install --only=prod)
# cleanup of useless files in dependencies
rm -r $DIR/node_modules/image-q/demo
-rm -r $DIR/node_modules/better-sqlite3/Release
+rm -r $DIR/node_modules/better-sqlite3/build/Release
rm -r $DIR/node_modules/better-sqlite3/deps/sqlite3.tar.gz
rm -r $DIR/node_modules/@jimp/plugin-print/fonts
rm -r $DIR/node_modules/jimp/browser

View file

@ -0,0 +1,3 @@
#!/bin/sh
exec node /usr/lib/trilium-dumpdb/dump-db.js $@

View file

@ -0,0 +1,3 @@
#!/bin/sh
exec node /usr/share/webapps/trilium-server/src/www $@

View file

@ -0,0 +1,15 @@
[Desktop Entry]
Name=Trilium Notes
GenericName=Note-taking
Comment=A hierarchical note taking application with focus on building large personal knowledge bases.
Exec=trilium
Terminal=false
Type=Application
Icon=trilium
Categories=Office;Utility
StartupWMClass=Trilium
Actions=safe-mode
[Desktop Action safe-mode]
Name=Run in safe mode
Exec=trilium --safe-mode

21
user/trilium/trilium.sh Normal file
View file

@ -0,0 +1,21 @@
#!/bin/sh
for i in "$@"; do
case $i in
--disable-tls-certificate-check)
export NODE_TLS_REJECT_UNAUTHORIZED=0 # Allows for certificates which aren't in the system's store
shift # This decreases security and shouldn't be used regularly in untrusted networks.
;;
--safe-mode)
export TRILIUM_SAFE_MODE=1 # Enables some extra safety measures (i.e. disabling user scripting) to allow Trilium to load
_safemodecmdargs="--disable-gpu"
shift # if something user-defined is causing it to crash
;;
*)
;;
esac
done
export ELECTRON_IS_DEV=0 # Without this env variable Arch's Electron would open devtools by default
exec electron@electronversion@ /usr/lib/trilium/app.asar $_safemodecmdargs $@