* [pve-devel] [PATCH proxmox-apt 1/2] fallback to Release file for Origin retrieval
@ 2023-04-12 7:17 Fabian Grünbichler
2023-04-12 7:17 ` [pve-devel] [PATCH proxmox-apt 2/2] fix #4653: (In)Release file: improve handling of special suites Fabian Grünbichler
2023-06-06 16:25 ` [pve-devel] applied-series: [PATCH proxmox-apt 1/2] fallback to Release file for Origin retrieval Thomas Lamprecht
0 siblings, 2 replies; 3+ messages in thread
From: Fabian Grünbichler @ 2023-04-12 7:17 UTC (permalink / raw)
To: pve-devel
APT will not store the InRelease file in some cases, and some repositories
might not even have one in the first place.
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
src/repositories/repository.rs | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/repositories/repository.rs b/src/repositories/repository.rs
index a5e3015..7a19af4 100644
--- a/src/repositories/repository.rs
+++ b/src/repositories/repository.rs
@@ -315,10 +315,13 @@ impl APTRepository {
pub fn get_cached_origin(&self) -> Result<Option<String>, Error> {
for uri in self.uris.iter() {
for suite in self.suites.iter() {
- let file = in_release_filename(uri, suite);
+ let mut file = release_filename(uri, suite, false);
if !file.exists() {
- continue;
+ file = release_filename(uri, suite, true);
+ if !file.exists() {
+ continue;
+ }
}
let raw = std::fs::read(&file)
@@ -354,17 +357,19 @@ impl APTRepository {
}
}
-/// Get the path to the cached InRelease file.
-fn in_release_filename(uri: &str, suite: &str) -> PathBuf {
+/// Get the path to the cached (In)Release file.
+fn release_filename(uri: &str, suite: &str, detached: bool) -> PathBuf {
let mut path = PathBuf::from(&crate::config::get().dir_state);
path.push(&crate::config::get().dir_state_lists);
- let filename = uri_to_filename(uri);
+ let encoded_uri = uri_to_filename(uri);
+ let filename = if detached { "Release" } else { "InRelease" };
path.push(format!(
- "{}_dists_{}_InRelease",
- filename,
+ "{}_dists_{}_{}",
+ encoded_uri,
suite.replace('/', "_"), // e.g. for buster/updates
+ filename,
));
path
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pve-devel] [PATCH proxmox-apt 2/2] fix #4653: (In)Release file: improve handling of special suites
2023-04-12 7:17 [pve-devel] [PATCH proxmox-apt 1/2] fallback to Release file for Origin retrieval Fabian Grünbichler
@ 2023-04-12 7:17 ` Fabian Grünbichler
2023-06-06 16:25 ` [pve-devel] applied-series: [PATCH proxmox-apt 1/2] fallback to Release file for Origin retrieval Thomas Lamprecht
1 sibling, 0 replies; 3+ messages in thread
From: Fabian Grünbichler @ 2023-04-12 7:17 UTC (permalink / raw)
To: pve-devel
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>
---
src/repositories/repository.rs | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/repositories/repository.rs b/src/repositories/repository.rs
index 7a19af4..ef77186 100644
--- a/src/repositories/repository.rs
+++ b/src/repositories/repository.rs
@@ -365,12 +365,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
}
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pve-devel] applied-series: [PATCH proxmox-apt 1/2] fallback to Release file for Origin retrieval
2023-04-12 7:17 [pve-devel] [PATCH proxmox-apt 1/2] fallback to Release file for Origin retrieval Fabian Grünbichler
2023-04-12 7:17 ` [pve-devel] [PATCH proxmox-apt 2/2] fix #4653: (In)Release file: improve handling of special suites Fabian Grünbichler
@ 2023-06-06 16:25 ` Thomas Lamprecht
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2023-06-06 16:25 UTC (permalink / raw)
To: Proxmox VE development discussion, Fabian Grünbichler
Am 12/04/2023 um 09:17 schrieb Fabian Grünbichler:
> APT will not store the InRelease file in some cases, and some repositories
> might not even have one in the first place.
>
> Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
> ---
> src/repositories/repository.rs | 19 ++++++++++++-------
> 1 file changed, 12 insertions(+), 7 deletions(-)
>
>
applied both patches, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-06 16:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-12 7:17 [pve-devel] [PATCH proxmox-apt 1/2] fallback to Release file for Origin retrieval Fabian Grünbichler
2023-04-12 7:17 ` [pve-devel] [PATCH proxmox-apt 2/2] fix #4653: (In)Release file: improve handling of special suites Fabian Grünbichler
2023-06-06 16:25 ` [pve-devel] applied-series: [PATCH proxmox-apt 1/2] fallback to Release file for Origin retrieval Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox