1.1 --- a/.gitignore Thu Aug 13 12:42:26 2009 +0100
1.2 +++ b/.gitignore Thu Aug 13 19:01:16 2009 +0100
1.3 @@ -16,3 +16,5 @@
1.4 plover/plover.pc
1.5 setup/resources.rc
1.6 setup/setup
1.7 +update/resources.rc
1.8 +update/update
2.1 --- a/Makefile.am Thu Aug 13 12:42:26 2009 +0100
2.2 +++ b/Makefile.am Thu Aug 13 19:01:16 2009 +0100
2.3 @@ -1,1 +1,1 @@
2.4 -SUBDIRS=plover setup
2.5 +SUBDIRS=plover setup update
3.1 --- a/configure.ac Thu Aug 13 12:42:26 2009 +0100
3.2 +++ b/configure.ac Thu Aug 13 19:01:16 2009 +0100
3.3 @@ -1,7 +1,7 @@
3.4 # -*- Autoconf -*-
3.5 # Process this file with autoconf to produce a configure script.
3.6
3.7 -AC_INIT([plover],[0.1],[ali@juiblex.co.uk])
3.8 +AC_INIT([plover],[0.2],[ali@juiblex.co.uk])
3.9 AC_PREREQ(2.59)
3.10 AC_CONFIG_AUX_DIR([config])
3.11 AC_CONFIG_SRCDIR([plover/plover.h])
3.12 @@ -11,6 +11,8 @@
3.13 plover/plover.pc
3.14 setup/Makefile
3.15 setup/resources.rc
3.16 +update/Makefile
3.17 +update/resources.rc
3.18 ])
3.19 AM_INIT_AUTOMAKE(no-define)
3.20 case $VERSION in
4.1 --- a/plover/plover.h Thu Aug 13 12:42:26 2009 +0100
4.2 +++ b/plover/plover.h Thu Aug 13 19:01:16 2009 +0100
4.3 @@ -34,6 +34,8 @@
4.4 };
4.5
4.6 char *plover_strconcat(const char *string,...);
4.7 +char *plover_default_prefix_for_vendor(const char *vendor);
4.8 +char *plover_get_program_directory(const char *argv0);
4.9
4.10 struct razor_set *plover_razor_set_create_from_yum(const char *base);
4.11
5.1 --- a/plover/razor.c Thu Aug 13 12:42:26 2009 +0100
5.2 +++ b/plover/razor.c Thu Aug 13 19:01:16 2009 +0100
5.3 @@ -262,6 +262,91 @@
5.4 return razor_root_commit(root);
5.5 }
5.6
5.7 +int plover_update(const char *base,const char *prefix,char **pkgs)
5.8 +{
5.9 + int i;
5.10 + char *install_root,*s;
5.11 + struct razor_root *root;
5.12 + struct razor_set *system,*set,*upstream,*next;
5.13 + struct razor_transaction *trans;
5.14 + struct razor_relocations *relocations;
5.15 + install_root=getenv("RAZOR_ROOT");
5.16 + if (!install_root)
5.17 + install_root="";
5.18 + if (prefix)
5.19 + {
5.20 + relocations=razor_relocations_create();
5.21 + razor_relocations_add(relocations,"/usr",prefix);
5.22 + }
5.23 + set=razor_root_open_read_only(install_root);
5.24 + if (!set)
5.25 + return 0;
5.26 + razor_set_destroy(set);
5.27 + root=razor_root_open(install_root);
5.28 + if (!root)
5.29 + return -1;
5.30 + system=razor_root_get_system_set(root);
5.31 + if (!system)
5.32 + {
5.33 + razor_root_close(root);
5.34 + return -1;
5.35 + }
5.36 + s=plover_strconcat(base,"/repodata",NULL);
5.37 + if (!s)
5.38 + {
5.39 + razor_root_close(root);
5.40 + return -1;
5.41 + }
5.42 + if (chdir(s)<0)
5.43 + {
5.44 + perror(s);
5.45 + free(s);
5.46 + razor_root_close(root);
5.47 + return -1;
5.48 + }
5.49 + free(s);
5.50 + set=plover_razor_set_create_from_yum(base);
5.51 + if (!set)
5.52 + {
5.53 + razor_root_close(root);
5.54 + return -1;
5.55 + }
5.56 + upstream=plover_relocate_packages(set,base,relocations);
5.57 + razor_set_destroy(set);
5.58 + trans=razor_transaction_create(system,upstream);
5.59 + if (pkgs)
5.60 + for(i=0;pkgs[i];i++)
5.61 + {
5.62 + if (plover_mark_package_for_update(trans,system,pkgs[i]))
5.63 + {
5.64 + fprintf(stderr,"%s: Package not found\n",pkgs[i]);
5.65 + razor_transaction_destroy(trans);
5.66 + razor_set_destroy(upstream);
5.67 + razor_set_destroy(system);
5.68 + razor_root_close(root);
5.69 + return -1;
5.70 + }
5.71 + }
5.72 + else
5.73 + razor_transaction_update_all(trans);
5.74 + razor_transaction_resolve(trans);
5.75 + if (razor_transaction_describe(trans)>0)
5.76 + {
5.77 + razor_transaction_destroy(trans);
5.78 + razor_set_destroy(upstream);
5.79 + razor_set_destroy(system);
5.80 + razor_root_close(root);
5.81 + return -1;
5.82 + }
5.83 + next=razor_transaction_commit(trans);
5.84 + plover_run_transaction(trans,base,install_root,system,next,relocations);
5.85 + razor_root_update(root,next);
5.86 + razor_transaction_destroy(trans);
5.87 + razor_set_destroy(next);
5.88 + razor_set_destroy(upstream);
5.89 + return razor_root_commit(root);
5.90 +}
5.91 +
5.92 static int plover_mark_packages_for_removal(struct razor_transaction *trans,
5.93 struct razor_set *set,const char *pkg)
5.94 {
6.1 --- a/plover/util.c Thu Aug 13 12:42:26 2009 +0100
6.2 +++ b/plover/util.c Thu Aug 13 19:01:16 2009 +0100
6.3 @@ -19,6 +19,11 @@
6.4 #include <stdlib.h>
6.5 #include <stdarg.h>
6.6 #include <string.h>
6.7 +#include <limits.h>
6.8 +#ifdef WIN32
6.9 +#include <windows.h>
6.10 +#include <shlobj.h>
6.11 +#endif
6.12 #include "config.h"
6.13 #include "plover.h"
6.14
6.15 @@ -51,3 +56,46 @@
6.16 }
6.17 return result;
6.18 }
6.19 +
6.20 +char *plover_default_prefix_for_vendor(const char *vendor)
6.21 +{
6.22 +#ifdef WIN32
6.23 + char path[PATH_MAX];
6.24 + SHGetFolderPath(NULL,CSIDL_PROGRAM_FILES|CSIDL_FLAG_DONT_VERIFY,NULL,0,
6.25 + path);
6.26 + return plover_strconcat(path,"\\",vendor?vendor:"Plover",NULL);
6.27 +#else
6.28 + return NULL;
6.29 +#endif
6.30 +}
6.31 +
6.32 +/*
6.33 + * Get the directory containing the program executable.
6.34 + */
6.35 +
6.36 +char *plover_get_program_directory(const char *argv0)
6.37 +{
6.38 + char *s;
6.39 +#ifdef WIN32
6.40 + char path[PATH_MAX],*t;
6.41 + GetModuleFileName(NULL,path,sizeof(path));
6.42 + s=strrchr(path,'/');
6.43 + if (s)
6.44 + {
6.45 + t=strrchr(s,'\\');
6.46 + if (t)
6.47 + s=t;
6.48 + }
6.49 + else
6.50 + s=strrchr(path,'\\');
6.51 + if (s)
6.52 + *s='\0';
6.53 + return strdup(path);
6.54 +#else
6.55 + s=argv0?strrchr(argv0,'/'):NULL;
6.56 + if (s)
6.57 + return strndup(argv0,s-argv0);
6.58 + else
6.59 + return strdup(".");
6.60 +#endif
6.61 +}
7.1 --- a/setup/setup.c Thu Aug 13 12:42:26 2009 +0100
7.2 +++ b/setup/setup.c Thu Aug 13 19:01:16 2009 +0100
7.3 @@ -86,34 +86,15 @@
7.4 return realloc(ptr,nsize);
7.5 }
7.6
7.7 -void setup()
7.8 +void setup(const char *argv0)
7.9 {
7.10 - char path[PATH_MAX],*s,*t,*prefix;
7.11 + char *path,*s,*prefix;
7.12 int changed;
7.13 struct comps *comps;
7.14 struct comps_group *group;
7.15 struct comps_requirement *pkg;
7.16 struct vector *packages=NULL;
7.17 -#ifdef WIN32
7.18 - SHGetFolderPath(NULL,CSIDL_PROGRAM_FILES|CSIDL_FLAG_DONT_VERIFY,NULL,0,
7.19 - path);
7.20 - prefix=strdup(path);
7.21 - GetModuleFileName(NULL,path,sizeof(path));
7.22 - s=strrchr(path,'/');
7.23 - if (s)
7.24 - {
7.25 - t=strrchr(s,'\\');
7.26 - if (t)
7.27 - s=t;
7.28 - }
7.29 - else
7.30 - s=strrchr(path,'\\');
7.31 - if (s)
7.32 - *s='\0';
7.33 -#else
7.34 - strcpy(path,"/tmp");
7.35 - prefix=NULL;
7.36 -#endif
7.37 + path=plover_get_program_directory(argv0);
7.38 s=plover_strconcat(path,"/repodata/comps.xml",NULL);
7.39 comps=plover_comps_new_from_file(s);
7.40 if (!comps)
7.41 @@ -122,11 +103,7 @@
7.42 exit(1);
7.43 }
7.44 free(s);
7.45 -#ifdef WIN32
7.46 - s=plover_strconcat(prefix,"\\",comps->vendor?comps->vendor:"Plover",NULL);
7.47 - free(prefix);
7.48 - prefix=s;
7.49 -#endif
7.50 + prefix=plover_default_prefix_for_vendor(comps->vendor);
7.51 group=plover_comps_lookup_group(comps,"base");
7.52 if (!group)
7.53 {
7.54 @@ -151,6 +128,7 @@
7.55 }
7.56 }
7.57 } while(changed);
7.58 + plover_comps_free(comps);
7.59 if (!packages->len)
7.60 {
7.61 fprintf(stderr,"No packages to install\n");
7.62 @@ -158,10 +136,8 @@
7.63 }
7.64 plover_install(path,prefix,packages->strings);
7.65 vector_free(packages);
7.66 - plover_comps_free(comps);
7.67 -#ifdef WIN32
7.68 free(prefix);
7.69 -#endif
7.70 + free(path);
7.71 }
7.72
7.73 int main(int argc,char **argv)
7.74 @@ -171,5 +147,5 @@
7.75 if (argc>1 && !strcmp(argv[1],"-u"))
7.76 plover_remove(NULL);
7.77 else
7.78 - setup();
7.79 + setup(argv[0]);
7.80 }
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/update/Makefile.am Thu Aug 13 19:01:16 2009 +0100
8.3 @@ -0,0 +1,22 @@
8.4 +AM_CFLAGS=-g $(SETUP_CFLAGS)
8.5 +LDADD=../plover/libplover.la $(SETUP_LIBS)
8.6 +INCLUDES=-I$(top_srcdir)
8.7 +
8.8 +bin_PROGRAMS=update
8.9 +
8.10 +update_SOURCES=update.c
8.11 +update_LDFLAGS=-all-static
8.12 +if HAVE_WINDRES
8.13 +update_SOURCES+=resources.rc
8.14 +endif
8.15 +
8.16 +.png.pnm:
8.17 + pngtopnm $< | pnmquant 256 > $@
8.18 +
8.19 +resources.$(OBJEXT): resources.rc update.ico
8.20 + $(WINDRES) resources.rc $@
8.21 +
8.22 +update.ico: icon16.pnm icon22.pnm icon32.pnm
8.23 + ppmtowinicon -output=$@ $^
8.24 +
8.25 +EXTRA_DIST=icon16.png icon22.png icon32.png
9.1 Binary file update/icon16.png has changed
10.1 Binary file update/icon22.png has changed
11.1 Binary file update/icon32.png has changed
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
12.2 +++ b/update/resources.rc.in Thu Aug 13 19:01:16 2009 +0100
12.3 @@ -0,0 +1,32 @@
12.4 +#include <winver.h>
12.5 +
12.6 +MAINICON ICON "update.ico"
12.7 +
12.8 +VS_VERSION_INFO VERSIONINFO
12.9 + FILEVERSION @PLOVER_MAJOR_VERSION@,@PLOVER_MINOR_VERSION@,@PLOVER_MICRO_VERS
12.10 +ION@,0
12.11 + PRODUCTVERSION @PLOVER_MAJOR_VERSION@,@PLOVER_MINOR_VERSION@,@PLOVER_MICRO_V
12.12 +ERSION@,0
12.13 + FILEOS VOS__WINDOWS32
12.14 + FILETYPE VFT_APP
12.15 + {
12.16 + BLOCK "StringFileInfo"
12.17 + {
12.18 + BLOCK "080904B0"
12.19 + {
12.20 + VALUE "CompanyName","The plover development team"
12.21 + VALUE "FileDescription","Plover setup program"
12.22 + VALUE "FileVersion","@PACKAGE_VERSION@"
12.23 + VALUE "InternalName","update"
12.24 + VALUE "LegalCopyright",
12.25 + "Copyright (c) 2009 J. Ali Harlow et al"
12.26 + VALUE "OriginalFilename","update.exe"
12.27 + VALUE "ProductName","plover"
12.28 + VALUE "ProductVersion","@PACKAGE_VERSION@"
12.29 + }
12.30 + }
12.31 + BLOCK "VarFileInfo"
12.32 + {
12.33 + VALUE "Translation",0x809,0x4B0
12.34 + }
12.35 + }
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
13.2 +++ b/update/update.c Thu Aug 13 19:01:16 2009 +0100
13.3 @@ -0,0 +1,52 @@
13.4 +/*
13.5 + * Copyright (C) 2009 J. Ali Harlow <ali@juiblex.co.uk>
13.6 + *
13.7 + * This program is free software; you can redistribute it and/or modify
13.8 + * it under the terms of the GNU General Public License as published by
13.9 + * the Free Software Foundation; either version 2 of the License, or
13.10 + * (at your option) any later version.
13.11 + *
13.12 + * This program is distributed in the hope that it will be useful,
13.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
13.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13.15 + * GNU General Public License for more details.
13.16 + *
13.17 + * You should have received a copy of the GNU General Public License along
13.18 + * with this program; if not, write to the Free Software Foundation, Inc.,
13.19 + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
13.20 + */
13.21 +
13.22 +#include <stdlib.h>
13.23 +#include <lua.h>
13.24 +#include "config.h"
13.25 +#include "plover/plover.h"
13.26 +#include "whelk/whelk.h"
13.27 +
13.28 +LUALIB_API int luaopen_posix(lua_State *L);
13.29 +
13.30 +void update(const char *argv0)
13.31 +{
13.32 + char *path,*s,*prefix;
13.33 + struct comps *comps;
13.34 + path=plover_get_program_directory(argv0);
13.35 + s=plover_strconcat(path,"/repodata/comps.xml",NULL);
13.36 + comps=plover_comps_new_from_file(s);
13.37 + if (!comps)
13.38 + {
13.39 + perror(s);
13.40 + exit(1);
13.41 + }
13.42 + free(s);
13.43 + prefix=plover_default_prefix_for_vendor(comps->vendor);
13.44 + plover_comps_free(comps);
13.45 + plover_update(path,prefix,NULL);
13.46 + free(prefix);
13.47 + free(path);
13.48 +}
13.49 +
13.50 +int main(int argc,char **argv)
13.51 +{
13.52 + razor_set_lua_loader("posix",luaopen_posix);
13.53 + razor_set_lua_loader("whelk",luaopen_whelk);
13.54 + update(argv[0]);
13.55 +}