aboutsummaryrefslogtreecommitdiffstats
path: root/typora-bin
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-08 21:34:56 +0200
committerDanilo M. <danix@danix.xyz>2026-08-08 21:34:56 +0200
commit4e34c235cd982baa2b8f8e01d081f3d148050cba (patch)
tree107ff167428e28d853a2614fff14c244654cf00c /typora-bin
parentf67bcd793194789ab78452f9d4f3133ce2517ee1 (diff)
downloadmy-slackbuilds-4e34c235cd982baa2b8f8e01d081f3d148050cba.tar.gz
my-slackbuilds-4e34c235cd982baa2b8f8e01d081f3d148050cba.zip
typora-bin: install to a versioned /opt directory
Was /opt/Typora-linux-x64 (upstream's own unversioned name), now /opt/typora-bin-$VERSION, matching kitty-bin and the rest of the repo. Upgrades can no longer leave a previous release's files behind. The versioned path is now generated rather than written down twice: the wrapper ships an @APPDIR@ placeholder that the SlackBuild substitutes, and the chrome-sandbox setuid line is appended to doinst.sh at build time. Both would otherwise be stale-version traps on the next bump, the doinst.sh one silently costing the sandbox its setuid bit. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'typora-bin')
-rw-r--r--typora-bin/README9
-rw-r--r--typora-bin/doinst.sh4
-rw-r--r--typora-bin/typora-bin.SlackBuild22
-rw-r--r--typora-bin/typora.sh4
4 files changed, 27 insertions, 12 deletions
diff --git a/typora-bin/README b/typora-bin/README
index a04f077..040e31c 100644
--- a/typora-bin/README
+++ b/typora-bin/README
@@ -11,8 +11,9 @@ Typora is proprietary paid software. It ships as a time-limited free
trial and needs a purchased license key for continued use. Packaging
the tarball does not grant a license; see the homepage for terms.
-The app is installed under /opt/Typora-linux-x64 and launched through
-the /usr/bin/typora wrapper, which enables Electron's Ozone Wayland
+The app is installed under a versioned directory in /opt (for this
+release, /opt/typora-bin-1.14.9) and launched through the
+/usr/bin/typora wrapper, which enables Electron's Ozone Wayland
backend when it detects a Wayland session and otherwise leaves the
default X11 path alone. Force either backend by setting
TYPORA_OZONE=wayland or TYPORA_OZONE=x11.
@@ -25,5 +26,5 @@ Export to PDF works out of the box. For docx, epub, LaTeX and other
pandoc formats, install pandoc (available on SBo).
Upstream's bundled Chromium license file is not duplicated into
-/usr/doc; it ships in place as
-/opt/Typora-linux-x64/LICENSES.chromium.html.
+/usr/doc; it ships in place as LICENSES.chromium.html in that same
+directory.
diff --git a/typora-bin/doinst.sh b/typora-bin/doinst.sh
index 16b9893..9d5d664 100644
--- a/typora-bin/doinst.sh
+++ b/typora-bin/doinst.sh
@@ -9,5 +9,5 @@ if [ -e usr/share/icons/hicolor/icon-theme.cache ]; then
fi
# Chromium's SUID sandbox helper must be setuid root. Re-assert in case the
-# package did not preserve the 4755 bit.
-chmod 4755 opt/Typora-linux-x64/chrome-sandbox 2>/dev/null
+# package did not preserve the 4755 bit. The versioned path is appended by
+# the SlackBuild, so it cannot go stale on a version bump.
diff --git a/typora-bin/typora-bin.SlackBuild b/typora-bin/typora-bin.SlackBuild
index be19fe7..c8788e1 100644
--- a/typora-bin/typora-bin.SlackBuild
+++ b/typora-bin/typora-bin.SlackBuild
@@ -53,9 +53,11 @@ TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
-# Where the Electron bundle lands. Upstream hardcodes nothing, but its own
-# tarball layout is bin/Typora-linux-x64, so keep that name under /opt.
-APPDIR=/opt/$SRCNAM-linux-x64
+# Where the Electron bundle lands. Versioned, so upgrades cannot leave a
+# previous release's files behind and two versions can coexist. Upstream
+# resolves resources/ relative to its own binary, so any prefix works as long
+# as the tree stays intact.
+APPDIR=/opt/$PRGNAM-$VERSION
set -e
@@ -92,10 +94,16 @@ done
# Launch through a wrapper rather than a symlink to the binary: it picks the
# Ozone Wayland backend when a Wayland session is detected, so one package
-# behaves correctly in both session types.
+# behaves correctly in both session types. APPDIR is versioned, so stamp it
+# in here instead of hardcoding it in the script.
mkdir -p $PKG/usr/bin
-cat $CWD/typora.sh > $PKG/usr/bin/typora
+sed "s|@APPDIR@|$APPDIR|" $CWD/typora.sh > $PKG/usr/bin/typora
chmod 755 $PKG/usr/bin/typora
+# Fail loudly rather than shipping a launcher that points nowhere.
+if grep -q '@APPDIR@' $PKG/usr/bin/typora ; then
+ echo "ERROR: @APPDIR@ substitution failed in typora.sh" 1>&2
+ exit 1
+fi
# Upstream ships no .desktop file and no hicolor icons, only a macOS-style
# icon set under resources/assets/icon. The @2x variants are just the next
@@ -122,6 +130,10 @@ cat $CWD/$PRGNAM.nvchecker > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.nvchecker
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh
+# APPDIR is versioned; append the chmod here so doinst.sh needs no edit on a
+# bump. Leading ./ and no slash on APPDIR: doinst.sh runs from the root of
+# the installed filesystem.
+echo "chmod 4755 .$APPDIR/chrome-sandbox 2>/dev/null" >> $PKG/install/doinst.sh
chown -R root:root $PKG
find -L $PKG \
diff --git a/typora-bin/typora.sh b/typora-bin/typora.sh
index 9ecdf48..4f56585 100644
--- a/typora-bin/typora.sh
+++ b/typora-bin/typora.sh
@@ -8,7 +8,9 @@
#
# Override either way with TYPORA_OZONE=wayland or TYPORA_OZONE=x11.
-APPDIR=/opt/Typora-linux-x64
+# @APPDIR@ is substituted by the SlackBuild at build time (it carries the
+# package version, so it must not be hardcoded here).
+APPDIR=@APPDIR@
ozone=${TYPORA_OZONE:-auto}
if [ "$ozone" = auto ]; then