@@ -247,8 +247,10 @@ pub struct Solver {
247247impl Solver {
248248 pub async fn get_solver ( & self , options : & Options ) -> Result < solve:: Solver > {
249249 let option_map = options. get_options ( ) ?;
250+
250251 let mut solver = solve:: Solver :: default ( ) ;
251252 solver. update_options ( option_map) ;
253+
252254 for ( name, repo) in self . repos . get_repos_for_non_destructive_operation ( ) . await ? {
253255 tracing:: debug!( repo=%name, "using repository" ) ;
254256 solver. add_repository ( repo) ;
@@ -264,9 +266,6 @@ impl Solver {
264266 self . check_impossible_builds || self . check_impossible_all ,
265267 ) ;
266268
267- for r in options. get_var_requests ( ) ? {
268- solver. add_request ( r. into ( ) ) ;
269- }
270269 Ok ( solver)
271270 }
272271}
@@ -391,34 +390,42 @@ impl Requests {
391390 Ok ( idents)
392391 }
393392
394- /// Parse and build a request from the given string and these flags
393+ /// Parse and build a request, and any extra options, from the
394+ /// given string and these flags. If the request expands into
395+ /// multiple requests, such as from a request file, this will
396+ /// return the last request. Any options returned are filtered to
397+ /// exclude any (override) options given in the options parameter.
395398 pub async fn parse_request < R : AsRef < str > > (
396399 & self ,
397400 request : R ,
398401 options : & Options ,
399402 repos : & [ Arc < storage:: RepositoryHandle > ] ,
400- ) -> Result < Request > {
401- Ok ( self
403+ ) -> Result < ( Request , OptionMap ) > {
404+ let ( mut requests , extra_options ) = self
402405 . parse_requests ( [ request. as_ref ( ) ] , options, repos)
403- . await ?
404- . pop ( )
405- . unwrap ( ) )
406+ . await ?;
407+ let last_request = requests . pop ( ) . unwrap ( ) ;
408+ Ok ( ( last_request , extra_options ) )
406409 }
407410
408- /// Parse and build requests from the given strings and these flags.
411+ /// Parse and build requests, and any extra options, from the
412+ /// given strings and these flags. Any options returned are
413+ /// filtered to exclude any (override) options given in the
414+ /// options parameter.
409415 pub async fn parse_requests < I , S > (
410416 & self ,
411417 requests : I ,
412418 options : & Options ,
413419 repos : & [ Arc < storage:: RepositoryHandle > ] ,
414- ) -> Result < Vec < Request > >
420+ ) -> Result < ( Vec < Request > , OptionMap ) >
415421 where
416422 I : IntoIterator < Item = S > ,
417423 S : AsRef < str > ,
418424 {
419425 let mut out = Vec :: < Request > :: new ( ) ;
420426 let override_options = options. get_options ( ) ?;
421427 let mut templating_options = override_options. clone ( ) ;
428+ let mut extra_options = OptionMap :: default ( ) ;
422429
423430 // From the positional REQUESTS arg
424431 for r in requests. into_iter ( ) {
@@ -437,25 +444,18 @@ impl Requests {
437444 )
438445 } ) ?;
439446
440- for request in requests_from_file. requirements {
441- // First, add all the requests, pkg and var, to
442- // the requests lists
443- out. push ( request. clone ( ) ) ;
444-
445- // Then, add any var requests to the templating
446- // options for use with subsequent requests files
447- // or package@stage spec files read in later
448- // iterations of the outer loop
449- if let Some ( var) = request. into_var ( ) {
450- // There is no command line override
451- // option for this name so can update it.
452- if override_options. get ( & var. var ) . is_none ( ) {
453- // Forcing a var request into an option
454- templating_options. insert (
455- var. var ,
456- var. value . as_pinned ( ) . unwrap_or_default ( ) . to_string ( ) ,
457- ) ;
458- }
447+ out. extend ( requests_from_file. requirements ) ;
448+
449+ for ( name, value) in requests_from_file. options {
450+ // Command line override options take precedence.
451+ // Only when there is no command line override for
452+ // this option name is it used
453+ if override_options. get ( & name) . is_none ( ) {
454+ // For template values in later files and specs
455+ templating_options. insert ( OptName :: new ( & name) ?. into ( ) , value. clone ( ) ) ;
456+ // For later use by commands, usually when
457+ // setting up a solver
458+ extra_options. insert ( OptName :: new ( & name) ?. into ( ) , value) ;
459459 }
460460 }
461461
@@ -474,7 +474,7 @@ impl Requests {
474474 )
475475 . into ( ) )
476476 } else {
477- Ok ( out)
477+ Ok ( ( out, extra_options ) )
478478 }
479479 }
480480
0 commit comments