1.1 --- a/pre-inst/pre-inst.c Fri Mar 08 13:50:07 2019 +0000
1.2 +++ b/pre-inst/pre-inst.c Mon Jul 13 13:19:03 2020 +0100
1.3 @@ -90,10 +90,11 @@
1.4 unsigned pre_install_thread(void *data)
1.5 {
1.6 int retval;
1.7 - char *path=data;
1.8 + gchar *path=data;
1.9 gchar *s,*uri;
1.10 char *install[]={"plover-gtkui",NULL};
1.11 GError *error=NULL;
1.12 + plover__uri_handler_init();
1.13 prefix=plover_pre_install_prefix();
1.14 s=g_strconcat(prefix,"/var/log/pre-install",NULL);
1.15 plover_log_open(s);
1.16 @@ -105,7 +106,7 @@
1.17 free(uri);
1.18 if (verify_and_fix(prefix))
1.19 {
1.20 - free(path);
1.21 + g_free(path);
1.22 g_free(prefix);
1.23 return -1;
1.24 }
1.25 @@ -117,7 +118,7 @@
1.26 fprintf(stderr,"%s\n",error->message);
1.27 g_error_free(error);
1.28 }
1.29 - free(path);
1.30 + g_free(path);
1.31 #ifdef WIN32
1.32 PostQuitMessage(retval);
1.33 PostThreadMessage(main_thread_id,WM_QUIT,retval,0);
1.34 @@ -455,6 +456,38 @@
1.35 }
1.36 #endif /* WIN32 */
1.37
1.38 +gchar *pre_install_default_path(const char *argv0)
1.39 +{
1.40 + size_t length;
1.41 + void *contents;
1.42 + gchar *path;
1.43 + gchar *s,*uri;
1.44 + struct razor_error *tmp_error=NULL;
1.45 + /*
1.46 + * The default path is the executable itself if it's an archive
1.47 + * or otherwise the directory in which the executable is stored.
1.48 + */
1.49 + path=plover_get_program(argv0);
1.50 + uri=razor_path_to_uri(path);
1.51 + s=g_strconcat(uri,"/repodata/comps.xml",NULL);
1.52 + free(uri);
1.53 + contents=razor_uri_get_contents(s,&length,FALSE,&tmp_error);
1.54 + g_free(s);
1.55 + if (contents)
1.56 + razor_uri_free_contents(contents,length);
1.57 + else
1.58 + {
1.59 + if (razor_error_matches(tmp_error,RAZOR_GENERAL_ERROR,
1.60 + RAZOR_GENERAL_ERROR_UNSUPPORTED_ARCHIVE))
1.61 + {
1.62 + g_free(path);
1.63 + path=plover_get_program_directory(argv0);
1.64 + }
1.65 + razor_error_free(tmp_error);
1.66 + }
1.67 + return path;
1.68 +}
1.69 +
1.70 int main(int argc,char **argv)
1.71 {
1.72 gboolean success,uninstall=FALSE,enable_post=FALSE;
1.73 @@ -512,7 +545,7 @@
1.74 else
1.75 {
1.76 if (!path)
1.77 - path=plover_get_program_directory(argv[0]);
1.78 + path=pre_install_default_path(argv[0]);
1.79 #ifdef WIN32
1.80 success=win32_pre_install_gui(path)==EXIT_SUCCESS;
1.81 #else