Skip to content

Commit b6119a4

Browse files
committed
Improve program check
1 parent eb6e83c commit b6119a4

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

atomic-update

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ from shlex import quote
2828
import xml.etree.ElementTree as ET
2929

3030
# Constants
31-
VERSION = "0.1.19"
31+
VERSION = "0.1.20"
3232
ZYPPER_PID_FILE = "/run/zypp.pid"
3333
VALID_CMD = ["dup", "run", "rollback"]
3434
VALID_OPT = ["--reboot", "--apply", "--shell", "--continue", "--no-verify", \
@@ -42,6 +42,7 @@ REQUIRED_DEP = ["zypper", "snapper", "btrfs", "echo", "ps", "sed", "awk", "bash"
4242
# The exit code of these programs (if it exists) in addition to the required programs
4343
# will be checked pre/post each transaction/update
4444
CHK_PROGRAMS = [
45+
"ssh",
4546
"Xorg",
4647
"Xwayland",
4748
"pipewire",
@@ -121,6 +122,18 @@ def get_atomic_snap(snapper_root_config, status):
121122
except:
122123
pass
123124

125+
# Function to get version string (option) associated with various shell programs
126+
def get_version_string(program):
127+
version_str = {
128+
"ssh": "-V",
129+
"Xorg": "-version",
130+
"Xwayland": "-version",
131+
}
132+
try:
133+
return version_str[program]
134+
except KeyError:
135+
return "--version"
136+
124137
# Function to verify snapshot's ability to run important programs -
125138
# acts as a basic check for missing and incompatible libraries
126139
def verify_programs(TMP_MOUNT_DIR):
@@ -131,9 +144,8 @@ def verify_programs(TMP_MOUNT_DIR):
131144
env_str = ""
132145
if program == "Hyprland":
133146
env_str = "XDG_RUNTIME_DIR="
134-
version_str = "-version" if program in ["Xorg", "Xwayland"] else "--version"
135147
command = f"chroot {TMP_MOUNT_DIR} bash -c '" \
136-
f"command -v {program} || exit 0 && sudo -u nobody {env_str} {program} {version_str}" \
148+
f"command -v {program} || exit 0 && sudo -u nobody {env_str} {program} {get_version_string(program)}" \
137149
f"'"
138150
out, ret = shell_exec(command)
139151
if ret != 0:

0 commit comments

Comments
 (0)