Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package agama-cli for openSUSE:Factory 
checked in at 2023-10-23 23:41:31
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/agama-cli (Old)
 and      /work/SRC/openSUSE:Factory/.agama-cli.new.1945 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "agama-cli"

Mon Oct 23 23:41:31 2023 rev:3 rq:1119699 version:0

Changes:
--------
--- /work/SRC/openSUSE:Factory/agama-cli/agama-cli.changes      2023-09-29 
21:14:18.831350603 +0200
+++ /work/SRC/openSUSE:Factory/.agama-cli.new.1945/agama-cli.changes    
2023-10-23 23:41:34.872871393 +0200
@@ -1,0 +2,11 @@
+Mon Oct 23 11:33:40 UTC 2023 - Imobach Gonzalez Sosa <igonzalezs...@suse.com>
+
+- Version 5
+
+-------------------------------------------------------------------
+Mon Oct 10 07:37:00 UTC 2023 - Michal Filka <mfi...@suse.com>
+
+- Improve file and directory names in "agama logs store".
+- Add an "agama logs list" subcommand.
+
+-------------------------------------------------------------------

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ _service ++++++
--- /var/tmp/diff_new_pack.sx1QeL/_old  2023-10-23 23:41:36.296923087 +0200
+++ /var/tmp/diff_new_pack.sx1QeL/_new  2023-10-23 23:41:36.300923232 +0200
@@ -4,7 +4,7 @@
     <param name="versionformat">@PARENT_TAG@</param>
     <param name="versionrewrite-pattern">v(.*)</param>
     <param name="scm">git</param>
-    <param name="revision">v4</param>
+    <param name="revision">v5</param>
     <param name="subdir">rust</param>
     <param name="without-version">enable</param>
     <param name="extract">package/agama-cli.changes</param>

++++++ agama.obscpio ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/agama/agama-cli/src/logs.rs 
new/agama/agama-cli/src/logs.rs
--- old/agama/agama-cli/src/logs.rs     2023-09-26 23:17:00.000000000 +0200
+++ new/agama/agama-cli/src/logs.rs     2023-10-23 14:02:31.000000000 +0200
@@ -10,6 +10,7 @@
 use std::process::Command;
 use tempdir::TempDir;
 
+// definition of "agama logs" subcommands, see clap crate for details
 #[derive(Subcommand, Debug)]
 pub enum LogsCommands {
     /// Collects and stores logs in a tar archive
@@ -22,17 +23,32 @@
     List,
 }
 
+// main entry point called from agama CLI main loop
 pub async fn run(subcommand: LogsCommands) -> anyhow::Result<()> {
     match subcommand {
-        LogsCommands::Store { verbose } => Ok(store(verbose)?),
-        LogsCommands::List => Err(anyhow::anyhow!("Not implemented")),
+        LogsCommands::Store { verbose } => {
+            // feed internal options structure by what was received from user
+            // for now we always use / add defaults if any
+            let options = LogOptions {
+                verbose,
+                ..Default::default()
+            };
+
+            Ok(store(options)?)
+        }
+        LogsCommands::List => {
+            list(LogOptions::default());
+
+            Ok(())
+        }
     }
 }
 
-const DEFAULT_COMMANDS: [&str; 3] = [
-    "journalctl -u agama",
-    "journalctl -u agama-auto",
-    "journalctl --dmesg",
+const DEFAULT_COMMANDS: [(&str, &str); 3] = [
+    // (<command to be executed>, <file name used for storing result of the 
command>)
+    ("journalctl -u agama", "agama"),
+    ("journalctl -u agama-auto", "agama-auto"),
+    ("journalctl --dmesg", "dmesg"),
 ];
 
 const DEFAULT_PATHS: [&str; 14] = [
@@ -55,6 +71,8 @@
 ];
 
 const DEFAULT_RESULT: &str = "/tmp/agama_logs";
+// what compression is used by default:
+// (<compression as distinguished by tar>, <an extension for resulting 
archive>)
 const DEFAULT_COMPRESSION: (&str, &str) = ("bzip2", "tar.bz2");
 const DEFAULT_TMP_DIR: &str = "agama-logs";
 
