diff -r a8e48c62ec03 -r 71127797ca73 plover-gtk/transactionhelper.c --- a/plover-gtk/transactionhelper.c Fri Mar 08 12:05:41 2019 +0000 +++ b/plover-gtk/transactionhelper.c Wed Jul 15 16:04:47 2020 +0100 @@ -68,6 +68,7 @@ g_free(priv->default_prefix); g_free(helper->error_primary_text); g_free(helper->base); + g_free(helper->base_uri); g_free(helper->unsatisfied); if (helper->comps) plover_comps_free(helper->comps); @@ -583,12 +584,12 @@ plover_transaction_helper_get_upstream(PloverTransactionHelper *helper, GError **error) { - const char *base; + const char *base_uri; g_return_val_if_fail(PLOVER_IS_TRANSACTION_HELPER(helper),NULL); if (!helper->upstream) { - base=plover_transaction_helper_get_base(helper); - helper->upstream=plover_repository_new_from_yum(base,error); + base_uri=plover_transaction_helper_get_base_uri(helper); + helper->upstream=plover_repository_new_from_yum_uri(base_uri,error); } return helper->upstream; } @@ -602,18 +603,53 @@ helper->upstream=g_object_ref(upstream); } +const char * + plover_transaction_helper_get_base_uri(PloverTransactionHelper *helper) +{ + g_return_val_if_fail(PLOVER_IS_TRANSACTION_HELPER(helper),NULL); + return helper->base_uri; +} + +static gboolean plover_gtk__uri_validate(const char *uri) +{ + char *s; + s=razor_path_relative_to_uri(uri,".",NULL); + free(s); + return !!s; +} + +void plover_transaction_helper_set_base_uri(PloverTransactionHelper *helper, + const char *base_uri) +{ + g_return_if_fail(PLOVER_IS_TRANSACTION_HELPER(helper)); + g_return_if_fail(helper->transactions == NULL); + g_return_if_fail(plover_gtk__uri_validate(base_uri)); + g_free(helper->base_uri); + helper->base_uri=g_strdup(base_uri); + g_free(helper->base); + helper->base=NULL; +} + const char *plover_transaction_helper_get_base(PloverTransactionHelper *helper) { g_return_val_if_fail(PLOVER_IS_TRANSACTION_HELPER(helper),NULL); + if (helper->base_uri && !helper->base) + helper->base=razor_path_from_uri(helper->base_uri,NULL); return helper->base; } void plover_transaction_helper_set_base(PloverTransactionHelper *helper, const char *base) { + gchar *base_uri; g_return_if_fail(PLOVER_IS_TRANSACTION_HELPER(helper)); g_return_if_fail(helper->transactions == NULL); - g_free(helper->base); + if (base) + base_uri=razor_path_to_uri(base); + else + base_uri=NULL; + plover_transaction_helper_set_base_uri(helper,base_uri); + g_free(base_uri); helper->base=g_strdup(base); } @@ -623,13 +659,10 @@ { gchar *s; g_return_val_if_fail(PLOVER_IS_TRANSACTION_HELPER(helper),NULL); - if (!helper->comps && helper->base) + if (!helper->comps && helper->base_uri) { - s=g_strconcat(helper->base,"/repodata/comps.xml",NULL); - helper->comps=plover_comps_new_from_file(s); - if (!helper->comps) - g_set_error(error,PLOVER_GENERAL_ERROR, - PLOVER_GENERAL_ERROR_FAILED,"%s: %s",s,g_strerror(errno)); + s=g_strconcat(helper->base_uri,"/repodata/comps.xml",NULL); + helper->comps=plover_comps_new_from_uri(s,error); g_free(s); } return helper->comps; @@ -643,9 +676,9 @@ struct comps *comps; PloverTransactionHelperPrivate *priv; g_return_val_if_fail(PLOVER_IS_TRANSACTION_HELPER(helper),NULL); - g_return_val_if_fail(helper->base != NULL || plover_transaction_helper_get_installed(helper) != NULL,NULL); + g_return_val_if_fail(helper->base_uri != NULL || plover_transaction_helper_get_installed(helper) != NULL,NULL); priv=PLOVER_TRANSACTION_HELPER_GET_PRIVATE(helper); - if (helper->base) + if (helper->base_uri) { comps=plover_transaction_helper_get_comps(helper,error); if (!comps) @@ -951,7 +984,7 @@ GError **error) { gboolean ok; - const char *base,*prefix; + const char *base_uri,*prefix; GError *tmp_error=NULL; PloverTransaction *transaction; g_return_val_if_fail(PLOVER_IS_TRANSACTION_HELPER(helper),NULL); @@ -969,8 +1002,9 @@ ok=plover_transaction_set_upstream(transaction,helper->upstream,error); else { - base=plover_transaction_helper_get_base(helper); - ok=plover_transaction_set_upstream_from_yum(transaction,base,error); + base_uri=plover_transaction_helper_get_base_uri(helper); + ok=plover_transaction_set_upstream_from_yum_uri(transaction,base_uri, + error); } if (!ok) {