# HG changeset patch # User J. Ali Harlow # Date 1624957713 -3600 # Node ID cc42fad3fe31be20ba6565e3f8992b810d276aa5 # Parent bbddb595e36660bebba6170914c788e23aa63203 Add a --paths option to app-manager and use it in setup.js and update.js diff -r bbddb595e366 -r cc42fad3fe31 app-manager/app-manager.c --- a/app-manager/app-manager.c Mon Aug 31 07:12:39 2020 +0100 +++ b/app-manager/app-manager.c Tue Jun 29 10:08:33 2021 +0100 @@ -211,10 +211,42 @@ gtk_window_set_default_icon_name(LOGO_NAME); } +static gboolean uri_validate(const char *uri) +{ + char *s; + s=razor_path_relative_to_uri(uri,".",NULL); + free(s); + return !!s; +} + +char *uri_from_base(const char *base,gboolean use_paths) +{ + char *retval; + if (use_paths) + { + retval=razor_path_to_uri(base); + if (!retval) + { + g_printerr("%s: Not a valid path\n",base); + exit(1); + } + } + else if (!uri_validate(base)) + { + g_printerr("%s: Not a valid URI\n",base); + exit(1); + } + else + retval=strdup(base); + return retval; +} + int main(int argc,char **argv) { + gboolean use_paths=FALSE; GError *err=0; GtkWidget *w; + char *uri; gchar *s,*database_uri,*contents; gchar *database=NULL,*setup_base=NULL,*update_base=NULL; gchar *default_action_base=NULL; @@ -226,12 +258,14 @@ GOptionEntry options[]={ {"database",0,0,G_OPTION_ARG_STRING,&database, "Operate on a distribution-local database","vendor/distribution"}, + {"paths",0,0,G_OPTION_ARG_NONE,&use_paths, + "Interpret locations as paths rather than URIs",NULL}, {"setup",0,0,G_OPTION_ARG_STRING,&setup_base, - "Setup from installation media","uri"}, + "Setup from installation media","location"}, {"update",0,0,G_OPTION_ARG_STRING,&update_base, - "Update from upgrade media","uri"}, + "Update from upgrade media","location"}, {"default-action",0,0,G_OPTION_ARG_STRING,&default_action_base, - "Install, remove or update from repository","uri"}, + "Install, remove or update from repository","location"}, {NULL} }; #ifdef WIN32 @@ -295,11 +329,23 @@ gtk_builder_connect_signals(ui,NULL); gtk_link_button_set_uri_hook(show_uri,NULL,NULL); if (setup_base) - started=setup(setup_base); + { + uri=uri_from_base(setup_base,use_paths); + started=setup(uri); + free(uri); + } else if (update_base) - started=update(update_base); + { + uri=uri_from_base(update_base,use_paths); + started=update(uri); + free(uri); + } else if (default_action_base) - started=default_action(default_action_base); + { + uri=uri_from_base(default_action_base,use_paths); + started=default_action(uri); + free(uri); + } else { if (database) diff -r bbddb595e366 -r cc42fad3fe31 plover-gtk/stockicons.c --- a/plover-gtk/stockicons.c Mon Aug 31 07:12:39 2020 +0100 +++ b/plover-gtk/stockicons.c Tue Jun 29 10:08:33 2021 +0100 @@ -115,7 +115,7 @@ #endif if (!prefix) prefix=g_strdup("/usr"); - datadir=g_strconcat(prefix,"share",NULL); + datadir=g_build_filename(prefix,"share",NULL); g_free(prefix); } if (plover_pixbuf_supports_svg()) diff -r bbddb595e366 -r cc42fad3fe31 plover-gtk/transactionhelper.c --- a/plover-gtk/transactionhelper.c Mon Aug 31 07:12:39 2020 +0100 +++ b/plover-gtk/transactionhelper.c Tue Jun 29 10:08:33 2021 +0100 @@ -492,10 +492,12 @@ g_return_val_if_fail(PLOVER_IS_TRANSACTION_HELPER(helper),NULL); if (!helper->installed) { - comps=plover_transaction_helper_get_comps(helper,NULL); + comps=plover_transaction_helper_get_comps(helper,&error); if (!comps) { - g_warning("plover_transaction_helper_get_installed: No comps"); + g_warning("plover_transaction_helper_get_installed: No comps: %s", + error->message); + g_error_free(error); return NULL; } install_root=getenv("RAZOR_ROOT"); @@ -656,13 +658,22 @@ plover_transaction_helper_get_comps(PloverTransactionHelper *helper, GError **error) { - gchar *s; + char *s; + GError *tmp_err=NULL; g_return_val_if_fail(PLOVER_IS_TRANSACTION_HELPER(helper),NULL); if (!helper->comps && helper->base_uri) { - s=g_strconcat(helper->base_uri,"/repodata/comps.xml",NULL); - helper->comps=plover_comps_new_from_uri(s,error); - g_free(s); + s=razor_path_relative_to_uri(helper->base_uri,"repodata/comps.xml", + NULL); + helper->comps=plover_comps_new_from_uri(s,&tmp_err); + if (!helper->comps) + { + g_warning( + "PloverTransactionHelper: Failed to get comps at '%s': %s", + s,tmp_err->message); + g_propagate_error(error,tmp_err); + } + free(s); } return helper->comps; } diff -r bbddb595e366 -r cc42fad3fe31 setup/setup.js.in --- a/setup/setup.js.in Mon Aug 31 07:12:39 2020 +0100 +++ b/setup/setup.js.in Tue Jun 29 10:08:33 2021 +0100 @@ -57,7 +57,7 @@ { path = FileSystemObject.BuildPath(install_prefix, "bin\\app-manager.exe"); - WshShell.Run("\"" + path + "\" --setup \"" + ScriptPath + "\""); + WshShell.Run("\"" + path + "\" --paths --setup \"" + ScriptPath + "\""); } else { diff -r bbddb595e366 -r cc42fad3fe31 update/update.js.in --- a/update/update.js.in Mon Aug 31 07:12:39 2020 +0100 +++ b/update/update.js.in Tue Jun 29 10:08:33 2021 +0100 @@ -49,7 +49,8 @@ { path = FileSystemObject.BuildPath(install_prefix, "bin\\app-manager.exe"); - WshShell.Run("\"" + path + "\" --update \"" + ScriptPath + "\""); + WshShell.Run("\"" + path + "\" --paths " + + "--update \"" + ScriptPath + "\""); } else {