Build, run and install from source
This page shows how to build each part of Tetheron and run what you built, in place of an installed copy or beside it. First set up a development environment.
Build the desktop side
All Cargo commands run in desktop/.
cd desktop
cargo build --workspace
The programs are in target/debug/:
| Program | Crate | What it is |
|---|---|---|
tetherd | tetherd | the daemon |
tether | tether-gtk | the GTK app |
tether-cli | tether-cli | the command-line client of the daemon |
To build one crate, name it: cargo build -p tetherd. With --release the
build is optimised and the programs are in target/release/.
Choose Cargo features
| Crate | Feature | Default | Effect |
|---|---|---|---|
tether-gtk | tray | on | Tray icon (StatusNotifierItem). Does nothing when the desktop has no tray host. |
tether-gtk | mirror | on | Video in the phone-screen and app windows, through GStreamer. Without it the windows open and show “No video in this build”. |
tether-gtk | mock | off | The --mock option: the app runs against a fake daemon inside its own process. |
tetherd | audio | on | Phone audio on the PC, through GStreamer. Without it PhoneAudioState is unsupported. |
tetherd | webcam | on | Phone as webcam, through GStreamer. Without it WebcamSetupState is unsupported. |
cargo build -p tether-gtk --features mock # app with the fake daemon
cargo build -p tetherd --no-default-features # daemon without GStreamer
cargo test --workspace --features tether-gtk/mock # all tests, including the mock's
Run a debug daemon and app in place of the installed ones
Use this to try your build with your real, already paired phone. The debug
daemon takes the installed daemon’s bus name and port, and reads the same
settings and data in ~/.config/tether and ~/.local/share/tether.
Warning
The debug daemon works on your real data. A daemon that is newer than the installed one may move the per-phone database to a newer schema, which the installed daemon then has to open. If you are changing the database, copy
~/.local/share/tetherfirst.
-
Stop the installed daemon and app:
systemctl --user stop tetherd pkill -x tether -
Start the debug daemon from
desktop/straight away and leave it running:RUST_LOG=info,tetherd=debug ./target/debug/tetherdThe installed package registers the daemon for D-Bus activation. While no daemon owns
org.tether.Daemon, a program that calls that name makes the session bus start the installed daemon again, and your debug daemon then fails withowning org.tether.Daemon (is another tetherd running?). -
In a second terminal, start the debug app:
./target/debug/tether -
Use
./target/debug/tether-clifor the command line.tether-cli mirrorandtether-cli appstart thetetherprogram that lies next totether-cli, so they open the debug app. SetTETHER_APPto a path to make them start a different one.
cargo run -p tetherd, cargo run -p tether-gtk and
cargo run -p tether-cli -- <command> do the same and rebuild first.
Switch back to the installed ones
-
Stop the debug app and daemon. Press
Ctrl+Cin their terminals, or:pkill -x tether pkill -x tetherdpkill -xmatches the exact program name. Never usepkill -f: it matches whole command lines, including that of the shell that runs it. -
Start the installed daemon again:
systemctl --user start tetherd -
Start the installed app from the application menu.
Run a debug daemon beside the installed one
Use this when the installed daemon should keep serving your phone while you work. The second daemon needs its own bus name, ports and directories.
| Variable | Effect | Default |
|---|---|---|
TETHER_BUS_NAME | Bus name the daemon takes. tether-cli reads the same variable to choose the daemon it talks to. | org.tether.Daemon |
TETHER_PORT | TCP port for phones and UDP port for discovery beacons | port in config.toml, 7360 |
TETHER_PEER_PORT | Port on which the daemon dials back a peer that connected to it. Needed only for a fake phone on a port other than 7360. | 7360 |
TETHER_ADB_PORT | Port of the daemon’s private adb server | adb_server_port in config.toml, 5038 |
XDG_CONFIG_HOME, XDG_DATA_HOME, XDG_CACHE_HOME | Where the settings, the identity and trusted devices, and the caches live | ~/.config, ~/.local/share, ~/.cache |
-
Create a directory for the second daemon:
mkdir -p ~/tether-debug/config ~/tether-debug/data ~/tether-debug/cache -
Start the daemon with all of the variables:
TETHER_BUS_NAME=org.tether.Debug \ TETHER_PORT=7362 \ TETHER_ADB_PORT=5039 \ XDG_CONFIG_HOME=$HOME/tether-debug/config \ XDG_DATA_HOME=$HOME/tether-debug/data \ XDG_CACHE_HOME=$HOME/tether-debug/cache \ ./target/debug/tetherd -
Talk to it with
tether-cli:TETHER_BUS_NAME=org.tether.Debug ./target/debug/tether-cli devices
Set every variable. Without TETHER_ADB_PORT, both daemons use the adb
server on port 5038, and the debug daemon stops that server when it exits.
Without the XDG_ variables, both daemons write the same files.
The second daemon has its own identity, so to a phone it is another computer.
It announces itself on the network unless its config.toml says
discoverable = false.
The GTK app does not read TETHER_BUS_NAME. It always talks to
org.tether.Daemon, and a second tether process hands over to the one that
is already running. Drive a second daemon with tether-cli or with a
fake phone. The tutorial is a complete example
of this set-up.
Run the app against its fake daemon
cargo run -p tether-gtk --features mock -- --mock
The mock app has its own application id (org.tether.Tether.Mock) and runs
beside the real app. It shares the real app’s settings file
(~/.config/tether/gtk.toml), its autostart switch, and the launcher entries
that “Pin to desktop” writes. Point it at scratch directories to keep those
apart:
XDG_CONFIG_HOME=/tmp/tether-mock/config XDG_DATA_HOME=/tmp/tether-mock/data \
cargo run -p tether-gtk --features mock -- --mock
The mock’s options are in Test your changes.
Build and install the Android app
All Gradle commands run in android/.
Debug APK
-
Build it:
cd android ./gradlew :app:assembleDebugThe APK is
app/build/outputs/apk/debug/app-debug.apk. -
Install it on the phone that is connected over adb, and start it:
adb install -r app/build/outputs/apk/debug/app-debug.apk adb shell am start -n org.tether.android/.ui.MainActivity
adb install -r replaces the app and keeps its data, so a debug APK installed
over an earlier debug APK from the same computer keeps the phone’s identity
and its pairing.
The debug and the release build have the same application id,
org.tether.android, and different signing keys. Android refuses to install
one over the other. Uninstall the app first. That removes the app’s data, so
you pair again afterwards.
Release APK
./gradlew :app:assembleRelease
The release build is minified with R8. It is signed only if the build finds a
keystore, through four TETHER_* environment variables or
android/keystore.properties (see “Sign the APK” in
Package and release). Without one the APK is unsigned,
and Android does not install an unsigned APK.
A release APK that you sign with your own key cannot replace the project’s released APK on a phone, because the keys differ.
Build and install the Debian package
-
Install
cargo-debonce:cargo install cargo-deb --locked -
Build the release programs and the package:
desktop/packaging/build-deb.shThe script runs
cargo build --release --workspaceand thencargo deb -p tetherd --no-build. The package is one file,desktop/target/debian/tether_<version>-1_<arch>.deb, and contains the daemon, the app andtether-cli. -
Inspect it if you changed the packaging:
dpkg-deb -c desktop/target/debian/tether_*.deb lintian desktop/target/debian/tether_*.deb -
Install it and restart the daemon:
sudo apt install ./desktop/target/debian/tether_*.deb systemctl --user restart tetherd
Build the tarball for other distributions
desktop/packaging/build-tarball.sh
The script builds the release programs and writes
desktop/target/tarball/tether-<version>-linux-<arch>.tar.gz. Unpack it and
run sudo ./install.sh to install your build under /usr/local, as
Install Tetheron on Linux describes for a
release. The programs need the GTK, libadwaita and glibc versions of the
machine that built them, or newer.
The package layout and the maintainer scripts are described in
desktop/packaging/README.md.
Releases are covered in Package and release.