1.1 --- a/setup/setup.c Thu Jul 09 08:23:50 2009 +0100
1.2 +++ b/setup/setup.c Thu Feb 11 19:47:47 2010 +0000
1.3 @@ -86,34 +86,15 @@
1.4 return realloc(ptr,nsize);
1.5 }
1.6
1.7 -void setup()
1.8 +void setup(const char *argv0)
1.9 {
1.10 - char path[PATH_MAX],*s,*t,*prefix;
1.11 + char *path,*s,*prefix;
1.12 int changed;
1.13 struct comps *comps;
1.14 struct comps_group *group;
1.15 struct comps_requirement *pkg;
1.16 struct vector *packages=NULL;
1.17 -#ifdef WIN32
1.18 - SHGetFolderPath(NULL,CSIDL_PROGRAM_FILES|CSIDL_FLAG_DONT_VERIFY,NULL,0,
1.19 - path);
1.20 - prefix=strdup(path);
1.21 - GetModuleFileName(NULL,path,sizeof(path));
1.22 - s=strrchr(path,'/');
1.23 - if (s)
1.24 - {
1.25 - t=strrchr(s,'\\');
1.26 - if (t)
1.27 - s=t;
1.28 - }
1.29 - else
1.30 - s=strrchr(path,'\\');
1.31 - if (s)
1.32 - *s='\0';
1.33 -#else
1.34 - strcpy(path,"/tmp");
1.35 - prefix=NULL;
1.36 -#endif
1.37 + path=plover_get_program_directory(argv0);
1.38 s=plover_strconcat(path,"/repodata/comps.xml",NULL);
1.39 comps=plover_comps_new_from_file(s);
1.40 if (!comps)
1.41 @@ -122,11 +103,7 @@
1.42 exit(1);
1.43 }
1.44 free(s);
1.45 -#ifdef WIN32
1.46 - s=plover_strconcat(prefix,"\\",comps->vendor?comps->vendor:"Plover",NULL);
1.47 - free(prefix);
1.48 - prefix=s;
1.49 -#endif
1.50 + prefix=plover_default_prefix_for_vendor(comps->vendor);
1.51 group=plover_comps_lookup_group(comps,"base");
1.52 if (!group)
1.53 {
1.54 @@ -151,6 +128,7 @@
1.55 }
1.56 }
1.57 } while(changed);
1.58 + plover_comps_free(comps);
1.59 if (!packages->len)
1.60 {
1.61 fprintf(stderr,"No packages to install\n");
1.62 @@ -158,10 +136,8 @@
1.63 }
1.64 plover_install(path,prefix,packages->strings);
1.65 vector_free(packages);
1.66 - plover_comps_free(comps);
1.67 -#ifdef WIN32
1.68 free(prefix);
1.69 -#endif
1.70 + free(path);
1.71 }
1.72
1.73 int main(int argc,char **argv)
1.74 @@ -171,5 +147,5 @@
1.75 if (argc>1 && !strcmp(argv[1],"-u"))
1.76 plover_remove(NULL);
1.77 else
1.78 - setup();
1.79 + setup(argv[0]);
1.80 }