Mercurial > code > home > repos > infra
annotate apt.py @ 195:ee6374edfc06
pkgs and signatures
author | drewp@bigasterisk.com |
---|---|
date | Wed, 14 Jun 2023 19:45:35 -0700 |
parents | 087b84e68765 |
children | 3fd439ae1380 |
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 | |
178
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
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 ]: |
6ec7cd3615f0
another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents:
155
diff
changeset
|
15 files.download(src=url, dest=f'/etc/apt/keyrings/{name}') |
187
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
16 server.shell(commands=[ |
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
17 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
|
18 ('https://packages.microsoft.com/keys/microsoft.asc', 'ms.gpg'), |
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
19 ('https://deb.nodesource.com/gpgkey/nodesource.gpg.key', 'nodesource.gpg'), |
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
20 ('https://dl.google.com/linux/linux_signing_key.pub', 'chrome.gpg'), |
195 | 21 ('https://ftp-master.debian.org/keys/archive-key-11.asc', 'bullseye.gpg'), |
22 ('https://ftp-master.debian.org/keys/archive-key-11-security.asc', 'bullseye-security.gpg'), | |
187
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
23 ] |
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
24 ]) |
195 | 25 if host.get_fact(Arch) == 'armv7l' or host.name == 'bang': # I mean raspbian/debian |
26 # this contaminates the apt-update | |
27 files.file(path="/etc/apt/trusted.gpg.d/podman.asc", present=False) | |
28 | |
29 | |
30 dir = Path('/etc/apt/sources.list.d') | |
31 | |
32 | |
33 def clear_known_sources_files(known=[dir / 'vscode.list']): | |
34 found = map(Path, host.get_fact(FindFiles, dir, quote_path=True)) | |
35 if set(found) - set(known): | |
36 raise SystemExit(f"new files in {host.name} /etc/apt/sources.list.d/ - please remove") | |
37 for f in known: | |
38 files.file(path=f, present=False) | |
155 | 39 |
40 | |
41 def apt_sources(): | |
42 if host.get_fact(Arch) == 'x86_64': | |
43 server.shell(commands=['dpkg --add-architecture i386']) | |
44 | |
45 files.template(src='templates/sources.list.j2', dest='/etc/apt/sources.list') | |
195 | 46 |
47 clear_known_sources_files() | |
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 |
195 | 61 |
155 | 62 pkg_keys() |
187
466108f0a509
redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents:
178
diff
changeset
|
63 apt_sources() |