From deb462188fc2adc168c782fca51fae746a299cca Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Sat, 26 Sep 2026 22:23:04 +0100 Subject: Declare official Keybase APT setup for Canonical --- scripts/canonical.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'scripts') diff --git a/scripts/canonical.py b/scripts/canonical.py index 35bfdcb..a4e0b5d 100644 --- a/scripts/canonical.py +++ b/scripts/canonical.py @@ -5,6 +5,7 @@ import json import os import platform import subprocess +import tempfile from pathlib import Path ROOT = Path(__file__).resolve().parents[1] @@ -74,6 +75,8 @@ def require_canonical() -> None: def install() -> None: subprocess.run(["sudo", "apt-get", "update"], check=True) + if "keybase" in packages("apt"): + install_keybase() subprocess.run(["sudo", "apt-get", "install", *packages("apt")], check=True) for command in snap_install_commands(): if subprocess.run( @@ -87,6 +90,38 @@ def install() -> None: subprocess.run(command, check=True) +def install_keybase() -> None: + status = subprocess.run( + ["dpkg-query", "-W", "-f=${Status}", "keybase"], + check=False, + capture_output=True, + text=True, + ) + if status.returncode == 0 and status.stdout == "install ok installed": + return + if platform.machine() != "x86_64": + raise SystemExit("The Keybase bootstrap package requires amd64.") + with tempfile.TemporaryDirectory(prefix="keybase-") as directory: + Path(directory).chmod(0o755) + package = str(Path(directory) / "keybase_amd64.deb") + subprocess.run( + [ + "curl", + "--fail", + "--location", + "--proto", + "=https", + "--proto-redir", + "=https", + "--output", + package, + "https://prerelease.keybase.io/keybase_amd64.deb", + ], + check=True, + ) + subprocess.run(["sudo", "apt-get", "install", package], check=True) + + def require_lab() -> None: marker = Path("/etc/canonical-lab") if not marker.is_file() or marker.stat().st_uid != 0: -- cgit v1.3.1