From 1ff61569bcd99ded3d2f7d4f028e25ca0284c6b6 Mon Sep 17 00:00:00 2001
From: Francois-Rene Rideau <fare@tunes.org>
Date: Tue, 18 Oct 2011 23:44:49 -0400
Subject: [PATCH] 3.016: Fixes for ABCL, CLISP, ECL, GCL.

---
 90INTERNALS      |  1 +
 95TODO           |  5 -----
 cl-launch.sh     | 39 ++++++++++++++++++++++++---------------
 debian/changelog |  6 ++++++
 4 files changed, 31 insertions(+), 20 deletions(-)

diff --git a/90INTERNALS b/90INTERNALS
index 60b3ffa..fca46d4 100644
--- a/90INTERNALS
+++ b/90INTERNALS
@@ -3,6 +3,7 @@ NOTE TO HACKERS WHO'D LIKE TO HACK cl-launch INTERNALS
 I conceive cl-launch as the ultimate exercise in "useful quining".
 It's a shell script, it's a Lisp program header and library,
 it outputs shell scripts and Lisp programs that may include parts of cl-launch.
+It also includes its own test system.
 
 cl-launch is very hard to hack. A change you'd think is innocuous will actually
 break some complex combination of options on some Lisp implementation and shell
diff --git a/95TODO b/95TODO
index 4bb7247..3f7db4e 100644
--- a/95TODO
+++ b/95TODO
@@ -1,10 +1,5 @@
 TODO for cl-launch as of 2.31
 
- * Add an option to wrap an existing image that already has cl-launch
-   loaded in it, and/or detect that the image does,
-   and skip the loading of cl-launch,
-   thereby save the time and disk space of image dumping.
-
  * When resuming from an image then dumping another, the INCLUDE_PATH
    becomes a very bad variable to look for the image.
    Include a test case and fix it.
diff --git a/cl-launch.sh b/cl-launch.sh
index dc08758..d6c78d9 100755
--- a/cl-launch.sh
+++ b/cl-launch.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 #| cl-launch.sh -- shell wrapper generator for Common Lisp software -*- Lisp -*-
-CL_LAUNCH_VERSION='3.015'
+CL_LAUNCH_VERSION='3.016'
 license_information () {
 AUTHOR_NOTE="\
 # Please send your improvements to the author:
@@ -408,7 +408,7 @@ Fully supported, but no standalone executables:
   scl:  Scieneer CL 1.3.9
 
 Incomplete support:
-  abcl:  ABCL 0.25.0 (no image dumping support at this time)
+  abcl:  ABCL 0.27.0 (no image dumping support at this time)
   gcl (GCL 2.6):  GCL 2.6.7 ansi mode  (no ASDF so --system not supported)
   xcl:  XCL 0.0.0.291 (cannot dump an image) (get a recent checkout)
 
@@ -1040,6 +1040,7 @@ include_lisp_header () {
   if [ -z "$INCLUDE_PATH" ] ; then
     print_lisp_header
   else
+    echo "#-cl-launch"
     load_form "$INCLUDE_PATH/launcher.lisp"
   fi
 }
@@ -1495,7 +1496,10 @@ t_system () {
   t_create clt-sys.lisp \
 	"(in-package :cl-user)$HELLO$(foo_provide "$NUM:system" system)$GOODBYE"
   t_args "--system ..."
-  t_next "$@" --system clt-asd --source-registry "${PWD}:${ASDF_DIR}"
+  t_next "$@" --system clt-asd --source-registry \
+  "(:source-registry \
+     (:directory \"${PWD}\") (:directory \"${ASDF_DIR}\") \
+     :ignore-inherited-configuration)"
 }
 t_init () {
   t_register "$(foo_require "$NUM:init" init)" xxx_t_init
@@ -1637,16 +1641,19 @@ do_tests () {
   # beware, it will clobber then remove a lot of file clt-*
   # and exercise your Lisp fasl cache
   for LISP in $LISPS ; do
-  export ASDF_DIR="$(case "$LISP" in xcl) LISP=sbcl ;; esac ; $PROG --lisp "$LISP" --quiet --system asdf --init '(cl-launch::finish-outputs)(format t "~%~A~%" (asdf:system-source-directory :asdf))' | tail -1)"
+  case $LISP in
+    gcl) ;; # doesn't support asdf.
+    *) export ASDF_DIR="$(case "$LISP" in xcl) LISP=sbcl ;; esac ; $PROG --lisp "$LISP" --quiet --system asdf --init '(cl-launch::finish-outputs)(format t "~%~A-~A: ~A~%" "SOURCE" "REGISTRY" (asdf:system-source-directory :asdf))' | grep ^SOURCE-REGISTRY: | tail -1 | cut -d' ' -f2- )" ;;
+  esac
   for TEST_SHELL in ${TEST_SHELLS:-${TEST_SHELL:-sh}} ; do
   echo "Using lisp implementation $LISP with test shell $TEST_SHELL"
   for TM in "" "image " ; do
   for TD in "" "dump " "dump_ " ; do
   case "$TM:$TD:$LISP" in
-    # we don't know how to dump from a dump with ABCL, ECL
-    image*:dump*:abcl|image*:dump*:ecl) ;;
-    # we don't know how to dump at all with XCL
-    *:dump*:xcl|image*:*:xcl) ;;
+    # we don't know how to dump from a dump with ECL
+    image*:dump*:ecl) ;;
+    # we don't know how to dump at all with ABCL, XCL
+    *:dump*:abcl|image*:*:abcl|*:dump*:xcl|image*:*:xcl) ;;
     # Actually, even dumping is largely broken on ECL as of 3.010 + ASDF 2.015
     *:dump*:ecl|image*:*:ecl) ;;
     *)