@@ -76,6 +94,27 @@
     print!("{}", text);
 }
 
+// Configurable parameters of the "agama logs" which can be
+// set by user when calling a (sub)command
+struct LogOptions {
+    paths: Vec<String>,
+    commands: Vec<(String, String)>,
+    verbose: bool,
+}
+
+impl Default for LogOptions {
+    fn default() -> Self {
+        Self {
+            paths: DEFAULT_PATHS.iter().map(|p| p.to_string()).collect(),
+            commands: DEFAULT_COMMANDS
+                .iter()
+                .map(|(cmd, name)| (cmd.to_string(), name.to_string()))
+                .collect(),
+            verbose: false,
+        }
+    }
+}
+
 // Struct for log represented by a file
 struct LogPath {
     // log source
@@ -99,14 +138,18 @@
     // command which stdout / stderr is logged
     cmd: String,
 
+    // user defined log file name (if any)
+    file_name: String,
+
     // place where to collect logs
     dst_path: PathBuf,
 }
 
 impl LogCmd {
-    fn new(cmd: &str, dst: &Path) -> Self {
+    fn new(cmd: &str, file_name: &str, dst: &Path) -> Self {
         Self {
             cmd: cmd.to_string(),
+            file_name: file_name.to_string(),
             dst_path: dst.to_owned(),
         }
     }
@@ -162,7 +205,16 @@
     }
 
     fn to(&self) -> PathBuf {
-        self.dst_path.as_path().join(format!("{}", self.cmd))
+        let mut file_name;
+
+        if self.file_name.is_empty() {
+            file_name = self.cmd.clone();
+        } else {
+            file_name = self.file_name.clone();
+        };
+
+        file_name.retain(|c| c != ' ');
+        self.dst_path.as_path().join(format!("{}", file_name))
     }
 
     fn store(&self) -> Result<(), io::Error> {
@@ -181,64 +233,87 @@
     }
 }
 
