From 2e78e3c095e12a151ad3ba93e0336c6d4cc180b8 Mon Sep 17 00:00:00 2001 From: ganglyu Date: Sun, 24 Apr 2022 17:08:09 +0800 Subject: [PATCH] Use pip to install systemd-python and update path. --- files/build_templates/sonic_debian_extension.j2 | 3 +++ src/sonic-host-services/scripts/sonic-host-server | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/files/build_templates/sonic_debian_extension.j2 b/files/build_templates/sonic_debian_extension.j2 index 8a04b682abae..349c195f975e 100644 --- a/files/build_templates/sonic_debian_extension.j2 +++ b/files/build_templates/sonic_debian_extension.j2 @@ -235,6 +235,9 @@ sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y in # Mark runtime dependencies as manually installed to avoid them being auto-removed while uninstalling build dependencies sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-mark manual gir1.2-glib-2.0 libdbus-1-3 libgirepository-1.0-1 libsystemd0 python3-dbus +# Install systemd-python for SONiC host services +sudo https_proxy=$https_proxy LANG=C chroot $FILESYSTEM_ROOT pip3 install systemd-python + # Install SONiC host services package SONIC_HOST_SERVICES_PY3_WHEEL_NAME=$(basename {{sonic_host_services_py3_wheel_path}}) sudo cp {{sonic_host_services_py3_wheel_path}} $FILESYSTEM_ROOT/$SONIC_HOST_SERVICES_PY3_WHEEL_NAME diff --git a/src/sonic-host-services/scripts/sonic-host-server b/src/sonic-host-services/scripts/sonic-host-server index eb1ae781a8d6..23dfc3f2ccb7 100755 --- a/src/sonic-host-services/scripts/sonic-host-server +++ b/src/sonic-host-services/scripts/sonic-host-server @@ -15,11 +15,11 @@ from gi.repository import GObject def find_module_path(): """Find path for host_moduels""" - for path in sys.path: - mod_path = path + '/host_modules' - if os.path.exists(mod_path): - return mod_path - return None + try: + from host_modules import host_service + return os.path.dirname(host_service.__file__) + except: + return None def register_modules(mod_path): """Register all host modules"""