aboutsummaryrefslogtreecommitdiff
path: root/scripts/setup-telega.sh
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-14 08:07:21 -0500
committerCraig Jennings <c@cjennings.net>2026-05-14 08:07:21 -0500
commit1e21c2c31a44d3a2a9e302de4712b482de597058 (patch)
tree452bf4098b4c58a7fc948aaa020ee0b51bc76287 /scripts/setup-telega.sh
parentaf12ac6a7375f1651cb207d3e1bcd194a97a77a9 (diff)
downloaddotemacs-1e21c2c31a44d3a2a9e302de4712b482de597058.tar.gz
dotemacs-1e21c2c31a44d3a2a9e302de4712b482de597058.zip
feat(setup-telega): install the telega Emacs package alongside docker setup
modules/telega-config.el uses `:ensure nil' on the use-package block (a stale MELPA archive index can 404 and take startup down if auto-install runs in init). The trade-off was that a fresh clone needed a one-time `M-x package-install RET telega' before the dashboard launcher or `C-; G' would work -- the autoload stub would fail with `Cannot open load file: telega' instead. Hit it on this machine just now: dashboard pressed, autoload tried to load telega.el, no telega.el on the load-path, cryptic error. Add `ensure_telega_package' to the setup script: probe with `(package-installed-p 'telega)' under `emacs --batch'; if absent, refresh MELPA and install via package.el; if that fails, surface the manual recovery path. Wire it into `main' after the docker checks. Four new bats tests cover the missing-emacs, already- installed, install-succeeds, and install-fails paths with `emacs' stubbed at the function level.
Diffstat (limited to 'scripts/setup-telega.sh')
-rwxr-xr-xscripts/setup-telega.sh43
1 files changed, 41 insertions, 2 deletions
diff --git a/scripts/setup-telega.sh b/scripts/setup-telega.sh
index 2b565e99..9a8c0d02 100755
--- a/scripts/setup-telega.sh
+++ b/scripts/setup-telega.sh
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# Craig Jennings <c@cjennings.net>
#
-# Prepares the docker environment telega.el uses for TDLib.
+# Prepares everything telega.el needs on a fresh clone.
#
# Sequence:
# - Verifies docker is installed and the daemon is responsive.
@@ -9,6 +9,11 @@
# - Pulls the telega-server image if a public one is configured (env var
# `TELEGA_DOCKER_IMAGE'); otherwise prints the in-Emacs build command
# (`M-x telega-server-build') for the user to run once.
+# - Installs the `telega' Emacs package via package.el if it isn't
+# already in package-user-dir. modules/telega-config.el uses
+# `:ensure nil' (a stale MELPA index can 404 and take startup down
+# if auto-install runs in init), so the install has to happen
+# explicitly somewhere. This is that somewhere.
#
# Does NOT handle Telegram account auth -- phone number + verification
# code is interactive and runs inside `M-x telega' on first launch.
@@ -63,13 +68,47 @@ EOF
fi
}
+ensure_telega_package() {
+ if ! command -v emacs >/dev/null 2>&1; then
+ echo " ✗ emacs not on PATH; install Emacs first"
+ return 1
+ fi
+ # Probe quietly whether telega is already in package-user-dir.
+ if emacs --batch --eval "(progn
+ (require 'package)
+ (package-initialize)
+ (kill-emacs (if (package-installed-p 'telega) 0 1)))" \
+ >/dev/null 2>&1; then
+ echo " ✓ telega Emacs package already installed"
+ return 0
+ fi
+ echo " → installing telega via package.el..."
+ if emacs --batch --eval "(progn
+ (require 'package)
+ (package-initialize)
+ (unless (assoc \"melpa\" package-archives)
+ (add-to-list 'package-archives '(\"melpa\" . \"https://melpa.org/packages/\") t))
+ (package-refresh-contents)
+ (package-install 'telega))" >/dev/null 2>&1; then
+ echo " ✓ telega installed"
+ else
+ echo " ✗ telega install failed"
+ echo " try interactively:"
+ echo " M-x package-refresh-contents"
+ echo " M-x package-install RET telega"
+ return 1
+ fi
+}
+
main() {
echo "→ checking docker..."
ensure_docker_installed
ensure_docker_running
echo "→ preparing telega-server image..."
pull_or_announce_image
- echo "✅ Telega docker setup complete."
+ echo "→ checking telega Emacs package..."
+ ensure_telega_package
+ echo "✅ Telega setup complete."
echo " First launch: M-x telega -- enter phone + verification code interactively."
}