Skip to content

Commit

Permalink
python: setup: debian: Initial setup for mkosi and systemd-nspawn
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
  • Loading branch information
nathanchance committed Jan 6, 2025
1 parent 6d3a926 commit 5fd99b5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions python/setup/deb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
19 changes: 17 additions & 2 deletions python/setup/debian.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import re
import shutil
import sys
from tempfile import NamedTemporaryFile

import deb

Expand All @@ -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')

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 5fd99b5

Please sign in to comment.