public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH proxmox-apt 1/3] release: add Commands file reference type
Date: Thu, 15 Sep 2022 15:09:13 +0200	[thread overview]
Message-ID: <20220915130918.727902-3-f.gruenbichler@proxmox.com> (raw)
In-Reply-To: <20220915130918.727902-1-f.gruenbichler@proxmox.com>

used by command-not-found to lookup which package ships which command.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---

Notes:
    this is technically a breaking change, but the only user of this already
    has a fallback match arm. I wonder whether we should mark this as
    non-exhaustive?

 src/deb822/release_file.rs | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/deb822/release_file.rs b/src/deb822/release_file.rs
index 6668450..2b7245b 100644
--- a/src/deb822/release_file.rs
+++ b/src/deb822/release_file.rs
@@ -51,6 +51,8 @@ pub type Component = String;
 /// `Packages` and `Sources` will contain further reference to binary or source package files.
 ///  These are handled in `PackagesFile` and `SourcesFile` respectively.
 pub enum FileReferenceType {
+    /// A `Commands` index listing command to package mappings
+    Commands(Architecture, Option<CompressionType>),
     /// A `Contents` index listing contents of binary packages
     Contents(Architecture, Option<CompressionType>),
     /// A `Contents` index listing contents of binary udeb packages
@@ -123,6 +125,20 @@ impl FileReferenceType {
                         Ok(FileReferenceType::Unknown)
                     }
                 }
+                "cnf" => {
+                    if let Some(rest) = rest.strip_prefix("Commands-") {
+                        if let Some((arch, ext)) = rest.rsplit_once('.') {
+                            Ok(FileReferenceType::Commands(
+                                arch.to_owned(),
+                                FileReferenceType::match_compression(ext).ok().flatten(),
+                            ))
+                        } else {
+                            Ok(FileReferenceType::Commands(rest.to_owned(), None))
+                        }
+                    } else {
+                        Ok(FileReferenceType::Unknown)
+                    }
+                },
                 "dep11" => {
                     if let Some((_path, ext)) = rest.rsplit_once('.') {
                         Ok(FileReferenceType::Dep11(
@@ -198,7 +214,8 @@ impl FileReferenceType {
 
     pub fn compression(&self) -> Option<CompressionType> {
         match *self {
-            FileReferenceType::Contents(_, comp)
+            FileReferenceType::Commands(_, comp)
+            | FileReferenceType::Contents(_, comp)
             | FileReferenceType::ContentsUdeb(_, comp)
             | FileReferenceType::Packages(_, comp)
             | FileReferenceType::Sources(comp)
-- 
2.30.2





  parent reply	other threads:[~2022-09-15 13:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-15 13:09 [pve-devel] [PATCH proxmox-apt/proxmox-offline-mirror 0/7] misc improvements Fabian Grünbichler
2022-09-15 13:09 ` [pve-devel] [PATCH proxmox-offline-mirror 1/4] mirror: use xz multi decoder Fabian Grünbichler
2022-09-15 13:09 ` Fabian Grünbichler [this message]
2022-09-15 13:09 ` [pve-devel] [PATCH proxmox-offline-mirror 2/4] mirror: skip failed, non Packages references Fabian Grünbichler
2022-09-15 13:09 ` [pve-devel] [PATCH proxmox-apt 2/3] release: add 'architecture' helper Fabian Grünbichler
2022-09-15 13:09 ` [pve-devel] [PATCH proxmox-offline-mirror 3/4] mirror: support acquiring indices by hash Fabian Grünbichler
2022-09-15 14:34   ` [pve-devel] [PATCH FIXUP proxmox-offline-mirror] clippy fix Fabian Grünbichler
2022-09-15 13:09 ` [pve-devel] [PATCH proxmox-apt 3/3] release: fix typo in 'Acquire-By-Hash' Fabian Grünbichler
2022-09-15 13:09 ` [pve-devel] [PATCH proxmox-offline-mirror 4/4] mirror: use new architecture helper Fabian Grünbichler
2022-09-15 14:36 ` [pve-devel] [PATCH follow-up proxmox-offline-mirror 8/7] mirror: handle indices which are only available compressed Fabian Grünbichler
2022-09-16 12:31 ` [pve-devel] applied-series: [PATCH proxmox-apt/proxmox-offline-mirror 0/7] misc improvements Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220915130918.727902-3-f.gruenbichler@proxmox.com \
    --to=f.gruenbichler@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal