Mercurial > code > home > repos > infra
view packages.py @ 288:3af02e24eaf9
minor
author | drewp@bigasterisk.com |
---|---|
date | Sun, 21 Apr 2024 17:01:13 -0700 |
parents | 73ec5064da44 |
children | 65e28d2e0cd8 |
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(path=local) server.shell(commands=[ 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(commands=[ "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(): # 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 server.shell(commands='apt --fix-broken install') apt.deb(src="http://ftp.osuosl.org/pub/ubuntu/pool/main/g/gpgme1.0/libgpgme11t64_1.18.0-4.1ubuntu4_amd64.deb") server.shell(commands='apt --fix-broken install') apt.deb(src="http://ftp.osuosl.org/pub/ubuntu/pool/universe/c/conmon/conmon_2.1.10+ds1-1build2_amd64.deb") apt.deb(src="http://ftp.osuosl.org/pub/ubuntu/pool/universe/libp/libpod/podman_4.9.3+ds1-1build2_amd64.deb") apt.packages(packages=['libsubid4', 'buildah', 'podman-docker'], latest=True) def pdm(): # https://github.com/pdm-project/pdm/blob/main/CHANGELOG.md server.shell(commands=["pip install --break-system-packages 'pdm==2.12.4'"]) 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" "#!/bin/sh\n exec /usr/bin/flatpak run --branch=stable --arch=x86_64 --command=vinegar org.vinegarhq.Vinegar player run -app\n" ), dest='/usr/local/bin/roblox.real', mode='755') for desktopFile in [ '/var/lib/flatpak/exports/share/applications/org.vinegarhq.Vinegar.app.desktop', '/var/lib/flatpak/app/org.vinegarhq.Vinegar/current/active/export/share/applications/org.vinegarhq.Vinegar.player.desktop', ]: files.line(path=desktopFile, line="^Exec", replace='Exec=/usr/local/bin/roblox') files.link(target='/usr/local/bin/run_while_allowed', path='/usr/local/bin/roblox', force=True) def kube_node(): apt.packages(packages=[ # https://longhorn.io/docs/1.6.1/deploy/install/#installation-requirements 'open-iscsi', 'nfs-common', ]) 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() is_kube_node = host.name in ['dash', 'slash', 'ditto', 'ws-printer', 'li-drums'] if is_kube_node: kube_node() 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() # todo: ./mrv2-v1.0.8-Linux-amd64.deb