From 5fd99b59e380e487a222dcc8760bb577d0acb3f8 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Sun, 5 Jan 2025 21:47:13 -0700 Subject: [PATCH] python: setup: debian: Initial setup for mkosi and systemd-nspawn Signed-off-by: Nathan Chancellor --- python/setup/deb.py | 5 +++++ python/setup/debian.py | 19 +++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/python/setup/deb.py b/python/setup/deb.py index ba087c2e..3d0b7d3d 100755 --- a/python/setup/deb.py +++ b/python/setup/deb.py @@ -155,6 +155,11 @@ def update_and_install_packages(additional_packages=None): 'file', 'locales', + # mkosi / systemd-nspawn + 'patch', + 'python3-venv', + 'systemd-container', + # Remote work 'mosh', 'ssh', diff --git a/python/setup/debian.py b/python/setup/debian.py index e11353cf..0f91d8cd 100755 --- a/python/setup/debian.py +++ b/python/setup/debian.py @@ -9,6 +9,7 @@ import re import shutil import sys +from tempfile import NamedTemporaryFile import deb @@ -19,6 +20,10 @@ # pylint: enable=wrong-import-position +def get_version_id(): + return int(lib.setup.get_os_rel_val('VERSION_ID')) + + def machine_is_trusted(): return lib.setup.get_hostname() in ('raspberrypi') @@ -78,11 +83,11 @@ def setup_repos(): apt_gpg = Path('/etc/apt/trusted.gpg.d') apt_sources = Path('/etc/apt/sources.list.d') codename = lib.setup.get_version_codename() - version_id = lib.setup.get_os_rel_val('VERSION_ID') + version_id = get_version_id() dpkg_arch = deb.get_dpkg_arch() # Docker - if int(version_id) < 12: # bullseye and earlier, bookworm's podman is not ancient + if version_id < 12: # bullseye and earlier, bookworm's podman is not ancient docker_gpg_key = Path(apt_gpg, 'docker.gpg') lib.setup.fetch_gpg_key('https://download.docker.com/linux/debian/gpg', docker_gpg_key) Path(apt_sources, 'docker.list').write_text( @@ -121,9 +126,19 @@ def update_and_install_packages(): packages = [] if machine_is_trusted(): packages += ['iptables', 'tailscale'] + if get_version_id() >= 13: + # This is only in bookworm backports + packages.append('distribution-gpg-keys') deb.update_and_install_packages(packages) + if 'distribution-gpg-keys' not in packages: + with NamedTemporaryFile() as tmppkg: + url = 'http://ftp.us.debian.org/debian/pool/main/d/distribution-gpg-keys/distribution-gpg-keys_1.106+ds-1~bpo12+1_all.deb' + lib.utils.curl(url, tmppkg) + + lib.utils.run(['dpkg', '-i', tmppkg]) + if __name__ == '__main__': args = parse_arguments()