[pve-devel] [PATCH proxmox-apt 2/3] release: add 'architecture' helper

Fabian Grünbichler f.gruenbichler at proxmox.com
Thu Sep 15 15:09:15 CEST 2022


which returns if a file reference is architecture specific, and for
which architecture it is relevant.

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
 src/deb822/release_file.rs | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/deb822/release_file.rs b/src/deb822/release_file.rs
index 2b7245b..5888728 100644
--- a/src/deb822/release_file.rs
+++ b/src/deb822/release_file.rs
@@ -228,6 +228,22 @@ impl FileReferenceType {
         }
     }
 
+    pub fn architecture(&self) -> Option<&Architecture> {
+        match self {
+            FileReferenceType::Commands(arch, _)
+            | FileReferenceType::Contents(arch, _)
+            | FileReferenceType::ContentsUdeb(arch, _)
+            | FileReferenceType::Packages(arch, _) => Some(arch),
+            FileReferenceType::PseudoRelease(arch) => arch.as_ref(),
+            FileReferenceType::Unknown
+            | FileReferenceType::PDiff
+            | FileReferenceType::Sources(_)
+            | FileReferenceType::Dep11(_)
+            | FileReferenceType::Translation(_)
+            | FileReferenceType::Ignored => None,
+        }
+    }
+
     pub fn is_package_index(&self) -> bool {
         matches!(self, FileReferenceType::Packages(_, _))
     }
-- 
2.30.2






More information about the pve-devel mailing list