Skip to content

Commit 63a5dd2

Browse files
author
Korney Gedert
committed
Add apt1_runner with pkcon_runner as fallback
1 parent e567811 commit 63a5dd2

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

gpoa/frontend/package_applier.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,28 @@
1919
import logging
2020
import subprocess
2121
from util.logging import log
22+
import dbus
2223

2324
from .applier_frontend import (
2425
applier_frontend
2526
, check_enabled
2627
)
2728

29+
def check_apt1():
30+
dbus_interface = 'org.altlinux.alterator.apt1'
31+
bus_name = 'org.altlinux.alterator'
32+
object_path = '/org/altlinux/alterator/apt'
33+
try:
34+
bus = dbus.SystemBus()
35+
if bus.name_has_owner(bus_name):
36+
dbus.Interface(bus.get_object(bus_name, object_path), dbus_interface)
37+
return True
38+
else:
39+
return False
40+
41+
except dbus.exceptions.DBusException as e:
42+
return False
43+
2844
class package_applier(applier_frontend):
2945
__module_name = 'PackagesApplier'
3046
__module_experimental = False
@@ -40,8 +56,13 @@ def __init__(self, storage):
4056
install_branch = '{}\\{}%'.format(self.__hklm_branch, self.__install_key_name)
4157
remove_branch = '{}\\{}%'.format(self.__hklm_branch, self.__remove_key_name)
4258
sync_branch = '{}\\{}%'.format(self.__hklm_branch, self.__sync_key_name)
59+
if check_apt1():
60+
runner = '/usr/libexec/gpupdate/apt1_runner'
61+
else:
62+
runner = '/usr/libexec/gpupdate/pkcon_runner'
63+
4364
self.fulcmd = []
44-
self.fulcmd.append('/usr/libexec/gpupdate/pkcon_runner')
65+
self.fulcmd.append(runner)
4566
self.fulcmd.append('--loglevel')
4667
logger = logging.getLogger()
4768
self.fulcmd.append(str(logger.level))
@@ -91,10 +112,15 @@ class package_applier_user(applier_frontend):
91112
__hkcu_branch = 'Software\\BaseALT\\Policies\\Packages'
92113

93114
def __init__(self, storage, username):
115+
if check_apt1():
116+
runner = '/usr/libexec/gpupdate/apt1_runner'
117+
else:
118+
runner = '/usr/libexec/gpupdate/pkcon_runner'
119+
94120
self.storage = storage
95121
self.username = username
96122
self.fulcmd = []
97-
self.fulcmd.append('/usr/libexec/gpupdate/pkcon_runner')
123+
self.fulcmd.append(runner)
98124
self.fulcmd.append('--user')
99125
self.fulcmd.append(self.username)
100126
self.fulcmd.append('--loglevel')

0 commit comments

Comments
 (0)