diff --git a/rust/agama-cli/src/logs.rs b/rust/agama-cli/src/logs.rs index 027da2c9a2..f6b6fcf404 100644 --- a/rust/agama-cli/src/logs.rs +++ b/rust/agama-cli/src/logs.rs @@ -112,7 +112,7 @@ const DEFAULT_PATHS: [&str; 14] = [ "/linuxrc.config", ]; -const DEFAULT_RESULT: &str = "/tmp/agama_logs"; +const DEFAULT_RESULT: &str = "/tmp/agama-logs"; // what compression is used by default: // (, ) const DEFAULT_COMPRESSION: (&str, &str) = ("bzip2", "tar.bz2"); @@ -398,7 +398,11 @@ fn store(options: LogOptions) -> Result<(), io::Error> { showln(verbose, "\t- proceeding output of commands"); // store it - showln(true, format!("Storing result in: \"{}\"", result).as_str()); + if verbose { + showln(true, format!("Storing result in: \"{}\"", result).as_str()); + } else { + showln(true, result.as_str()); + } for log in log_sources.iter() { show( diff --git a/service/Gemfile.lock b/service/Gemfile.lock old mode 100644 new mode 100755 index 10affd1b06..9f6cb9c0d0 --- a/service/Gemfile.lock +++ b/service/Gemfile.lock @@ -73,4 +73,4 @@ DEPENDENCIES yard (~> 0.9.0) BUNDLED WITH - 2.3.26 + 2.4.22 diff --git a/service/lib/agama/dbus/manager.rb b/service/lib/agama/dbus/manager.rb index 1a759ce672..d1f129d18e 100644 --- a/service/lib/agama/dbus/manager.rb +++ b/service/lib/agama/dbus/manager.rb @@ -60,7 +60,7 @@ def initialize(backend, logger) dbus_method(:Probe, "") { config_phase } dbus_method(:Commit, "") { install_phase } dbus_method(:CanInstall, "out result:b") { can_install? } - dbus_method(:CollectLogs, "out tarball_filesystem_path:s, in user:s") { |u| collect_logs(u) } + dbus_method(:CollectLogs, "out tarball_filesystem_path:s") { collect_logs } dbus_method(:Finish, "") { finish_phase } dbus_reader :installation_phases, "aa{sv}" dbus_reader :current_installation_phase, "u" @@ -92,8 +92,8 @@ def can_install? end # Collects the YaST logs - def collect_logs(user) - backend.collect_logs(user) + def collect_logs + backend.collect_logs end # Last action for the installer diff --git a/service/lib/agama/manager.rb b/service/lib/agama/manager.rb index ae9f0d4401..48579520c6 100644 --- a/service/lib/agama/manager.rb +++ b/service/lib/agama/manager.rb @@ -205,18 +205,21 @@ def valid? # Collects the logs and stores them into an archive # - # @param user [String] local username who will own archive + # @param path [String] directory where to store logs + # # @return [String] path to created archive - def collect_logs(user) - output = Yast::Execute.locally!("save_y2logs", stderr: :capture) - path = output[/^.* (\/tmp\/y2log-\S*)/, 1] - Yast::Execute.locally!("chown", "#{user}:", path) + def collect_logs(path: nil) + opt = "-d #{path}" unless path.nil? || path.empty? - path + `agama logs store #{opt}`.strip end # Whatever has to be done at the end of installation def finish_installation + logs = collect_logs(path: "/tmp/var/logs/") + + logger.info("Installation logs stored in #{logs}") + cmd = if iguana? "/usr/bin/agamactl -k" else diff --git a/service/test/agama/manager_test.rb b/service/test/agama/manager_test.rb index 38a41d2ed3..b9e70a30fd 100644 --- a/service/test/agama/manager_test.rb +++ b/service/test/agama/manager_test.rb @@ -214,13 +214,12 @@ describe "#collect_logs" do it "collects the logs and returns the path to the archive" do - expect(Yast::Execute).to receive(:locally!) - .with("save_y2logs", stderr: :capture) - .and_return("Saving YaST logs to /tmp/y2log-hWBn95.tar.xz") - expect(Yast::Execute).to receive(:locally!) - .with("chown", "ytm:", /y2log-hWBn95/) + # %x returns the command output including trailing \n + expect(subject).to receive(:`) + .with("agama logs store ") + .and_return("/tmp/y2log-hWBn95.tar.xz\n") - path = subject.collect_logs("ytm") + path = subject.collect_logs expect(path).to eq("/tmp/y2log-hWBn95.tar.xz") end end diff --git a/setup-service.sh b/setup-service.sh index 97c3dcd8af..ae2d853903 100755 --- a/setup-service.sh +++ b/setup-service.sh @@ -44,6 +44,9 @@ $SUDO zypper --non-interactive --gpg-auto-import-keys install gcc gcc-c++ make o # only install cargo if it is not available (avoid conflicts with rustup) which cargo || $SUDO zypper --non-interactive install cargo +# if agama is already running -> stop it +$SUDO systemctl stop agama.service + # - Install service rubygem dependencies ( cd $MYDIR/service @@ -70,7 +73,7 @@ $SUDO cp -v $MYDIR/service/share/dbus.conf /usr/share/dbus-1/agama.conf # cleanup previous installation [[ -d $DBUSDIR ]] && $SUDO rm -r $DBUSDIR - # create services + # create services $SUDO mkdir -p $DBUSDIR for SVC in org.opensuse.Agama*.service; do sudosed "s@\(Exec\)=/usr/bin/@\1=$MYDIR/service/bin/@" $SVC $DBUSDIR/$SVC diff --git a/setup.sh b/setup.sh index 2f4bcaeb24..c7c7c77e4b 100755 --- a/setup.sh +++ b/setup.sh @@ -23,7 +23,12 @@ fi # Backend setup -$MYDIR/setup-service.sh +if ! $MYDIR/setup-service.sh; then + echo "Backend setup failed." + echo "Agama service is NOT running." + + exit 2 +fi; # Install Frontend dependencies diff --git a/web/src/client/manager.js b/web/src/client/manager.js index ee847521fc..fcd223c505 100644 --- a/web/src/client/manager.js +++ b/web/src/client/manager.js @@ -86,7 +86,7 @@ class ManagerBaseClient { */ async fetchLogs() { const proxy = await this.client.proxy(MANAGER_IFACE); - const path = await proxy.CollectLogs("root"); + const path = await proxy.CollectLogs(); const file = cockpit.file(path, { binary: true }); return file.read(); } diff --git a/web/src/components/core/LogsButton.jsx b/web/src/components/core/LogsButton.jsx index 1c7987ce13..a4140931fb 100644 --- a/web/src/components/core/LogsButton.jsx +++ b/web/src/components/core/LogsButton.jsx @@ -27,7 +27,7 @@ import { Alert, Button } from "@patternfly/react-core"; import { Icon } from "~/components/layout"; import { _ } from "~/i18n"; -const FILENAME = "y2logs.tar.xz"; +const FILENAME = "agama-installation-logs.tar.bzip2"; const FILETYPE = "application/x-xz"; /** diff --git a/web/src/components/core/LogsButton.test.jsx b/web/src/components/core/LogsButton.test.jsx index 0b643d3be0..cfb9c3ccb3 100644 --- a/web/src/components/core/LogsButton.test.jsx +++ b/web/src/components/core/LogsButton.test.jsx @@ -119,7 +119,7 @@ describe("LogsButton", () => { // And test what we're looking for expect(document.createElement).toHaveBeenCalledWith('a'); expect(anchorMock).toHaveAttribute("href", "fake-blob-url"); - expect(anchorMock).toHaveAttribute("download", expect.stringMatching(/y2logs/)); + expect(anchorMock).toHaveAttribute("download", expect.stringMatching(/agama-installation-logs/)); expect(anchorMock.click).toHaveBeenCalled(); // Be polite and restore document.createElement function,