annotate apt/apt.py @ 326:5b88b38f2471

huge reorg, reog toplevel functions in preparation of a ui with nice task lists
author drewp@bigasterisk.com
date Mon, 20 Jan 2025 21:55:08 -0800
parents 11d3bcedb9f0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
326
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
1 import io
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
326
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
3 from pyinfra.context 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
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
5 from pyinfra.operations import apt, files, server
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
6
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
7 TZ = 'America/Los_Angeles'
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
8
282
e10ee3ddadcf pi changes
drewp@bigasterisk.com
parents: 280
diff changeset
9
326
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
10 def ubuntuReleases():
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
11 if 'pi' not in host.groups:
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
12 files.line(path='/etc/update-manager/release-upgrades', line="^Prompt=", replace="Prompt=normal")
203
3fd439ae1380 minor & some upgrades
drewp@bigasterisk.com
parents: 195
diff changeset
13
326
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
14 def pkgKeys():
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
15 files.directory(path='/etc/apt/keyrings/') # for raspi
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
16 files.sync(src='apt/keyrings/', dest='/usr/share/keyrings/', delete=False)
195
ee6374edfc06 pkgs and signatures
drewp@bigasterisk.com
parents: 188
diff changeset
17
211
drewp@bigasterisk.com
parents: 209
diff changeset
18 # also these
drewp@bigasterisk.com
parents: 209
diff changeset
19 #-rw-r--r-- 1 root root 2794 Mar 26 2021 /etc/apt/trusted.gpg.d/ubuntu-keyring-2012-cdimage.gpg
drewp@bigasterisk.com
parents: 209
diff changeset
20 #-rw-r--r-- 1 root root 1733 Mar 26 2021 /etc/apt/trusted.gpg.d/ubuntu-keyring-2018-archive.gpg
282
e10ee3ddadcf pi changes
drewp@bigasterisk.com
parents: 280
diff changeset
21
280
5c5c314051c5 updates for pis
drewp@bigasterisk.com
parents: 278
diff changeset
22 # raspi needs wget http://archive.raspbian.org/raspbian.public.key -O - | sudo apt-key add -
195
ee6374edfc06 pkgs and signatures
drewp@bigasterisk.com
parents: 188
diff changeset
23
249
5c10b1e8d0e1 add unity key
drewp@bigasterisk.com
parents: 247
diff changeset
24
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
25 def arch386():
326
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
26 if host.get_fact(Arch) != 'x86_64':
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
27 return
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
28 server.shell(commands=['dpkg --add-architecture i386'])
195
ee6374edfc06 pkgs and signatures
drewp@bigasterisk.com
parents: 188
diff changeset
29
ee6374edfc06 pkgs and signatures
drewp@bigasterisk.com
parents: 188
diff changeset
30
326
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
31 def aptUpdate():
155
522f26c8f691 split apt.py from system.py
drewp@bigasterisk.com
parents:
diff changeset
32 apt.packages(update=True,
187
466108f0a509 redo pkg keys and future podman 4.3.1 version
drewp@bigasterisk.com
parents: 178
diff changeset
33 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
34 packages=['tzdata'],
6ec7cd3615f0 another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents: 155
diff changeset
35 force=True,
6ec7cd3615f0 another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents: 155
diff changeset
36 _env={
6ec7cd3615f0 another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents: 155
diff changeset
37 'TZ': TZ,
6ec7cd3615f0 another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents: 155
diff changeset
38 '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
39 'DEBIAN_FRONTEND': 'noninteractive'
6ec7cd3615f0 another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents: 155
diff changeset
40 })
6ec7cd3615f0 another try at apt.key, but it doesn't completely work because prime
drewp@bigasterisk.com
parents: 155
diff changeset
41
188
087b84e68765 comment
drewp@bigasterisk.com
parents: 187
diff changeset
42 # squib 1st setup seemed to need more updates for node(nodesource)
087b84e68765 comment
drewp@bigasterisk.com
parents: 187
diff changeset
43 # 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
44
283
drewp@bigasterisk.com
parents: 282
diff changeset
45
326
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
46 def flatpakSources():
286
73ec5064da44 k3s pkgs for longhorn
drewp@bigasterisk.com
parents: 283
diff changeset
47 apt.packages(update=True, cache_time=86400, packages=['flatpak'])
288
drewp@bigasterisk.com
parents: 286
diff changeset
48 server.shell(commands='flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo')
195
ee6374edfc06 pkgs and signatures
drewp@bigasterisk.com
parents: 188
diff changeset
49
282
e10ee3ddadcf pi changes
drewp@bigasterisk.com
parents: 280
diff changeset
50
326
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
51 def sources():
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
52 files.put(src=io.StringIO("# see .d\n"), dest="/etc/apt/sources.list")
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
53 if 'pi' in host.groups:
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
54 osName = "pi"
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
55 elif host.name == 'pipe':
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
56 osName = "odroid"
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
57 else:
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
58 osName = "ubuntu"
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
59 files.template(src=f'apt/templates/{osName}.sources.j2', dest=f'/etc/apt/sources.list.d/{osName}.sources')
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
60 files.template(src='apt/templates/more.sources.j2', dest='/etc/apt/sources.list.d/more.sources')
282
e10ee3ddadcf pi changes
drewp@bigasterisk.com
parents: 280
diff changeset
61
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
62
326
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
63 operations = [
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
64 ubuntuReleases,
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
65 arch386,
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
66 pkgKeys,
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
67 sources,
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
68 aptUpdate,
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
69 flatpakSources,
5b88b38f2471 huge reorg, reog toplevel functions in preparation of a ui with nice task lists
drewp@bigasterisk.com
parents: 320
diff changeset
70 ]