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