cargo-debstatus icon indicating copy to clipboard operation
cargo-debstatus copied to clipboard

[FR] Add experimental support

Open werdahias opened this issue 2 years ago • 5 comments

Currently cargo-debstatus checks only packages in sid. While there aren't a lot of rust packages in experimental it'd be nice to check experimental too in case they are. Maybe the color could be a slightly greener shade than the one used for unstable ?

werdahias avatar Jun 05 '23 14:06 werdahias

commit 2b14c6dc1a00e734d37bbb91bebe5607884f2bc9
Author: Matthias Geiger <[email protected]>
Date:   Mon Jun 5 17:35:03 2023 +0200

    Added exp support

diff --git a/src/db.rs b/src/db.rs
index c3cba82..878f75a 100644
--- a/src/db.rs
+++ b/src/db.rs
@@ -115,6 +115,23 @@ impl Connection {
         self.write_cache("sid", package, version, found)?;
         Ok(found)
     }
+    
+    pub fn search_exp(&mut self, package: &str, version: &str) -> Result<bool, Error> {
+        if let Some(found) = self.check_cache("exp", package, version)? {
+            return Ok(found);
+        }
+
+        // config.shell().status("Querying", format!("sid: {}", package))?;
+        info!("Querying -> exp: {}", package);
+        let found = self.search_generic(
+            "SELECT version::text FROM sources WHERE source=$1 AND release='rc-buggy';",
+            package,
+            version,
+        )?;
+
+        self.write_cache("exp", package, version, found)?;
+        Ok(found)
+    }    
 
     pub fn search_new(&mut self, package: &str, version: &str) -> Result<bool, Error> {
         if let Some(found) = self.check_cache("new", package, version)? {
diff --git a/src/debian.rs b/src/debian.rs
index 1f0959f..3f82dab 100644
--- a/src/debian.rs
+++ b/src/debian.rs
@@ -40,7 +40,7 @@ impl Pkg {
 
     pub fn in_debian(&self) -> bool {
         if let Some(deb) = &self.debinfo {
-            deb.in_unstable || deb.in_new
+            deb.in_unstable || deb.in_new || deb.in_experimental
         } else {
             false
         }
@@ -52,12 +52,14 @@ pub struct DebianInfo {
     pub in_unstable: bool,
     pub in_new: bool,
     pub outdated: bool,
+    pub in_experimental: bool,
 }
 
 fn run_task(db: &mut Connection, pkg: Pkg) -> Result<DebianInfo> {
     let mut deb = DebianInfo {
         in_unstable: false,
         in_new: false,
+	in_experimental: false,
         outdated: false,
     };
 
@@ -65,8 +67,9 @@ fn run_task(db: &mut Connection, pkg: Pkg) -> Result<DebianInfo> {
         deb.in_unstable = true;
     } else if db.search_new(&pkg.name, &pkg.version.to_string()).unwrap() {
         deb.in_new = true;
+    } else if db.search_exp(&pkg.name, &pkg.version.to_string()).unwrap() {
+	deb.in_experimental = true;
     }
-
     Ok(deb)
 }
 
diff --git a/src/format/mod.rs b/src/format/mod.rs
index b4d212a..2ec493b 100644
--- a/src/format/mod.rs
+++ b/src/format/mod.rs
@@ -59,7 +59,9 @@ impl<'a> fmt::Display for Display<'a> {
                     if let Some(deb) = &self.package.debinfo {
                         if deb.in_unstable {
                             write!(fmt, "{} (in debian)", pkg.green())?;
-                        } else if deb.in_new {
+                        } else if deb.in_experimental {
+			    write!(fmt, "{} (in debian)", pkg.green())?; //another color for exp? is there a light green?
+			} else if deb.in_new {
                             write!(fmt, "{} (in debian NEW queue)", pkg.blue())?;
                         } else if deb.outdated {
                             write!(fmt, "{} (outdated)", pkg.yellow())?;

werdahias avatar Jun 05 '23 15:06 werdahias

I had been thinking of this, too. Maybe rather than using a different color, change the output from (in debian) to (in debian experimental)?

jamessan avatar Aug 19 '23 13:08 jamessan

Yeah, that's definitely a good idea. I'd appreciate it someone more skilled in rust could take a look at this (the patch does not work for some reason).

werdahias avatar Aug 19 '23 13:08 werdahias

updated diff:

diff --git a/src/db.rs b/src/db.rs
index 8842317..50d2fd8 100644
--- a/src/db.rs
+++ b/src/db.rs
@@ -105,6 +105,24 @@ impl Connection {
         self.write_cache("sid", package, version, found)?;
         Ok(found)
     }
+    
+    pub fn search_exp(&mut self, package: &str, version: &Version) -> Result<bool, Error> {
+         if let Some(found) = self.check_cache("exp", package, version)? {
+             return Ok(found);
+         }
+ 
+         // config.shell().status("Querying", format!("sid: {}", package))?;
+         info!("Querying -> exp: {}", package);
+         let found = self.search_generic(
+             "SELECT version::text FROM sources WHERE source in ($1, $2) AND release='rc-buggy';",
+             package,
+             version,
+         )?;
+ 
+         self.write_cache("exp", package, version, found)?;
+         Ok(found)
+     }
+
 
     pub fn search_new(&mut self, package: &str, version: &Version) -> Result<bool, Error> {
         if let Some(found) = self.check_cache("new", package, version)? {
diff --git a/src/debian.rs b/src/debian.rs
index 53f4805..6e3c5d1 100644
--- a/src/debian.rs
+++ b/src/debian.rs
@@ -40,7 +40,7 @@ impl Pkg {
 
     pub fn in_debian(&self) -> bool {
         if let Some(deb) = &self.debinfo {
-            deb.in_unstable || deb.in_new
+            deb.in_unstable || deb.in_new || deb.in_exp
         } else {
             false
         }
@@ -52,12 +52,14 @@ pub struct DebianInfo {
     pub in_unstable: bool,
     pub in_new: bool,
     pub outdated: bool,
+    pub in_exp: bool,
 }
 
 fn run_task(db: &mut Connection, pkg: Pkg) -> Result<DebianInfo> {
     let mut deb = DebianInfo {
         in_unstable: false,
         in_new: false,
+        in_exp: false,
         outdated: false,
     };
 
@@ -65,6 +67,8 @@ fn run_task(db: &mut Connection, pkg: Pkg) -> Result<DebianInfo> {
         deb.in_unstable = true;
     } else if db.search_new(&pkg.name, &pkg.version).unwrap() {
         deb.in_new = true;
+    } else if db.search_exp(&pkg.name, &pkg.version).unwrap() {
+	deb.in_exp = true;
     }
 
     Ok(deb)
diff --git a/src/format/mod.rs b/src/format/mod.rs
index b4d212a..50b83f9 100644
--- a/src/format/mod.rs
+++ b/src/format/mod.rs
@@ -59,6 +59,8 @@ impl<'a> fmt::Display for Display<'a> {
                     if let Some(deb) = &self.package.debinfo {
                         if deb.in_unstable {
                             write!(fmt, "{} (in debian)", pkg.green())?;
+                        } else if deb.in_exp {
+                            write!(fmt, "{} (in debian experimental)", pkg.bright_green())?;
                         } else if deb.in_new {
                             write!(fmt, "{} (in debian NEW queue)", pkg.blue())?;
                         } else if deb.outdated {

It still show lcms2-sys in new rather then unstable so I can't test it yet. Feel free to improve upon my code.

werdahias avatar Aug 22 '23 07:08 werdahias

@alexanderkjall can you maybe take a look ?

werdahias avatar Sep 12 '24 09:09 werdahias