@@ -2420,8 +2427,8 @@ Returns two values: the fasl path, and T if the file was (re)compiled"
             (multiple-value-bind (path warnings failures)
                 (apply 'compile-file
                        truesource :output-file fasl
-                       (append #+ecl '(:system-p system-p)
-                               #-gcl-pre2.7 '(:print verbose :verbose verbose)))
+                       (append #+ecl `(:system-p ,system-p)
+                               #-gcl-pre2.7 `(:print ,verbose :verbose ,verbose)))
               (declare (ignorable warnings failures))
               (unless (equal (truename fasl) (truename path))
                 (error "CL-Launch: file compiled to ~A, expected ~A" path fasl))
@@ -2571,7 +2578,7 @@ any of the characters in the sequence SEPARATOR."
 (defvar *quit* t)
 
 (defun raw-command-line-arguments ()
-  #+abcl (cdr ext:*command-line-argument-list*) ; abcl adds a "--" to our "--"
+  #+abcl ext:*command-line-argument-list* ; Beware: requires abcl 0.27.0, or we must take the cdr
   #+allegro (sys:command-line-arguments) ; default: :application t
   #+clisp (coerce (ext:argv) 'list)
   #+clozure (ccl::command-line-arguments)
@@ -2586,13 +2593,15 @@ any of the characters in the sequence SEPARATOR."
 
 (defun command-line-arguments ()
   (let* ((raw (raw-command-line-arguments))
+         #-abcl
          (cooked
-          #+(or sbcl allegro) raw
-          #-(or sbcl allegro)
+          #+(or allegro sbcl) raw
+          #-(or allegro sbcl)
           (if (eq *dumped* :standalone)
               raw
               (member "--" raw :test 'string-equal))))
-    (cdr cooked)))
+    #+abcl raw
+    #-abcl (cdr cooked)))
 
 (defun compute-arguments ()
   (setf *cl-launch-file* (getenv* "CL_LAUNCH_FILE")
@@ -2802,7 +2811,7 @@ any of the characters in the sequence SEPARATOR."
 (defun load-systems (&rest systems)
   (dolist (s systems) (call :asdf :load-system s :verbose *verbose*)))
 
-;;(eval-when (:compile-toplevel :load-toplevel :execute) (when *verbose* (format *trace-output* "Enabling some debugging~%") (handler-bind (#+ecl (si::simple-package-error (lambda (x) (declare (ignore x)) (invoke-restart 'continue)))) #+ecl (trace c::builder c::build-fasl c:build-static-library c:build-program ensure-lisp-file-name ensure-lisp-file cleanup-temporary-files delete-package) #+ecl (setf c::*compiler-break-enable* t) #+clisp (require "asdf") (trace load-asdf asdf2-p recent-asdf-p make-package load-file load-stream load-systems build-and-dump build-and-run run resume compute-arguments do-resume compile-and-load-file compile-file-pathname* load compile-file) (setf *verbose* t *load-verbose* t *compile-verbose* t))))
+;;(handler-bind (#+ecl (si::simple-package-error (lambda (x) (declare (ignore x)) (invoke-restart 'continue)))) (format *trace-output* "Enabling some debugging~%") #+ecl (trace c::builder c::build-fasl c:build-static-library c:build-program ensure-lisp-file-name ensure-lisp-file cleanup-temporary-files delete-package) #+ecl (setf c::*compiler-break-enable* t) #+clisp (require "asdf") (trace load-asdf asdf2-p recent-asdf-p make-package load-file load-stream load-systems build-and-dump build-and-run run resume compute-arguments do-resume compile-and-load-file compile-file-pathname* load compile-file) (setf *verbose* t *load-verbose* t *compile-verbose* t))
 
 (pushnew :cl-launch *features*))
 NIL
diff --git a/debian/changelog b/debian/changelog
index 1a8a6e5..a036f58 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+cl-launch (3.016-1) unstable; urgency=low
+
+  * More fixes for ABCL, CLISP, ECL, GCL.
+
+ -- Francois-Rene Rideau <fare@tunes.org>  Tue, 18 Oct 2011 23:44:28 -0400
+
 cl-launch (3.015-1) unstable; urgency=low
 
   * CLISP: don't (setf *source-file-types* nil custom:*compiled-file-types nil)
-- 
GitLab