1.1 --- a/plover/razor.c Thu Jul 07 19:03:54 2016 +0100
1.2 +++ b/plover/razor.c Fri Jul 08 08:26:29 2016 +0100
1.3 @@ -205,6 +205,30 @@
1.4 return retval;
1.5 }
1.6
1.7 +gboolean plover_update_uri(const char *base_uri,const char *prefix,char **pkgs,
1.8 + GError **error)
1.9 +{
1.10 + gboolean retval;
1.11 + GError *tmp_error=NULL;
1.12 + PloverTransaction *transaction;
1.13 + transaction=plover_transaction_new_update_uri(base_uri,prefix,pkgs,
1.14 + &tmp_error);
1.15 + if (!transaction)
1.16 + {
1.17 + retval=g_error_matches(tmp_error,PLOVER_POSIX_ERROR,ENOENT);
1.18 + if (retval)
1.19 + g_error_free(tmp_error);
1.20 + else
1.21 + g_propagate_error(error,tmp_error);
1.22 + }
1.23 + else
1.24 + {
1.25 + retval=plover_transaction_commit(transaction,NULL,error);
1.26 + g_object_unref(transaction);
1.27 + }
1.28 + return retval;
1.29 +}
1.30 +
1.31 gboolean plover_update(const char *base,const char *prefix,char **pkgs,
1.32 GError **error)
1.33 {
2.1 --- a/plover/transaction.c Thu Jul 07 19:03:54 2016 +0100
2.2 +++ b/plover/transaction.c Fri Jul 08 08:26:29 2016 +0100
2.3 @@ -630,6 +630,26 @@
2.4 return transaction;
2.5 }
2.6
2.7 +PloverTransaction *plover_transaction_new_update_uri(const char *base_uri,
2.8 + const char *prefix,char **pkgs,GError **error)
2.9 +{
2.10 + PloverTransaction *transaction;
2.11 + transaction=plover_transaction_new();
2.12 + plover_transaction_set_prefix(transaction,prefix);
2.13 + if (!plover_transaction_set_upstream_from_yum_uri(transaction,base_uri,
2.14 + error))
2.15 + {
2.16 + g_object_unref(transaction);
2.17 + return NULL;
2.18 + }
2.19 + if (!plover_transaction_update(transaction,pkgs,error))
2.20 + {
2.21 + g_object_unref(transaction);
2.22 + return NULL;
2.23 + }
2.24 + return transaction;
2.25 +}
2.26 +
2.27 PloverTransaction *plover_transaction_new_update(const char *base,
2.28 const char *prefix,char **pkgs,GError **error)
2.29 {
3.1 --- a/plover/transaction.h Thu Jul 07 19:03:54 2016 +0100
3.2 +++ b/plover/transaction.h Fri Jul 08 08:26:29 2016 +0100
3.3 @@ -65,6 +65,8 @@
3.4 const char *prefix,char **pkgs,GError **error);
3.5 gboolean plover_transaction_update(PloverTransaction *transaction,
3.6 char **pkgs,GError **error);
3.7 +PloverTransaction *plover_transaction_new_update_uri(const char *base_uri,
3.8 + const char *prefix,char **pkgs,GError **error);
3.9 PloverTransaction *plover_transaction_new_update(const char *base,
3.10 const char *prefix,char **pkgs,GError **error);
3.11 gboolean plover_transaction_remove(PloverTransaction *transaction,
4.1 --- a/plover/util.c Thu Jul 07 19:03:54 2016 +0100
4.2 +++ b/plover/util.c Fri Jul 08 08:26:29 2016 +0100
4.3 @@ -231,6 +231,17 @@
4.4 return path;
4.5 }
4.6
4.7 +char *plover_get_program(const char *argv0)
4.8 +{
4.9 +#ifdef WIN32
4.10 + char path[PATH_MAX];
4.11 + GetModuleFileName(NULL,path,sizeof(path));
4.12 + return strdup(path);
4.13 +#else
4.14 + return strdup(argv0);
4.15 +#endif
4.16 +}
4.17 +
4.18 /*
4.19 * Get the directory containing the program executable.
4.20 */
5.1 --- a/update/updatez.c Thu Jul 07 19:03:54 2016 +0100
5.2 +++ b/update/updatez.c Fri Jul 08 08:26:29 2016 +0100
5.3 @@ -1,5 +1,5 @@
5.4 /*
5.5 - * Copyright (C) 2009, 2011 J. Ali Harlow <ali@juiblex.co.uk>
5.6 + * Copyright (C) 2009, 2011, 2016 J. Ali Harlow <ali@juiblex.co.uk>
5.7 *
5.8 * This program is free software; you can redistribute it and/or modify
5.9 * it under the terms of the GNU General Public License as published by
5.10 @@ -25,16 +25,18 @@
5.11
5.12 LUALIB_API int luaopen_posix(lua_State *L);
5.13
5.14 -void update(const char *argv0)
5.15 +void update_from_executable_zip(const char *argv0)
5.16 {
5.17 - char *path;
5.18 + char *uri;
5.19 gchar *s,*prefix;
5.20 int ch;
5.21 struct comps *comps;
5.22 GError *error=NULL;
5.23 - path=plover_get_program_directory(argv0);
5.24 - s=g_strconcat(path,"/repodata/comps.xml",NULL);
5.25 - comps=plover_comps_new_from_file(s);
5.26 + s=plover_get_program(argv0);
5.27 + uri=g_strconcat("file:",s,NULL);
5.28 + g_free(s);
5.29 + s=g_strconcat(uri,"/repodata/comps.xml",NULL);
5.30 + comps=plover_comps_new_from_uri(s);
5.31 if (!comps)
5.32 {
5.33 perror(s);
5.34 @@ -60,14 +62,14 @@
5.35 }
5.36 }
5.37 plover_comps_free(comps);
5.38 - if (!plover_update(path,prefix,NULL,&error))
5.39 + if (!plover_update_uri(uri,prefix,NULL,&error))
5.40 {
5.41 fprintf(stderr,"%s\n",error->message);
5.42 g_error_free(error);
5.43 exit(1);
5.44 }
5.45 g_free(prefix);
5.46 - free(path);
5.47 + free(uri);
5.48 }
5.49
5.50 int main(int argc,char **argv)
5.51 @@ -75,6 +77,6 @@
5.52 plover_exception_handler_init();
5.53 razor_set_lua_loader("posix",(void (*)())luaopen_posix);
5.54 razor_set_lua_loader("whelk",(void (*)())luaopen_whelk);
5.55 - update(argv[0]);
5.56 + update_from_executable_zip(argv[0]);
5.57 exit(0);
5.58 }