Mercurial > code > home > repos > infra
annotate apt/apt.py @ 320:11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
author | drewp@bigasterisk.com |
---|---|
date | Fri, 08 Nov 2024 23:16:56 -0800 |
parents | apt.py@f17d9925a2aa |
children | 5b88b38f2471 |
rev | line source |
---|---|
280 | 1 import shlex |
320
11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
drewp@bigasterisk.com
parents:
309
diff
changeset
|
2 |
155 | 3 from pyinfra import host |
320
11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
drewp@bigasterisk.com
parents:
309
diff
changeset
|
4 from pyinfra.facts.server import Arch |
155 | 5 from pyinfra.operations import apt, files, server |
6 | |
7 TZ = 'America/Los_Angeles' | |
8 | |
282 | 9 |
155 | 10 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
|
11 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
|
12 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
|
13 ('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
|
14 ]: |
247 | 15 files.download(src=url, dest=f'/usr/share/keyrings/{name}') |
203 | 16 |
297 | 17 apt.packages(packages=['curl', 'gpg']) |
187
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
18 server.shell(commands=[ |
280 | 19 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
|
20 ('https://packages.microsoft.com/keys/microsoft.asc', 'ms.gpg'), |
240 | 21 ('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
|
22 ('https://dl.google.com/linux/linux_signing_key.pub', 'chrome.gpg'), |
195 | 23 ('https://ftp-master.debian.org/keys/archive-key-11.asc', 'bullseye.gpg'), |
24 ('https://ftp-master.debian.org/keys/archive-key-11-security.asc', 'bullseye-security.gpg'), | |
209 | 25 ('https://packages.cloud.google.com/apt/doc/apt-key.gpg', 'coral.gpg'), |
249 | 26 ('https://hub.unity3d.com/linux/keys/public', 'unityhub.gpg'), |
254 | 27 ('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
|
28 ] |
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
29 ]) |
195 | 30 |
211 | 31 # also these |
32 #-rw-r--r-- 1 root root 2794 Mar 26 2021 /etc/apt/trusted.gpg.d/ubuntu-keyring-2012-cdimage.gpg | |
33 #-rw-r--r-- 1 root root 1733 Mar 26 2021 /etc/apt/trusted.gpg.d/ubuntu-keyring-2018-archive.gpg | |
282 | 34 |
280 | 35 # raspi needs wget http://archive.raspbian.org/raspbian.public.key -O - | sudo apt-key add - |
195 | 36 |
249 | 37 |
320
11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
drewp@bigasterisk.com
parents:
309
diff
changeset
|
38 def arch386(): |
11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
drewp@bigasterisk.com
parents:
309
diff
changeset
|
39 server.shell(commands=['dpkg --add-architecture i386']) |
195 | 40 |
41 | |
320
11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
drewp@bigasterisk.com
parents:
309
diff
changeset
|
42 def old_deleteme_apt_sources(): |
11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
drewp@bigasterisk.com
parents:
309
diff
changeset
|
43 files.template(src='apt/templates/sources.list.j2', dest='/etc/apt/sources.list') |
11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
drewp@bigasterisk.com
parents:
309
diff
changeset
|
44 apt_update() |
155 | 45 |
46 | |
320
11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
drewp@bigasterisk.com
parents:
309
diff
changeset
|
47 def apt_update(): |
155 | 48 apt.packages(update=True, |
187
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
49 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
|
50 packages=['tzdata'], |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
51 force=True, |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
52 _env={ |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
53 'TZ': TZ, |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
54 '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
|
55 'DEBIAN_FRONTEND': 'noninteractive' |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
56 }) |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
57 |
188 | 58 # squib 1st setup seemed to need more updates for node(nodesource) |
59 # 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
|
60 |
283 | 61 |
271 | 62 def flatpak_sources(): |
286 | 63 apt.packages(update=True, cache_time=86400, packages=['flatpak']) |
288 | 64 server.shell(commands='flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo') |
195 | 65 |
282 | 66 |
320
11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
drewp@bigasterisk.com
parents:
309
diff
changeset
|
67 if host.get_fact(Arch) == 'x86_64': |
11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
drewp@bigasterisk.com
parents:
309
diff
changeset
|
68 arch386() |
282 | 69 |
155 | 70 pkg_keys() |
320
11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
drewp@bigasterisk.com
parents:
309
diff
changeset
|
71 using_new_sources = ['tofu'] |
11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
drewp@bigasterisk.com
parents:
309
diff
changeset
|
72 if host.name in using_new_sources: |
11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
drewp@bigasterisk.com
parents:
309
diff
changeset
|
73 # todo: rm /etc/apt/sources.list.d/*.list |
11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
drewp@bigasterisk.com
parents:
309
diff
changeset
|
74 files.template(src='apt/templates/ubuntu.sources.j2', dest='/etc/apt/sources.list.d/ubuntu.sources') |
11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
drewp@bigasterisk.com
parents:
309
diff
changeset
|
75 files.template(src='apt/templates/more.sources.j2', dest='/etc/apt/sources.list.d/more.sources') |
11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
drewp@bigasterisk.com
parents:
309
diff
changeset
|
76 apt_update() |
11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
drewp@bigasterisk.com
parents:
309
diff
changeset
|
77 else: |
11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
drewp@bigasterisk.com
parents:
309
diff
changeset
|
78 old_deleteme_apt_sources() |
11d3bcedb9f0
updates for tofu rebuild; some dead code; start moving tasks into subdirs with their files and templates
drewp@bigasterisk.com
parents:
309
diff
changeset
|
79 |
282 | 80 flatpak_sources() |