This commit is contained in:
Antoine Martin 2023-05-03 20:31:36 -04:00
parent 3be6a2d1e5
commit 3572424321
4 changed files with 90 additions and 58 deletions

View file

@ -3,22 +3,19 @@
pkgname="joplin"
pkgver=2.9.17
pkgdesc="A note taking and to-do application with synchronization capabilities"
pkgrel=0
install="joplin.install"
depends="
electron
gtk3
libexif
libgsf
libjpeg-turbo
libwebp
libxss
nodejs>=17.3
nss
orc
rsync
libvips
libappindicator-gtk2
coreutils
"
arch="x86_64"
makedepends="
@ -29,15 +26,20 @@ makedepends="
jq
yq
electron
libgsf
libgsf-dev
libexif-dev
libjpeg-turbo-dev
libwebp-dev
libxss-dev
node-gyp>=8.4.1
libvips
libvips-dev
libsecret-dev
"
url="https://joplinapp.org/"
subpackages="$pkgname-desktop"
license="MIT"
source="
joplin-${pkgver}.tar.gz::https://github.com/laurent22/joplin/archive/v${pkgver}.tar.gz
joplin-$pkgver.tar.gz::https://github.com/laurent22/joplin/archive/v$pkgver.tar.gz
joplin.desktop
joplin-desktop.sh
joplin.sh
@ -48,54 +50,54 @@ _yarn_cache="yarn-cache"
## Sets up a local cache to prevent the redownloding the packages on rebuilds
_get_cache() {
if [[ "${_yarn_cache}" =~ ^/ ]]; then
printf "%s" "${_yarn_cache}"
if [[ "$_yarn_cache" =~ ^/ ]]; then
printf "%s" "$_yarn_cache"
else
printf "%s" "${srcdir}/${_yarn_cache}"
printf "%s" "$srcdir/$_yarn_cache"
fi
}
_get_yarn_bin() {
local yarn_bin=$(yq ".yarnPath" ${srcdir}/joplin-${pkgver}/.yarnrc.yml)
local yarn_bin=$(yq ".yarnPath" $srcdir/joplin-$pkgver/.yarnrc.yml)
#Remove quotes
yarn_bin="${yarn_bin%\"}"
yarn_bin="${yarn_bin#\"}"
printf "%s" "${srcdir}/joplin-${pkgver}/${yarn_bin}"
printf "%s" "$srcdir/joplin-$pkgver/$yarn_bin"
}
prepare() {
local cache=$(_get_cache)
local yarn_bin=$(_get_yarn_bin)
msg2 "Yarn cache directory: $cache"
msg2 "Yarn binary: ${yarn_bin}"
msg2 "Yarn binary: $yarn_bin"
msg2 "Disabling husky (git hooks)"
sed -i '/"husky": ".*"/d' "${srcdir}/joplin-${pkgver}/package.json"
sed -i '/"husky": ".*"/d' "$srcdir/joplin-$pkgver/package.json"
# There are so many people
msg2 "Checking Node PATH"
local w_node=$(which node)
if [[ $w_node != "/usr/bin/node" ]]; then
msg2 "WARNING: Using path ${w_node} beware its not the defualt path, check if you are using nvm or similar"
msg2 "WARNING: Using path $w_node beware its not the defualt path, check if you are using nvm or similar"
fi
msg2 "Tweaking .yarnrc"
yq -i -y ".cacheFolder=(\"${cache}\")" "${srcdir}/joplin-${pkgver}/.yarnrc.yml"
yq -i -y ".cacheFolder=(\"$cache\")" "$srcdir/joplin-$pkgver/.yarnrc.yml"
msg2 "Tweaking lerna.json"
local tmp_json="$(mktemp --tmpdir="$srcdir")"
local lerna_json="${srcdir}/joplin-${pkgver}/lerna.json"
local lerna_json="$srcdir/joplin-$pkgver/lerna.json"
msg2 "Deleting app-mobile"
rm -r "${srcdir}/joplin-${pkgver}/packages/app-mobile"
rm -r "${srcdir}/joplin-${pkgver}/packages/app-clipper"
rm -r "$srcdir/joplin-$pkgver/packages/app-mobile"
rm -r "$srcdir/joplin-$pkgver/packages/app-clipper"
if [[ ${pkgver} == 2.9.17 ]]; then
if [[ $pkgver == 2.9.17 ]]; then
# Temporary fix for 2.9.17
# Let yarn resolve version ^2.12.1 of nan package to 2.17.0 instead of 2.15.0 (https://github.com/nodejs/nan/pull/943)
local package_json=${srcdir}/joplin-${pkgver}/package.json
local package_json=$srcdir/joplin-$pkgver/package.json
cp $package_json $package_json.bak
jq '. + {"resolutions": {"nan@^2.12.1": "2.17.0"}}' $package_json.bak > $package_json
jq '. + {"resolutions": {"nan@^2.12.1": "2.17.0"}' $package_json.bak > $package_json
fi
}
@ -104,7 +106,7 @@ build() {
local cache=$(_get_cache)
local yarn_bin=$(_get_yarn_bin)
msg2 "Yarn cache directory: $cache"
cd "${srcdir}/joplin-${pkgver}"
cd "$srcdir/joplin-$pkgver"
# Force Lang
# INFO: https://github.com/alfredopalhares/joplin-pkgbuild/issues/25
@ -126,23 +128,21 @@ check() {
}
package() {
depends=('coreutils' 'libsecret' 'nodejs' 'python')
local cache=$(_get_cache)
local yarn_bin=$(_get_yarn_bin)
msg2 "Yarn cache directory: $cache"
msg2 "Packaging CLI with Repo Gulp"
cd "${srcdir}/joplin-${pkgver}/packages/app-cli/"
cd "$srcdir/joplin-$pkgver/packages/app-cli/"
gulp_bin=$($yarn_bin bin gulp)
msg2 "Using gulp: ${gulp_bin}"
${gulp_bin} build
msg2 "Using gulp: $gulp_bin"
$gulp_bin build
$yarn_bin pack
msg2 "Installing package"
mkdir -p "${pkgdir}/usr/share/joplin/"
mv package.tgz tt"${pkgdir}/usr/share/joplin/"
cd "${pkgdir}/usr/share/joplin/"
mkdir -p "$pkgdir/usr/share/joplin/"
mv package.tgz tt"$pkgdir/usr/share/joplin/"
cd "$pkgdir/usr/share/joplin/"
$yarn_bin init
# FIXME: The repo wran crashed
# You also need to pipe yes, for depeendy
@ -151,7 +151,7 @@ package() {
msg2 "Fixing Directories Permissions"
# Non-deterministic race in npm gives 777 permissions to random directories.
# See https://github.com/npm/cli/issues/1103 for details.
find "${pkgdir}/usr" -type d -exec chmod 755 {} +
find "$pkgdir/usr" -type d -exec chmod 755 {} +
msg2 "Removing References to \$pkgdir"
find "$pkgdir" -name package.json -print0 | xargs -0 sed -i "/_where/d"
@ -159,52 +159,52 @@ package() {
msg2 "Fixing Permissions set by npm"
# npm gives ownership of ALL FILES to build user
# https://bugs.archlinux.org/task/63396
chown -R root:root "${pkgdir}"
chown -R root:root "$pkgdir"
msg2 "Installing LICENSE"
install -Dm644 "${srcdir}/joplin-${pkgver}/LICENSE" -t "${pkgdir}/usr/share/licenses/${pkgname}/"
install -Dm644 "$srcdir/joplin-$pkgver/LICENSE" -t "$pkgdir/usr/share/licenses/$pkgname/"
msg2 "Installing Startup Script"
cd "${srcdir}"
install -Dm755 joplin.sh "${pkgdir}/usr/bin/joplin"
cd "$srcdir"
install -Dm755 joplin.sh "$pkgdir/usr/bin/joplin"
}
package_joplin-desktop() {
pkgdesc="A note taking and to-do application with synchronization capabilities - Desktop"
depends=('electron' 'gtk3' 'libexif' 'libgsf' 'libjpeg-turbo' 'libwebp' 'libxss' 'nodejs'
'nss' 'orc')
optdepends=('libappindicator-gtk3: for tray icon')
conflicts=('joplin-desktop-electron')
desktop() {
# ./generateSha512.js fails if AppImage is not built
mkdir -p "${srcdir}/joplin-${pkgver}/packages/app-desktop/dist/"
touch "${srcdir}/joplin-${pkgver}/packages/app-desktop/dist/AppImage"
mkdir -p "$srcdir/joplin-$pkgver/packages/app-desktop/dist/"
touch "$srcdir/joplin-$pkgver/packages/app-desktop/dist/AppImage"
cd "${srcdir}/joplin-${pkgver}/packages/app-desktop/node_modules/@joplin/"
cd "$srcdir/joplin-$pkgver/packages/app-desktop/node_modules/@joplin/"
ln -sf "../../../fork-uslug" "."
msg2 "Packaging the desktop..."
# TODO: Cleanup app.asar file
cd dist/linux-unpacked/
mkdir -p "${pkgdir}/usr/share/joplin-desktop"
cp -R "." "${pkgdir}/usr/share/joplin-desktop"
mkdir -p "$pkgdir/usr/share/joplin-desktop"
cp -R "." "$pkgdir/usr/share/joplin-desktop"
msg2 "Installing LICENSE..."
cd "${srcdir}/joplin-${pkgver}/"
install -Dm644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
cd "$srcdir/joplin-$pkgver/"
install -Dm644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname"
msg "Installing startup script and desktop file..."
cd "${srcdir}"
install -Dm755 ${srcdir}/joplin-desktop.sh "${pkgdir}/usr/bin/joplin-desktop"
install -Dm644 ${srcdir}/joplin.desktop -t "${pkgdir}/usr/share/applications"
cd "$srcdir"
install -Dm755 $srcdir/joplin-desktop.sh "$pkgdir/usr/bin/joplin-desktop"
install -Dm644 $srcdir/joplin.desktop -t "$pkgdir/usr/share/applications"
msg "Installing icons"
local -r src_icon_dir="${srcdir}/joplin-${pkgver}/packages/app-desktop/build/icons"
local -r src_icon_dir="$srcdir/joplin-$pkgver/packages/app-desktop/build/icons"
local -i size
for size in 16 22 24 32 36 48 64 72 96 128 192 256 512; do
[[ -f "${src_icon_dir}/${size}x${size}.png" ]] && install -Dm644 \
"${src_icon_dir}/${size}x${size}.png" \
"${pkgdir}/usr/share/icons/hicolor/${size}x${size}/apps/joplin.png"
[[ -f "$src_icon_dir/${size}x$size.png" ]] && install -Dm644 \
"$src_icon_dir/${size}x$size.png" \
"$pkgdir/usr/share/icons/hicolor/${size}x$size/apps/joplin.png"
done
}
sha512sums="
decf01d1dd51d6fdfdba7ffd7074d2d22d686e112064fd9232ae7d9947e4261e35c6b7ff30b086321f59adf9fe53f645cf41957216712e49e9ef104a62dc2e0f joplin-2.9.17.tar.gz
dd838bf77552bcd6a4b876ce0a21ab67f01f6462d89954017f7fa587fc0cda7607f92c4969f346c4bb08537f6ec7e62511965b62b65796517a6d29a3a78fe306 joplin.desktop
2e388b2446330ebfa299700969f4ca649a5cac8aac98e574503a7348084eda3741fe5017f35df5ad68a6c1a80bb28a9c1a7fdf4ff207fb8b20f42ac5c26a5ff7 joplin-desktop.sh
723f160523249541ba0f0045a7ddd81563bdaf1463bd64a745605573073b3c1869eb8489bd66cdcbc67a262629b8d5e0f2d021d178280804db4fd97d72937bd5 joplin.sh
"

View file

@ -0,0 +1,12 @@
#!/bin/bash
readonly joplin_dir="/usr/share/joplin-desktop/"
if [[ ! -d $joplin_dir ]]; then
echo "Cannot find /usr/share/joplin-desktop/"
exit 1
fi
cd $joplin_dir
./@joplinapp-desktop "$@"

View file

@ -0,0 +1,8 @@
[Desktop Entry]
Name=Joplin
Comment=Joplin - a note taking and to-do application with synchronization capabilities for Windows, macOS, Linux, Android and iOS.
Exec=/usr/bin/joplin-desktop
Icon=/usr/share/joplin-desktop/resources/build/icons/128x128.png
Terminal=false
Type=Application
Categories=Application;Office;

12
user/joplin/joplin.sh Normal file
View file

@ -0,0 +1,12 @@
#!/bin/bash
readonly joplin_dir="/usr/share/joplin/node_modules/joplin/app/"
if [[ ! -d $joplin_dir ]]; then
echo "Cannot find ${joplin_dir}"
exit 1
fi
cd $joplin_dir
node main.js ${@}