public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH proxmox] fix #5513: apt: do not assume that sources.list file exists
@ 2024-06-05  8:29 Fiona Ebner
  2024-06-06  9:08 ` [pve-devel] applied: " Fabian Grünbichler
  0 siblings, 1 reply; 2+ messages in thread
From: Fiona Ebner @ 2024-06-05  8:29 UTC (permalink / raw)
  To: pve-devel

Some users might want to switch to using only the newer .sources files
already, which Debian is going to switch to in the long run.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 proxmox-apt/src/repositories/mod.rs | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/proxmox-apt/src/repositories/mod.rs b/proxmox-apt/src/repositories/mod.rs
index 7bfe9cae..26e4192c 100644
--- a/proxmox-apt/src/repositories/mod.rs
+++ b/proxmox-apt/src/repositories/mod.rs
@@ -146,12 +146,21 @@ pub fn repositories() -> Result<Repositories, Error> {
 
     let sources_list_d_path = PathBuf::from(APT_SOURCES_LIST_DIRECTORY);
 
-    match APTRepositoryFile::new(sources_list_path) {
-        Ok(Some(mut file)) => match file.parse() {
-            Ok(()) => files.push(file),
-            Err(err) => errors.push(err),
-        },
-        _ => bail!("internal error with '{}'", APT_SOURCES_LIST_FILENAME),
+    if sources_list_path.exists() {
+        if sources_list_path.is_file() {
+            match APTRepositoryFile::new(sources_list_path) {
+                Ok(Some(mut file)) => match file.parse() {
+                    Ok(()) => files.push(file),
+                    Err(err) => errors.push(err),
+                },
+                _ => bail!("internal error with '{}'", APT_SOURCES_LIST_FILENAME),
+            }
+        } else {
+            errors.push(APTRepositoryFileError {
+                path: APT_SOURCES_LIST_FILENAME.to_string(),
+                error: "not a regular file!".to_string(),
+            });
+        }
     }
 
     if !sources_list_d_path.exists() {
-- 
2.39.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pve-devel] applied: [PATCH proxmox] fix #5513: apt: do not assume that sources.list file exists
  2024-06-05  8:29 [pve-devel] [PATCH proxmox] fix #5513: apt: do not assume that sources.list file exists Fiona Ebner
@ 2024-06-06  9:08 ` Fabian Grünbichler
  0 siblings, 0 replies; 2+ messages in thread
From: Fabian Grünbichler @ 2024-06-06  9:08 UTC (permalink / raw)
  To: Proxmox VE development discussion

thanks!

On June 5, 2024 10:29 am, Fiona Ebner wrote:
> Some users might want to switch to using only the newer .sources files
> already, which Debian is going to switch to in the long run.
> 
> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
> ---
>  proxmox-apt/src/repositories/mod.rs | 21 +++++++++++++++------
>  1 file changed, 15 insertions(+), 6 deletions(-)
> 
> diff --git a/proxmox-apt/src/repositories/mod.rs b/proxmox-apt/src/repositories/mod.rs
> index 7bfe9cae..26e4192c 100644
> --- a/proxmox-apt/src/repositories/mod.rs
> +++ b/proxmox-apt/src/repositories/mod.rs
> @@ -146,12 +146,21 @@ pub fn repositories() -> Result<Repositories, Error> {
>  
>      let sources_list_d_path = PathBuf::from(APT_SOURCES_LIST_DIRECTORY);
>  
> -    match APTRepositoryFile::new(sources_list_path) {
> -        Ok(Some(mut file)) => match file.parse() {
> -            Ok(()) => files.push(file),
> -            Err(err) => errors.push(err),
> -        },
> -        _ => bail!("internal error with '{}'", APT_SOURCES_LIST_FILENAME),
> +    if sources_list_path.exists() {
> +        if sources_list_path.is_file() {
> +            match APTRepositoryFile::new(sources_list_path) {
> +                Ok(Some(mut file)) => match file.parse() {
> +                    Ok(()) => files.push(file),
> +                    Err(err) => errors.push(err),
> +                },
> +                _ => bail!("internal error with '{}'", APT_SOURCES_LIST_FILENAME),
> +            }
> +        } else {
> +            errors.push(APTRepositoryFileError {
> +                path: APT_SOURCES_LIST_FILENAME.to_string(),
> +                error: "not a regular file!".to_string(),
> +            });
> +        }
>      }
>  
>      if !sources_list_d_path.exists() {
> -- 
> 2.39.2
> 
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 
> 


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-06-06  9:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-05  8:29 [pve-devel] [PATCH proxmox] fix #5513: apt: do not assume that sources.list file exists Fiona Ebner
2024-06-06  9:08 ` [pve-devel] applied: " Fabian Grünbichler

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