From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <f.ebner@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id 8E7B59CDA1
 for <pve-devel@lists.proxmox.com>; Thu,  1 Jun 2023 18:14:45 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 6C21A20DFF
 for <pve-devel@lists.proxmox.com>; Thu,  1 Jun 2023 18:14:45 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [94.136.29.106])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS
 for <pve-devel@lists.proxmox.com>; Thu,  1 Jun 2023 18:14:43 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 87EA148276
 for <pve-devel@lists.proxmox.com>; Thu,  1 Jun 2023 18:14:43 +0200 (CEST)
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Thu,  1 Jun 2023 18:14:37 +0200
Message-Id: <20230601161439.114525-2-f.ebner@proxmox.com>
X-Mailer: git-send-email 2.39.2
In-Reply-To: <20230601161439.114525-1-f.ebner@proxmox.com>
References: <20230601161439.114525-1-f.ebner@proxmox.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.049 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 T_SCC_BODY_TEXT_LINE    -0.01 -
Subject: [pve-devel] [PATCH proxmox 2/4] apt: split Ceph main repository
 into no-subscription and enterprise
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Thu, 01 Jun 2023 16:14:45 -0000

The old 'main' component stays valid, pointing to no-subscription,
which means the is_referenced_repository() check needs a special case
for it. It will eventually go away, together with the handles for
Quincy.

Alternatively, the standard repository's info() could've been changed
to return multiple possible components, similar to URLs, but as
opposed to URLs, there could be a standard repository that wants to
have multiple components and it feels a bit unnatural, because
multiple components are usually not aliases of the same. And adapting
is_referenced_repository() would be needed here too. So overall, the
above alternative just felt better.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---

Hope the URLs are correct like this.

 proxmox-apt/src/repositories/mod.rs        |  3 +-
 proxmox-apt/src/repositories/repository.rs | 10 ++++++-
 proxmox-apt/src/repositories/standard.rs   | 35 +++++++++++++++-------
 proxmox-apt/tests/repositories.rs          |  3 +-
 4 files changed, 38 insertions(+), 13 deletions(-)

diff --git a/proxmox-apt/src/repositories/mod.rs b/proxmox-apt/src/repositories/mod.rs
index 11f52dd..b2e83a0 100644
--- a/proxmox-apt/src/repositories/mod.rs
+++ b/proxmox-apt/src/repositories/mod.rs
@@ -90,7 +90,8 @@ pub fn standard_repositories(
 
     if product == "pve" {
         result.append(&mut vec![
-            APTStandardRepository::from(APTRepositoryHandle::CephQuincy),
+            APTStandardRepository::from(APTRepositoryHandle::CephQuincyEnterprise),
+            APTStandardRepository::from(APTRepositoryHandle::CephQuincyNoSubscription),
             APTStandardRepository::from(APTRepositoryHandle::CephQuincyTest),
         ]);
     }
diff --git a/proxmox-apt/src/repositories/repository.rs b/proxmox-apt/src/repositories/repository.rs
index a5e3015..ba4e8b1 100644
--- a/proxmox-apt/src/repositories/repository.rs
+++ b/proxmox-apt/src/repositories/repository.rs
@@ -285,11 +285,19 @@ impl APTRepository {
             found_uri = found_uri || handle_uris.iter().any(|handle_uri| handle_uri == uri);
         }
 
+        // In the past it was main instead of enterprise/no-subscription, and main now maps to
+        // no-subscription. Note this only applies for Quincy.
+        let found_component = if handle == APTRepositoryHandle::CephQuincyNoSubscription {
+            self.components.contains(&component) || self.components.contains(&"main".to_string())
+        } else {
+            self.components.contains(&component)
+        };
+
         self.types.contains(&package_type)
             && found_uri
             // using contains would require a &String
             && self.suites.iter().any(|self_suite| self_suite == suite)
-            && self.components.contains(&component)
+            && found_component
     }
 
     /// Guess the origin from the repository's URIs.
diff --git a/proxmox-apt/src/repositories/standard.rs b/proxmox-apt/src/repositories/standard.rs
index 33c4842..838a42b 100644
--- a/proxmox-apt/src/repositories/standard.rs
+++ b/proxmox-apt/src/repositories/standard.rs
@@ -46,8 +46,10 @@ pub enum APTRepositoryHandle {
     NoSubscription,
     /// The test repository.
     Test,
-    /// Ceph Quincy repository.
-    CephQuincy,
+    /// Ceph Quincy enterprise repository.
+    CephQuincyEnterprise,
+    /// Ceph Quincy no-subscription repository.
+    CephQuincyNoSubscription,
     /// Ceph Quincy test repository.
     CephQuincyTest,
 }
@@ -71,7 +73,8 @@ impl TryFrom<&str> for APTRepositoryHandle {
             "enterprise" => Ok(APTRepositoryHandle::Enterprise),
             "no-subscription" => Ok(APTRepositoryHandle::NoSubscription),
             "test" => Ok(APTRepositoryHandle::Test),
-            "ceph-quincy" => Ok(APTRepositoryHandle::CephQuincy),
+            "ceph-quincy-enterprise" => Ok(APTRepositoryHandle::CephQuincyEnterprise),
+            "ceph-quincy-no-subscription" => Ok(APTRepositoryHandle::CephQuincyNoSubscription),
             "ceph-quincy-test" => Ok(APTRepositoryHandle::CephQuincyTest),
             _ => bail!("unknown repository handle '{}'", string),
         }
