Mercurial > code > home > repos > infra
annotate apt.py @ 280:5c5c314051c5
updates for pis
author | drewp@bigasterisk.com |
---|---|
date | Sun, 14 Apr 2024 20:58:39 -0700 |
parents | 4e424a144183 |
children | e10ee3ddadcf |
rev | line source |
---|---|
195 | 1 from pathlib import Path |
280 | 2 import shlex |
155 | 3 from pyinfra import host |
4 from pyinfra.facts.files import FindFiles | |
5 from pyinfra.facts.server import Arch, LinuxDistribution | |
6 from pyinfra.operations import apt, files, server | |
7 | |
8 TZ = 'America/Los_Angeles' | |
9 | |
278 | 10 is_pi = host.get_fact(LinuxDistribution)['name'] in ['Debian', 'Raspbian GNU/Linux'] |
178
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
11 |
155 | 12 def pkg_keys(): |
178
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
13 files.directory(path='/etc/apt/keyrings/') # for raspi |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
14 for url, name in [ |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
15 ('https://repo.steampowered.com/steam/archive/stable/steam.gpg', 'steam.gpg'), |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
16 ]: |
247 | 17 files.download(src=url, dest=f'/usr/share/keyrings/{name}') |
203 | 18 |
19 # vscode keeps making this, but I fetch my own | |
235
19a7f714273c
pkg updates, take out nvidia drv for now
drewp@bigasterisk.com
parents:
230
diff
changeset
|
20 files.file(path='/etc/apt/trusted.gpg.d/microsoft.gpg', present=False) |
203 | 21 |
230 | 22 # and it makes this, which is redundant with my sources.list template line |
23 files.file(path='/etc/apt/sources.list.d/vscode.list', present=False) | |
24 | |
240 | 25 apt.packages(packages=['curl']) |
187
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
26 server.shell(commands=[ |
280 | 27 f"curl -fsSL {shlex.quote(url)} | gpg --dearmor > /etc/apt/keyrings/{name}" for (url, name) in [ |
187
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
28 ('https://packages.microsoft.com/keys/microsoft.asc', 'ms.gpg'), |
249 | 29 ('https://deb.nodesource.com/gpgkey/nodesource.gpg.key', 'nodesource-older.gpg'), # rm after everything's on 23.10 |
240 | 30 ('https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key', 'nodesource.gpg'), |
187
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
31 ('https://dl.google.com/linux/linux_signing_key.pub', 'chrome.gpg'), |
195 | 32 ('https://ftp-master.debian.org/keys/archive-key-11.asc', 'bullseye.gpg'), |
33 ('https://ftp-master.debian.org/keys/archive-key-11-security.asc', 'bullseye-security.gpg'), | |
209 | 34 ('https://packages.cloud.google.com/apt/doc/apt-key.gpg', 'coral.gpg'), |
249 | 35 ('https://hub.unity3d.com/linux/keys/public', 'unityhub.gpg'), |
254 | 36 ('https://nvidia.github.io/libnvidia-container/gpgkey', 'nvidia.gpg'), |
187
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
37 ] |
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
38 ]) |
280 | 39 if is_pi or host.name == 'bang': |
195 | 40 # this contaminates the apt-update |
41 files.file(path="/etc/apt/trusted.gpg.d/podman.asc", present=False) | |
42 | |
211 | 43 # also these |
44 #-rw-r--r-- 1 root root 2794 Mar 26 2021 /etc/apt/trusted.gpg.d/ubuntu-keyring-2012-cdimage.gpg | |
45 #-rw-r--r-- 1 root root 1733 Mar 26 2021 /etc/apt/trusted.gpg.d/ubuntu-keyring-2018-archive.gpg | |
280 | 46 |
47 # raspi needs wget http://archive.raspbian.org/raspbian.public.key -O - | sudo apt-key add - | |
195 | 48 |
249 | 49 |
195 | 50 dir = Path('/etc/apt/sources.list.d') |
51 | |
52 | |
240 | 53 def clear_known_sources_files(known=[ |
249 | 54 dir / 'vscode.list', |
55 dir / 'google-chrome.list', | |
56 dir / 'steam-beta.list', | |
57 dir / 'google-chrome-unstable.list', | |
58 dir / 'steam-stable.list', | |
280 | 59 dir / 'raspi.list', |
240 | 60 ]): |
195 | 61 found = map(Path, host.get_fact(FindFiles, dir, quote_path=True)) |
62 if set(found) - set(known): | |
63 raise SystemExit(f"new files in {host.name} /etc/apt/sources.list.d/ - please remove") | |
64 for f in known: | |
65 files.file(path=f, present=False) | |
155 | 66 |
67 | |
68 def apt_sources(): | |
69 if host.get_fact(Arch) == 'x86_64': | |
70 server.shell(commands=['dpkg --add-architecture i386']) | |
71 | |
72 files.template(src='templates/sources.list.j2', dest='/etc/apt/sources.list') | |
195 | 73 |
74 clear_known_sources_files() | |
155 | 75 apt.packages(update=True, |
187
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
76 cache_time=86400, |
178
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
77 packages=['tzdata'], |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
78 force=True, |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
79 _env={ |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
80 'TZ': TZ, |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
81 'LANG': 'en_US.UTF-8', |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
82 'DEBIAN_FRONTEND': 'noninteractive' |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
83 }) |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
84 |
188 | 85 # squib 1st setup seemed to need more updates for node(nodesource) |
86 # and steam-launcher | |
178
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
87 |
271 | 88 def flatpak_sources(): |
89 server.shell('flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo') | |
195 | 90 |
155 | 91 pkg_keys() |
187
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
92 apt_sources() |
271 | 93 flatpak_sources() |