ali@3: /* ali@59: * Copyright (C) 2009, 2011, 2016 J. Ali Harlow ali@3: * ali@3: * This program is free software; you can redistribute it and/or modify ali@3: * it under the terms of the GNU General Public License as published by ali@3: * the Free Software Foundation; either version 2 of the License, or ali@3: * (at your option) any later version. ali@3: * ali@3: * This program is distributed in the hope that it will be useful, ali@3: * but WITHOUT ANY WARRANTY; without even the implied warranty of ali@3: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ali@3: * GNU General Public License for more details. ali@3: * ali@3: * You should have received a copy of the GNU General Public License along ali@3: * with this program; if not, write to the Free Software Foundation, Inc., ali@3: * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. ali@3: */ ali@3: ali@3: #include ali@13: #include ali@3: #include ali@3: #include "config.h" ali@3: #include "plover/plover.h" ali@3: #include "whelk/whelk.h" ali@3: ali@3: LUALIB_API int luaopen_posix(lua_State *L); ali@3: ali@59: void update_from_executable_zip(const char *argv0) ali@3: { ali@59: char *uri; ali@24: gchar *s,*prefix; ali@13: int ch; ali@3: struct comps *comps; ali@24: GError *error=NULL; ali@59: s=plover_get_program(argv0); ali@59: uri=g_strconcat("file:",s,NULL); ali@59: g_free(s); ali@59: s=g_strconcat(uri,"/repodata/comps.xml",NULL); ali@59: comps=plover_comps_new_from_uri(s); ali@3: if (!comps) ali@3: { ali@3: perror(s); ali@3: exit(1); ali@3: } ali@24: g_free(s); ali@3: prefix=plover_default_prefix_for_vendor(comps->vendor); ali@13: if (!plover_installed_files_match_prefix(prefix)) ali@13: { ali@13: printf("The existing installation is not under %s\n" ali@13: "In order to continue, all the existing packages must be removed.\n" ali@13: "Do you want to remove all existing packages? ",prefix); ali@13: ch=getchar(); ali@13: if (ch!='y' && ch!='Y' && ch!=EOF && ch!='\n') ali@13: exit(1); ali@13: while(ch!='\n' && ch!=EOF) ali@13: ch=getchar(); ali@24: if (plover_remove(NULL,&error)) ali@24: { ali@24: fprintf(stderr,"%s\n",error->message); ali@24: g_error_free(error); ali@24: exit(1); ali@24: } ali@13: } ali@3: plover_comps_free(comps); ali@59: if (!plover_update_uri(uri,prefix,NULL,&error)) ali@24: { ali@24: fprintf(stderr,"%s\n",error->message); ali@24: g_error_free(error); ali@24: exit(1); ali@24: } ali@24: g_free(prefix); ali@59: free(uri); ali@3: } ali@3: ali@3: int main(int argc,char **argv) ali@3: { ali@31: plover_exception_handler_init(); ali@38: razor_set_lua_loader("posix",(void (*)())luaopen_posix); ali@38: razor_set_lua_loader("whelk",(void (*)())luaopen_whelk); ali@59: update_from_executable_zip(argv[0]); ali@13: exit(0); ali@3: }