@@ -84,7 +87,8 @@ impl Display for APTRepositoryHandle {
             APTRepositoryHandle::Enterprise => write!(f, "enterprise"),
             APTRepositoryHandle::NoSubscription => write!(f, "no-subscription"),
             APTRepositoryHandle::Test => write!(f, "test"),
-            APTRepositoryHandle::CephQuincy => write!(f, "ceph-quincy"),
+            APTRepositoryHandle::CephQuincyEnterprise => write!(f, "ceph-quincy-enterprise"),
+            APTRepositoryHandle::CephQuincyNoSubscription => write!(f, "ceph-quincy-no-subscription"),
             APTRepositoryHandle::CephQuincyTest => write!(f, "ceph-quincy-test"),
         }
     }
@@ -107,8 +111,12 @@ impl APTRepositoryHandle {
                 "This repository contains the latest packages and is primarily used for test labs \
                 and by developers to test new features."
             }
-            APTRepositoryHandle::CephQuincy => {
-                "This repository holds the main Proxmox Ceph Quincy packages."
+            APTRepositoryHandle::CephQuincyEnterprise => {
+                "This repository holds the production-ready Proxmox Ceph Quincy packages."
+            }
+            APTRepositoryHandle::CephQuincyNoSubscription => {
+                "This repository holds the Proxmox Ceph Quincy packages intended for \
+                non-production use."
             }
             APTRepositoryHandle::CephQuincyTest => {
                 "This repository contains the Ceph Quincy packages before they are moved to the \
@@ -124,7 +132,8 @@ impl APTRepositoryHandle {
             APTRepositoryHandle::Enterprise => "Enterprise",
             APTRepositoryHandle::NoSubscription => "No-Subscription",
             APTRepositoryHandle::Test => "Test",
-            APTRepositoryHandle::CephQuincy => "Ceph Quincy",
+            APTRepositoryHandle::CephQuincyEnterprise => "Ceph Quincy Enterprise",
+            APTRepositoryHandle::CephQuincyNoSubscription => "Ceph Quincy No-Subscription",
             APTRepositoryHandle::CephQuincyTest => "Ceph Quincy Test",
         }
         .to_string()
@@ -138,7 +147,8 @@ impl APTRepositoryHandle {
             }
             APTRepositoryHandle::NoSubscription => "/etc/apt/sources.list".to_string(),
             APTRepositoryHandle::Test => "/etc/apt/sources.list".to_string(),
-            APTRepositoryHandle::CephQuincy => "/etc/apt/sources.list.d/ceph.list".to_string(),
+            APTRepositoryHandle::CephQuincyEnterprise => "/etc/apt/sources.list.d/ceph.list".to_string(),
+            APTRepositoryHandle::CephQuincyNoSubscription => "/etc/apt/sources.list.d/ceph.list".to_string(),
             APTRepositoryHandle::CephQuincyTest => "/etc/apt/sources.list.d/ceph.list".to_string(),
         }
     }
@@ -181,10 +191,15 @@ impl APTRepositoryHandle {
                 },
                 format!("{}test", product),
             ),
-            APTRepositoryHandle::CephQuincy => (
+            APTRepositoryHandle::CephQuincyEnterprise => (
+                APTRepositoryPackageType::Deb,
+                vec!["https://enterprise.proxmox.com/debian/ceph-quincy".to_string()],
+                "enterprise".to_string(),
+            ),
+            APTRepositoryHandle::CephQuincyNoSubscription => (
                 APTRepositoryPackageType::Deb,
                 vec!["http://download.proxmox.com/debian/ceph-quincy".to_string()],
-                "main".to_string(),
+                "no-subscription".to_string(),
             ),
             APTRepositoryHandle::CephQuincyTest => (
                 APTRepositoryPackageType::Deb,
diff --git a/proxmox-apt/tests/repositories.rs b/proxmox-apt/tests/repositories.rs
index ea714e6..4b3c9de 100644
--- a/proxmox-apt/tests/repositories.rs
+++ b/proxmox-apt/tests/repositories.rs
@@ -362,7 +362,8 @@ fn test_standard_repositories() -> Result<(), Error> {
         APTStandardRepository::from(APTRepositoryHandle::Enterprise),
         APTStandardRepository::from(APTRepositoryHandle::NoSubscription),
         APTStandardRepository::from(APTRepositoryHandle::Test),
-        APTStandardRepository::from(APTRepositoryHandle::CephQuincy),
+        APTStandardRepository::from(APTRepositoryHandle::CephQuincyEnterprise),
+        APTStandardRepository::from(APTRepositoryHandle::CephQuincyNoSubscription),
         APTStandardRepository::from(APTRepositoryHandle::CephQuincyTest),
     ];
 
-- 
2.39.2