This repository was archived by the owner on Jan 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsystem-update.py
More file actions
60 lines (52 loc) · 2.67 KB
/
system-update.py
File metadata and controls
60 lines (52 loc) · 2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python3
# This script is used to update Depthboot/EupneaOS between releases.
import json
from functions import *
if __name__ == "__main__":
# Check if running under Depthboot or EupneaOS
with open("/etc/eupnea.json", "r") as f:
config = json.load(f)
try:
current_version = config["depthboot_version"]
os_type = "depthboot_version"
with open("/usr/lib/eupnea-system-update/configs/depthboot_versions.txt", "r") as f:
versions_array = f.read().splitlines()
from depthboot_updates import * # import the depthboot updates
except KeyError:
current_version = config["eupnea_os_version"]
os_type = "eupnea_os_version"
# Convert versions.txt into an array
with open("/usr/lib/eupnea-system-update/configs/eupnea_os_versions.txt", "r") as f:
versions_array = f.read().splitlines()
from eupnea_os_updates import * # import the EupneaOS updates
# Remove versions older than current version from the array
try:
versions_array = versions_array[versions_array.index(current_version) + 1:]
except ValueError:
print_error("Your local eupnea version is higher than the package version. This should not happen. Please "
"report this issue on the Eupnea GitHub.")
exit(1)
if len(versions_array) == 0: # No updates available.
exit(0)
else:
# Create /var/tmp/eupnea-updates for the modify-packages script
mkdir("/var/tmp/eupnea-updates", create_parents=True)
# Execute update scripts for all versions in the array
for version in versions_array:
version = version.replace(".", "_") # Functions cant have dots in their names -> replace with underscores
globals()[f"v{version}"]() # This calls the function named after the version
# Do not try interacting with systemctl if running in a chroot
if not path_exists("/proc/mounts"):
print_warning("Chroot detected: Skipping systemd service activation. Ignore this if you are building")
else:
bash("systemctl daemon-reload")
print_status("Starting eupnea-update service to install package updates...")
# --no-block prevents systemd from waiting for the service to finish
bash("systemctl start --no-block eupnea-update.service")
# Update version in config with the latest version in the array
# reload config from disk
with open("/etc/eupnea.json", "r") as f:
config = json.load(f)
config[os_type] = versions_array[-1]
with open("/etc/eupnea.json", "w") as file:
json.dump(config, file)