diff --git a/packaging/suse/portusctl/lib/cli.rb b/packaging/suse/portusctl/lib/cli.rb index c53c346d9..6fe3005a4 100644 --- a/packaging/suse/portusctl/lib/cli.rb +++ b/packaging/suse/portusctl/lib/cli.rb @@ -136,6 +136,7 @@ def logs(*args) ensure_root Runner.produce_versions_file! + Runner.produce_crono_log_file! Runner.tar_files("log/production.log", "log/crono.log", "log/versions.log") end diff --git a/packaging/suse/portusctl/lib/runner.rb b/packaging/suse/portusctl/lib/runner.rb index e8365e93d..4973555a7 100644 --- a/packaging/suse/portusctl/lib/runner.rb +++ b/packaging/suse/portusctl/lib/runner.rb @@ -2,12 +2,17 @@ class Runner # Run a simple external command def self.exec(cmd, args = []) - final_cmd = cmd + " " + args.map { |a| Shellwords.escape(a) }.join(" ") + final_cmd = Runner.escape_command(cmd, args) unless system(final_cmd) raise "Something went wrong while invoking: #{final_cmd}" end end + # Returns a string containing the command with its arguments all escaped. + def self.escape_command(cmd, args = []) + cmd + " " + args.map { |a| Shellwords.escape(a) }.join(" ") + end + # Run an external command using the bundler binary shipped with Portus' RPM def self.bundler_exec(cmd, args, extra_env_variables) Dir.chdir(PORTUS_ROOT) do @@ -42,6 +47,15 @@ def self.produce_versions_file! end end + # Creates a new file called "crono.log" with the logs stored by systemd about + # crono. + def self.produce_crono_log_file! + File.open(File.join(PORTUS_ROOT, "log/crono.log"), "w+") do |file| + cmd = Runner.escape_command("journalctl", ["--no-pager", "-u", "portus_crono"]) + file.puts(`#{cmd}`) + end + end + # Tar and compress the given files into the /tmp directory. It's assumed that # these files are located inside of PORTUS_ROOT. def self.tar_files(*files)