# HG changeset patch # User J. Ali Harlow # Date 1594825487 -3600 # Node ID 71127797ca73adc53ea8bc5d51a863687cd2ccc4 # Parent 55ae076f393c56e3ea02b9a213730ec6f016c096 app-manager --update and --setup are documented to take URIs but they are not treated as such diff -r 55ae076f393c -r 71127797ca73 app-manager/setup.c --- a/app-manager/setup.c Tue Jul 14 18:03:26 2020 +0100 +++ b/app-manager/setup.c Wed Jul 15 16:04:47 2020 +0100 @@ -38,7 +38,7 @@ if (!helper) { helper=plover_transaction_helper_new(ui); - plover_transaction_helper_set_base(helper,base); + plover_transaction_helper_set_base_uri(helper,base); prefix=plover_transaction_helper_get_prefix(helper,&error); if (error) g_clear_error(&error); diff -r 55ae076f393c -r 71127797ca73 app-manager/update.c --- a/app-manager/update.c Tue Jul 14 18:03:26 2020 +0100 +++ b/app-manager/update.c Wed Jul 15 16:04:47 2020 +0100 @@ -39,7 +39,7 @@ if (!helper) { helper=plover_transaction_helper_new(ui); - plover_transaction_helper_set_base(helper,base); + plover_transaction_helper_set_base_uri(helper,base); prefix=plover_transaction_helper_get_prefix(helper,&error); if (error) g_clear_error(&error); diff -r 55ae076f393c -r 71127797ca73 plover-gtk/transactionhelper.c --- a/plover-gtk/transactionhelper.c Tue Jul 14 18:03:26 2020 +0100 +++ 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) { diff -r 55ae076f393c -r 71127797ca73 plover-gtk/transactionhelper.h --- a/plover-gtk/transactionhelper.h Tue Jul 14 18:03:26 2020 +0100 +++ b/plover-gtk/transactionhelper.h Wed Jul 15 16:04:47 2020 +0100 @@ -36,7 +36,7 @@ PloverPackageSet *alternate_installed,*installed; PloverRepository *upstream; PloverPackageSet *relocated_upstream; - gchar *base; + gchar *base_uri,*base; gchar *unsatisfied; struct comps *comps; gboolean check_vendor; @@ -67,6 +67,10 @@ GError **error); void plover_transaction_helper_set_upstream(PloverTransactionHelper *helper, PloverRepository *upstream); +const char * + plover_transaction_helper_get_base_uri(PloverTransactionHelper *helper); +void plover_transaction_helper_set_base_uri(PloverTransactionHelper *helper, + const char *base); const char *plover_transaction_helper_get_base(PloverTransactionHelper *helper); void plover_transaction_helper_set_base(PloverTransactionHelper *helper, const char *base);