mirror of
https://github.com/roswell/roswell.git
synced 2026-09-10 07:16:17 -04:00
start supporting win32
This commit is contained in:
parent
cbb31def66
commit
2c51b3e2b3
|
|
@ -1,8 +1,8 @@
|
|||
# -*- Autoconf -*-
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ([2.68])
|
||||
AC_INIT([lsp],[0.0.0.4],snmsts@gmail.com)
|
||||
AC_PREREQ([2.65])
|
||||
AC_INIT([lsp],[0.0.0.5],snmsts@gmail.com)
|
||||
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
AC_CONFIG_FILES([Makefile src/Makefile])
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ int installed_p(char* impl,char* version)
|
|||
impl=subseq(impl,0,pos);
|
||||
}else
|
||||
impl=q(impl);
|
||||
i=s_cat(homedir(),q("impls/"),q(impl),q("-"),q(version),q("/"),NULL);
|
||||
i=s_cat(homedir(),q("impls"),q(SLASH),q(impl),q("-"),q(version),q(SLASH),NULL);
|
||||
ret=directory_exist_p(i);
|
||||
s(i),s(impl);
|
||||
return ret;
|
||||
|
|
@ -48,11 +48,11 @@ int start(char* impl,char* version)
|
|||
printf("It seems running installation process for $1/$2.\n");
|
||||
return 0;
|
||||
}
|
||||
p=cat(home,"tmp/",impl,"-",version,"/",NULL);
|
||||
p=cat(home,"tmp",SLASH,impl,"-",version,SLASH,NULL);
|
||||
ensure_directories_exist(p);
|
||||
s(p);
|
||||
|
||||
p=cat(home,"tmp/",impl,"-",version,".lock",NULL);
|
||||
p=cat(home,"tmp",SLASH,impl,"-",version,".lock",NULL);
|
||||
setup_signal_handler(p);
|
||||
touch(p);
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ int download(char* impl,char* version)
|
|||
printf("Downloading archive.:%s\n",url);
|
||||
/*TBD proxy support... etc*/
|
||||
if(url) {
|
||||
impl_archive=cat(home,"archives/",impl,"-",version,".",(*(install_impl->extention))(impl,version),NULL);
|
||||
impl_archive=cat(home,"archives",SLASH,impl,"-",version,".",(*(install_impl->extention))(impl,version),NULL);
|
||||
ensure_directories_exist(impl_archive);
|
||||
|
||||
if(download_simple(url,impl_archive,0)) {
|
||||
|
|
@ -105,7 +105,7 @@ int expand(char* impl,char* version)
|
|||
}else
|
||||
impl=q(impl);
|
||||
version=q(version);
|
||||
dist_path=cat(home,"src/",impl,"-",version,"/",NULL);
|
||||
dist_path=cat(home,"src",SLASH,impl,"-",version,SLASH,NULL);
|
||||
|
||||
printf("Extracting archive. %s to %s\n",archive,dist_path);
|
||||
|
||||
|
|
@ -113,8 +113,8 @@ int expand(char* impl,char* version)
|
|||
ensure_directories_exist(dist_path);
|
||||
|
||||
/* TBD log output */
|
||||
argv[1]=cat(home,"archives/",archive,NULL);
|
||||
argv[3]=cat(home,"src/",NULL);
|
||||
argv[1]=cat(home,"archives",SLASH,archive,NULL);
|
||||
argv[3]=cat(home,"src",SLASH,NULL);
|
||||
cmd_tar(argc,argv);
|
||||
|
||||
s(argv[1]),s(argv[3]);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
#include "pull.h"
|
||||
#include "opt.h"
|
||||
|
||||
extern char* sbcl_extention(char* impl,char* version);
|
||||
extern int sbcl_install(char* impl,char* version);
|
||||
|
||||
char* arch(void) {
|
||||
|
|
@ -16,8 +15,9 @@ char* sbcl_bin(char* file);
|
|||
char* sbcl_version_bin(char* impl,char* version)
|
||||
{
|
||||
char* home= homedir();
|
||||
char* platforms_html=cat(home,"tmp/sbcl.html",NULL);
|
||||
char* platforms_html=cat(home,"tmp",SLASH,"sbcl.html",NULL);
|
||||
ensure_directories_exist(platforms_html);
|
||||
|
||||
/* TBD */
|
||||
if(version) {
|
||||
s(platforms_html);
|
||||
|
|
@ -36,19 +36,91 @@ char* sbcl_version_bin(char* impl,char* version)
|
|||
}
|
||||
}
|
||||
|
||||
char* sbcl_bin_extention(char* impl,char* version) {
|
||||
#ifdef _WIN32
|
||||
return "msi";
|
||||
#else
|
||||
return "tar.bz2";
|
||||
#endif
|
||||
}
|
||||
|
||||
char* sbcl_uri_bin(char* impl,char* version)
|
||||
{
|
||||
/*should I care about it's existance? */
|
||||
return cat("http://prdownloads.sourceforge.net/sbcl/sbcl-",version,
|
||||
"-binary.tar.bz2",NULL);
|
||||
"-binary.",
|
||||
sbcl_bin_extention(impl,version)
|
||||
,NULL);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
int sbcl_bin_expand(char* impl,char* version){
|
||||
int ret;
|
||||
char* home= homedir();
|
||||
char* archive=cat(impl,"-",version,".msi",NULL);
|
||||
char* log_path=cat(home,"impls",SLASH,"log",SLASH,impl,"-",version,SLASH,"install.log",NULL);
|
||||
char* dist_path;
|
||||
int pos=position_char("-",impl);
|
||||
if(pos!=-1) {
|
||||
impl=subseq(impl,0,pos);
|
||||
}else
|
||||
impl=q(impl);
|
||||
version=q(version);
|
||||
dist_path=cat(home,"src",SLASH,impl,"-",version,SLASH,NULL);
|
||||
printf("Extracting 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);
|
||||
|
||||
char* cmd=cat("start /wait msiexec.exe /a \"",
|
||||
archive,
|
||||
"\" targetdir=\"",
|
||||
dist_path,
|
||||
"\" /qn /lv ",
|
||||
"\"",
|
||||
log_path,
|
||||
"\"",
|
||||
NULL);
|
||||
ret=system(cmd);
|
||||
s(impl);
|
||||
s(dist_path);
|
||||
s(log_path);
|
||||
s(archive);
|
||||
s(cmd),s(home),s(version);
|
||||
return !ret;
|
||||
}
|
||||
int sbcl_bin_install(char* impl,char* version) {
|
||||
char* home= homedir();
|
||||
char* str;
|
||||
char* version_num= subseq(version,0,position_char("-",version));
|
||||
str=cat("echo f|xcopy \"",
|
||||
home,"src\\sbcl-",version,"\\PFiles\\Steel Bank Common Lisp\\",version_num,"\\sbcl.exe\" \"",
|
||||
home,"impls\\sbcl-",version,"\\bin\\sbcl.exe\" >NUL",NULL);
|
||||
system(str),s(str);
|
||||
str=cat("echo f|xcopy \"",
|
||||
home,"src\\sbcl-",version,"\\PFiles\\Steel Bank Common Lisp\\",version_num,"\\sbcl.core\" \"",
|
||||
home,"impls\\sbcl-",version,"\\lib\\sbcl\\sbcl.core\" >NUL",NULL);
|
||||
system(str),s(str);
|
||||
str=cat("echo d|xcopy \"",
|
||||
home,"src\\sbcl-",version,"\\PFiles\\Steel Bank Common Lisp\\",version_num,"\\contrib\" \"",
|
||||
home,"impls\\sbcl-",version,"\\lib\\sbcl\\contrib\" >NUL",NULL);
|
||||
system(str),s(str);
|
||||
s(home);
|
||||
}
|
||||
#endif
|
||||
|
||||
install_cmds install_sbcl_bin_full[]={
|
||||
start,
|
||||
download,
|
||||
#ifndef _WIN32
|
||||
expand,
|
||||
sbcl_install,
|
||||
#else
|
||||
sbcl_bin_expand,
|
||||
sbcl_bin_install,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
||||
struct install_impls impls_sbcl_bin={ "sbcl-bin", install_sbcl_bin_full,sbcl_version_bin,sbcl_uri_bin,sbcl_extention};
|
||||
struct install_impls impls_sbcl_bin={ "sbcl-bin", install_sbcl_bin_full,sbcl_version_bin,sbcl_uri_bin,sbcl_bin_extention};
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ int sbcl_install(char* impl,char* version) {
|
|||
printf("done.\n");
|
||||
return ret;
|
||||
#else
|
||||
#error not implemented.
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,22 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include "util.h"
|
||||
#include "opt.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
BOOL WINAPI ConsoleCtrlHandler(DWORD ctrlChar){
|
||||
CHAR szPrintBuffer[512];
|
||||
DWORD nCharsWritten;
|
||||
if(CTRL_C_EVENT == ctrlChar){
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
int cmd_run(int argc,char **argv)
|
||||
{
|
||||
int ret=1;
|
||||
|
|
@ -41,10 +55,14 @@ int cmd_run(int argc,char **argv)
|
|||
}
|
||||
}
|
||||
if(strcmp(impl,"sbcl")==0) {
|
||||
char* impl_path= cat(home,"impls/",impl,"-",version,NULL);
|
||||
char* impl_path= cat(home,"impls",SLASH,impl,"-",version,NULL);
|
||||
int core_p=1;
|
||||
offset=2;
|
||||
bin= cat(impl_path,"/bin/sbcl",NULL);
|
||||
bin= cat(impl_path,SLASH,"bin",SLASH,"sbcl",
|
||||
#ifdef _WIN32
|
||||
".exe",
|
||||
#endif
|
||||
NULL);
|
||||
for(i=0;i<argc;++i) {
|
||||
if(strcmp(argv[i],"--core")==0) {
|
||||
core_p=0;
|
||||
|
|
@ -56,7 +74,7 @@ int cmd_run(int argc,char **argv)
|
|||
arg[0]=bin;
|
||||
if(core_p) {
|
||||
arg[1]="--core";
|
||||
arg[2]=cat(impl_path,"/lib/sbcl/sbcl.core",NULL);
|
||||
arg[2]=cat("\"",impl_path,SLASH,"lib",SLASH,"sbcl",SLASH,"sbcl.core","\"",NULL);
|
||||
}
|
||||
s(impl_path);
|
||||
}else if (strcmp(impl,"native")==0) {
|
||||
|
|
@ -75,7 +93,17 @@ int cmd_run(int argc,char **argv)
|
|||
}
|
||||
if(file_exist_p(bin)) {
|
||||
arg[i+1+offset]=NULL;
|
||||
#ifdef _WIN32
|
||||
s(home);home=q(arg[0]);
|
||||
for(i=1;arg[i]!=NULL;++i) {
|
||||
home=s_cat(home,q(" "),q(arg[i]),NULL);
|
||||
}
|
||||
SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE);
|
||||
system(home);
|
||||
//_execvp(bin,arg);
|
||||
#else
|
||||
execvp(bin,arg);
|
||||
#endif
|
||||
}else{
|
||||
printf("%s/%s is not installed.stop.\n",impl,version);
|
||||
}
|
||||
|
|
|
|||
68
src/util.c
68
src/util.c
|
|
@ -8,6 +8,10 @@
|
|||
#include <pwd.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#else
|
||||
#include <windows.h>
|
||||
#include <Shellapi.h>
|
||||
#include <shlobj.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
#include <sys/stat.h>
|
||||
|
|
@ -188,8 +192,8 @@ char* downcase(char* orig) {
|
|||
|
||||
char* append_trail_slash(char* str) {
|
||||
char* ret;
|
||||
if(str[strlen(str)-1]!='/') {
|
||||
ret=s_cat2(q(str),q("/"));
|
||||
if(str[strlen(str)-1]!=SLASH[0]) {
|
||||
ret=s_cat2(q(str),q(SLASH));
|
||||
}else {
|
||||
ret=q(str);
|
||||
}
|
||||
|
|
@ -198,9 +202,6 @@ char* append_trail_slash(char* str) {
|
|||
}
|
||||
|
||||
char* homedir(void) {
|
||||
#ifdef _WIN32
|
||||
return q("/dummy");
|
||||
#else
|
||||
char *c;
|
||||
char *postfix="_HOME";
|
||||
struct passwd * pwd;
|
||||
|
|
@ -213,17 +214,22 @@ char* homedir(void) {
|
|||
if(env) {
|
||||
return append_trail_slash(q(env));
|
||||
}
|
||||
#ifdef _WIN32
|
||||
TCHAR szAppData[MAX_PATH];
|
||||
if(SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROFILE, NULL, 0, szAppData))) {
|
||||
c=q(szAppData);
|
||||
}
|
||||
#else
|
||||
pwd= getpwnam(getenv("USER"));
|
||||
if(pwd) {
|
||||
c=q(pwd->pw_dir);
|
||||
}else {
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
/* error? */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
c=append_trail_slash(c);
|
||||
return s_cat(c,q("."),q(PACKAGE),q("/"),NULL);
|
||||
#endif
|
||||
return s_cat(append_trail_slash(c),q("."),q(PACKAGE),q(SLASH),NULL);
|
||||
}
|
||||
|
||||
char* pathname_directory(char* path) {
|
||||
|
|
@ -251,13 +257,13 @@ char* file_namestring(char* path) {
|
|||
char* ensure_directories_exist (char* path) {
|
||||
int len = strlen(path);
|
||||
if(len) {
|
||||
for(--len;(path[len]!='/'||len==-1);--len);
|
||||
for(--len;(path[len]!=SLASH[0]||len==-1);--len);
|
||||
path=subseq(path,0,len+1);
|
||||
}
|
||||
#ifndef _WIN32
|
||||
char* cmd=s_cat2(q("mkdir -p "),path);
|
||||
#else
|
||||
char* cmd=q("");
|
||||
char* cmd=s_cat(q("mkdir "),path,q(" 2>NUL"),NULL);
|
||||
#endif
|
||||
if(system(cmd)==-1) {
|
||||
printf("failed:%s\n",cmd);
|
||||
|
|
@ -318,7 +324,18 @@ int delete_directory(char* pathspec,int recursive) {
|
|||
return 1;
|
||||
}
|
||||
#else
|
||||
#error not implemented delete_directory
|
||||
if(!recursive) {
|
||||
return(!!RemoveDirectory(pathspec));
|
||||
}else {
|
||||
SHFILEOPSTRUCT fs;
|
||||
ZeroMemory(&fs, sizeof(SHFILEOPSTRUCT));
|
||||
fs.hwnd = NULL;
|
||||
fs.wFunc = FO_DELETE;
|
||||
fs.pFrom = pathspec;
|
||||
fs.pTo = NULL;
|
||||
fs.fFlags=FOF_SIMPLEPROGRESS|FOF_NOCONFIRMATION;
|
||||
return (SHFileOperation(&fs) == 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -335,7 +352,7 @@ int delete_file(char* pathspec) {
|
|||
return 1;
|
||||
}
|
||||
#else
|
||||
#error not implemented delete_file
|
||||
// #error not implemented delete_file
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -459,6 +476,7 @@ int free_cmdline(char** argv)
|
|||
|
||||
int system_redirect(const char* cmd,char* filename)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
pid_t pid;
|
||||
int fd[2];
|
||||
char c;
|
||||
|
|
@ -498,10 +516,12 @@ int system_redirect(const char* cmd,char* filename)
|
|||
}
|
||||
}
|
||||
return(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
int system_redirect_function(const char* cmd,Function1 f)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
pid_t pid;
|
||||
int fd[2];
|
||||
char c;
|
||||
|
|
@ -527,27 +547,37 @@ int system_redirect_function(const char* cmd,Function1 f)
|
|||
FILE *in,*out;
|
||||
close(fd[1]);
|
||||
if((in=fdopen(fd[0], "r"))!=NULL) {
|
||||
f(in);
|
||||
f((LVal)in);
|
||||
fclose(in);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
char* uname(void) {
|
||||
#ifndef _WIN32
|
||||
char *p=system_("uname");
|
||||
char *p2;
|
||||
p2=remove_char("\r\n",p);
|
||||
s(p);
|
||||
return downcase(p2);
|
||||
#else
|
||||
return q("windows");
|
||||
#endif
|
||||
}
|
||||
|
||||
char* uname_m(void) {
|
||||
#ifndef _WIN32
|
||||
char *p=system_("uname -m");
|
||||
char *p2;
|
||||
p2=remove_char("\r\n",p);
|
||||
s(p);
|
||||
return substitute_char('-','_',p2);
|
||||
#else
|
||||
/*TBD check x86 or x86-64 */
|
||||
return q("x86");
|
||||
#endif
|
||||
}
|
||||
|
||||
char* which(char* cmd) {
|
||||
|
|
@ -560,7 +590,7 @@ char* which(char* cmd) {
|
|||
|
||||
LVal directory(char* path)
|
||||
{
|
||||
//#ifndef _WIN32
|
||||
#ifndef _WIN32
|
||||
LVal ret=0;
|
||||
DIR* dir=opendir(path);
|
||||
struct dirent *dirent;
|
||||
|
|
@ -576,7 +606,7 @@ LVal directory(char* path)
|
|||
}
|
||||
closedir(dir);
|
||||
return ret;
|
||||
//#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -596,7 +626,7 @@ void atexit_handler(void) {
|
|||
|
||||
void setup_signal_handler (char* file_to_delete)
|
||||
{
|
||||
//#ifndef _WIN32
|
||||
#ifndef _WIN32
|
||||
atexit_delete=q(file_to_delete);
|
||||
signal(SIGHUP, signal_callback_handler);
|
||||
signal(SIGINT, signal_callback_handler);
|
||||
|
|
@ -604,7 +634,7 @@ void setup_signal_handler (char* file_to_delete)
|
|||
signal(SIGQUIT, signal_callback_handler);
|
||||
signal(SIGTERM, signal_callback_handler);
|
||||
atexit(atexit_handler);
|
||||
//#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/*list*/
|
||||
|
|
|
|||
|
|
@ -14,6 +14,12 @@ struct Cons {
|
|||
LVal next;
|
||||
};
|
||||
|
||||
#ifdef _WIN32
|
||||
#define SLASH "\\"
|
||||
#else
|
||||
#define SLASH "/"
|
||||
#endif
|
||||
|
||||
typedef LVal (*Function1)(LVal v);
|
||||
typedef LVal (*Compare2)(LVal v1,LVal v2);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue