1.1 --- a/update/update.c Thu Aug 13 19:01:16 2009 +0100
1.2 +++ b/update/update.c Tue Feb 21 22:55:40 2012 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /*
1.5 - * Copyright (C) 2009 J. Ali Harlow <ali@juiblex.co.uk>
1.6 + * Copyright (C) 2009, 2011 J. Ali Harlow <ali@juiblex.co.uk>
1.7 *
1.8 * This program is free software; you can redistribute it and/or modify
1.9 * it under the terms of the GNU General Public License as published by
1.10 @@ -17,6 +17,7 @@
1.11 */
1.12
1.13 #include <stdlib.h>
1.14 +#include <stdio.h>
1.15 #include <lua.h>
1.16 #include "config.h"
1.17 #include "plover/plover.h"
1.18 @@ -27,6 +28,7 @@
1.19 void update(const char *argv0)
1.20 {
1.21 char *path,*s,*prefix;
1.22 + int ch;
1.23 struct comps *comps;
1.24 path=plover_get_program_directory(argv0);
1.25 s=plover_strconcat(path,"/repodata/comps.xml",NULL);
1.26 @@ -38,6 +40,18 @@
1.27 }
1.28 free(s);
1.29 prefix=plover_default_prefix_for_vendor(comps->vendor);
1.30 + if (!plover_installed_files_match_prefix(prefix))
1.31 + {
1.32 + printf("The existing installation is not under %s\n"
1.33 + "In order to continue, all the existing packages must be removed.\n"
1.34 + "Do you want to remove all existing packages? ",prefix);
1.35 + ch=getchar();
1.36 + if (ch!='y' && ch!='Y' && ch!=EOF && ch!='\n')
1.37 + exit(1);
1.38 + while(ch!='\n' && ch!=EOF)
1.39 + ch=getchar();
1.40 + plover_remove(NULL);
1.41 + }
1.42 plover_comps_free(comps);
1.43 plover_update(path,prefix,NULL);
1.44 free(prefix);
1.45 @@ -49,4 +63,5 @@
1.46 razor_set_lua_loader("posix",luaopen_posix);
1.47 razor_set_lua_loader("whelk",luaopen_whelk);
1.48 update(argv[0]);
1.49 + exit(0);
1.50 }