File tree Expand file tree Collapse file tree 2 files changed +32
-5
lines changed Expand file tree Collapse file tree 2 files changed +32
-5
lines changed Original file line number Diff line number Diff line change @@ -216,7 +216,19 @@ impl<'a> OmaRefresh<'a> {
216
216
let paths = if let Some ( ref paths) = self . sources_lists_paths {
217
217
paths. to_vec ( )
218
218
} else {
219
- scan_sources_lists_paths_from_sysroot ( & self . source )
219
+ #[ cfg( feature = "apt" ) ]
220
+ let list_file = self . apt_config . get ( "Dir::Etc::sourcelist" ) . unwrap_or_else ( || "sources.list" . to_string ( ) ) ;
221
+
222
+ #[ cfg( feature = "apt" ) ]
223
+ let list_dir = self . apt_config . get ( "Dir::Etc::sourceparts" ) . unwrap_or_else ( || "sources.list.d" . to_string ( ) ) ;
224
+
225
+ #[ cfg( not( feature = "apt" ) ) ]
226
+ let list_file = "/etc/apt/sources.list" ;
227
+
228
+ #[ cfg( not( feature = "apt" ) ) ]
229
+ let list_dir = "/etc/apt/sources.list.d" ;
230
+
231
+ scan_sources_lists_paths_from_sysroot ( & self . source , list_file, list_dir)
220
232
. await
221
233
. map_err ( RefreshError :: ScanSourceError ) ?
222
234
} ;
Original file line number Diff line number Diff line change @@ -55,17 +55,32 @@ impl Debug for OmaSourceEntry<'_> {
55
55
}
56
56
57
57
pub ( crate ) async fn scan_sources_lists_paths_from_sysroot (
58
- sysroot : impl AsRef < Path > ,
58
+ dir : impl AsRef < Path > ,
59
+ list_file : impl AsRef < str > ,
60
+ list_dir : impl AsRef < str > ,
59
61
) -> Result < Vec < PathBuf > , SourcesListError > {
60
62
let mut paths = vec ! [ ] ;
61
- let default = sysroot. as_ref ( ) . join ( "etc/apt/sources.list" ) ;
63
+ let default = Path :: new ( list_file. as_ref ( ) ) ;
64
+ let list_dir = Path :: new ( list_dir. as_ref ( ) ) ;
65
+
66
+ let default = if !default. is_absolute ( ) {
67
+ dir. as_ref ( ) . join ( "etc/apt" ) . join ( default)
68
+ } else {
69
+ dir. as_ref ( ) . join ( default)
70
+ } ;
62
71
63
72
if default. exists ( ) {
64
73
paths. push ( default) ;
65
74
}
66
75
67
- if sysroot. as_ref ( ) . join ( "etc/apt/sources.list.d/" ) . exists ( ) {
68
- let mut dir = tokio:: fs:: read_dir ( sysroot. as_ref ( ) . join ( "etc/apt/sources.list.d/" ) ) . await ?;
76
+ let list_dir = if !list_dir. is_absolute ( ) {
77
+ dir. as_ref ( ) . join ( "etc/apt" ) . join ( list_dir)
78
+ } else {
79
+ dir. as_ref ( ) . join ( list_dir)
80
+ } ;
81
+
82
+ if list_dir. exists ( ) {
83
+ let mut dir = tokio:: fs:: read_dir ( list_dir) . await ?;
69
84
while let Some ( entry) = dir. next_entry ( ) . await ? {
70
85
let path = entry. path ( ) ;
71
86
if !path. is_file ( ) {
You can’t perform that action at this time.
0 commit comments