update/update.c
author J. Ali Harlow <ali@juiblex.co.uk>
Thu Nov 10 11:15:09 2011 +0000 (2011-11-10)
changeset 13 b0a35bae4961
parent 3 868db5c1f2d7
child 24 2b9f54d14cc2
permissions -rw-r--r--
Support razor 0.5 (atomic transactions).
Don't create repositories with multiple roots.
Filter out "other" arches from yum repositories.
Mark win32 binaries as needing elevated privileges.
ali@3
     1
/*
ali@13
     2
 * Copyright (C) 2009, 2011  J. Ali Harlow <ali@juiblex.co.uk>
ali@3
     3
 *
ali@3
     4
 * This program is free software; you can redistribute it and/or modify
ali@3
     5
 * it under the terms of the GNU General Public License as published by
ali@3
     6
 * the Free Software Foundation; either version 2 of the License, or
ali@3
     7
 * (at your option) any later version.
ali@3
     8
 *
ali@3
     9
 * This program is distributed in the hope that it will be useful,
ali@3
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ali@3
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ali@3
    12
 * GNU General Public License for more details.
ali@3
    13
 *
ali@3
    14
 * You should have received a copy of the GNU General Public License along
ali@3
    15
 * with this program; if not, write to the Free Software Foundation, Inc.,
ali@3
    16
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
ali@3
    17
 */
ali@3
    18
ali@3
    19
#include <stdlib.h>
ali@13
    20
#include <stdio.h>
ali@3
    21
#include <lua.h>
ali@3
    22
#include "config.h"
ali@3
    23
#include "plover/plover.h"
ali@3
    24
#include "whelk/whelk.h"
ali@3
    25
ali@3
    26
LUALIB_API int luaopen_posix(lua_State *L);
ali@3
    27
ali@3
    28
void update(const char *argv0)
ali@3
    29
{
ali@3
    30
    char *path,*s,*prefix;
ali@13
    31
    int ch;
ali@3
    32
    struct comps *comps;
ali@3
    33
    path=plover_get_program_directory(argv0);
ali@3
    34
    s=plover_strconcat(path,"/repodata/comps.xml",NULL);
ali@3
    35
    comps=plover_comps_new_from_file(s);
ali@3
    36
    if (!comps)
ali@3
    37
    {
ali@3
    38
	perror(s);
ali@3
    39
	exit(1);
ali@3
    40
    }
ali@3
    41
    free(s);
ali@3
    42
    prefix=plover_default_prefix_for_vendor(comps->vendor);
ali@13
    43
    if (!plover_installed_files_match_prefix(prefix))
ali@13
    44
    {
ali@13
    45
	printf("The existing installation is not under %s\n"
ali@13
    46
	  "In order to continue, all the existing packages must be removed.\n"
ali@13
    47
	  "Do you want to remove all existing packages? ",prefix);
ali@13
    48
	ch=getchar();
ali@13
    49
	if (ch!='y' && ch!='Y' && ch!=EOF && ch!='\n')
ali@13
    50
	    exit(1);
ali@13
    51
	while(ch!='\n' && ch!=EOF)
ali@13
    52
	    ch=getchar();
ali@13
    53
	plover_remove(NULL);
ali@13
    54
    }
ali@3
    55
    plover_comps_free(comps);
ali@3
    56
    plover_update(path,prefix,NULL);
ali@3
    57
    free(prefix);
ali@3
    58
    free(path);
ali@3
    59
}
ali@3
    60
ali@3
    61
int main(int argc,char **argv)
ali@3
    62
{
ali@3
    63
    razor_set_lua_loader("posix",luaopen_posix);
ali@3
    64
    razor_set_lua_loader("whelk",luaopen_whelk);
ali@3
    65
    update(argv[0]);
ali@13
    66
    exit(0);
ali@3
    67
}