Building signal-cli for FreeBSD
signal-cli is a command-line API interface for Signal Messenger. It requires libsignal-client on the target machine, but only comes with the library prebuilt for a few OSes (Linux, Windows, macOS).
Instructions for building the library are included on the signal-cli Wiki, but needed a few tweaks to be successful for me on FreeBSD:
Pre-requisites
- JDK (Version 21 as of signal-cli 0.13.10)
- rust (from https://rustup.rs/)
- protobuf
- cmake
- zip
# pkg install openjdk21 javavmwrapper protobuf cmake zip
# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Downloading and Building
I recommend downloading a release tarball for signal-cli. Each release of signal-cli requires a specific version of libsignal. To determin the exact version, download the signal-cli release package, extract it and look in the provided lib/ directory:
$ wget https://github.com/AsamK/signal-cli/releases/download/v0.13.10/signal-cli-<version>.tar.gz
$ tar xvzf signal-cli-<version>.tar.gz
$ ls signal-cli-<version>/lib
...
libsignal-client-<version>.jar
...
Now you can retrieve and extract the specified release of libsignal:
$ wget https://github.com/signalapp/libsignal/archive/refs/tags/v<version>.tar.gz
$ tar xvzf v<version>.tar.gz
$ cd libsignal-<version>/java
Edit settings.gradle to comment out the Android build:
if (hasProperty('skipAndroid')) {
// Do nothing
} else if (JavaVersion.current().isJava11Compatible()) {
// include ':android', ':android:benchmarks' <--- This Line
Then run the build script:
$ bash ./build_jni.sh desktop
Installing
This should complete successfully, and a new libsignal_jni.so will be placed in libsignal-/target/x86_64-unknown-freebsd/release/
In order to update the signal-cli library so that it finds it correctly, cd to that directory and perform the following steps from there:
$ cd /full/path/to/libsignal-<version>/target/x86_64-unknown-freebsd/release/
# remove the incompatible library:
$ zip -d /full/path/to/signal-cli-<version>/lib/libsignal-client-<version>.jar libsignal_jni.so
# Install the FreeBSD-native library:
$ zip /full/path/to/signal-cli-<version>/lib/libsignal-client-<version>.jar libsignal_jni.so
Now copy the script and libraries into a location in your $PATH and $LD_PATH:
$ cp signal-cli-<version>/bin/signal-cli $HOME/bin
$ cp signal-cli-<version>/lib/* $HOME/lib