From df801118446820e40d8198dcc4edae14e62009cd Mon Sep 17 00:00:00 2001 From: SANO Masatoshi Date: Sun, 30 Jul 2017 17:27:29 +0900 Subject: [PATCH] better env support. --- lisp/dump.ros | 2 +- lisp/init.lisp | 2 +- lisp/init.ros | 12 ++++++++++-- lisp/list-env.lisp | 9 ++++++--- lisp/setup.ros | 24 ++++++++++++++---------- lisp/util-dump.lisp | 5 +++-- src/cmd-run.c | 12 ++++++++---- 7 files changed, 43 insertions(+), 23 deletions(-) diff --git a/lisp/dump.ros b/lisp/dump.ros index c64db1b..c162dde 100644 --- a/lisp/dump.ros +++ b/lisp/dump.ros @@ -34,7 +34,7 @@ exec ros -- $0 "$@" ((and (equal (first params) "-o")) (format *error-output* "Missing the pathname for an image.~%")) (t (let ((path (merge-pathnames (format nil "~A.~A" (first params) (core-extention)) - (dump-dir)))) + (dump-dir (equal (first params) "roswell"))))) (%dump (ensure-directories-exist path) :normal)))))) (defun executable (func params) diff --git a/lisp/init.lisp b/lisp/init.lisp index 7d1ee52..719c924 100644 --- a/lisp/init.lisp +++ b/lisp/init.lisp @@ -168,7 +168,7 @@ have the latest asdf, and this file has a workaround for this. ".roswell/local-projects/" *default-pathname-defaults*))))) (when (probe-file path) - (cl:load path) + (cl:load path :verbose (verbose)) (loop with symbol = (read-from-string "ql:*local-project-directories*") for path in `(,local ,@(and (or path (and environment (getenv environment))) `(,(merge-pathnames "local-projects/" (opt "homedir"))))) diff --git a/lisp/init.ros b/lisp/init.ros index 959b438..e6ac192 100644 --- a/lisp/init.ros +++ b/lisp/init.ros @@ -5,8 +5,16 @@ exec ros -Q -m roswell -L sbcl-bin -- $0 "$@" |# (progn - (roswell:quicklisp :environment nil) - (roswell:include "util")) + (roswell:include "util") + (let ((script (read-from-string (format nil "(~A)" (ros:opt "script"))))) + (roswell:quicklisp + :environment nil + :path (when (and (equal (file-namestring (first script)) "dump.ros") + (equal (second script) "output") + (equal (third script) "-f") + (equal (fourth script) "roswell")) + (merge-pathnames "lisp/quicklisp/" + (funcall (read-from-string "roswell.util:homedir"))))))) (defpackage :ros.script.init.3672012201 (:use :cl :roswell.util)) diff --git a/lisp/list-env.lisp b/lisp/list-env.lisp index 1fc1ba5..21cf57f 100644 --- a/lisp/list-env.lisp +++ b/lisp/list-env.lisp @@ -1,3 +1,5 @@ +(roswell:include "util-config") + (defpackage :roswell.list.env (:use :cl) (:export :env :env-list)) @@ -8,6 +10,7 @@ (directory (merge-pathnames "env/*/config" (roswell:opt "homedir"))))) (defun env (&rest r) - (cond ((null r) - (dolist (i (env-list)) - (format t "~A~A~%" (if (equal (roswell:opt "roswellenv") i) :* " ") i))))) + (let ((name (third (assoc "roswellenv" (roswell.util.config:load-config ".roswellenv") :test 'equal)))) + (cond ((null r) + (dolist (i (env-list)) + (format t "~A~A~%" (if (equal name i) :* " ") i)))))) diff --git a/lisp/setup.ros b/lisp/setup.ros index fb8f3ae..33527f2 100644 --- a/lisp/setup.ros +++ b/lisp/setup.ros @@ -71,30 +71,34 @@ exec ros -Q -L sbcl-bin -- $0 "$@" (when (roswell:verbose) (format *error-output* "Parameter for install quicklisp '~{~A ~}'~%" params)) (roswell:roswell params :interactive nil)))) - (let ((dir (sort + (let* ((dir (sort (delete-if-not (dump-filter dump) (append (directory (make-pathname :defaults *load-pathname* :name :wild :type "ros")) (directory (merge-pathnames "cmds/*.ros" (homedir))) (directory (merge-pathnames "lisp/*.lisp" (homedir))) - (directory (merge-pathnames "bin/*" (homedir))))) #'string< :key 'pathname-name))) + (directory (merge-pathnames "bin/*" (homedir))))) #'string< :key 'pathname-name)) + (dir (cons (find "init.ros" dir :key #'file-namestring :test 'equal) + (remove "init.ros" dir :key #'file-namestring :test 'equal))) + (use-env (equal dump "roswell"))) (when (roswell:verbose) (format *error-output* "Targets for dump:~%~{~A~%~}~%" dir)) - (unless (equal dump "roswell") - (format *error-output* "building dump:~A~%" dump)) + (when (or (not (equal dump "roswell")) + (roswell:verbose)) + (format *error-output* "building dump:~A~%" (make-pathname :defaults (dump-dir use-env) :name dump :type "core"))) (force-output *error-output*) (unless (ignore-errors (when (> (file-write-date - (make-pathname :defaults (dump-dir) :name "hage" :type "core")) + (make-pathname :defaults (dump-dir use-env) :name dump :type "core")) (loop for i in dir maximize (file-write-date i))) (format *error-output* "up to date. stop~%") t)) - (roswell:roswell `("+R " ,(if (roswell:verbose) "-v" "") " -L " "sbcl-bin" - " --eval " #-win32 "'" "(roswell:ignore-shebang)" #-win32 "'" " " - ,@(loop for i in dir - collect "--load " + (roswell:roswell `(,(if (roswell:verbose) "-v" "") " +R" " +Q" " -L " "sbcl-bin" + " --eval " #-win32 "'" "(roswell:ignore-shebang)" #-win32 "'" " " + ,@(loop for i in dir + collect "--load " collect (format nil "~A " i)) - "dump output -f " ,dump) + "dump output -f " ,dump) t nil)))) ;;; vim: set ft=lisp lisp: diff --git a/lisp/util-dump.lisp b/lisp/util-dump.lisp index 9790fc9..1be776e 100644 --- a/lisp/util-dump.lisp +++ b/lisp/util-dump.lisp @@ -31,9 +31,10 @@ The default value contains the minimal blacklist.") These are appended to the blacklist before destroying the package system. Notably, it must include all nicknames.") -(defun dump-dir () +(defun dump-dir (use-env) (merge-pathnames (format nil "~Aimpls/~A/~A/~A/dump/" - (if (opt "roswellenv") + (if (and (not use-env) + (opt "roswellenv")) (format nil "env/~A/" (opt "roswellenv")) "") (uname-m) (uname) (opt "impl")) diff --git a/src/cmd-run.c b/src/cmd-run.c index 2dce2ae..41d742f 100644 --- a/src/cmd-run.c +++ b/src/cmd-run.c @@ -107,7 +107,7 @@ void set_env_opt(char* path) { case 2: value=subseq(buf,last,i); if(strcmp("quicklisp",name)==0) { - set_opt(&local_opt,"quicklisp",s_escape_string(cat(configdir(),"env"SLASH"lisp",SLASH,value,SLASH,"quicklisp",SLASH,NULL))); + set_opt(&local_opt,"quicklisp",s_escape_string(cat(configdir(),"env"SLASH,value,SLASH,"lisp",SLASH,"quicklisp",SLASH,NULL))); }else if(strcmp("dists",name)==0) { }else set_opt(&local_opt,name,q(value)); @@ -124,9 +124,13 @@ void set_env_opt(char* path) { void star_set_opt(void) { char* config=configdir(); char*lisp=get_opt("lisp",1); - set_env_opt("."PACKAGE_NAME"env"); - /*If 'roswellenv' not set the below would endup fail to open cause it will be taken as a directory.*/ - set_env_opt(s_escape_string(cat(configdir(),"env",SLASH,get_opt(PACKAGE_NAME"env",1),SLASH,"config",NULL))); + char*image=get_opt("image",0); + if(!image || + strcmp("roswell",image)!=0) { + set_env_opt("."PACKAGE_NAME"env"); + /*If 'roswellenv' not set the below would endup fail to open cause it will be taken as a directory.*/ + set_env_opt(s_escape_string(cat(configdir(),"env",SLASH,get_opt(PACKAGE_NAME"env",1),SLASH,"config",NULL))); + } lisp=lisp?lisp:get_opt("*lisp",0); set_opt(&local_opt,"impl",determin_impl(lisp)); if(!get_opt("quicklisp",0))