int sbcl_version_bin(struct install_options* param) { char* home=configdir(); char* platforms_html=cat(home,"tmp",SLASH,"sbcl-bin.html",NULL); cond_printf(1,"sbcl_version_bin\n"); ensure_directories_exist(platforms_html); param->version_not_specified=param->version?0:1; if(param->version_not_specified) { int ret; printf("No SBCL version specified. Downloading platform-table.html to see the available versions...\n"); char* uri=get_opt("sbcl-bin-version-uri",0); ret=download_simple(uri?uri:PLATFORM_HTML_URI,platforms_html,0); if(ret!=0) { printf("Something wrong! Check the connection or sbcl.org is down. Download failed (Code=%d), tring the backup URL.\n",ret); ret=download_simple(PLATFORM_HTML_BACKUP_URI,platforms_html,0); } if(ret!=0) { printf("Download failed (Code=%d)\n",ret); return 0; } sbcl_bin_check_file(platforms_html); param->version=sbcl_bin(platforms_html,param->version_not_specified++); }else param->version=q(param->version); printf("Installing sbcl-bin/%s...\n",param->version); param->arch_in_archive_name=1; s(platforms_html),s(home); return 1; }
int sbcl_bin_download(struct install_options* param) { int result; char* home=configdir(); char* arch=arch_(param); char* uri=get_opt("sbcl-bin-uri",0); cond_printf(1,"sbcl_bin_download\n"); int retry=10; do { param->expand_path=cat(home,"src",SLASH,"sbcl","-",param->version,"-",arch,SLASH,NULL); impls_sbcl_bin.uri=cat(uri?uri:SBCL_BIN_URI ,param->version,"/sbcl-",param->version, "-",arch,"-binary",sbcl_bin_extention(param),NULL); result = download(param); if(!result && param->version_not_specified) { int len = strlen(param->version)-1; if('1'<= param->version[len] && param->version[len] <= '9') { param->version[len]--; s(param->expand_path),s(impls_sbcl_bin.uri); }else if('2' <= param->version[len-1] && param->version[len-1] <= '9') { param->version[len-1]--; param->version[len] = '9'; s(param->expand_path),s(impls_sbcl_bin.uri); }else if('1' == param->version[len-1]) { param->version[len-1] = '9'; param->version[len] = '\0'; s(param->expand_path),s(impls_sbcl_bin.uri); }else{ s(arch),s(home); return 0; } } }while (!result && retry--); s(arch),s(home); return !!result; }
int sbcl_bin_install(struct install_options* param) { char* version=param->version; char* arch=param->arch; char* home=configdir(); char *str,*str2,*str3,*str4; char* version_num= q(version); int ret; str2=cat(home,"src\\sbcl-",version,"-",arch,"-windows\\PFiles\\Steel Bank Common Lisp\\",version_num,"\\sbcl.exe",NULL); str3=cat(home,"impls\\",arch,"\\windows\\sbcl-bin\\",version,"\\bin\\sbcl.exe",NULL); str=cat("cmd /c \"echo f|xcopy ^\"",str2,"^\" ^\"",str3,"^\" > NUL","\"",NULL); s(str2),s(str3); ret=System(str);s(str); if(ret) return 0; str2=cat(home,"src\\sbcl-",version,"-",arch,"-windows\\PFiles\\Steel Bank Common Lisp\\",version_num,"\\sbcl.core",NULL); str3=cat(home,"impls\\",arch,"\\windows\\sbcl-bin\\",version,"\\lib\\sbcl\\sbcl.core",NULL); str=cat("cmd /c \"echo f|xcopy ^\"",str2,"^\" ^\"",str3,"^\" > NUL","\"",NULL); ret=System(str);s(str); if(ret) return 0; str=cat("echo d|xcopy ^\"", home,"src\\sbcl-",version,"-",arch,"-windows\\PFiles\\Steel Bank Common Lisp\\",version_num,"\\contrib^\" ^\"", home,"impls\\",arch,"\\windows\\sbcl-bin\\",version,"\\lib\\sbcl\\contrib^\" >NUL",NULL); str2=cat(home,"src\\sbcl-",version,"-",arch,"-windows\\PFiles\\Steel Bank Common Lisp\\",version_num,"\\contrib",NULL); str3=cat(home,"impls\\",arch,"\\windows\\sbcl-bin\\",version,"\\lib\\sbcl\\contrib",NULL); str=cat("cmd /c \"echo d|xcopy ^\"",str2,"^\" ^\"",str3,"^\""," > NUL","\"",NULL); ret=System(str); s(str),s(home); if(ret) return 0; return 1; }
int sbcl_bin_install(struct install_options* param) { int ret; char* home=configdir(); char* impl=param->impl; char* version=param->version; char* impl_path= cat(home,impldir(param->arch,param->os,impl,version),NULL); char* src=param->expand_path; char* sbcl_home=cat(impl_path,"/lib/sbcl",NULL); char* install_root=q(impl_path); char* log_path=cat(home,"impls/log/",impl,"-",version,"/install.log",NULL); cond_printf(0,"Building %s/%s...",impl,version); ensure_directories_exist(impl_path); ensure_directories_exist(log_path); change_directory(src); setenv("SBCL_HOME",sbcl_home,1); setenv("INSTALL_ROOT",install_root,1); ret=System("(cat find-gnumake.sh; echo find_gnumake)|sh"); if(ret!=0) { fprintf(stderr,"'make' command not available.\n"); return 0; } ret=1; if(system_redirect("sh install.sh",log_path)==-1) ret=0; s(home),s(impl_path),s(sbcl_home),s(install_root),s(log_path); printf(" Done.\n"); return ret; }
int start(struct install_options* param) { char *home=configdir(),*p; char *localprojects=cat(home,"local-projects/",NULL); setup_uid(1); ensure_directories_exist(localprojects); s(localprojects); if(installed_p(param)) { printf("%s/%s is already installed. Try (TBD) for the forced re-installation.\n",param->impl,param->version?param->version:""); return 0; } if(install_running_p(param)) { printf("It seems another installation process for $1/$2 is in progress somewhere in the system.\n"); return 0; } p=cat(home,"tmp",SLASH,param->impl,param->version?"-":"",param->version?param->version:"",SLASH,NULL); ensure_directories_exist(p); s(p); p=cat(home,"tmp",SLASH,param->impl,param->version?"-":"",param->version?param->version:"",".lock",NULL); delete_at_exit(p); touch(p); s(p),s(home); return 1; }
int cmd_config(int argc,char **argv,struct sub_command* cmd) { char* home=configdir(); char* path=cat(home,"config",NULL); if(argc==1) { printf("oneshot:\n"); print_opts(local_opt); printf("local:\n"); print_opts(global_opt); }else { struct opts* opt=global_opt; struct opts** opts=&opt; // TBD parse options if(argc==2) { unset_opt(opts, argv[1]); save_opts(path,opt); }else { if(strcmp(argv[1],"set")==0) { set_opt(opts, argv[2],(char*)argv[3],0); save_opts(path,opt); }else if (strcmp(argv[1],"show")==0) { printf("%s\n",_get_opt(opt,argv[2])); }else { set_opt(opts, argv[1],(char*)argv[2],0); save_opts(path,opt); } } } s(home),s(path); return 0; }
int sbcl_bin_expand(struct install_options* param) { cond_printf(1,"sbcl_bin_expand\n"); char* argv[6]={"","-xf",NULL,"-C",NULL,NULL}; char* archive=download_archive_name(param); char* dist_path=param->expand_path; char* home=configdir(); printf("Extracting %s to %s\n",archive,dist_path); delete_directory(dist_path,1); ensure_directories_exist(dist_path); argv[2]=cat(home,"archives",SLASH,archive,NULL); argv[4]=cat(home,"src",SLASH,NULL); return !cmd_tar(array_stringlist(5,argv),NULL); }
int installed_p(struct install_options* param) { int ret; char *i,*impl; impl=q(param->impl); //TBD for util. i=s_cat(configdir(),q("impls"),q(SLASH),q(param->arch),q(SLASH),q(param->os),q(SLASH), q(impl),q(param->version?SLASH:""),q(param->version?param->version:""),q(SLASH),NULL); ret=directory_exist_p(i); cond_printf(1,"directory_exist_p(%s)=%d\n",i,ret); s(i),s(impl); return ret; }
int cmd_version(int argc,char **argv,struct sub_command* cmd) { fprintf(stderr,"%s",PACKAGE_STRING); if(strlen(ROS_REVISION)>0) fprintf(stderr,"(%s)",ROS_REVISION); if(strcmp(argv[0],"--version")!=0) { char *c= configdir(),*l=lispdir(); fprintf(stderr,"\nbuild with %s",ROS_COMPILE_ENVIRONMENT); #ifdef HAVE_CURL_CURL_H fprintf(stderr,"\nlibcurl %s",LIBCURL_VERSION); #endif fprintf(stderr,"\nlispdir='%s'",l),s(l); if(c) fprintf(stderr,"\nconfigdir='%s'",c),s(c); } fprintf(stderr,"\n"); return 0; }
char* determin_impl(char* impl) { char* version=NULL; int pos; cond_printf(1,"determin_impl:%s\n",impl); if(impl && (pos=position_char("/",impl))!=-1) { version=subseq(impl,pos+1,0); impl=subseq(impl,0,pos); }else { if(!impl) impl=get_opt("default.lisp",1); if(impl) { char* opt=s_cat(q(impl),q("."),q("version"),NULL); version=get_opt(opt,1); s(opt); } if(!impl) impl=DEFAULT_IMPL; impl=q(impl); if(version) version=q(version); } if(!version&&strcmp(impl,DEFAULT_IMPL)!=0) { cond_printf(1,"once!%s,%s\n",impl,version); if(!version) s(version); version=q("system"); } if(!(impl && version)) { char* cmd=cat(which(argv_orig[0]),verbose>0?(verbose>1?" -v -v":" -v"):""," setup",NULL); char* ret; if(impl) s(impl); impl=q(DEFAULT_IMPL); cond_printf(1,"cmd:%s\n",cmd); ret=system_(cmd); cond_printf(1,"ret:%s\n",ret); s(ret); char* path=s_cat(configdir(),q("config"),NULL); global_opt=load_opts(path),s(path);; version=get_opt(DEFAULT_IMPL".version",0); } return s_cat(impl,q("/"),version,NULL); }
int sbcl_bin_expand(struct install_options* param) { char* impl=param->impl; char* version=q(param->version); int ret; char* home=configdir(); char* arch= arch_(param); char* archive=cat(impl,"-",version,"-",arch,".msi",NULL); char* log_path=cat(home,"impls",SLASH,"log",SLASH,impl,"-",version,"-",arch,SLASH,"install.log",NULL); char* dist_path; int pos=position_char("-",impl); if(pos!=-1) { impl=subseq(impl,0,pos); }else impl=q(impl); dist_path=cat(home,"src",SLASH,impl,"-",version,"-",arch,SLASH,NULL); printf("Extracting the msi archive. %s to %s\n",archive,dist_path); archive=s_cat(q(home),q("archives"),q(SLASH),archive,NULL); delete_directory(dist_path,1); ensure_directories_exist(dist_path); ensure_directories_exist(log_path); if(dist_path[strlen(dist_path)-1]=='\\') dist_path[strlen(dist_path)-1]='\0'; char* cmd=cat("msiexec.exe /a \"", archive, "\" targetdir=\"", dist_path, "\" /qn /lv ", "\"", log_path, "\"", NULL); cmd=cat("cmd /c \"",cmd,"\"",NULL); cond_printf(1,"msiexeccmd:%s\n",cmd); ret=System(cmd); s(impl); s(dist_path); s(log_path); s(archive); s(cmd),s(home),s(version),s(arch); return !ret; }
char* extract_command_str(int flags,const char *filename,int do_extract,const char* outputpath,char* type) { char* str; char* _uname_m=uname_m(); char* _uname=uname(); char* _homedir=configdir(); char* exe=s_escape_string(cat(_homedir,"impls",SLASH,_uname_m,SLASH,_uname,SLASH,"7za",SLASH,"9.20",SLASH,"7za.exe",NULL)); char *outputpath2=q(outputpath); char *filename2=q(filename); substitute_char('\\','/',outputpath2); outputpath2=s_escape_string(outputpath2); filename2=s_escape_string(filename2); ensure_directories_exist(outputpath2); if(strcmp(type,"gzip")==0 || strcmp(type,"bzip2")==0 || strcmp(type,"xz")==0) { str=cat("cmd /c \"",exe," ",do_extract?"x ":"l ",filename2," -so |",exe," x -ttar -si -y -o",outputpath2,"\"",NULL); }else if(strcmp(type,"7za")==0) { ensure_directories_exist(outputpath2); str=cat(exe," ",do_extract?"x":"t"," -y -o",outputpath2," ",filename2,NULL); } s(outputpath2),s(filename2),s(_homedir),s(_uname),s(_uname_m); return str; }
int download(struct install_options* param) { char* home=configdir(); char* url=install_impl->uri; char* archive_name=download_archive_name(param); char* impl_archive=cat(home,"archives",SLASH,archive_name,NULL); if(!file_exist_p(impl_archive) || get_opt("download.force",1)) { printf("Downloading %s\n",url); /*TBD proxy support... etc*/ if(url) { ensure_directories_exist(impl_archive); int status = download_simple(url,impl_archive,0); if(status) { printf("Download Failed with status %d. See download_simple in src/download.c\n", status); return 0; /* fail */ } s(url); } } else printf("Skip downloading %s\n",url); s(impl_archive),s(home); return 1; }
int cmd_run_star(int argc,char **argv,struct sub_command* cmd) { int ret=1; char* config=configdir(); set_opt(&local_opt,"quicklisp",s_escape_string(cat(config,"impls",SLASH,"ALL",SLASH,"ALL",SLASH,"quicklisp",SLASH,NULL)),0); set_opt(&local_opt,"argv0",argv_orig[0],0); set_opt(&local_opt,"wargv0",which(argv_orig[0]),0); set_opt(&local_opt,"homedir",config,0); if(rc) { char* init=s_cat(configdir(),q("init.lisp"),NULL); #ifdef _WIN32 char* etc=""; #else char* etc="/etc/rosrc"; #endif char* current=get_opt("program",0); char *path,*would; if(file_exist_p(init)) { path=cat("(:load \"",init,"\")",NULL); would=cat(path,current?current:"",NULL); s(current); set_opt(&local_opt,"program",would,0); s(path); } s(init); current=get_opt("program",0); if(file_exist_p(etc)) { path=cat("(:load \"",etc,"\")",NULL); would=cat(path,current?current:"",NULL); set_opt(&local_opt,"program",would,0); } } char*lisp=get_opt("lisp",1); if(!lisp) lisp=get_opt("*lisp",0); set_opt(&local_opt,"impl",determin_impl(lisp),0); char** arg=NULL; int i; char* wrap=get_opt("wrap",1); { struct sub_command cmd; int i; char *_= get_opt("impl",0); i=position_char("/",_); cmd.name=subseq(_,0,i); cmd.short_name=subseq(_,i+1,0); for(i=0;i<sizeof(impls_to_run)/sizeof(struct run_impl_t);++i) if(strcmp(impls_to_run[i].name,cmd.name)==0) { arg=impls_to_run[i].impl(argc,argv,&cmd); break; } s((char*)cmd.name),s((char*)cmd.short_name); } if(wrap) arg[0]=q(wrap); if(arg && file_exist_p(arg[1])) { char* opts=sexp_opts(local_opt); setenv("ROS_OPTS",opts,1); if(verbose&1 ||testing) { fprintf(stderr,"args "); for(i=0;arg[i]!=NULL;++i) fprintf(stderr,"%s ",arg[i]); fprintf(stderr,"\nROS_OPTS %s\n",getenv("ROS_OPTS")); if(testing) s(opts),exit(EXIT_SUCCESS); } s(opts); #ifdef _WIN32 { char* cmd=q(arg[wrap?0:1]); for(i=wrap?1:2;arg[i]!=NULL;++i) { cmd=s_cat(cmd,q(" "),q("\""),escape_string(arg[i]),q("\""),NULL); } SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE); exit(System(cmd)); s(cmd); } #else execvp(arg[wrap?0:1],&(arg[wrap?0:1])); #endif }else fprintf(stderr,"%s is not installed.stop.\n",get_opt("impl",0)); s(config); return ret; }
int cmd_install(int argc,char **argv,struct sub_command* cmd) { install_cmds *cmds=NULL; struct install_options param; quicklisp=1; param.os=uname(); param.arch=uname_m(); param.arch_in_archive_name=0; param.expand_path=NULL; if(argc!=1) { int ret=1,k; for(k=1;k<argc;++k) { int i,pos; param.impl=argv[k]; pos=position_char("/",param.impl); if(pos!=-1) { param.version=subseq(param.impl,pos+1,0); param.impl=subseq(param.impl,0,pos); }else { param.version=NULL; param.impl=q(param.impl); } for(install_impl=NULL,i=0;i<sizeof(impls_to_install)/sizeof(struct install_impls*);++i) { struct install_impls* j=impls_to_install[i]; if(strcmp(param.impl,j->name)==0) { install_impl=j; } } if(install_impl) { for(cmds=install_impl->call;*cmds&&ret;++cmds) ret=(*cmds)(¶m); if(ret) { // after install latest installed impl/version should be default for 'run' struct opts* opt=global_opt; struct opts** opts=&opt; char* home=configdir(); char* path=cat(home,"config",NULL); char* v=cat(param.impl,".version",NULL); char* version=param.version; if(!install_impl->util) { int i; for(i=0;version[i]!='\0';++i) if(version[i]=='-') version[i]='\0'; set_opt(opts,"default.lisp",param.impl,0); set_opt(opts,v,version,0); save_opts(path,opt); } s(home),s(path),s(v); } }else { char* lisp_path=lispdir(); int i,j,argc_; char** tmp; char* install_ros=s_cat2(lisp_path,q("install.ros")); if(verbose&1) { fprintf(stderr,"%s is not implemented internal. %s argc:%d\n",param.impl,install_ros,argc); for(i=0;i<argc;++i) fprintf(stderr,"%s:",argv[i]); fprintf(stderr,"\n"); } tmp=(char**)alloc(sizeof(char*)*(argc+9)); i=0; tmp[i++]=q("--"); tmp[i++]=install_ros; tmp[i++]=q("install"); tmp[i++]=q(argv[1]); for(j=2;j<argc;tmp[i++]=q(argv[j++])); argc_=i; if(verbose&1) { int j; fprintf(stderr,"argc_=%d",argc_); for(j=0;j<argc_;++j) fprintf(stderr,"argv[%d]=%s,",j,tmp[j]); } for(i=0;i<argc_;i+=proccmd(argc_-i,&tmp[i],top_options,top_commands)); for(j=0;j<argc_;s(tmp[j++])); dealloc(tmp); return 0; } if(param.version)s(param.version); s(param.impl),s(param.arch),s(param.os); s(param.expand_path); if(!ret) exit(EXIT_FAILURE); } }else { char* tmp[]={"help","install"}; proccmd(2,tmp,top_options,top_commands); exit(EXIT_SUCCESS); } return 0; }