]> git.proxmox.com Git - proxmox.git/commitdiff
fix #4653: (In)Release file: improve handling of special suites
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Wed, 12 Apr 2023 07:17:58 +0000 (09:17 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 6 Jun 2023 16:24:39 +0000 (18:24 +0200)
APT doesn't mind a repository with either "/" or "./" as suite/distribution,
such as

 deb https://example.com/debian ./

in that case, the 'dists' part of the URL and the trailing slash (which would
be encoded as '_') is dropped in the file name in '/var/lib/apt/lists/'.

Other suite values with a trailing or leading '/' are rejected with an error by APT:

 E: Malformed entry 1 in sources file /etc/apt/sources.list.d/test.list (absolute Suite Component)
 E: The list of sources could not be read.

so this should be the only special case requiring handling.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
proxmox-apt/src/repositories/repository.rs

index 60e619c6547aee07967ae4114643db6673874e36..c2df2c748efff271c0bbec654d75f50ae0a23080 100644 (file)
@@ -373,12 +373,18 @@ fn release_filename(uri: &str, suite: &str, detached: bool) -> PathBuf {
     let encoded_uri = uri_to_filename(uri);
     let filename = if detached { "Release" } else { "InRelease" };
 
-    path.push(format!(
-        "{}_dists_{}_{}",
-        encoded_uri,
-        suite.replace('/', "_"), // e.g. for buster/updates
-        filename,
-    ));
+    if suite == "/" {
+        path.push(format!("{encoded_uri}_{filename}"));
+    } else if suite == "./" {
+        path.push(format!("{encoded_uri}_._{filename}"));
+    } else {
+        path.push(format!(
+            "{}_dists_{}_{}",
+            encoded_uri,
+            suite.replace('/', "_"), // e.g. for buster/updates
+            filename,
+        ));
+    }
 
     path
 }