@@ -255,8 +255,10 @@ pub struct Solver {
255255impl Solver {
256256 pub async fn get_solver ( & self , options : & Options ) -> Result < solve:: Solver > {
257257 let option_map = options. get_options ( ) ?;
258+
258259 let mut solver = solve:: Solver :: default ( ) ;
259260 solver. update_options ( option_map) ;
261+
260262 for ( name, repo) in self . repos . get_repos_for_non_destructive_operation ( ) . await ? {
261263 tracing:: debug!( repo=%name, "using repository" ) ;
262264 solver. add_repository ( repo) ;
@@ -272,9 +274,6 @@ impl Solver {
272274 self . check_impossible_builds || self . check_impossible_all ,
273275 ) ;
274276
275- for r in options. get_var_requests ( ) ? {
276- solver. add_request ( r. into ( ) ) ;
277- }
278277 Ok ( solver)
279278 }
280279}
@@ -399,34 +398,42 @@ impl Requests {
399398 Ok ( idents)
400399 }
401400
402- /// Parse and build a request from the given string and these flags
401+ /// Parse and build a request, and any extra options, from the
402+ /// given string and these flags. If the request expands into
403+ /// multiple requests, such as from a request file, this will
404+ /// return the last request. Any options returned are filtered to
405+ /// exclude any (override) options given in the options parameter.
403406 pub async fn parse_request < R : AsRef < str > > (
404407 & self ,
405408 request : R ,
406409 options : & Options ,
407410 repos : & [ Arc < storage:: RepositoryHandle > ] ,
408- ) -> Result < Request > {
409- Ok ( self
411+ ) -> Result < ( Request , OptionMap ) > {
412+ let ( mut requests , extra_options ) = self
410413 . parse_requests ( [ request. as_ref ( ) ] , options, repos)
411- . await ?
412- . pop ( )
413- . unwrap ( ) )
414+ . await ?;
415+ let last_request = requests . pop ( ) . unwrap ( ) ;
416+ Ok ( ( last_request , extra_options ) )
414417 }
415418
416- /// Parse and build requests from the given strings and these flags.
419+ /// Parse and build requests, and any extra options, from the
420+ /// given strings and these flags. Any options returned are
421+ /// filtered to exclude any (override) options given in the
422+ /// options parameter.
417423 pub async fn parse_requests < I , S > (
418424 & self ,
419425 requests : I ,
420426 options : & Options ,
421427 repos : & [ Arc < storage:: RepositoryHandle > ] ,
422- ) -> Result < Vec < Request > >
428+ ) -> Result < ( Vec < Request > , OptionMap ) >
423429 where
424430 I : IntoIterator < Item = S > ,
425431 S : AsRef < str > ,
426432 {
427433 let mut out = Vec :: < Request > :: new ( ) ;
428434 let override_options = options. get_options ( ) ?;
429435 let mut templating_options = override_options. clone ( ) ;
436+ let mut extra_options = OptionMap :: default ( ) ;
430437
431438 // From the positional REQUESTS arg
432439 for r in requests. into_iter ( ) {
@@ -445,25 +452,18 @@ impl Requests {
445452 )
446453 } ) ?;
447454
448- for request in requests_from_file. requirements {
449- // First, add all the requests, pkg and var, to
450- // the requests lists
451- out. push ( request. clone ( ) ) ;
452-
453- // Then, add any var requests to the templating
454- // options for use with subsequent requests files
455- // or package@stage spec files read in later
456- // iterations of the outer loop
457- if let Some ( var) = request. into_var ( ) {
458- // There is no command line override
459- // option for this name so can update it.
460- if override_options. get ( & var. var ) . is_none ( ) {
461- // Forcing a var request into an option
462- templating_options. insert (
463- var. var ,
464- var. value . as_pinned ( ) . unwrap_or_default ( ) . to_string ( ) ,
465- ) ;
466- }
455+ out. extend ( requests_from_file. requirements ) ;
456+
457+ for ( name, value) in requests_from_file. options {
458+ // Command line override options take precedence.
459+ // Only when there is no command line override for
460+ // this option name is it used
461+ if override_options. get ( & name) . is_none ( ) {
462+ // For template values in later files and specs
463+ templating_options. insert ( OptName :: new ( & name) ?. into ( ) , value. clone ( ) ) ;
464+ // For later use by commands, usually when
465+ // setting up a solver
466+ extra_options. insert ( OptName :: new ( & name) ?. into ( ) , value) ;
467467 }
468468 }
469469 continue ;
@@ -481,7 +481,7 @@ impl Requests {
481481 )
482482 . into ( ) )
483483 } else {
484- Ok ( out)
484+ Ok ( ( out, extra_options ) )
485485 }
486486 }
487487
0 commit comments