Files
alex 3c14906e40 deb packaging: build-deb.sh + packaging/deb, icons from ico/
- scripts/build-deb.sh: binary built in ubuntu:22.04 (glibc 2.35 baseline),
  Depends via dpkg-shlibdeps, DEB_REVISION (0.1.28-1), changelog.Debian.gz,
  postinst/postrm cache refresh, REPO=1 local apt index, self-checks
  (version/upgrade path, stale binary, desktop-file-validate)
- packaging/deb/: control.in, rcalc.desktop, appdata metainfo, changelog, hooks
- ico/: new app icon in 32/48/64/96/256/512, used for the hicolor slots
- convert.rs: fix clippy::approx_constant error in roundtrip test (PI constant)
- README: install/update/release instructions
2026-09-17 19:48:05 +03:00

118 lines
4.7 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# rcalc
Desktop calculator for Linux/Windows/macOS, inspired by the Windows Calculator (standard mode).
Built with Rust + [Slint](https://slint.dev).
## Run
```bash
cargo run --release
# or
./dist/rcalc
```
## Install as a Debian package
```bash
./scripts/build-deb.sh # → dist/rcalc_<version>-<rev>_<arch>.deb
sudo apt install ./dist/rcalc_*_amd64.deb
rcalc # or start it from the application menu
```
The binary is compiled in an Ubuntu 22.04 container (Docker) by default, so the
package keeps a glibc 2.35 baseline and installs on Ubuntu 22.04 / 24.04 / 26.04.
`Depends:` are generated from the ELF with `dpkg-shlibdeps`.
Menu/taskbar icons come from `ico/` — every PNG there is placed into the
hicolor slot matching its real pixel size (file names do not matter), and the
remaining smaller sizes are downsampled from the biggest one. Without `ico/`
the icons are resized from `assets/icon.png`. The icon inside the window
(`ui/app.slint`) and the Windows `rcalc.exe` icon still use `assets/`.
Useful switches:
| Variable | Effect |
| --- | --- |
| `DEB_REVISION=` | packaging revision, `1` by default → `Version: 0.1.28-1` |
| `REPO=1` | also write `dist/Packages(.gz)` so `dist/` works as a local apt repo |
| `SKIP_DOCKER=1` | build on the host (needs this host's glibc on the target) |
| `PREBUILT=1` | package the existing `dist/rcalc`, no compile |
| `NO_STRIP=1` | keep symbols (bigger package) |
| `KEEP_STAGE=1` | leave `dist/deb-root/` for inspection |
| `DOCKER_IMAGE=` | other build image, e.g. `debian:12` for an older baseline |
| `DEB_MAINTAINER=` | `"Name <mail>"` in `Maintainer:` (default: git user) |
### Version and updates
Package version = `<version from Cargo.toml>-<DEB_REVISION>`, e.g. `0.1.28-1`.
* changed app code → bump `version` in `Cargo.toml` (it is also the window title);
* changed only packaging (icon, `.desktop`, `Depends`, rebuilt binary) → `DEB_REVISION=2`.
`dpkg` compares these in order (`0.1.28-1 < 0.1.28-2 < 0.1.29-1`, and
`0.1.9 < 0.1.10`), so every new build is an upgrade, never a downgrade. The
script prints the resulting upgrade path and warns if the version being built is
not newer than the installed one — an `apt upgrade` of such a package does nothing.
Release notes live in `packaging/deb/changelog` and are installed as
`/usr/share/doc/rcalc/changelog.Debian.gz`.
Update in place (config in `~/.config/rcalc/config.json` is a user file, it survives):
```bash
sudo apt install ./dist/rcalc_0.1.28-2_amd64.deb
```
Or keep `dist/` as a local repository and update with plain `apt` (build with
`REPO=1`, then point apt at the folder):
```bash
echo 'deb [trusted=yes] file:/path/to/RCalc/dist ./' | sudo tee /etc/apt/sources.list.d/rcalc.list
sudo apt update && sudo apt install rcalc # later: sudo apt upgrade
```
> If `scripts/install-desktop.sh` was ever run, `~/.local/bin/rcalc` (a symlink to
> `dist/rcalc`) shadows `/usr/bin/rcalc` — remove it after switching to the package,
> otherwise `rcalc` in the terminal still starts the old binary. The script warns
> about this during the build.
### Icon (Linux / Wayland)
On **Wayland** the window `icon` property is ignored — the desktop uses
`.desktop` + `app_id`. Install once:
```bash
./scripts/install-desktop.sh
```
Then start **rcalc** from the app menu (or `~/.local/bin/rcalc`), not by
clicking a random binary path, so KDE/GNOME can match `app_id=rcalc` to
`rcalc.desktop` and show the icon.
## Features
- Modes: **Standard**, **Engineering**, **Programmer**, **Convert**, **CRC**, **Settings**
- Standard: `+ − × ÷`, `%`, `±`, `1/x`, `x²`, `√x`, memory, formula panel
- Engineering: trig functions, log/pow, DEG/RAD, SI prefixes
- Programmer: simultaneous **HEX / DEC / OCT / BIN**, sizes **QWORD / DWORD / DINT / WORD / INT / BYTE**,
bitwise ops, clickable bits
(WORD/DWORD — unsigned DEC; INT/DINT — signed)
- Convert: **float32 ↔ two 16-bit words** with endian **AB CD / CD AB / BA DC / DC BA**
- Convert → **Ratio**: float → minimal **num/den** for electronic gear (Byte≤255 / Word≤65535)
- Convert → **ASCII**: Char ↔ Hex ↔ Dec (control names for NUL…DEL)
- **CRC**: Modbus RTU CRC-16 + Modbus ASCII LRC from hex bytes (`01 03 00 00 00 0A`)
- Keyboard input
## Project layout
- `src/engine.rs` — standard calculator logic
- `src/programmer.rs` — programmer mode logic
- `src/convert.rs` — float32 / word endian convert
- `src/main.rs` — UI wiring
- `ui/app.slint` — Slint interface
- `dist/rcalc` — release binary
- `scripts/build-deb.sh` + `packaging/deb/` — .deb package (control, desktop
file, AppStream metainfo, maintainer scripts)
- `scripts/build-appimage.sh` — portable AppImage
- `scripts/install-desktop.sh` — per-user launcher + icon (no root needed)