1.1 --- a/plover-gtk/transactionhelper.c Fri Mar 08 12:05:41 2019 +0000
1.2 +++ b/plover-gtk/transactionhelper.c Wed Jul 15 16:04:47 2020 +0100
1.3 @@ -68,6 +68,7 @@
1.4 g_free(priv->default_prefix);
1.5 g_free(helper->error_primary_text);
1.6 g_free(helper->base);
1.7 + g_free(helper->base_uri);
1.8 g_free(helper->unsatisfied);
1.9 if (helper->comps)
1.10 plover_comps_free(helper->comps);
1.11 @@ -583,12 +584,12 @@
1.12 plover_transaction_helper_get_upstream(PloverTransactionHelper *helper,
1.13 GError **error)
1.14 {
1.15 - const char *base;
1.16 + const char *base_uri;
1.17 g_return_val_if_fail(PLOVER_IS_TRANSACTION_HELPER(helper),NULL);
1.18 if (!helper->upstream)
1.19 {
1.20 - base=plover_transaction_helper_get_base(helper);
1.21 - helper->upstream=plover_repository_new_from_yum(base,error);
1.22 + base_uri=plover_transaction_helper_get_base_uri(helper);
1.23 + helper->upstream=plover_repository_new_from_yum_uri(base_uri,error);
1.24 }
1.25 return helper->upstream;
1.26 }
1.27 @@ -602,18 +603,53 @@
1.28 helper->upstream=g_object_ref(upstream);
1.29 }
1.30
1.31 +const char *
1.32 + plover_transaction_helper_get_base_uri(PloverTransactionHelper *helper)
1.33 +{
1.34 + g_return_val_if_fail(PLOVER_IS_TRANSACTION_HELPER(helper),NULL);
1.35 + return helper->base_uri;
1.36 +}
1.37 +
1.38 +static gboolean plover_gtk__uri_validate(const char *uri)
1.39 +{
1.40 + char *s;
1.41 + s=razor_path_relative_to_uri(uri,".",NULL);
1.42 + free(s);
1.43 + return !!s;
1.44 +}
1.45 +
1.46 +void plover_transaction_helper_set_base_uri(PloverTransactionHelper *helper,
1.47 + const char *base_uri)
1.48 +{
1.49 + g_return_if_fail(PLOVER_IS_TRANSACTION_HELPER(helper));
1.50 + g_return_if_fail(helper->transactions == NULL);
1.51 + g_return_if_fail(plover_gtk__uri_validate(base_uri));
1.52 + g_free(helper->base_uri);
1.53 + helper->base_uri=g_strdup(base_uri);
1.54 + g_free(helper->base);
1.55 + helper->base=NULL;
1.56 +}
1.57 +
1.58 const char *plover_transaction_helper_get_base(PloverTransactionHelper *helper)
1.59 {
1.60 g_return_val_if_fail(PLOVER_IS_TRANSACTION_HELPER(helper),NULL);
1.61 + if (helper->base_uri && !helper->base)
1.62 + helper->base=razor_path_from_uri(helper->base_uri,NULL);
1.63 return helper->base;
1.64 }
1.65
1.66 void plover_transaction_helper_set_base(PloverTransactionHelper *helper,
1.67 const char *base)
1.68 {
1.69 + gchar *base_uri;
1.70 g_return_if_fail(PLOVER_IS_TRANSACTION_HELPER(helper));
1.71 g_return_if_fail(helper->transactions == NULL);
1.72 - g_free(helper->base);
1.73 + if (base)
1.74 + base_uri=razor_path_to_uri(base);
1.75 + else
1.76 + base_uri=NULL;
1.77 + plover_transaction_helper_set_base_uri(helper,base_uri);
1.78 + g_free(base_uri);
1.79 helper->base=g_strdup(base);
1.80 }
1.81
1.82 @@ -623,13 +659,10 @@
1.83 {
1.84 gchar *s;
1.85 g_return_val_if_fail(PLOVER_IS_TRANSACTION_HELPER(helper),NULL);
1.86 - if (!helper->comps && helper->base)
1.87 + if (!helper->comps && helper->base_uri)
1.88 {
1.89 - s=g_strconcat(helper->base,"/repodata/comps.xml",NULL);
1.90 - helper->comps=plover_comps_new_from_file(s);
1.91 - if (!helper->comps)
1.92 - g_set_error(error,PLOVER_GENERAL_ERROR,
1.93 - PLOVER_GENERAL_ERROR_FAILED,"%s: %s",s,g_strerror(errno));
1.94 + s=g_strconcat(helper->base_uri,"/repodata/comps.xml",NULL);
1.95 + helper->comps=plover_comps_new_from_uri(s,error);
1.96 g_free(s);
1.97 }
1.98 return helper->comps;
1.99 @@ -643,9 +676,9 @@
1.100 struct comps *comps;
1.101 PloverTransactionHelperPrivate *priv;
1.102 g_return_val_if_fail(PLOVER_IS_TRANSACTION_HELPER(helper),NULL);
1.103 - g_return_val_if_fail(helper->base != NULL || plover_transaction_helper_get_installed(helper) != NULL,NULL);
1.104 + g_return_val_if_fail(helper->base_uri != NULL || plover_transaction_helper_get_installed(helper) != NULL,NULL);
1.105 priv=PLOVER_TRANSACTION_HELPER_GET_PRIVATE(helper);
1.106 - if (helper->base)
1.107 + if (helper->base_uri)
1.108 {
1.109 comps=plover_transaction_helper_get_comps(helper,error);
1.110 if (!comps)
1.111 @@ -951,7 +984,7 @@
1.112 GError **error)
1.113 {
1.114 gboolean ok;
1.115 - const char *base,*prefix;
1.116 + const char *base_uri,*prefix;
1.117 GError *tmp_error=NULL;
1.118 PloverTransaction *transaction;
1.119 g_return_val_if_fail(PLOVER_IS_TRANSACTION_HELPER(helper),NULL);
1.120 @@ -969,8 +1002,9 @@
1.121 ok=plover_transaction_set_upstream(transaction,helper->upstream,error);
1.122 else
1.123 {
1.124 - base=plover_transaction_helper_get_base(helper);
1.125 - ok=plover_transaction_set_upstream_from_yum(transaction,base,error);
1.126 + base_uri=plover_transaction_helper_get_base_uri(helper);
1.127 + ok=plover_transaction_set_upstream_from_yum_uri(transaction,base_uri,
1.128 + error);
1.129 }
1.130 if (!ok)
1.131 {