|
| 1 | +#!/usr/bin/env bash |
| 2 | +# Build a .deb package for Tesseract. |
| 3 | +# Run from anywhere; output is tesseract_<version>_amd64.deb at the repo root. |
| 4 | +set -euo pipefail |
| 5 | + |
| 6 | +REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" |
| 7 | +VERSION="$(grep '^version' "$REPO/Cargo.toml" | head -1 | sed 's/.*"\(.*\)".*/\1/')" |
| 8 | +ARCH="$(dpkg --print-architecture)" |
| 9 | +PKG="tesseract_${VERSION}_${ARCH}" |
| 10 | +STAGING="$REPO/target/deb-staging/$PKG" |
| 11 | + |
| 12 | +echo "==> Building release binaries…" |
| 13 | +cd "$REPO" |
| 14 | +cargo build --release -p tesseract-agent -p tesseract-cli -p tesseract-gui |
| 15 | +REL="$REPO/target/release" |
| 16 | + |
| 17 | +echo "==> Assembling package tree at $STAGING…" |
| 18 | +rm -rf "$STAGING" |
| 19 | +install -d \ |
| 20 | + "$STAGING/DEBIAN" \ |
| 21 | + "$STAGING/usr/bin" \ |
| 22 | + "$STAGING/usr/lib/systemd/user" \ |
| 23 | + "$STAGING/usr/share/applications" \ |
| 24 | + "$STAGING/usr/share/metainfo" \ |
| 25 | + "$STAGING/usr/share/icons/hicolor/scalable/apps" \ |
| 26 | + "$STAGING/usr/share/fonts/truetype/tesseract" \ |
| 27 | + "$STAGING/usr/share/polkit-1/actions" |
| 28 | + |
| 29 | +# Binaries |
| 30 | +install -m755 "$REL/tesseract" "$STAGING/usr/bin/tesseract" |
| 31 | +install -m755 "$REL/tesseract-agent" "$STAGING/usr/bin/tesseract-agent" |
| 32 | +install -m755 "$REL/tesseract-gui" "$STAGING/usr/bin/tesseract-gui" |
| 33 | + |
| 34 | +# Desktop integration |
| 35 | +install -m644 "$REPO/packaging/com.jegly.tesseract.desktop" "$STAGING/usr/share/applications/" |
| 36 | +install -m644 "$REPO/packaging/com.jegly.tesseract.metainfo.xml" "$STAGING/usr/share/metainfo/" |
| 37 | +install -m644 "$REPO/packaging/com.jegly.tesseract.svg" "$STAGING/usr/share/icons/hicolor/scalable/apps/" |
| 38 | +install -m644 "$REPO/packaging/com.jegly.tesseract.policy" "$STAGING/usr/share/polkit-1/actions/" |
| 39 | +sed 's|ExecStart=.*tesseract-agent|ExecStart=/usr/bin/tesseract-agent|' \ |
| 40 | + "$REPO/packaging/tesseract-agent.service" \ |
| 41 | + > "$STAGING/usr/lib/systemd/user/tesseract-agent.service" |
| 42 | +chmod 644 "$STAGING/usr/lib/systemd/user/tesseract-agent.service" |
| 43 | + |
| 44 | +# Font |
| 45 | +install -m644 "$REPO/tesseract-gui/resources/fonts/DotGothic16-Regular.ttf" \ |
| 46 | + "$STAGING/usr/share/fonts/truetype/tesseract/" |
| 47 | + |
| 48 | +# DEBIAN/control |
| 49 | +cat > "$STAGING/DEBIAN/control" <<EOF |
| 50 | +Package: tesseract |
| 51 | +Version: $VERSION |
| 52 | +Architecture: $ARCH |
| 53 | +Maintainer: jegly <jjjegly@gmail.com> |
| 54 | +Depends: libgtk-4-1 (>= 4.10), libadwaita-1-0 (>= 1.4), udisks2, fuse3 |
| 55 | +Section: utils |
| 56 | +Priority: optional |
| 57 | +Homepage: https://github.com/jegly/Tesseract |
| 58 | +Description: Multi-cipher cascade encryption with post-quantum key wrapping |
| 59 | + Privilege-separated, post-quantum disk and file encryption for the Linux |
| 60 | + desktop. Stack AES, Serpent, Twofish, ChaCha20 and more in any order you |
| 61 | + choose. A sandboxed key agent owns all key material; the GTK4 GUI and CLI |
| 62 | + never touch a key. Runs entirely without root. |
| 63 | +EOF |
| 64 | + |
| 65 | +# DEBIAN/postinst — reload user units and update caches |
| 66 | +cat > "$STAGING/DEBIAN/postinst" <<'EOF' |
| 67 | +#!/bin/sh |
| 68 | +set -e |
| 69 | +if [ "$1" = "configure" ]; then |
| 70 | + systemctl --user daemon-reload 2>/dev/null || true |
| 71 | + gtk-update-icon-cache -f -t /usr/share/icons/hicolor 2>/dev/null || true |
| 72 | + fc-cache -f /usr/share/fonts/truetype/tesseract 2>/dev/null || true |
| 73 | +fi |
| 74 | +EOF |
| 75 | +chmod 755 "$STAGING/DEBIAN/postinst" |
| 76 | + |
| 77 | +# DEBIAN/postrm — clean up caches on remove |
| 78 | +cat > "$STAGING/DEBIAN/postrm" <<'EOF' |
| 79 | +#!/bin/sh |
| 80 | +set -e |
| 81 | +if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then |
| 82 | + gtk-update-icon-cache -f -t /usr/share/icons/hicolor 2>/dev/null || true |
| 83 | + fc-cache -f 2>/dev/null || true |
| 84 | +fi |
| 85 | +EOF |
| 86 | +chmod 755 "$STAGING/DEBIAN/postrm" |
| 87 | + |
| 88 | +echo "==> Building .deb…" |
| 89 | +dpkg-deb --build --root-owner-group "$STAGING" "$REPO/${PKG}.deb" |
| 90 | + |
| 91 | +echo "" |
| 92 | +echo "Done: $REPO/${PKG}.deb" |
| 93 | +echo "Install with: sudo dpkg -i ${PKG}.deb" |
| 94 | +echo " sudo apt-get install -f # if deps are missing" |
0 commit comments