-// collect existing / requested paths which should already exist turns them 
into list of log
-// sources
-fn paths_to_log_sources(paths: &[&str], tmp_dir: &TempDir) -> Vec<Box<dyn 
LogItem>> {
+// Collect existing / requested paths which should already exist in the system.
+// Turns them into list of log sources
+fn paths_to_log_sources(paths: &Vec<String>, tmp_dir: &TempDir) -> Vec<Box<dyn 
LogItem>> {
     let mut log_sources: Vec<Box<dyn LogItem>> = Vec::new();
 
-    for path in paths {
+    for path in paths.iter() {
         // assumption: path is full path
         if Path::new(path).try_exists().is_ok() {
-            log_sources.push(Box::new(LogPath::new(path, tmp_dir.path())));
+            log_sources.push(Box::new(LogPath::new(path.as_str(), 
tmp_dir.path())));
         }
     }
 
     log_sources
 }
 
-// some info can be collected via particular commands only, turn it into log 
sources
-fn cmds_to_log_sources(commands: &[&str], tmp_dir: &TempDir) -> Vec<Box<dyn 
LogItem>> {
+// Some info can be collected via particular commands only, turn it into log 
sources
+fn cmds_to_log_sources(
+    commands: &Vec<(String, String)>,
+    tmp_dir: &TempDir,
+) -> Vec<Box<dyn LogItem>> {
     let mut log_sources: Vec<Box<dyn LogItem>> = Vec::new();
 
-    for cmd in commands {
-        log_sources.push(Box::new(LogCmd::new(cmd, tmp_dir.path())));
+    for cmd in commands.iter() {
+        log_sources.push(Box::new(LogCmd::new(
+            cmd.0.as_str(),
+            cmd.1.as_str(),
+            tmp_dir.path(),
+        )));
     }
 
     log_sources
 }
 
-// compress given directory into a tar archive
+// Compress given directory into a tar archive
 fn compress_logs(tmp_dir: &TempDir, result: &String) -> io::Result<()> {
     let compression = DEFAULT_COMPRESSION.0;
+    let tmp_path = tmp_dir
+        .path()
+        .parent()
+        .and_then(|p| p.as_os_str().to_str())
+        .ok_or(io::Error::new(
+            io::ErrorKind::InvalidInput,
+            "Malformed path to temporary directory",
+        ))?;
+    let dir = tmp_dir
+        .path()
+        .file_name()
+        .and_then(|f| f.to_str())
+        .ok_or(io::Error::new(
+            io::ErrorKind::InvalidInput,
+            "Malformed path to temporary director",
+        ))?;
     let compress_cmd = format!(
-        "tar -c -f {} --warning=no-file-changed --{} --dereference -C {} .",
-        result,
-        compression,
-        tmp_dir.path().display()
+        "tar -c -f {} --warning=no-file-changed --{} --dereference -C {} {}",
+        result, compression, tmp_path, dir,
     );
     let cmd_parts = compress_cmd.split_whitespace().collect::<Vec<&str>>();
-
-    match Command::new(cmd_parts[0])
+    let res = Command::new(cmd_parts[0])
         .args(cmd_parts[1..].iter())
-        .status()
-    {
-        Ok(_o) => Ok(()),
-        Err(_e) => Err(io::Error::new(
+        .status()?;
+
+    if res.success() {
+        Ok(())
+    } else {
+        Err(io::Error::new(
             io::ErrorKind::Other,
             "Cannot create tar archive",
-        )),
+        ))
     }
 }
 
-// handler for the "agama logs store" subcommand
-fn store(verbose: bool) -> Result<(), io::Error> {
+// Handler for the "agama logs store" subcommand
+fn store(options: LogOptions) -> Result<(), io::Error> {
     if !Uid::effective().is_root() {
         panic!("No Root, no logs. Sorry.");
     }
 
     // preparation, e.g. in later features some log commands can be added / 
excluded per users request or
-    let commands = DEFAULT_COMMANDS;
-    let paths = DEFAULT_PATHS;
+    let commands = options.commands;
+    let paths = options.paths;
+    let verbose = options.verbose;
     let result = format!("{}.{}", DEFAULT_RESULT, DEFAULT_COMPRESSION.1);
 
     showln(verbose, "Collecting Agama logs:");
@@ -278,3 +353,22 @@
 
     compress_logs(&tmp_dir, &result)
 }
+
+// Handler for the "agama logs list" subcommand
+fn list(options: LogOptions) {
+    for list in [
+        ("Log paths: ", options.paths),
+        (
+            "Log commands: ",
+            options.commands.iter().map(|c| c.0.clone()).collect(),
+        ),
+    ] {
+        println!("{}", list.0);
+
+        for item in list.1.iter() {
+            println!("\t{}", item);
+        }
+
+        println!();
+    }
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/agama/agama-dbus-server/src/network/dbus/interfaces.rs 
new/agama/agama-dbus-server/src/network/dbus/interfaces.rs
--- old/agama/agama-dbus-server/src/network/dbus/interfaces.rs  2023-09-26 
23:17:00.000000000 +0200
+++ new/agama/agama-dbus-server/src/network/dbus/interfaces.rs  2023-10-23 
14:02:31.000000000 +0200
@@ -164,11 +164,12 @@
         Ok(())
     }
 
+    /// Notifies than a new interface has been added.
     #[dbus_interface(signal)]
     pub async fn connection_added(
         ctxt: &SignalContext<'_>,
         id: &str,
-        path: &str,
+        path: &ObjectPath<'_>,
     ) -> zbus::Result<()>;
 }
 
@@ -279,7 +280,7 @@
 
 #[dbus_interface(name = "org.opensuse.Agama1.Network.Connection.Match")]
 impl Match {
-    /// List of driver
+    /// List of driver names to match.
     #[dbus_interface(property)]
     pub async fn driver(&self) -> Vec<String> {
         let connection = self.get_connection().await;
@@ -294,7 +295,7 @@
         self.update_connection(connection).await
     }
 
-    /// List of paths
+    /// List of paths to match agains the ID_PATH udev property of devices.
     #[dbus_interface(property)]
     pub async fn path(&self) -> Vec<String> {
         let connection = self.get_connection().await;
@@ -308,7 +309,7 @@
         config.path = path;
         self.update_connection(connection).await
     }
-    /// List of driver
+    /// List of interface names to match.
     #[dbus_interface(property)]
     pub async fn interface(&self) -> Vec<String> {
         let connection = self.get_connection().await;
@@ -323,7 +324,7 @@
         self.update_connection(connection).await
     }
 
-    /// List of kernel options
+    /// List of kernel options to match.
     #[dbus_interface(property)]
     pub async fn kernel(&self) -> Vec<String> {
         let connection = self.get_connection().await;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/agama/agama-dbus-server/src/network/dbus/tree.rs 
new/agama/agama-dbus-server/src/network/dbus/tree.rs
--- old/agama/agama-dbus-server/src/network/dbus/tree.rs        2023-09-26 
23:17:00.000000000 +0200
+++ new/agama/agama-dbus-server/src/network/dbus/tree.rs        2023-10-23 
14:02:31.000000000 +0200
@@ -202,7 +202,11 @@
     }
 
     /// Notify that a new connection has been added
-    async fn notify_connection_added(&self, id: &str, path: &str) -> 
Result<(), ServiceError> {
+    async fn notify_connection_added(
+        &self,
+        id: &str,
+        path: &ObjectPath<'_>,
+    ) -> Result<(), ServiceError> {
         let object_server = self.connection.object_server();
         let iface_ref = object_server
             .interface::<_, interfaces::Connections>(CONNECTIONS_PATH)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/agama/agama-lib/src/network/client.rs 
new/agama/agama-lib/src/network/client.rs
--- old/agama/agama-lib/src/network/client.rs   2023-09-26 23:17:00.000000000 
+0200
+++ new/agama/agama-lib/src/network/client.rs   2023-10-23 14:02:31.000000000 
+0200
@@ -163,7 +163,7 @@
 
         loop {
             let signal = stream.next().await.unwrap();
-            let (id, _path): (String, String) = signal.body().unwrap();
+            let (id, _path): (String, OwnedObjectPath) = 
signal.body().unwrap();
             if id == conn.id {
                 break;
             };
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/agama/package/agama-cli.changes 
new/agama/package/agama-cli.changes
--- old/agama/package/agama-cli.changes 2023-09-26 23:17:00.000000000 +0200
+++ new/agama/package/agama-cli.changes 2023-10-23 14:02:31.000000000 +0200
@@ -1,4 +1,15 @@
 -------------------------------------------------------------------
+Mon Oct 23 11:33:40 UTC 2023 - Imobach Gonzalez Sosa <igonzalezs...@suse.com>
+
+- Version 5
+
+-------------------------------------------------------------------
+Mon Oct 10 07:37:00 UTC 2023 - Michal Filka <mfi...@suse.com>
+
+- Improve file and directory names in "agama logs store".
+- Add an "agama logs list" subcommand.
+
+-------------------------------------------------------------------
 Tue Sep 26 15:57:14 UTC 2023 - Imobach Gonzalez Sosa <igonzalezs...@suse.com>
 
 - Version 4

++++++ agama.obsinfo ++++++
--- /var/tmp/diff_new_pack.sx1QeL/_old  2023-10-23 23:41:36.420927588 +0200
+++ /var/tmp/diff_new_pack.sx1QeL/_new  2023-10-23 23:41:36.424927734 +0200
@@ -1,5 +1,5 @@
 name: agama
-version: 4
-mtime: 1695763020
-commit: 1bbd9c27435cc595d8eff9842a1f829675617a5e
+version: 5
+mtime: 1698062551
+commit: 0b494c95fa1fa38d3d358131e2e2bb2e1c659714
 

++++++ vendor.tar.zst ++++++
Binary files /var/tmp/diff_new_pack.sx1QeL/_old and 
/var/tmp/diff_new_pack.sx1QeL/_new differ

Reply via email to