💾 Archived View for xavi.privatedns.org › telescope-static-binary.gmi captured on 2024-08-18 at 16:56:38. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-07-08)

-=-=-=-=-=-=-

Building a static binary for Telescope

A few days ago, a BBS user asked for pre-built binaries for the Telescope Gemini client, presumably for x86 Linux distributions:

BBS thread asking for a x86 Telescope binary

According to the project capsule, Telescope has few dependencies, namely:

- LibreTLS

- libevent

- Ncurses

- Bison

Gemini capsule for the Telescope project

Therefore, I felt challenged to provide a static x86 binary that would literally work on any Linux distribution. So I made use of my existing project, spm-packages:

spm-packages project

spm-packages collects a bunch of Dockerfiles based on Alpine Linux (and, therefore, using musl as their libc) that can be thought as some sort of software packaging system. Of course, such Dockerfiles are not meant for end users, but only as a way for packages to define automated builds.

Projects can include their dependencies by dumping their prefix into /usr/local, via COPY. For example:

COPY --from=libopenssl:3.1.1-minimal /opt/spm/openssl-3.1.1/ /usr/local/

Then, it is expected to "docker cp" the final, stripped executable from the container to the host system, so it can be redistributed.

This method was used to distribute multi-arch (x86, x86_64, armv7l and aarch64) static Linux binaries for slcl:

slcl 0.1.0 release

So I used the same method for Telescope, with the resulting static binaries:

telescope-0.8.1 for linux-amd64

telescope-0.8.1 for linux-x86

aarch64 and armv7l binaries should be easy to provide, too.

Because of limitations (see section below), the following error message shall appear (xterm-256color is my configured $TERM, so YMMV):

Error opening terminal: xterm-256color.

The terminal database is not accessible to Telescope, as it expects it on the prefix used to build Ncurses (namely, /opt/spm/libncurses-6.3). Therefore, execute the following command before running Telescope for the first time:

$ ln -s /usr/share/terminfo $HOME/.terminfo

xterm-256color might not be available on your system's terminal database, so set TERM explicitly to any other terminal name found in $HOME/.terminfo. xterm-xi seems to work well enough:

TERM=xterm-xi ./telescope-0.8.1-linux-x86

Now, Telescope should work. Enjoy!

Safety note

The binaries above were built using the steps exactly as described on the relevant Dockerfiles from the spm-packages project, which you are encouraged to read and improve. However, if you do not trust running random binaries from a random Gemini guy, remember to set up a proper sandbox environment beforehand e.g.: via firejail, chroot, Docker, etc.

Limitations

- Applications relying on system files still need a way to find them, hence limiting portability. To work around this, I plan to set up a library that allows packagers to embed files directly into the static binary and remap standard I/O functions. As of the time of this writing, this is still WIP:

libfswrap, a C99 library that remaps standard I/O functions to in-memory buffers

fswrap, a code generator for libfswrap

- Mostly due to their high complexity and long list of dependencies, GUI applications (typically, those depending on GTK or Qt) might be very difficult or even impossible to build as static binaries.

- Static binaries is mostly possible thanks to the musl libc project. Projects written in other programming languages might not allow static builds at all.

Contact me

Back to main page