forked from Proxmox/proxmox
fix #5513: apt: do not assume that sources.list file exists
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>
This commit is contained in:
parent
04505ada7a
commit
2c2497e5be
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user