# Porting tectonic (Xetex frontend)



## mendenlama (Feb 7, 2022)

Tectonic (https://tectonic-typesetting.github.io/) is some sort of a Texlive/Xetex wrapper, written in Rust. I have tried it on Linux and it seems to run fine. It's main feature is (for me): you do not need to install Texlive at all.

Besides the source code, Tectonic provides binaries for Linux, Mac (X86_64), Windows). A FreeBSD port seems to be missing so far. Do you know if someone works on this?

Yesterday, I tried to compile it from source and did succeed eventually, with all dependencies fullfilled. So I know that it does run on FreeBSD 13.0 (X86_64).


----------



## zirias@ (Feb 7, 2022)

mendenlama said:


> you do not need to install Texlive at all.


So, it bundles everything needed?  Normally, you try to avoid unnecessary redundancy in ports... but if it at least won't conflict with texlive ports installed, maybe it's still fine (btw, someone's currently working on updating texlive ports from 2015 to 2021).


mendenlama said:


> Yesterday, I tried to compile it from source and did succeed eventually, with all dependencies fullfilled. So I know that it does run on FreeBSD 13.0 (X86_64).


Well that's great, then you should probably start with the Porter's Handbook.


----------



## grahamperrin@ (Feb 7, 2022)

Welcome to FreeBSD Forums.



mendenlama said:


> … A FreeBSD port seems to be missing so far. Do you know if someone works on this? …



<https://wiki.freebsd.org/WantedPorts#Q-T> it's not listed as wanted there.

What software would you like to see ported/packaged? – if you ask there, use a mention i.e. `/u/FUZxxl` for the opening poster to be notified.

pandoc(1) mentions tectonic, however this mention might be a minor bug in that (as far as I can tell), no package provides tectonic:


```
% pkg provides pandoc.1.gz
Name    : hs-pandoc-2.14.2
Desc    : Conversion between markup formats
Repo    : FreeBSD
Filename: usr/local/man/man1/pandoc.1.gz
% pkg info --list hs-pandoc | grep -i tectonic
% pkg provides tectonic
Name    : texlab-3.3.1_1
Desc    : Language Server Protocol for LaTeX
Repo    : FreeBSD
Filename: usr/local/share/doc/texlab/docs/tectonic.md

Name    : stardict-rptts-2.1.0
Desc    : Real People TTS for StarDict
Repo    : FreeBSD
Filename: usr/local/share/WyabdcRealPeopleTTS/t/tectonics.wav
          usr/local/share/WyabdcRealPeopleTTS/t/tectonically.wav
          usr/local/share/WyabdcRealPeopleTTS/t/tectonic.wav

Name    : sauerbraten-20201221_1
Desc    : First person shooter based on Cube
Repo    : FreeBSD
Filename: usr/local/share/sauerbraten/packages/base/tectonic_readme.txt
          usr/local/share/sauerbraten/packages/base/tectonic.wpt
          usr/local/share/sauerbraten/packages/base/tectonic.ogz
          usr/local/share/sauerbraten/packages/base/tectonic.jpg
          usr/local/share/sauerbraten/packages/base/tectonic.cfg

Name    : py38-citeproc-py-styles-0.1.3
Desc    : Static resources package for citeproc-py
Repo    : FreeBSD
Filename: usr/local/lib/python3.8/site-packages/citeproc_styles/styles/dependent/tectonics.csl

Name    : lmms-1.2.2_3,2
Desc    : All-in-one sequencer, drum machine, sampler, and more
Repo    : FreeBSD
Filename: usr/local/share/lmms/projects/demos/Farbro-Tectonic.mmpz

Name    : freeorion-0.4.10.2
Desc    : Turn-based space empire and galactic conquest game
Repo    : FreeBSD
Filename: usr/local/share/freeorion/default/data/art/icons/specials_tiny/tectonic_instability.png
          usr/local/share/freeorion/default/data/art/icons/specials_large/tectonic_instability.png
          usr/local/share/freeorion/default/data/art/icons/specials_huge/tectonic_instability.png
%
```


----------



## mendenlama (Feb 7, 2022)

Zirias said:


> So, it bundles everything needed?  Normally, you try to avoid unnecessary redundancy in ports... but if it at least won't conflict with texlive ports installed, maybe it's still fine (btw, someone's currently working on updating texlive ports from 2015 to 2021).
> 
> Well that's great, then you should probably start with the Porter's Handbook.



Yes it bundles Xetex/Xelatex + Bibtex. The auxilliary files, like macros, font or language definitions, font metrics and so on are loaded on the fly when the .tex file requires them. Tectonic loads them from an online repository and puts the data on a per-user basis in <home-directory>/.cache/Tectonic/... Since the files are stored with numerical hashes and not in the texmf directory structure, Texlive and Tectonic do not intefere with one another and may co-exist.
On the positive side: it runs fast, produces pdf files by default, works together with pandoc and so on. On the critical side: it requires an online connection (at least on the first run), and loading stuff from the net may be a security issue. On a multi-user system it may lead to redundancy when different users load the same files again and again - provided the case they all use Tectonic. On a single person workstation like in my case this doesn't really hurt.



grahamperrin said:


> <https://wiki.freebsd.org/WantedPorts#Q-T> it's not listed as wanted there.
> 
> What software would you like to see ported/packaged? – if you ask there, use a mention i.e. `/u/FUZxxl` for the opening poster to be notified.
> 
> ...



In Pandoc (at least version 2.14 and above) Tectonic can replace Texlive for pdf generation, with pandoc --pdf-engine=tectonic. So, Pandoc may use it, but the standard way of producing pdfs remains Texlive. 

Concerning the question of porting by myself, well, I am a bit reluctant. First, it needs some testing before doing so. And secondly, I know practically nothing of Rust, besides the fact that it seems to be quite popular now. I am a long-term Linux and Mac user, but rather a newbie in FreeBSD (I installed it the first time in January 2022 on real hardware after I tested it in virtual machines). So I have to delve into before going further.
Anyway, thanks for the hints.


----------



## kpedersen (Feb 11, 2022)

mendenlama said:


> Concerning the question of porting by myself, well, I am a bit reluctant. First, it needs some testing before doing so.


Indeed, it can often be a considerable commitment to go from "Oh, its working!" to `pkg install x`.

Possibly if you do only have a simple shell script that does the build (i.e commands in the right order), then that would be really useful for someone to make the port later on. I would be tempted to just share it on the mailing list for someone to start from at least.


----------



## mendenlama (Feb 12, 2022)

kpedersen said:


> Indeed, it can often be a considerable commitment to go from "Oh, its working!" to `pkg install x`.
> 
> Possibly if you do only have a simple shell script that does the build (i.e commands in the right order), then that would be really useful for someone to make the port later on. I would be tempted to just share it on the mailing list for someone to start from at least.


Ok, I did it again. This time in a vanilla FreeBSD installation in a virtual machine (created with virtualbox).

I took the 13.0-RELEASE version (bootonly iso) for the amd64 platform, created a vm with the FreeBSD 64bit profile, EFI boot, 2048 MB RAM, 16 GB virtual harddisk, VMSVGA graphics. During the installation I took the UFS filesystem and set the regional settings to my region, everything else to the defaults. After the install I did freebsd-update and pushed the system to 13.0-RELEASE p7.

For Tectonic I was following the build inscructions in https://tectonic-typesetting.github.io/book/latest/howto/build-tectonic/index.html

For getting the dependencies together I loaded some packages; some are unrelated to the build but rather to my ease; in any case, they pulled in some dependencies, too. So I mention them here. Summarized in a script:


```
#!/bin/sh
##########################
# According to the build instructions in
# https://tectonic-typesetting.github.io/book/latest/howto/build-tectonic/index.html (last
# access: 2022-02-12)
# Build system: FreeBSD 13.0-RELEASE-p7 #0: Mon Jan 31 18:24:03 UTC 2022
# root@amd64-builder.daemonology.net:/usr/obj/usr/src/amd64.amd64/sys/GENERIC
# amd64
#
# Loading Packages:
# (you have to be root or have root privileges)
# Some of them are unrelated but may pull in dependencies. Git isn't needed
# until you clone the latest github source. Cargo loads and compiles everything
# needed for tectonic

pkg install shells/bash
pkg install editors/vim
pkg install security/doas
pkg install www/links
pkg install x11/xorg
pkg install sysutils/py-ranger
pkg install devel/git
pkg install lang/rust
pkg install graphics/graphite2
pkg install print/harfbuzz
pkg install print/harfbuzz-icu
pkg install security/openssl
pkg install archivers/lzlib
pkg install devel/pkgconf

# Setting up a variable for static linking (libc is linked dynamically, though)
TECTONIC_PKGCONFIG_FORCE_SEMI_STATIC=pkg-config

# Start cargo for the compiling
if [ -x /usr/local/bin/cargo ];
then
    cargo install tectonic
fi

# Build from git (latest version):
# cargo install --git https://github.com/tectonic-typesetting/tectonic.git
# cd tectonic
# cargo build
```

Compiling was successful. cargo installs the binary in $HOME/.cargo/bin. After transferring the binary to the FreeBSD host machine and running the binary on the command line with:


```
peter@elagabal ~]$ cat <<_END_ | ~/tectonic -
> \documentclass{article}
> \title{This is a Tectonic Test}
> \author{Peter}
> \begin{document}
> \maketitle
> 
> \section{Introduction}
> 
> In case you ask me why my texts are so good: I copy everything from the recent tabloids. 
> 
> \end{document}
> _END_
```

it gives a file texput.pdf that looks like this (snippet):




So I know it works beyond two machines with the same 13.0 p7, but with different settings. 

Hope it helps
Peter


----------

