Add Debian packaging and arm64 cross build
cargo-deb metadata produces a .deb with the binary, the packaged user unit variant, man page and example config; arm64 cross-builds as a static musl binary via an isolated rustup and rust-lld (recipe in README). Add MIT LICENSE for the package copyright.
This commit is contained in:
1 parent
b4e51a58f6
commit
b93c0134dd
9 files changed
+189
-1
No files matched your search
@@ -42,6 +42,17 @@ rearms monitoring. See README.md for the full design.
|
||||
- `android/` — companion beacon app (Kotlin/Compose, separate Gradle
|
||||
build; see `android/README.md`). Counter-rotating ServiceData payload
|
||||
defeats the BlueZ RSSI dedupe from the phone side.
|
||||
- `packaging/` — Debian packaging: user unit variant for the packaged
|
||||
binary and the man page; consumed by `cargo deb` (see
|
||||
`[package.metadata.deb]` in Cargo.toml).
|
||||
- MSRV gotcha: `cargo-deb` 3.x does not build on rustc 1.85 (let-chains);
|
||||
pin `cargo install cargo-deb --version 2.12.1`.
|
||||
- arm64 cross-build recipe (isolated rustup + static musl + rust-lld as
|
||||
linker, `cargo-deb --no-strip`) lives in README under "arm64"; the
|
||||
rustup env is ephemeral — re-run the recipe to rebuild.
|
||||
- Android release signing: `android/keystore.properties` (gitignored)
|
||||
points at the keystore in `~/.config/btle-proximity/`; without it
|
||||
`assembleRelease` produces an unsigned APK.
|
||||
|
||||
## Domain gotchas (learned the hard way — see docs/HANDOFF.md)
|
||||
|
||||
|
||||
+22
-1
@@ -5,7 +5,28 @@ edition = "2021"
|
||||
rust-version = "1.85"
|
||||
resolver = "3"
|
||||
description = "BLE proximity screen locker: locks the desktop session when your phone leaves Bluetooth range"
|
||||
license = "MIT"
|
||||
license-file = "LICENSE"
|
||||
|
||||
[package.metadata.deb]
|
||||
maintainer = "Bastian Mäuser <bma@netz.org>"
|
||||
copyright = "2026, Bastian Mäuser"
|
||||
section = "utils"
|
||||
priority = "optional"
|
||||
depends = "systemd, bluez (>= 5.50)"
|
||||
extended-description = """\
|
||||
BLE proximity screen locker: watches advertisement updates from a paired \
|
||||
phone via BlueZ over D-Bus, escalates the radio duty cycle as sightings \
|
||||
stale, and locks the desktop session via loginctl once the phone is \
|
||||
confirmed unreachable by a connection probe.\
|
||||
"""
|
||||
assets = [
|
||||
["target/release/btle-proximity", "usr/bin/", "755"],
|
||||
["packaging/systemd/btle-proximity.service", "usr/lib/systemd/user/", "644"],
|
||||
["packaging/man/btle-proximity.1", "usr/share/man/man1/", "644"],
|
||||
["config.toml.example", "usr/share/doc/btle-proximity/examples/config.toml", "644"],
|
||||
["README.md", "usr/share/doc/btle-proximity/README.md", "644"],
|
||||
["LICENSE", "usr/share/doc/btle-proximity/LICENSE", "644"],
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1"
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Bastian Mäuser
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -85,6 +85,43 @@ RUST_LOG=debug btle-proximity --dry-run
|
||||
Tune `rssi_lock` / `presence_timeout_secs` / `missing_after_secs` to your
|
||||
room. Then install the user service (runs inside your session, Type=notify):
|
||||
|
||||
### Debian package
|
||||
|
||||
```sh
|
||||
cargo install cargo-deb --version 2.12.1 # 3.x needs rustc > 1.85
|
||||
cargo deb # -> target/debian/btle-proximity_*.deb
|
||||
sudo apt install ./target/debian/btle-proximity_0.1.0-1_amd64.deb
|
||||
systemctl --user enable --now btle-proximity
|
||||
```
|
||||
|
||||
Installs the binary to `/usr/bin`, the user unit to
|
||||
`/usr/lib/systemd/user/`, a man page and the config example to
|
||||
`/usr/share/doc/btle-proximity/`. Per-user config still lives at
|
||||
`~/.config/btle-proximity/config.toml`. If you previously installed via
|
||||
`cargo install`, remove that copy (`cargo uninstall btle-proximity`) to
|
||||
avoid PATH shadowing.
|
||||
|
||||
#### arm64 (aarch64)
|
||||
|
||||
Cross-built as a **static musl binary**, so no cross-gcc/sysroot is needed
|
||||
and the result runs on any arm64 Linux (Ubuntu 24.04/26.04 included). Uses
|
||||
an isolated rustup under `/tmp` so the distro cargo is not touched:
|
||||
|
||||
```sh
|
||||
export RUSTUP_HOME=/tmp/rustup CARGO_HOME=/tmp/rustup-cargo PATH=/tmp/rustup-cargo/bin:$PATH
|
||||
curl -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.85.0 --profile minimal --no-modify-path
|
||||
rustup target add aarch64-unknown-linux-musl
|
||||
mkdir -p /tmp/lld-bin && ln -sf "$(rustc --print rustlib-dir)"/x86_64-unknown-linux-gnu/bin/rust-lld /tmp/lld-bin/ld.lld
|
||||
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=/tmp/lld-bin/ld.lld
|
||||
~/.cargo/bin/cargo-deb --target aarch64-unknown-linux-musl --no-strip
|
||||
# -> target/aarch64-unknown-linux-musl/debian/btle-proximity_*_arm64.deb
|
||||
```
|
||||
|
||||
The `--no-strip` matters: the release profile already strips via the
|
||||
linker, and the host `strip` cannot read aarch64 objects.
|
||||
|
||||
### Manual install (dev flow)
|
||||
|
||||
```sh
|
||||
cp systemd/btle-proximity.service ~/.config/systemd/user/
|
||||
systemctl --user daemon-reload
|
||||
|
||||
@@ -7,3 +7,6 @@ local.properties
|
||||
.kotlin/
|
||||
captures/
|
||||
*.swp
|
||||
*.keystore
|
||||
*.jks
|
||||
keystore.properties
|
||||
@@ -32,6 +32,14 @@ cd android
|
||||
# -> app/build/outputs/apk/debug/app-debug.apk
|
||||
```
|
||||
|
||||
Release builds are signed when `keystore.properties` (gitignored, see
|
||||
`AGENTS.md`) exists; otherwise they come out unsigned:
|
||||
|
||||
```sh
|
||||
./gradlew assembleRelease
|
||||
# -> app/build/outputs/apk/release/btle-proximity-beacon-release.apk
|
||||
```
|
||||
|
||||
Install: `adb install app/build/outputs/apk/debug/app-debug.apk`, or copy
|
||||
the APK to the phone and open it.
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
import java.util.Properties
|
||||
|
||||
plugins {
|
||||
id("com.android.application")
|
||||
@@ -6,10 +7,21 @@ plugins {
|
||||
id("org.jetbrains.kotlin.plugin.compose")
|
||||
}
|
||||
|
||||
// Release signing lives outside the repo: android/keystore.properties
|
||||
// (gitignored) points at the keystore and holds its passwords.
|
||||
val keystoreProps = Properties().apply {
|
||||
val f = rootProject.file("keystore.properties")
|
||||
if (f.exists()) f.inputStream().use { load(it) }
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "org.netz.btleproximity"
|
||||
compileSdk = 36
|
||||
|
||||
base {
|
||||
archivesName = "btle-proximity-beacon"
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "org.netz.btleproximity"
|
||||
minSdk = 26
|
||||
@@ -18,9 +30,23 @@ android {
|
||||
versionName = "1.0"
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
if (keystoreProps.isNotEmpty()) {
|
||||
create("release") {
|
||||
storeFile = rootProject.file(keystoreProps.getProperty("storeFile"))
|
||||
storePassword = keystoreProps.getProperty("storePassword")
|
||||
keyAlias = keystoreProps.getProperty("keyAlias")
|
||||
keyPassword = keystoreProps.getProperty("keyPassword")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
if (keystoreProps.isNotEmpty()) {
|
||||
signingConfig = signingConfigs.getByName("release")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
.TH BTLE\-PROXIMITY 1 "November 2026" "btle\-proximity 0.1.0" "User Commands"
|
||||
.SH NAME
|
||||
btle\-proximity \- lock the desktop session when your phone leaves Bluetooth range
|
||||
.SH SYNOPSIS
|
||||
.B btle\-proximity
|
||||
.RB [ \-c ", " \-\-config " " \fIFILE\fR ]
|
||||
.RB [ \-\-dry\-run ]
|
||||
.RI [ COMMAND ]
|
||||
.SH DESCRIPTION
|
||||
.B btle\-proximity
|
||||
watches BLE advertisements of a paired phone via BlueZ and locks the desktop
|
||||
session with
|
||||
.BR "loginctl lock-session"
|
||||
when the phone stops being reachable. There is no unlock: the phone
|
||||
returning only rearms monitoring. Before locking, a short connection probe
|
||||
verifies the phone is really unreachable.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.BR \-c ", " \-\-config " " \fIFILE\fR
|
||||
Path to the TOML configuration file.
|
||||
.TP
|
||||
.B \-\-dry\-run
|
||||
Log lock actions instead of executing them.
|
||||
.TP
|
||||
.BR \-h ", " \-\-help
|
||||
Print help.
|
||||
.TP
|
||||
.BR \-V ", " \-\-version
|
||||
Print version.
|
||||
.SH COMMANDS
|
||||
.TP
|
||||
.B run
|
||||
Run the daemon (default when no command is given).
|
||||
.TP
|
||||
.B list\-paired
|
||||
List paired Bluetooth devices and exit; use it to pick the
|
||||
.B device_mac
|
||||
for the configuration.
|
||||
.SH FILES
|
||||
.TP
|
||||
.I $XDG_CONFIG_HOME/btle\-proximity/config.toml
|
||||
Per-user configuration; see
|
||||
.I /usr/share/doc/btle\-proximity/examples/config.toml
|
||||
for every knob and its tuning guidance.
|
||||
.SH SEE ALSO
|
||||
.BR loginctl (1),
|
||||
.BR bluetoothd (8)
|
||||
@@ -0,0 +1,14 @@
|
||||
[Unit]
|
||||
Description=BLE proximity screen locker (packaged)
|
||||
Wants=bluetooth.service
|
||||
After=bluetooth.service
|
||||
PartOf=graphical-session.target
|
||||
|
||||
[Service]
|
||||
Type=notify
|
||||
ExecStart=/usr/bin/btle-proximity --config %h/.config/btle-proximity/config.toml
|
||||
Restart=on-failure
|
||||
RestartSec=5s
|
||||
|
||||
[Install]
|
||||
WantedBy=graphical-session.target
|
||||
Reference in new issue
Block a user