@@ -3753,10 +3753,78 @@ builder_manifest_show_deps (BuilderManifest *self,
37533753 return TRUE;
37543754}
37553755
3756+ static gboolean
3757+ builder_manifest_install_single_dep (const char * ref ,
3758+ const char * remote ,
3759+ gboolean opt_user ,
3760+ const char * opt_installation ,
3761+ GError * * error )
3762+ {
3763+ g_autoptr (GPtrArray ) args = NULL ;
3764+ args = g_ptr_array_new_with_free_func (g_free );
3765+ g_ptr_array_add (args , g_strdup ("flatpak" ));
3766+ add_installation_args (args , opt_user , opt_installation );
3767+
3768+ g_ptr_array_add (args , g_strdup ("install" ));
3769+ g_ptr_array_add (args , g_strdup (remote ));
3770+
3771+ g_ptr_array_add (args , g_strdup ("-y" ));
3772+ if (flatpak_version_check (1 , 2 , 0 ))
3773+ g_ptr_array_add (args , g_strdup ("--noninteractive" ));
3774+
3775+ g_ptr_array_add (args , g_strdup (ref ));
3776+ g_ptr_array_add (args , NULL );
3777+
3778+ if (!builder_maybe_host_spawnv (NULL , NULL , 0 , error , (const char * const * )args -> pdata ))
3779+ {
3780+ g_autofree char * commandline = flatpak_quote_argv ((const char * * )args -> pdata );
3781+ g_prefix_error (error , "running `%s`: " , commandline );
3782+ return FALSE;
3783+ }
3784+ else
3785+ {
3786+ return TRUE;
3787+ }
3788+ }
3789+
3790+
3791+ static gboolean
3792+ builder_manifest_update_single_dep (const char * ref ,
3793+ gboolean opt_user ,
3794+ const char * opt_installation ,
3795+ GError * * error )
3796+ {
3797+ g_autoptr (GPtrArray ) args = NULL ;
3798+ args = g_ptr_array_new_with_free_func (g_free );
3799+ g_ptr_array_add (args , g_strdup ("flatpak" ));
3800+ add_installation_args (args , opt_user , opt_installation );
3801+
3802+ g_ptr_array_add (args , g_strdup ("update" ));
3803+ g_ptr_array_add (args , g_strdup ("--subpath=" ));
3804+
3805+ g_ptr_array_add (args , g_strdup ("-y" ));
3806+ if (flatpak_version_check (1 , 2 , 0 ))
3807+ g_ptr_array_add (args , g_strdup ("--noninteractive" ));
3808+
3809+ g_ptr_array_add (args , g_strdup (ref ));
3810+ g_ptr_array_add (args , NULL );
3811+
3812+ if (!builder_maybe_host_spawnv (NULL , NULL , 0 , error , (const char * const * )args -> pdata ))
3813+ {
3814+ g_autofree char * commandline = flatpak_quote_argv ((const char * * )args -> pdata );
3815+ g_prefix_error (error , "running `%s`: " , commandline );
3816+ return FALSE;
3817+ }
3818+ else
3819+ {
3820+ return TRUE;
3821+ }
3822+ }
3823+
37563824static gboolean
37573825builder_manifest_install_dep (BuilderManifest * self ,
37583826 BuilderContext * context ,
3759- const char * remote ,
3827+ char * const * remotes ,
37603828 gboolean opt_user ,
37613829 const char * opt_installation ,
37623830 const char * runtime ,
@@ -3766,8 +3834,6 @@ builder_manifest_install_dep (BuilderManifest *self,
37663834{
37673835 g_autofree char * ref = NULL ;
37683836 g_autofree char * commit = NULL ;
3769- g_autoptr (GPtrArray ) args = NULL ;
3770- gboolean installed ;
37713837
37723838 if (version == NULL )
37733839 version = builder_manifest_get_runtime_version (self );
@@ -3777,37 +3843,44 @@ builder_manifest_install_dep (BuilderManifest *self,
37773843 builder_context_get_arch (context ));
37783844
37793845 commit = flatpak_info (opt_user , opt_installation , "--show-commit" , ref , NULL );
3780- installed = (commit != NULL );
37813846
3782- args = g_ptr_array_new_with_free_func (g_free );
3783- g_ptr_array_add (args , g_strdup ("flatpak" ));
3784- add_installation_args (args , opt_user , opt_installation );
3785- if (installed )
3847+ if (commit != NULL )
37863848 {
3787- g_ptr_array_add (args , g_strdup ("update" ));
3788- g_ptr_array_add (args , g_strdup ("--subpath=" ));
3849+ g_print ("Updating %s\n" , ref );
3850+ if (builder_manifest_update_single_dep (ref , opt_user , opt_installation ,
3851+ error ))
3852+ {
3853+ return TRUE;
3854+ }
37893855 }
37903856 else
37913857 {
3792- g_ptr_array_add (args , g_strdup ("install" ));
3793- g_ptr_array_add (args , g_strdup (remote ));
3794- }
3795-
3796- g_ptr_array_add (args , g_strdup ("-y" ));
3797- if (flatpak_version_check (1 , 2 , 0 ))
3798- g_ptr_array_add (args , g_strdup ("--noninteractive" ));
3799-
3800- g_ptr_array_add (args , g_strdup (ref ));
3801- g_ptr_array_add (args , NULL );
3802-
3803- if (!builder_maybe_host_spawnv (NULL , NULL , 0 , error , (const char * const * )args -> pdata ))
3804- {
3805- g_autofree char * commandline = flatpak_quote_argv ((const char * * )args -> pdata );
3806- g_prefix_error (error , "running `%s`: " , commandline );
3807- return FALSE;
3858+ gboolean multiple_remotes = (* (remotes + 1 ) != NULL );
3859+ for (const char * remote = * remotes ; remote != NULL ; remote = * (++ remotes ))
3860+ {
3861+ g_autoptr (GError ) current_error = NULL ;
3862+ if (multiple_remotes )
3863+ {
3864+ g_print ("Trying to install %s from %s\n" , ref , remote );
3865+ }
3866+ else {
3867+ g_print ("Installing %s from %s\n" , ref , remote );
3868+ }
3869+ if (builder_manifest_install_single_dep (ref , remote , opt_user , opt_installation ,
3870+ & current_error ))
3871+ {
3872+ current_error = g_steal_pointer (error );
3873+ return TRUE;
3874+ }
3875+ else if (* error == NULL )
3876+ {
3877+ * error = g_steal_pointer (& current_error );
3878+ }
3879+ if ((* error )-> domain != G_SPAWN_EXIT_ERROR )
3880+ return FALSE;
3881+ }
38083882 }
3809-
3810- return TRUE;
3883+ return FALSE;
38113884}
38123885
38133886static gboolean
@@ -3816,7 +3889,7 @@ builder_manifest_install_extension_deps (BuilderManifest *self,
38163889 const char * runtime ,
38173890 const char * runtime_version ,
38183891 char * * runtime_extensions ,
3819- const char * remote ,
3892+ char * const * remotes ,
38203893 gboolean opt_user ,
38213894 const char * opt_installation ,
38223895 gboolean opt_yes ,
@@ -3864,7 +3937,7 @@ builder_manifest_install_extension_deps (BuilderManifest *self,
38643937 extension_version = g_strdup (runtime_version );
38653938
38663939 g_print ("Dependency Extension: %s %s\n" , runtime_extensions [i ], extension_version );
3867- if (!builder_manifest_install_dep (self , context , remote , opt_user , opt_installation ,
3940+ if (!builder_manifest_install_dep (self , context , remotes , opt_user , opt_installation ,
38683941 runtime_extensions [i ], extension_version ,
38693942 opt_yes ,
38703943 error ))
@@ -3877,7 +3950,7 @@ builder_manifest_install_extension_deps (BuilderManifest *self,
38773950gboolean
38783951builder_manifest_install_deps (BuilderManifest * self ,
38793952 BuilderContext * context ,
3880- const char * remote ,
3953+ char * const * remotes ,
38813954 gboolean opt_user ,
38823955 const char * opt_installation ,
38833956 gboolean opt_yes ,
@@ -3902,15 +3975,15 @@ builder_manifest_install_deps (BuilderManifest *self,
39023975
39033976 /* Sdk */
39043977 g_print ("Dependency Sdk: %s %s\n" , sdk , sdk_branch );
3905- if (!builder_manifest_install_dep (self , context , remote , opt_user , opt_installation ,
3978+ if (!builder_manifest_install_dep (self , context , remotes , opt_user , opt_installation ,
39063979 sdk , sdk_branch ,
39073980 opt_yes ,
39083981 error ))
39093982 return FALSE;
39103983
39113984 /* Runtime */
39123985 g_print ("Dependency Runtime: %s %s\n" , self -> runtime , builder_manifest_get_runtime_version (self ));
3913- if (!builder_manifest_install_dep (self , context , remote , opt_user , opt_installation ,
3986+ if (!builder_manifest_install_dep (self , context , remotes , opt_user , opt_installation ,
39143987 self -> runtime , builder_manifest_get_runtime_version (self ),
39153988 opt_yes ,
39163989 error ))
@@ -3919,7 +3992,7 @@ builder_manifest_install_deps (BuilderManifest *self,
39193992 if (self -> base )
39203993 {
39213994 g_print ("Dependency Base: %s %s\n" , self -> base , builder_manifest_get_base_version (self ));
3922- if (!builder_manifest_install_dep (self , context , remote , opt_user , opt_installation ,
3995+ if (!builder_manifest_install_dep (self , context , remotes , opt_user , opt_installation ,
39233996 self -> base , builder_manifest_get_base_version (self ),
39243997 opt_yes ,
39253998 error ))
@@ -3928,15 +4001,15 @@ builder_manifest_install_deps (BuilderManifest *self,
39284001
39294002 if (!builder_manifest_install_extension_deps (self , context ,
39304003 sdk , sdk_branch , self -> sdk_extensions ,
3931- remote , opt_user , opt_installation ,
4004+ remotes , opt_user , opt_installation ,
39324005 opt_yes ,
39334006 error ))
39344007 return FALSE;
39354008
39364009 if (!builder_manifest_install_extension_deps (self , context ,
39374010 self -> runtime , builder_manifest_get_runtime_version (self ),
39384011 self -> platform_extensions ,
3939- remote , opt_user , opt_installation ,
4012+ remotes , opt_user , opt_installation ,
39404013 opt_yes ,
39414014 error ))
39424015 return FALSE;
@@ -3951,7 +4024,7 @@ builder_manifest_install_deps (BuilderManifest *self,
39514024 continue ;
39524025
39534026 g_print ("Dependency Extension: %s %s\n" , name , version );
3954- if (!builder_manifest_install_dep (self , context , remote , opt_user , opt_installation ,
4027+ if (!builder_manifest_install_dep (self , context , remotes , opt_user , opt_installation ,
39554028 name , version ,
39564029 opt_yes ,
39574030 error ))
0 commit comments