Skip to content

Instantly share code, notes, and snippets.

@kinggrowler
Last active December 31, 2021 19:19
Show Gist options
  • Save kinggrowler/be2c6f0f8af27010e9484ea2052f462e to your computer and use it in GitHub Desktop.
Save kinggrowler/be2c6f0f8af27010e9484ea2052f462e to your computer and use it in GitHub Desktop.
How To detailing the creation of a Scrivener for Linux AppImage
How to build a "Scrivener for Linux" (64bit) AppImage from Source
===============
v1.6 - 2021_12_29
Pre-built AppImages for "Scrivener for Linux" can be downloaded here:
https://www.appimagehub.com/p/1673680
* What is Scrivener?
Scrivener is a word-processing program and outliner designed for authors. Scrivener provides a management system for documents, notes and metadata. This allows the user to organize notes, concepts, research and whole documents for easy access and reference (documents including rich text, images, PDF, audio, video, web pages, etc.). Scrivener offers templates for screenplays, fiction, and non-fiction manuscripts. After writing a text, the user may export it for final formatting to a standard word processor, screenwriting software, desktop publishing software, and others.
Features include a corkboard, the ability to rearrange files by dragging-and-dropping virtual index cards on the corkboard, an outliner, a split screen mode that enables users to edit several documents at once, a full-screen mode, the ability to export text into multiple document formats (including popular e-book formats like EPUB and Mobipocket for Kindle, and various markup languages), the ability to assign multiple keywords (and other metadata) to parts of a text and to sort the parts by keyword (such as characters, locations, themes, narrative lines, etc.), hyperlinks between parts of a text, and "snapshots" (the ability to save a copy of a particular document prior to any drastic changes).
Because of its breadth of interfaces and features, Scrivener has positioned itself not only as a word processor, but as THE project management tool for writers.
Note: Some of these features may not be available in the "Scrivener for Linux" package.
More information about Scrivener:
https://www.literatureandlatte.com/scrivener/overview
https://en.wikipedia.org/wiki/Scrivener_(software)
Additional information on "Scrivener for Linux" can be found on the official forum:
https://forum.literatureandlatte.com/c/scrivener/scrivener-on-linux-unofficial/48
Note: "Scrivener for Linux" is unsupported by Literature & Latte and no future versions are planned; if you need Scrivener functionality that is unavailable in the 1.9.0.1 Linux version, you are welcome to install the latest Scrivener via Wine or in a virtual machine.
Per official comment in this forum post:
https://forum.literatureandlatte.com/t/linux-1-9-01-beta-released/31623
"Version 1.7.2.4 is identical to the current Linux 1.7.2.3 version, but with the beta expiry removed. Version 1.9.0.1 also has no expiry."
"Note that we [Literature & Latte] currently have no capacity or plans to release another Linux version. As a gesture of good-will, we decided to make a concerted effort to provision 1.9.0.1 to the Linux community instead of just removing the trial expiry date on the current version and re-releasing."
* What is an AppImage?
An AppImage is a Linux app that runs on most Linux systems! Download an application, make it executable, and that's it! No need to install. No system libraries or system preferences are altered.
AppImage is a format for distributing portable software on Linux without needing superuser permissions to install the application. It tries to allow Linux distribution-agnostic binary software deployment for application developers.
AppImage aims to be an application deployment system for Linux with the following objectives: simplicity, binary compatibility, distro agnosticism, no installation, no root permission, being portable, and keeping the underlying operating system untouched.
AppImage does not install the application in the traditional Linux sense. Instead of putting the application's various files in the distro's appropriate places in the file system, the AppImage file is just the application's compressed image. When it runs, the file is mounted with FUSE.
More information about the appimage format:
https://appimage.org/
https://docs.appimage.org/introduction/
* Who should use this AppImage?
Anyone who wants a portable way to run "Scrivener for Linux!" All dependencies are handled and it should "just work" on your 64bit Linux system.
But you don't need to build your own version from scratch! Attila Orosz is kind enough to host a pre-build, downloadable version on his website; all steps in this document use his original work as inspiration; all errors herein are mine and not Attila's.
Sadly, Attila's website describing the "Scrivener for Linux" AppImage seems to no longer be maintained; you can view an archive of his old website here:
https://web.archive.org/web/20210414231146/https://www.wayoflinux.com/blog/scrivener-returns
* Adding additional Spelling-check Dictionaries:
Instructions for adding new Spell-check dictionaries can be found at the end of this document, in Appendix A.
* Recipe for a 64bit AppImage:
It is HIGHLY recommended that you familiarize yourself with this entire document first before trying it.
Note: We (mostly) use 64bit Ubuntu Xenial packages because those have proven to be stable for this application. We assume a bash shell. The author understands that there are many, many ways to do the same tasks in Linux; the following commands are examples of some of these, and perhaps not the simplest!
This document uses the official Literature & Latte Debian packages to create this AppImage. 'Literature & Latte' is sometimes referred to as 'L&L' below.
All paths below use fictional user 'erkus' as an example; all commands are run as an ordinary user--root or sudo is not used!
# here we go...
1) Create a working directory and download files:
]$ cd $HOME ; mkdir -p $HOME/appimage/{squashfs-root,source,aspell}
]$ cd $HOME/appimage/source/
]$ pwd
/home/erkus/appimage/source
+ Download "Scrivener for Linux" 64bit versions from L&L:
https://forum.literatureandlatte.com/t/linux-1-9-01-beta-released/31623
http://www.literatureandlatte.com/scrivenerforlinux/scrivener-1.9.0.1-amd64.deb
http://www.literatureandlatte.com/scrivenerforlinux/scrivener-1.7.2.4-amd64.deb
# we use wget (but you can certainly use curl if you prefer)
]$ wget http://www.literatureandlatte.com/scrivenerforlinux/scrivener-1.9.0.1-amd64.deb
]$ wget http://www.literatureandlatte.com/scrivenerforlinux/scrivener-1.7.2.4-amd64.deb
+ Download Ubuntu libraries:
Note: All commands specify a US mirror, however you can pick an Ubuntu mirror closest to you; you can view a list of mirrors like so:
]$ wget -qO - mirrors.ubuntu.com/mirrors.txt | less
+ Download libaspell and libaspell-dev:
https://launchpad.net/ubuntu/xenial/amd64/libaspell15/0.60.7~20110707-3ubuntu0.1
https://launchpad.net/ubuntu/xenial/amd64/libaspell-dev/0.60.7~20110707-3ubuntu0.1
]$ wget http://launchpadlibrarian.net/446732899/libaspell15_0.60.7~20110707-3ubuntu0.1_amd64.deb
]$ wget http://launchpadlibrarian.net/446732895/libaspell-dev_0.60.7~20110707-3ubuntu0.1_amd64.deb
+ Download libpng16-16:
https://launchpad.net/ubuntu/xenial/amd64/libpng16-16/1.6.20-2
]$ wget http://launchpadlibrarian.net/240323544/libpng16-16_1.6.20-2_amd64.deb
+ Download libgstreamer and libgstreamer-plugins-base:
https://launchpad.net/ubuntu/xenial/amd64/libgstreamer0.10-0/0.10.36-1.5ubuntu1
https://launchpad.net/ubuntu/xenial/amd64/libgstreamer-plugins-base0.10-0/0.10.36-2ubuntu0.2
]$ wget http://launchpadlibrarian.net/215074266/libgstreamer0.10-0_0.10.36-1.5ubuntu1_amd64.deb
]$ wget http://launchpadlibrarian.net/421117832/libgstreamer-plugins-base0.10-0_0.10.36-2ubuntu0.2_amd64.deb
+ Download Ubuntu Focal libfreetype6:
(Xenial version does not work, as we need libfreetype > 2.9.1)
https://launchpad.net/ubuntu/focal/amd64/libfreetype6/2.10.1-2ubuntu0.1
]$ wget http://launchpadlibrarian.net/502747085/libfreetype6_2.10.1-2ubuntu0.1_amd64.deb
+ Download libbz2 (necessary for using this AppImage on Fedora):
https://launchpad.net/ubuntu/xenial/amd64/libbz2-1.0/1.0.6-8ubuntu0.2
]$ wget http://launchpadlibrarian.net/431755124/libbz2-1.0_1.0.6-8ubuntu0.2_amd64.deb
+ Download AppImage 'AppRun' and 'AppImageKit' binaries:
https://github.com/AppImage/AppImageKit/releases
]$ wget https://github.com/AppImage/AppImageKit/releases/download/13/AppRun-x86_64
]$ wget https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-x86_64.AppImage
+ Download AppImage Desktop Integration file:
Note: AppImage "desktopintegration" script is deprecated in favor of installing appimaged instead; however this author prefers using the script rather than installing a separate 'appimaged' application. You can skip this if you prefer appimaged.
https://raw.githubusercontent.com/simoniz0r/AppImages/master/resources/desktopintegration
]$ wget https://raw.githubusercontent.com/simoniz0r/AppImages/master/resources/desktopintegration
# what do we have so far?
]$ pwd ; ls -1
/home/erkus/appimage/source
appimagetool-x86_64.AppImage
AppRun-x86_64
desktopintegration
libaspell15_0.60.7~20110707-3ubuntu0.1_amd64.deb
libaspell-dev_0.60.7~20110707-3ubuntu0.1_amd64.deb
libbz2-1.0_1.0.6-8ubuntu0.2_amd64.deb
libfreetype6_2.10.1-2ubuntu0.1_amd64.deb
libgstreamer0.10-0_0.10.36-1.5ubuntu1_amd64.deb
libgstreamer-plugins-base0.10-0_0.10.36-2ubuntu0.2_amd64.deb
libpng16-16_1.6.20-2_amd64.deb
scrivener-1.7.2.4-amd64.deb
scrivener-1.9.0.1-amd64.deb
2) Extract some packages into $HOME/working/squashfs-root:
Note: This $HOME/working/squashfs-root/ directory will become the AppImage base directory.
# extract latest Scrivener package
]$ pwd
/home/erkus/appimage/source
# ...but let's look inside this package first
]$ ar -t ./scrivener-1.9.0.1-amd64.deb
debian-binary
control.tar.gz
data.tar.gz
# use 'ar' utility (from binutils package) to extract only the necessary archive
]$ ar -xv scrivener-1.9.0.1-amd64.deb data.tar.gz
# use 'tar' to extract archive contents to the AppImage base directory
]$ tar -xvzpf ./data.tar.gz -C ../squashfs-root/
]$ ls -F1A ../squashfs-root/
usr/
# extract libraries to AppImage base directory
]$ pwd ; ls -1 lib*.deb
/home/erkus/appimage/source
libaspell15_0.60.7~20110707-3ubuntu0.1_amd64.deb
libaspell-dev_0.60.7~20110707-3ubuntu0.1_amd64.deb
libbz2-1.0_1.0.6-8ubuntu0.2_amd64.deb
libfreetype6_2.10.1-2ubuntu0.1_amd64.deb
libgstreamer0.10-0_0.10.36-1.5ubuntu1_amd64.deb
libgstreamer-plugins-base0.10-0_0.10.36-2ubuntu0.2_amd64.deb
libpng16-16_1.6.20-2_amd64.deb
# each extraction of "data.tar.xz" overwrites the previous, so no need to delete them
]$ ar -xv libaspell15_0.60.7~20110707-3build1_amd64.deb data.tar.xz
]$ tar -xvf ./data.tar.xz -C ../squashfs-root/
]$ ar -xv libaspell-dev_0.60.7~20110707-3build1_amd64.deb data.tar.xz
]$ tar -xvf ./data.tar.xz -C ../squashfs-root/
]$ ar xv libfreetype6_2.9.1-3_amd64.deb data.tar.xz
]$ tar -xvf ./data.tar.xz -C ../squashfs-root/
]$ ar -xv libgstreamer0.10-0_0.10.36-1.5ubuntu1_amd64.deb data.tar.xz
]$ tar -xvf ./data.tar.xz -C ../squashfs-root/
]$ ar -xv libgstreamer-plugins-base0.10-0_0.10.36-2ubuntu0.2_amd64.deb data.tar.xz
]$ tar -xvf ./data.tar.xz -C ../squashfs-root/
]$ ar xv libpng16-16_1.6.20-2_amd64.deb data.tar.xz
]$ tar -xvf ./data.tar.xz -C ../squashfs-root/
OR do this all in one shot:
]$ shopt -s nullglob ; for x in lib*.deb ; do ar -xv $x data.tar.xz && tar -C ../squashfs-root/ -xvf ./data.tar.xz ; done ; shopt -u nullglob
]$ rm data.tar.xz
OR even:
]$ shopt -s nullglob ; for x in lib*.deb ; do ar -p $x data.tar.xz | tar -C ../squashfs-root/ -xJ ; done ; shopt -u nullglob
# we must delete the old libfreetype libraries installed with the scrivener package
]$ cd $HOME/appimage/squashfs-root/usr/lib/lib/x86_64-linux-gnu
]$ rm -fv libfreetype.so*
removed './libfreetype.so.6'
removed './libfreetype.so.6.17.1'
3) Download aspell dictionary source files:
]$ cd $HOME/appimage/aspell
]$ pwd
/home/erkus/appimage/aspell
+ Download dictionaries from here:
Note: As an example, we will download English, French and Spanish.
https://ftp.gnu.org/gnu/aspell/dict/0index.html
]$ wget ftp://ftp.gnu.org/gnu/aspell/dict/en/aspell6-en-2020.12.07-0.tar.bz2
]$ wget ftp://ftp.gnu.org/gnu/aspell/dict/fr/aspell-fr-0.50-3.tar.bz2
]$ wget ftp://ftp.gnu.org/gnu/aspell/dict/es/aspell6-es-1.11-2.tar.bz2
+ Extract Aspell source files:
]$ cd $HOME/appimage/aspell
]$ pwd
/home/erkus/appimage/aspell
]$ tar -xvjpf aspell6-en-2020.12.07-0.tar.bz2
]$ tar -xvjpf aspell6-es-1.11-2.tar.bz2
]$ tar -xvjpf aspell-fr-0.50-3.tar.bz2
]$ ls -F1A
aspell6-en-2020.12.07-0/
aspell6-en-2020.12.07-0.tar.bz2
aspell6-es-1.11-2/
aspell6-es-1.11-2.tar.bz2
aspell-fr-0.50-3/
aspell-fr-0.50-3.tar.bz2
+ Build Dictionaries:
Note: We MUST put all Aspell dictionaries and data in ./usr/lib/aspell, else the 'libaspell.so' library won't work correctly!
# set a handy ENV variable to assist our build
]$ export ASPELL_VAL="data-dir $HOME/appimage/squashfs-root/usr/lib/aspell ; dict-dir $HOME/appimage/squashfs-root/usr/lib/aspell"
]$ echo $ASPELL_VAL
data-dir /home/erkus/appimage/squashfs-root/usr/lib/aspell ; dict-dir /home/erkus/appimage/squashfs-root/usr/lib/aspell
# install English dictionary
]$ cd $HOME/appimage/aspell/aspell6-en-2020.12.07-0/
]$ env ASPELL_CONF="$ASPELL_VAL" ./configure
]$ make && make install
# install French dictionary
]$ cd $HOME/appimage/aspell/aspell-fr-0.50-3
]$ env ASPELL_CONF="$ASPELL_VAL" ./configure
]$ make && make install
# install Spanish dictionary
]$ cd $HOME/appimage/aspell/aspell6-es-1.11-2
]$ env ASPELL_CONF="$ASPELL_VAL" ./configure
]$ make && make install
4) copy AppRun binary to $HOME/working/squashfs-root directory:
]$ cd $HOME/appimage/source
]$ cp ./AppRun-x86_64 ../squashfs-root/AppRun
]$ chmod 755 ../squashfs-root/AppRun
5) This is a tricky part: we move some directories and files around:
(We do this partially to neaten the directory structure but also to make AppImage env variables easier to read.)
# what do we have in the AppImage root?
]$ cd $HOME/appimage/squashfs-root
]$ pwd ; ls -F1A
/home/erkus/appimage/squashfs-root
AppRun*
lib/
usr/
# move the ./lib/ contents to ./usr/lib/
]$ cd $HOME/appimage/squashfs-root/lib
]$ pwd
/home/erkus/appimage/squashfs-root/lib
# use tar to make an exact copy of the 'lib' directory contents (you can certainly use a different command for this!)
]$ tar -cpf - . | ( cd ../usr/lib ; tar -xvpf - )
]$ cd ..
]$ rm -rf lib/
# tidy the 'scrivener' directories
]$ cd $HOME/appimage/squashfs-root/usr/share/scrivener
]$ mv translations/ ..
]$ mkdir -p ../doc/scrivener
]$ mv licence.htm readme.txt WordNet_License.txt ../doc/scrivener/
# move all the Scrivener files to ./usr directory
]$ cd $HOME/appimage/squashfs-root/usr/share/scrivener
]$ tar -cpf - . | ( cd ../../ ; tar -xvpf - . --keep-old-files )
]$ cd ..
]$ rm -rf scrivener/
# relocate icons per AppImage specification
]$ cd $HOME/appimage/squashfs-root/usr/share/icons
]$ mkdir hicolor
]$ mv * ./hicolor/
Note: These next two are very strange.... As mentioned, we must have Aspell dictionaries and data in ./usr/lib/aspell, however Scrivener ALSO needs them in ./usr/bin/aspell/{data,dict} !
If we are missing either one, NONE of it works--Scrivener needs the one location, and libaspell.so* libraries need the other.
But there's no sense keeping TWO copies of the Aspell data-dir and dict-dir....
# move all original Aspell data files, but DO NOT clobber any we installed moments earlier
# ...we then create a symlink so that the Scrivener binary can still find them
]$ cd $HOME/appimage/squashfs-root/usr/bin/Aspell/data
]$ mv -vn * ../../../lib/aspell/
]$ cd ..
]$ rm -rf data && ln -s ../../lib/aspell/ data
# move all original Aspell dictionary files, but DO NOT clobber any we installed moments earlier
# ...we then create a symlink so that the Scrivener binary can still find them
]$ cd $HOME/appimage/squashfs-root/usr/bin/Aspell/dict
]$ mv -vn * ../../../lib/aspell/
]$ cd ..
]$ rm -rf dict && ln -s ../../lib/aspell/ dict
# how does it look in the AppImage root so far?
]$ cd $HOME/appimage/squashfs-root/
]$ ls -F1A
AppRun*
usr/
# start to create AppImage files and links
]$ ln -s ./usr/share/applications/Scrivener.desktop
]$ ln -s ./usr/share/icons/hicolor/256x256/apps/Scrivener.png
]$ ln -s Scrivener.png .DirIcon
ls -F1A
AppRun*
.DirIcon@
Scrivener.desktop@
Scrivener.png@
usr/
Note: these symlinks are per the AppImage design spec here:
https://docs.appimage.org/reference/appdir.html
"Can be a symlink to subdirectories such as usr/share/applications/..."
"Can be a symlink to subdirectories such as usr/share/icons/hicolor/...
6) Edit some files (use your favorite editor):
Edit ./Scrivener.desktop to call scrivener_env.wrapper rather than the Scrivener binary or other script,
per this archived document (THIS is what enables desktop integration):
https://raw.githubusercontent.com/simoniz0r/AppImages/master/resources/desktopintegration
Note: AppImage "desktopintegration" script is deprecated in favor of installing appimaged instead:
https://github.com/AppImage/AppImageKit/wiki/AppImageKit-components#desktopintegration
...but why should we install a separate service? The author prefers not to do so.
The relevant Exec lines in ./Scrivener.desktop file should look like this:
Exec=scrivener_env.wrapper %U
TryExec=scrivener_env.wrapper
Also delete the PATH line from Scrivener.desktop file.
Also add these lines at the end:
X-KDE-SubstituteUID=false
X-AppImage-Version=1.9.0.1_beta
We MUST add a semicolon to the end of key "Categories":
Categories=Office;
Add "StartupWMClass=Scrivener" at the end of the file (to prevent duplicate Scrivener icons appearing in some docks):
The final .desktop file should look similar to this:
[Desktop Entry]
Name=Scrivener
GenericName=Scrivener writing software
Comment=Scrivener writing software
Icon=Scrivener
Exec=scrivener_env.wrapper %U
TryExec=scrivener_env.wrapper
StartupNotify=true
Terminal=false
Type=Application
Version=1.0
Categories=Office;
X-KDE-SubstituteUID=false
X-AppImage-Version=1.9.0.1_beta
StartupWMClass=Scrivener
7) Edit ./usr/bin/scrivener_env correctly:
Note, we simply move scrivener.sh to scrivener_env and tweak paths to fit new location.
(See the Note below to do this with a patch file instead...)
]$ cd $HOME/appimage/squashfs-root/usr/bin
]$ mv scrivener.sh scrivener_env
+ Add the following lines at the top under the shebang:
# unset XDG_DATA_DIRS to make tray icon work in Ubuntu Unity
# see https://github.com/AppImage/AppImageKit/issues/351
unset XDG_DATA_DIRS
unset QT_PLUGIN_PATH
#export QT_DEBUG_PLUGINS=1
+ We REPLACE "bindir" and "libdir" lines with the following, and delete the old LD_LIBRARY_PATH lines:
currentdir=`dirname "$me"`
libdir=`cd "$currentdir/../lib" ; pwd`
LD_LIBRARY_PATH="$libdir:${LD_LIBRARY_PATH}"
LD_LIBRARY_PATH="$libdir:$libdir/x86_64-linux-gnu:${LD_LIBRARY_PATH}"
export LD_LIBRARY_PATH
+ Change the last line so that ./usr/bin/scrivener_env execs:
exec "$currentdir/Scrivener" ${1+"$@"}
Note: If 'patch' utility is installed, you can save yourself a lot of trouble.
Here is a patch for scrivener.sh that makes all these changes; run it like so:
]$ cd $HOME/appimage/squashfs-root/usr/bin
]$ patch -lu scrivener.sh -i env.patch -o scrivener_env
]$ chmod 755 scrivener_env
]$ rm scrivener.sh env.patch
# Save this patch file to $HOME/appimage/squashfs-root/usr/bin as "env.patch"
--- scrivener.sh 2015-10-20 09:21:21.000000000 -0700
+++ scrivener_env 2019-10-09 08:33:52.080437885 -0700
@@ -1,5 +1,12 @@
#! /bin/sh
+# unset XDG_DATA_DIRS to make tray icon work in Ubuntu Unity
+# see https://github.com/AppImage/AppImageKit/issues/351
+unset XDG_DATA_DIRS
+
+unset QT_PLUGIN_PATH
+#export QT_DEBUG_PLUGINS=1
+
makeAbsolute() {
case $1 in
/*)
@@ -28,10 +35,11 @@
fi
fi
-bindir=`dirname "$me"`
-libdir=`cd "$bindir/../lib" ; pwd`
-LD_LIBRARY_PATH=$libdir
+currentdir=`dirname "$me"`
+libdir=`cd "$currentdir/../lib" ; pwd`
+
+LD_LIBRARY_PATH="$libdir:${LD_LIBRARY_PATH}"
+LD_LIBRARY_PATH="$libdir:$libdir/x86_64-linux-gnu:${LD_LIBRARY_PATH}"
export LD_LIBRARY_PATH
-unset QT_PLUGIN_PATH
-#export QT_DEBUG_PLUGINS=1
-exec "$bindir/Scrivener" ${1+"$@"}
+
+exec "$currentdir/Scrivener" ${1+"$@"}
+ Delete the now-useless script ./usr/bin/scrivener
]$ cd $HOME/appimage/squashfs-root/usr/bin/
]$ rm -v scrivener
+ We must copy $HOME/appimage/source/desktopintegration to ./usr/bin/scrivener_env.wrapper
]$ cd $HOME/appimage/squashfs-root/usr/bin/
]$ cp ../../../source/desktopintegration ./scrivener_env.wrapper
]$ chmod 755 ./scrivener_env.wrapper
8) Tweak hardcoded "/usr" directory in our libraries:
Note: This is specifically for libaspell.so, otherwise spell-check does not work!
We swap "/usr" (4 characters) for "././" (also 4 characters, but means "here" instead of "/usr")
More information:
https://docs.appimage.org/packaging-guide/manual.html
# we are changing a value in the binary files
]$ cd $HOME/appimage/squashfs-root/usr/lib/x86_64-linux-gnu
]$ find . -type f -exec sed -i -e "s|/usr|././|g" {} \;
You can see the change in libaspell.so.15.2.0:
# before
]$ strings libaspell.so.15.2.0 | grep -B1 "prefix directory"
/usr
prefix directory
# after
]$ strings libaspell.so.15.2.0 | grep -B1 "prefix directory"
././
prefix directory
9) Set some sane file and directory permissions:
Note: We probably don't need to do this, but it pleases the author nonetheless.
]$ cd $HOME/appimage/squashfs-root/usr/lib
]$ find . -type f -perm 755 -exec chmod 644 "{}" +
]$ cd $HOME/appimage/squashfs-root/usr
]$ find . -type d -exec chmod 755 "{}" +
10) Delete some cruft:
# we don't need any of these library documents (but you can keep them if you wish)
]$ cd $HOME/appimage/squashfs-root/usr/share
]$ rm -rf ./doc-base/ gst-plugins-base/ lintian/ locale/ doc/lib*
11) There is a handy "Scrivener for Linux" readme document from L&L; let's make it more accessible:
]$ cd $HOME/appimage/squashfs-root/
]$ ln -s ./usr/share/doc/scrivener/readme.txt Scrivener_for_Linux_Readme.txt
12) Package the AppImage:
# it's time for the good stuff
]$ cd $HOME/appimage
]$ chmod 755 ./source/appimagetool-x86_64.AppImage
]$ ./source/appimagetool-x86_64.AppImage -vn ./squashfs-root/ Scrivener-1.9.0.1beta-x86_64.AppImage
13) Copy your new Scrivener AppImage anywhere, and run it as a user, NOT as root or via sudo!
Note: While your AppImage program is running, a read-only directory structure can be browsed at:
/tmp/.mount_ScrivXXXXXXX/
(...where XXXXXXX are 7 random characters.)
eg.
]$ cd /tmp/.mount_Scrivea9aePi/
]$ less Scrivener_for_Linux_Readme.txt
* END *
-----
* Appendix A: Adding additional spell-check dictionaries:
Note: If you have already built your own AppImage per the above, you probably have a good idea how to do this.
WARNING! Most Aspell dictionaries should work with this but a few may simply be too old moribund. For example, the author cannot get the Esperanto dictionary to integrate with Scrivener, no matter which is used (aspell6-eo-21 or aspell-eo-051).
These are well over ten years old and possibly broken/defunct. Every other dictionary I've tried has worked fine but I have not tried them all. You should be fine but be aware that the Aspell dictionary itself may not integrate due to age.
It is possible to commit no mistakes and still lose. That is not a weakness. That is life.
--Jean-Luc Picard
1) Create a working directory and download dictionary files:
]$ cd $HOME ; mkdir -p $HOME/appimage/aspell
2) Extract existing "Scrivener for Linux" AppImage:
Note: You can simply copy an existing on your system, build one from scratch as above, or download a 64bit version from here:
https://www.appimagehub.com/p/1673680
]$ cd $HOME/appimage
]$ ls -1
aspell
squashfs-root # this may be here if previously built
# IF there is an existing ./squashfs-root directory, delete it!
]$ rm -rf ./squashfs-root/
# copy an existing Scrivener AppImage to working directory
]$ cp <path_to_appimage>/Scrivener-1.9.0.1beta-x86_64.AppImage .
# extract it
]$ ./Scrivener-1.9.0.1beta-x86_64.AppImage --appimage-extract
# delete the old AppImage
]$ rm Scrivener-1.9.0.1beta-x86_64.AppImage
]$ ls -1
aspell
squashfs-root
3) Download new dictionaries from here:
Note: As an example, we will download Swedish and German.
https://ftp.gnu.org/gnu/aspell/dict/0index.html
]$ cd $HOME/appimage/aspell/
]$ pwd
/home/erkus/appimage/aspell
]$ wget ftp://ftp.gnu.org/gnu/aspell/dict/sv/aspell-sv-0.51-0.tar.bz2
]$ wget ftp://ftp.gnu.org/gnu/aspell/dict/de/aspell6-de-20161207-7-0.tar.bz2
+ Extract Aspell source files:
]$ cd $HOME/appimage/aspell
]$ pwd
/home/erkus/appimage/aspell
]$ tar -xvjpf aspell-sv-0.51-0.tar.bz2
]$ tar -xvjpf aspell6-de-20161207-7-0.tar.bz2
]$ ls -F1A
aspell-sv-0.51-0/
aspell-sv-0.51-0.tar.bz2
aspell6-de-20161207-7-0/
aspell6-de-20161207-7-0.tar.bz2
+ Build Dictionaries:
Note: We MUST put all Aspell dictionaries and data in ./usr/lib/aspell, else the 'libaspell.so' library won't work correctly!
# set a handy ENV variable to assist our build
]$ export ASPELL_VAL="data-dir $HOME/appimage/squashfs-root/usr/lib/aspell ; dict-dir $HOME/appimage/squashfs-root/usr/lib/aspell"
]$ echo $ASPELL_VAL
data-dir /home/erkus/appimage/squashfs-root/usr/lib/aspell ; dict-dir /home/erkus/appimage/squashfs-root/usr/lib/aspell
# install German dictionary
]$ cd $HOME/appimage/aspell/aspell6-de-20161207-7-0/
]$ env ASPELL_CONF="$ASPELL_VAL" ./configure
]$ make && make install
# install Swedish dictionary
]$ cd $HOME/appimage/aspell/aspell-sv-0.51-0/
]$ env ASPELL_CONF="$ASPELL_VAL" ./configure
]$ make && make install
4) Tweak hardcoded "/usr" directory in our libraries:
Note: This is specifically for libaspell.so, otherwise spell-check does not work!
(We only need to do this if we are adding dictionaries to an older AppImage, or if you are unsure....)
We swap "/usr" (4 characters) for "././" (also 4 characters, but means "here" instead of "/usr")
More information:
https://docs.appimage.org/packaging-guide/manual.html
# we are changing a value in the binary files
]$ cd $HOME/appimage/squashfs-root/usr/lib/x86_64-linux-gnu
]$ find . -type f -exec sed -i -e "s|/usr|././|g" {} \;
You can see the change in libaspell.so.15.2.0:
# before
]$ strings libaspell.so.15.2.0 | grep -B1 "prefix directory"
/usr
prefix directory
# after
]$ strings libaspell.so.15.2.0 | grep -B1 "prefix directory"
././
prefix directory
5) Package the AppImage:
# it's time for the good stuff
]$ cd $HOME/appimage
]$ chmod 755 ./source/appimagetool-x86_64.AppImage
]$ ./source/appimetool-x86_64.AppImage -vn ./squashfs-root/ Scrivener-1.9.0.1beta-x86_64.AppImage
6) Copy your new Scrivener AppImage anywhere, and run it as a user, NOT as root or via sudo!
Enjoy your new spell-check dictionaries, found under "Tools --> Options --> Corrections -> Dictionary"
* Appendix B: Add translation files from 1.7.2.4:
Note: Add 'qm' files to ./usr/share/scrivener/translations, per this discussion:
https://forum.literatureandlatte.com/t/changing-interface-language-doesn-t-work/32428/7
e.g.
./usr/share/scrivener/translations/Scrivener_bg.qm
etc....
(I'm NOT sure this does anything, but may help people with the issue in the forum above.)
]$ cd $HOME/appimage/source
]$ ar xv scrivener-1.7.2.4-amd64.deb data.tar.gz
]$ tar -xvf ./data.tar.gz -C ../squashfs-root/ ./usr/share/scrivener/translations/
]$ rm data.tar.gz
]$ cd $HOME/appimage/squashfs-root/usr/share
]$ rmdir translations && ln -s scrivener/translations
* Appendix C: Add a thumbnail icon to the Scrivener Appimage:
Note: This hack is completely unsupported by the folks behind AppImage. As discussed earlier, they prefer using 'appimaged' to handle this issue (as well as others). But, if you would like your new Scrivener AppImage to sport a nifty icon in your file browser, you can implement this workaround.
More info here:
https://github.com/AppImage/AppImageKit/issues/346#issuecomment-459901438
1) Before "Step 12: Package the AppImage" above, edit the scrivener_env file located in
squashfs-root/usr/bin
+ Insert these lines near the top, somewhere under the shebang, perhaps above function 'makeAbsolute':
if [ ! -z "$APPIMAGE" ] && [ ! -z "$APPDIR" ]; then
MD5=$(echo -n "file://$APPIMAGE" | md5sum | cut -d' ' -f1)
cp "$APPDIR/usr/share/icons/hicolor/128x128/apps/Scrivener.png" "$HOME/.cache/thumbnails/normal/$MD5.png"
cp "$APPDIR/usr/share/icons/hicolor/256x256/apps/Scrivener.png" "$HOME/.cache/thumbnails/large/$MD5.png"
xdg-icon-resource forceupdate
fi
+ Compile the AppImage as in Step 12 - your new AppImage should now display the Scrivener icon in the file browser!
(You will need start the AppImage at least one time to force your file browser to use this icon; also, it
may not display on your Desktop and will ONLY work with GTK-based desktop environments.)
* END APPENDICES * * END DOCUMENT*
@kinggrowler
Copy link
Author

Updating old links and adding libbz2 library to build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment