From ba92f0802aed81b3725f41c3f11fed385e4705e1 Mon Sep 17 00:00:00 2001 From: Rodolfo Olivieri Date: Mon, 16 Dec 2024 13:03:06 -0300 Subject: [PATCH 1/2] Update specfile to include config from release dir --- data/release/config.toml | 19 +++++++++++++++++++ packaging/command-line-assistant.spec | 9 +++++++++ 2 files changed, 28 insertions(+) diff --git a/data/release/config.toml b/data/release/config.toml index e69de29..367833a 100644 --- a/data/release/config.toml +++ b/data/release/config.toml @@ -0,0 +1,19 @@ +[output] +# otherwise recording via script session will be enforced +enforce_script = false +# file with output(s) of regular commands (e.g. ls, echo, etc.) +file = "/tmp/command-line-assistant/output.txt" +# Keep non-empty if your file contains only output of commands (not prompt itself) +prompt_separator = "$" + +[history] +enabled = true +file = "/tmp/command-line-assistant/history.json" +# max number of queries in history (including responses) +max_size = 100 + +[backend] +endpoint = "http://localhost:8080" + +[logging] +level = "DEBUG" diff --git a/packaging/command-line-assistant.spec b/packaging/command-line-assistant.spec index b6bdab1..f6046c8 100644 --- a/packaging/command-line-assistant.spec +++ b/packaging/command-line-assistant.spec @@ -44,6 +44,7 @@ A simple wrapper to interact with RAG # Create sbin directory in buildroot %{__install} -d %{buildroot}/%{_sbindir} +%{__install} -d %{buildroot}/%{_sysconfdir}/xdg/%{python_package_src} # Move the daemon to /usr/sbin instead of /usr/bin %{__install} -m 0755 %{buildroot}/%{_bindir}/%{daemon_binary_name} %{buildroot}/%{_sbindir}/%{daemon_binary_name} @@ -52,6 +53,9 @@ A simple wrapper to interact with RAG # System units %{__install} -D -m 0644 data/release/%{daemon_binary_name}.service %{buildroot}/%{_unitdir}/%{daemon_binary_name}.service +# Config file +%{__install} -D -m 0644 data/release/config.toml %{buildroot}/%{_sysconfdir}/xdg/%{python_package_src}/config.toml + %files %doc README.md %license LICENSE @@ -61,8 +65,13 @@ A simple wrapper to interact with RAG # Binaries %{_bindir}/%{binary_name} %{_sbindir}/%{daemon_binary_name} + +# System units %{_unitdir}/%{daemon_binary_name}.service +# Config file +%config %{_sysconfdir}/xdg/%{python_package_src}/config.toml + %preun if [ "$1" -eq 0 ]; then systemctl stop %{daemon_binary_name}.service || : From d42e8293eae7aa0db9048bdcec2f0aef198ba47b Mon Sep 17 00:00:00 2001 From: Rodolfo Olivieri Date: Mon, 16 Dec 2024 13:56:02 -0300 Subject: [PATCH 2/2] Use a SystemMessageBus and a config for dbus --- command_line_assistant/dbus/constants.py | 4 ++-- data/release/clad.service | 5 ++--- data/release/com.redhat.lightspeed.conf | 15 +++++++++++++++ packaging/command-line-assistant.spec | 2 ++ 4 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 data/release/com.redhat.lightspeed.conf diff --git a/command_line_assistant/dbus/constants.py b/command_line_assistant/dbus/constants.py index 62b2bf0..3aa146f 100644 --- a/command_line_assistant/dbus/constants.py +++ b/command_line_assistant/dbus/constants.py @@ -1,10 +1,10 @@ -from dasbus.connection import SessionMessageBus +from dasbus.connection import SystemMessageBus from dasbus.error import ErrorMapper from dasbus.identifier import DBusServiceIdentifier ERROR_MAPPER = ErrorMapper() -SESSION_BUS = SessionMessageBus(error_mapper=ERROR_MAPPER) +SESSION_BUS = SystemMessageBus(error_mapper=ERROR_MAPPER) SERVICE_NAMESPACE = ("com", "redhat", "lightspeed") diff --git a/data/release/clad.service b/data/release/clad.service index 3fc1c8e..2ddce8c 100644 --- a/data/release/clad.service +++ b/data/release/clad.service @@ -4,11 +4,10 @@ Documentation=https://github.com/rhel-lightspeed/command-line-assistant After=network.service [Service] -BusName=com.rhel.lightspeed PrivateTmp=yes RemainAfterExit=no -ExecStart=$(exec_prefix}/sbin/clad +ExecStart=/usr/sbin/clad [Install] -WantedBy=multi-user.target +WantedBy=default.target Alias=clad.service diff --git a/data/release/com.redhat.lightspeed.conf b/data/release/com.redhat.lightspeed.conf new file mode 100644 index 0000000..9de351f --- /dev/null +++ b/data/release/com.redhat.lightspeed.conf @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + diff --git a/packaging/command-line-assistant.spec b/packaging/command-line-assistant.spec index f6046c8..9b722ad 100644 --- a/packaging/command-line-assistant.spec +++ b/packaging/command-line-assistant.spec @@ -52,6 +52,7 @@ A simple wrapper to interact with RAG # System units %{__install} -D -m 0644 data/release/%{daemon_binary_name}.service %{buildroot}/%{_unitdir}/%{daemon_binary_name}.service +%{__install} -D -m 0644 data/release/com.redhat.lightspeed.conf %{buildroot}/%{_sysconfdir}/dbus-1/system.d/com.redhat.lightspeed.conf # Config file %{__install} -D -m 0644 data/release/config.toml %{buildroot}/%{_sysconfdir}/xdg/%{python_package_src}/config.toml @@ -71,6 +72,7 @@ A simple wrapper to interact with RAG # Config file %config %{_sysconfdir}/xdg/%{python_package_src}/config.toml +%config %{_sysconfdir}/dbus-1/system.d/com.redhat.lightspeed.conf %preun if [ "$1" -eq 0 ]; then