Mercurial > code > home > repos > infra
view packages.py @ 275:058c312ffdce
new host `pillow`
author | drewp@bigasterisk.com |
---|---|
date | Sat, 23 Mar 2024 14:20:20 -0700 |
parents | f7178138b736 |
children | 7f79cbbb6f24 |
line wrap: on
line source
from io import StringIO from pyinfra import host from pyinfra.facts.server import LinuxDistribution from pyinfra.operations import apt, files, server, systemd import package_lists is_pi = host.get_fact(LinuxDistribution)['name'] in ['Debian', 'Raspbian GNU/Linux'] def kitty(): vers = '0.31.0' # see https://github.com/kovidgoyal/kitty/releases home = '/home/drewp' local = f"{home}/.local/kitty" dl = f'/tmp/kitty-{vers}-x86_64.txz' files.download(src=f"https://github.com/kovidgoyal/kitty/releases/download/v{vers}/kitty-{vers}-x86_64.txz", dest=dl) files.directory(local) server.shell([ f"mkdir -p {local}", # https://github.com/Fizzadar/pyinfra/issues/777 f"aunpack --extract-to={local} {dl}", ]) files.link(target="{local}/bin/kitty", path="{home}/bin/kitty") def nodejs(): apt.packages(packages=['libnode72'], present=False, force=True) apt.packages(packages=['nodejs'], latest=True) server.shell([ "rm -f /usr/local/bin/pnp{m,x}", "corepack enable", # https://github.com/pnpm/pnpm/releases # but also https://pnpm.io/installation#compatibility "corepack prepare 'pnpm@8.6.3' --activate", ]) def podman(): apt.packages(packages=['libsubid4', 'buildah', 'podman-docker'], latest=True) # frigate build wants to mount a single file from the host, which needs podman 4.5.1 # https://github.com/containers/podman/issues/12123#issuecomment-1620439593 apt.deb(src="http://ftp.osuosl.org/pub/ubuntu/pool/universe/libp/libpod/podman_4.9.3+ds1-1_amd64.deb") def pdm(): # https://github.com/pdm-project/pdm/blob/main/CHANGELOG.md server.shell(["pip install --break-system-packages 'pdm==2.12.2'"]) def proper_locate(): apt.packages(packages='mlocate', present=False) if not is_pi and host.name not in ['prime', 'pipe']: apt.packages(packages='plocate') def proper_man(): if host.name in ['pipe', 'prime'] or is_pi: apt.packages(packages=['mandb'], present=False) def no_unwanted_services(): systemd.service(service='nginx', enabled=False, running=False) kw = dict(present=True, latest=True) apt.packages(packages=package_lists.setup, **kw) def roblox(): server.shell('flatpak install -y org.freedesktop.Platform/x86_64/23.08') server.shell('flatpak install -y flathub org.vinegarhq.Vinegar') # (roblox runner) files.put(src=StringIO("#!/bin/sh\nexec flatpak run org.vinegarhq.Vinegar player run 'roblox-player:1'\n"), dest='/usr/local/bin/roblox', mode='755') if not is_pi: if host.name != 'pipe': apt.packages(packages=['reptyr']) kitty() else: apt.packages(packages=package_lists.pi_setup) proper_locate() proper_man() apt.packages(packages=package_lists.general, **kw) apt.packages(packages=package_lists.debug, **kw) if host.name in ["bang", 'ditto']: apt.packages(packages=package_lists.for_bang_ditto, **kw) if host.name == "pipe": apt.packages(packages=package_lists.for_pipe, **kw) if host.name == "prime": apt.packages(packages=package_lists.for_prime, **kw) if host.name == 'plus': apt.packages(packages=package_lists.laptop, **kw) if host.name in ['dash', 'slash', 'ditto', 'dot']: apt.packages(packages=package_lists.k8s_node_with_nvidia_gpu(host.name)) # no kw, or apt will remove nvidia-utils-VERS (!) if host.name in ['dash', 'slash', 'ditto']: podman() if host.name == 'ditto': # should have happened in the previous step, but it gets reverted. apt.packages(packages=['nvidia-utils-535-server']) if not is_pi: apt.packages(packages=package_lists.non_pi, **kw) else: # move to another file? files.template(src="templates/pigpiod.service.j2", dest="/etc/systemd/system/pigpiod.service") systemd.service(service='pigpiod', daemon_reload=True, enabled=True) desktop_env = host.name in ['dash', 'slash', 'plus', 'dot', 'squib', 'pillow'] if desktop_env: apt.packages(packages=package_lists.xorg + package_lists.desktop, **kw) roblox() if desktop_env or host.name in ['bang', 'ditto']: pdm() no_unwanted_services()