There are many aspell dictionary packages available for Ubuntu, but not all of them. If you’re a somewhat esoteric project like Distributed Proofreaders, you may discover that you need things like the Latin aspell dictionary (aspell-la) which I can’t seem to find packaged anywhere.
Installing from source
It’s super easy and perfectly possible to install any of the aspell dictionaries directly. Just fetch the file, configure, make, and make install and you’re golden:
wget https://ftp.gnu.org/gnu/aspell/dict/la/aspell6-la-20020503-0.tar.bz2 tar xvfj aspell6-la-20020503-0.tar.bz2 cd aspell6-la-20020503-0 ./configure make make install
The quick and dirty works but for systems maintained by multiple people it’s a recipe for disaster without a lot of documentation. How will someone remember that this needs to be done again for the next server upgrade or server migration? In these cases it’s usually best to create a system package and install the package.
Building & installing a package
Building a package for Ubuntu / Debian can be mind-boggling complicated when all you want to do is package up a few files to lay down on the filesystem. Luckily for aspell dictionaries we can easily borrow the template used by the aspell-en package.
Start by finding and downloading the aspell dictionary that you want to install from the list available and extracting it.
wget https://ftp.gnu.org/gnu/aspell/dict/la/aspell6-la-20020503-0.tar.bz2 tar xvfj aspell6-la-20020503-0.tar.bz2
Configure and build it to create the .rws file:
cd aspell6-la-20020503-0 ./configure make
Now head over to the aspell-en package on LaunchPad, to find and download the aspell-en_*.debian.tar.xz file from the Ubuntu version that most closely matches your own, then extract it into the the dictionary directory. This is the source file for the debian/ control directory used to build the aspell-en package, which we’ll use as a template for our own.
# from within aspell6-la-20020503-0/ wget https://launchpad.net/ubuntu/+archive/primary/+files/aspell-en_2017.08.24-0-0.1.debian.tar.xz tar xvfJ aspell-en_2017.08.24-0-0.1.debian.tar.xz
This contains several files that we don’t need for our simple dictionary, so we can clean things up a bit. Keep in mind that we’re not creating a dictionary for distribution, just for ourselves, so this doesn’t have to be perfect.
cd debian rm aspell-en.info-aspell changelog copyright extrawords.txt cp ../COPYING copyright
You’ll need to update some of the files to reference your language, most of these are fairly straightforward:
- control – Update references to aspell-en to your aspell dictionary; also update Maintainer and Description. You might need to change the debhelper version to whatever is installed on your system (Ubuntu 16.04 uses v9 not v10). If you change this, you should change it in compat too.
- watch – Update the last line to point to where you got your aspell dictionary from — you probably just need to change the two instances of ‘en’ to your language’s code.
Three files require a little more finessing: install, rules, and source/format.
The install file specifies which files should be copied into the package for installation. For reasons that I, frankly, just don’t understand, we need to specify that the .rws file needs to be installed. Your install file should look like this:
*.multi usr/lib/aspell *.alias usr/lib/aspell *.dat usr/lib/aspell *.rws var/lib/aspell
The rules files is a makefile that does all of the heavy lifting for building the package. The version for aspell-en includes bits that we don’t care about, namely everything related to docs and extrawords, we can remove those and update the DICT_LANG which leaves us with:
#!/usr/bin/make -f include /usr/share/cdbs/1/rules/debhelper.mk DICT_LANG := la DEB_DH_MD5SUMS_ARGS += -Xvar/lib/aspell install/aspell-$(DICT_LANG):: for f in `LC_ALL=C ls *.cwl`; do \ gzip -9 -n -c "$$f" > "$(DEB_DESTDIR)/usr/share/aspell/"$$f".gz"; \ WL=`echo $$f | sed 's/\.cwl$$//'`; \ touch "$(DEB_DESTDIR)/var/lib/aspell/$$WL.rws"; \ dh_link "var/lib/aspell/$$WL.rws" "usr/lib/aspell/$$WL.rws"; \ echo "$$WL" >> "$(DEB_DESTDIR)/usr/share/aspell/$(DICT_LANG).contents"; \ done touch $(DEB_DESTDIR)/var/lib/aspell/$(DICT_LANG).compat installdeb-aspell
Note that the 8-space indents above should be tabs in your version — this is a makefile!
The final thing to do is change source/format to say we want to use the 1.0 version:
The last thing to do is to create the changelog file using dch. This file is used by the packager to determine the name and version of the package file. To keep things simple, I recommend sticking with the version from the source file itself, even if that differs from the normal Debian version format.
# from within aspell6-la-20020503-0/ dch --create -v 20020503-0 --package aspell-la
Now all that’s left is building the package:
# from within aspell6-la-20020503-0/ debuild -us -uc
If successful, this will put a aspell-la_20020503-0_all.deb file in the parent directory.
$ ls -1 aspell-la_20020503-0.dsc aspell-la_20020503-0.tar.gz aspell-la_20020503-0_all.deb aspell-la_20020503-0_amd64.build aspell-la_20020503-0_amd64.changes aspell6-la-20020503-0 aspell6-la-20020503-0.tar.bz2
You can now install this via:
sudo apt install ./aspell-la_20020503-0_all.deb
Note, the ./ is required, otherwise it will look in the package catalog instead of on disk for the package.
You can test that your new dictionary works via:
$ echo hello | aspell list --lang=la
If that returns with “hello” as misspelled word, it worked. If you have problems, you can remove the package (sudo apt remove aspell-la), futz with some of the files, and try rebuilding it again. Things to watch out for are ensuring you’ve configured and make’d the package and that your changes to the install and rules files are correct.