Mercurial > code > home > repos > infra
annotate packages.py @ 271:0ed4add0b1a4
roblox
author | drewp@bigasterisk.com |
---|---|
date | Fri, 16 Feb 2024 20:10:20 -0800 |
parents | 34ab4aec7d4b |
children | f7178138b736 |
rev | line source |
---|---|
271 | 1 from io import StringIO |
12 | 2 from pyinfra import host |
3 from pyinfra.facts.server import LinuxDistribution | |
186 | 4 from pyinfra.operations import apt, files, server, systemd |
205 | 5 |
114
7e280bf26dba
package lists big update, pulling from /var/log/apt on a few hosts
drewp@bigasterisk.com
parents:
108
diff
changeset
|
6 import package_lists |
12 | 7 |
8 is_pi = host.get_fact(LinuxDistribution)['name'] in ['Debian', 'Raspbian GNU/Linux'] | |
103
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
9 |
12 | 10 |
103
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
11 def kitty(): |
246 | 12 vers = '0.31.0' # see https://github.com/kovidgoyal/kitty/releases |
103
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
13 home = '/home/drewp' |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
14 local = f"{home}/.local/kitty" |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
15 dl = f'/tmp/kitty-{vers}-x86_64.txz' |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
16 files.download(src=f"https://github.com/kovidgoyal/kitty/releases/download/v{vers}/kitty-{vers}-x86_64.txz", dest=dl) |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
17 files.directory(local) |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
18 server.shell([ |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
19 f"mkdir -p {local}", # https://github.com/Fizzadar/pyinfra/issues/777 |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
20 f"aunpack --extract-to={local} {dl}", |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
21 ]) |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
22 files.link(target="{local}/bin/kitty", path="{home}/bin/kitty") |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
23 |
12 | 24 |
174
b6b11048d0fb
collect nodejs pkg install stuff together
drewp@bigasterisk.com
parents:
169
diff
changeset
|
25 def nodejs(): |
b6b11048d0fb
collect nodejs pkg install stuff together
drewp@bigasterisk.com
parents:
169
diff
changeset
|
26 apt.packages(packages=['libnode72'], present=False, force=True) |
b6b11048d0fb
collect nodejs pkg install stuff together
drewp@bigasterisk.com
parents:
169
diff
changeset
|
27 apt.packages(packages=['nodejs'], latest=True) |
103
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
28 server.shell([ |
169 | 29 "rm -f /usr/local/bin/pnp{m,x}", |
30 "corepack enable", | |
103
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
31 # https://github.com/pnpm/pnpm/releases |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
32 # but also https://pnpm.io/installation#compatibility |
203 | 33 "corepack prepare 'pnpm@8.6.3' --activate", |
103
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
34 ]) |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
35 |
205 | 36 |
203 | 37 def pdm(): |
206 | 38 # https://github.com/pdm-project/pdm/blob/main/CHANGELOG.md |
255 | 39 server.shell(["pip install --break-system-packages 'pdm==2.12.2'"]) |
69 | 40 |
205 | 41 |
103
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
42 def proper_locate(): |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
43 apt.packages(packages='mlocate', present=False) |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
44 if not is_pi and host.name not in ['prime', 'pipe']: |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
45 apt.packages(packages='plocate') |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
46 |
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
47 |
131 | 48 def proper_man(): |
49 if host.name in ['pipe', 'prime'] or is_pi: | |
50 apt.packages(packages=['mandb'], present=False) | |
12 | 51 |
205 | 52 |
196
c409ea5a1d5c
don't tie up 80/443 with an unwanted nginx instance
drewp@bigasterisk.com
parents:
192
diff
changeset
|
53 def no_unwanted_services(): |
c409ea5a1d5c
don't tie up 80/443 with an unwanted nginx instance
drewp@bigasterisk.com
parents:
192
diff
changeset
|
54 systemd.service(service='nginx', enabled=False, running=False) |
c409ea5a1d5c
don't tie up 80/443 with an unwanted nginx instance
drewp@bigasterisk.com
parents:
192
diff
changeset
|
55 |
c409ea5a1d5c
don't tie up 80/443 with an unwanted nginx instance
drewp@bigasterisk.com
parents:
192
diff
changeset
|
56 |
240 | 57 kw = dict(present=True, latest=True) |
12 | 58 |
143
6b4226845254
actually update packages, and add google chrome to the sources
drewp@bigasterisk.com
parents:
138
diff
changeset
|
59 apt.packages(packages=package_lists.setup, **kw) |
131 | 60 |
271 | 61 |
62 def roblox(): | |
63 server.shell('flatpak install -y org.freedesktop.Platform/x86_64/23.08') | |
64 server.shell('flatpak install -y flathub org.vinegarhq.Vinegar') # (roblox runner) | |
65 files.put(src=StringIO("#!/bin/sh\nexec flatpak run org.vinegarhq.Vinegar player run 'roblox-player:1'\n"), | |
66 dest='/usr/local/bin/roblox', | |
67 mode='755') | |
68 | |
69 | |
12 | 70 if not is_pi: |
83 | 71 if host.name != 'pipe': |
131 | 72 apt.packages(packages=['reptyr']) |
103
8b8ef9d8f0fd
dead code and templates, reformat, maybe a little refactor
drewp@bigasterisk.com
parents:
93
diff
changeset
|
73 kitty() |
131 | 74 else: |
75 apt.packages(packages=package_lists.pi_setup) | |
12 | 76 |
114
7e280bf26dba
package lists big update, pulling from /var/log/apt on a few hosts
drewp@bigasterisk.com
parents:
108
diff
changeset
|
77 proper_locate() |
131 | 78 proper_man() |
79 | |
143
6b4226845254
actually update packages, and add google chrome to the sources
drewp@bigasterisk.com
parents:
138
diff
changeset
|
80 apt.packages(packages=package_lists.general, **kw) |
6b4226845254
actually update packages, and add google chrome to the sources
drewp@bigasterisk.com
parents:
138
diff
changeset
|
81 apt.packages(packages=package_lists.debug, **kw) |
56 | 82 |
205 | 83 if host.name in ["bang", 'ditto']: |
146 | 84 apt.packages(packages=package_lists.for_bang_ditto, **kw) |
114
7e280bf26dba
package lists big update, pulling from /var/log/apt on a few hosts
drewp@bigasterisk.com
parents:
108
diff
changeset
|
85 |
7e280bf26dba
package lists big update, pulling from /var/log/apt on a few hosts
drewp@bigasterisk.com
parents:
108
diff
changeset
|
86 if host.name == "pipe": |
143
6b4226845254
actually update packages, and add google chrome to the sources
drewp@bigasterisk.com
parents:
138
diff
changeset
|
87 apt.packages(packages=package_lists.for_pipe, **kw) |
37
fbd0849dfdbd
redo networking to be much simpler. Uses systemd-networkd
drewp@bigasterisk.com
parents:
34
diff
changeset
|
88 |
131 | 89 if host.name == "prime": |
143
6b4226845254
actually update packages, and add google chrome to the sources
drewp@bigasterisk.com
parents:
138
diff
changeset
|
90 apt.packages(packages=package_lists.for_prime, **kw) |
131 | 91 |
37
fbd0849dfdbd
redo networking to be much simpler. Uses systemd-networkd
drewp@bigasterisk.com
parents:
34
diff
changeset
|
92 if host.name == 'plus': |
143
6b4226845254
actually update packages, and add google chrome to the sources
drewp@bigasterisk.com
parents:
138
diff
changeset
|
93 apt.packages(packages=package_lists.laptop, **kw) |
114
7e280bf26dba
package lists big update, pulling from /var/log/apt on a few hosts
drewp@bigasterisk.com
parents:
108
diff
changeset
|
94 |
268
34ab4aec7d4b
notes and changes for getting nvidia gpu k3d support going, which was very hard
drewp@bigasterisk.com
parents:
261
diff
changeset
|
95 if host.name in ['dash', 'slash', 'ditto', 'dot']: |
271 | 96 apt.packages(packages=package_lists.k8s_node_with_nvidia_gpu(host.name)) # no kw, or apt will remove nvidia-utils-VERS (!) |
254 | 97 |
268
34ab4aec7d4b
notes and changes for getting nvidia gpu k3d support going, which was very hard
drewp@bigasterisk.com
parents:
261
diff
changeset
|
98 if host.name == 'ditto': |
34ab4aec7d4b
notes and changes for getting nvidia gpu k3d support going, which was very hard
drewp@bigasterisk.com
parents:
261
diff
changeset
|
99 # should have happened in the previous step, but it gets reverted. |
34ab4aec7d4b
notes and changes for getting nvidia gpu k3d support going, which was very hard
drewp@bigasterisk.com
parents:
261
diff
changeset
|
100 apt.packages(packages=['nvidia-utils-535-server']) |
131 | 101 |
102 if not is_pi: | |
143
6b4226845254
actually update packages, and add google chrome to the sources
drewp@bigasterisk.com
parents:
138
diff
changeset
|
103 apt.packages(packages=package_lists.non_pi, **kw) |
186 | 104 else: |
105 # move to another file? | |
205 | 106 files.template(src="templates/pigpiod.service.j2", dest="/etc/systemd/system/pigpiod.service") |
186 | 107 systemd.service(service='pigpiod', daemon_reload=True, enabled=True) |
196
c409ea5a1d5c
don't tie up 80/443 with an unwanted nginx instance
drewp@bigasterisk.com
parents:
192
diff
changeset
|
108 |
268
34ab4aec7d4b
notes and changes for getting nvidia gpu k3d support going, which was very hard
drewp@bigasterisk.com
parents:
261
diff
changeset
|
109 desktop_env = host.name in ['dash', 'slash', 'plus', 'dot', 'squib'] |
240 | 110 if desktop_env: |
111 apt.packages(packages=package_lists.xorg + package_lists.desktop, **kw) | |
271 | 112 roblox() |
261 | 113 if desktop_env or host.name in ['bang', 'ditto']: |
240 | 114 pdm() |
115 | |
205 | 116 no_unwanted_services() |