[clfswm-devel] [PATCH] contrib/clfswm: new revision

Xavier Maillard xma at gnu.org
Mon Mar 10 01:00:06 UTC 2008


Hi,

As requested by Philippe, here is a new revision of my clfswm
startup script.

This is a complete rewrite of the previous one and it includes
these enhancements:

1. modularity
2. support of several command line arguments to control the
script
3. check for errors
4. cleaner than the previous one

You now have the choice to dump an image and launch it using
either SBCL or CLISP (--with-lisp option), you can specify where
is located your CLFSWM installation, you can ask to just dump an
image and exit after that, etc.

I tested it with CLISP *only* but the SBCL part has proven to be
runnable in the past.

Tell me what I could add or change.

Cheers,

	Xavier

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 24)
+++ ChangeLog	(working copy)
@@ -1,3 +1,11 @@
+2008-03-10  Xavier Maillard  <xma at gnu.org>
+
+	* contrib/clfswm: Complete rewrite of the script. Detect error and
+	act accordingly. Add command line arguments to configure the
+	script execution. User can now choose different common lisp
+	implementation (clisp and sbcl only), choose where to store the
+	dumped image, where to find clfswm source.
+
 2008-03-09  Philippe Brochard  <hocwp at free.fr>
 
 	* clfswm-internal.lisp (process-new-window): Beginning of new
@@ -8,9 +16,7 @@
 
 	* contrib/clfswm: New script. Dump a CLISP image of CLFSWM then
  	call the resulting executable.
-	
-2008-03-08  Xavier Maillard  <xma at gnu.org>
-	
+
 	* clfswm.lisp (read-conf-file): Check for the user config file in
 	XDG_CONFIG_HOME *first*. Freedesktop.org standards should be
 	prefered whenever possible.
Index: contrib/clfswm
===================================================================
--- contrib/clfswm	(revision 24)
+++ contrib/clfswm	(working copy)
@@ -1,26 +1,7 @@
 #!/bin/bash -e
 #
-# #Date#:
+# (C) 2008 Xavier Maillard <xma at gnu.org>
 #
-# --------------------------------------------------------------------------
-# Documentation:
-#
-# Original code and idea: http://stumpwm.antidesktop.net/cgi-bin/wiki/SetUp
-#
-# This script is targeted to CLisp users. It will help in starting
-# CLFSWM quicker by dumping an image of CLFSWM.
-#
-# Installation:
-# Put this script wherever you want and just call it from your .xinitrc file
-#
-# The first time you will launch it, it will build the final
-# executable and then call it. To force a rebuild of your executable
-# (say you have updated something in the CLFSWM source tree), just
-# delete the image and restart your X session.
-# --------------------------------------------------------------------------
-
-# (C) 2008 Xavier Maillard <xma at gnu.org>
-
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 3 of the License, or
@@ -35,20 +16,121 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 #
+#
 # --------------------------------------------------------------------------
+# Documentation:
+#
+# Original code and idea: http://stumpwm.antidesktop.net/cgi-bin/wiki/SetUp
+#
+# Installation:
+# Put this script wherever you want and just call it from your .xinitrc file
+#
+# The first time you will launch it, it will build the final
+# executable and then call it. To force a rebuild of your executable
+# (say you have updated something in the CLFSWM source tree), just
+# delete the image and restart your X session.
+# --------------------------------------------------------------------------
 
-# Tweak this
-IMAGE="$HOME/var/cache/clfswm-$(cksum $(type -p clisp) | cut -d ' ' -f 1).core"
-ASDF=$HOME/usr/src/SVNed/clfswm
-CLFSWMASDPATH=$HOME/usr/share/common-lisp/systems
+usage() {
 
-if  test ! -e "$x" ||
-    (   for i in "$(dirname $(readlink $CLFSWMASDPATH/clfswm.asd))"/*.lisp
-        do  test "$x" -ot "$i" && exit 1
+    echo "$0 [options]
+--
+n,no-start           don't start CLFSWM after image dump
+f,force              force image dump
+rebuild              same as -f,--force
+l,with-lisp=         use <lisp> as the common lisp implementation
+d,dump-path=         path to the dump directory
+with-clfswm          path to clfswm.asd file
+with-asdf            path to the asdf.lisp file"
+
+    exit 0
+}
+
+die() {
+	echo >&2 "$@"
+	exit 1
+}
+
+build_clisp ()
+{
+    clisp -m 8MB -E ISO-8859-1 -q -K full -i $asdf_path/asdf.lisp -x "(asdf:oos 'asdf:load-op :clfswm)\
+       		(EXT:SAVEINITMEM \"$dump_image\" :INIT-FUNCTION 'clfswm:main :EXECUTABLE t :norc t)"
+}
+
+build_sbcl()
+{
+   sbcl --disable-debugger --eval "(mapc 'require '(asdf clfswm))" \
+       --eval "(save-lisp-and-die \"$dump_image\" :toplevel 'clfswm:main)"
+}
+
+no_start=no
+lisp=clisp
+dump_path=$HOME/var/cache
+asdf_path=$HOME/usr/src/SVNed/clfswm
+clfswm_asd_path=$HOME/usr/share/common-lisp/systems
+
+while test $# != 0
+do
+    case "$1" in
+	-n|--no-start)
+	    no_start=yes ;;
+	-f|--force|--rebuild)
+	    force=yes ;;
+	-d|--dump-path)
+	    shift
+	    dump_path="$1" ;;
+	--with-clfswm)
+	    shift
+	    clfswm_asd_path="$1" ;;
+	--with-asdf)
+	    shift
+	    asdf_path="$1" ;;
+	-l|--with-lisp)
+	    shift
+	    case "$1" in
+		'')
+		    usage;;
+		clisp|sbcl)
+		    lisp="$1" ;;
+	    esac
+	    ;;
+	--)
+	    shift
+	    break ;;
+	*)
+	    usage ;;
+    esac
+    shift
+done
+
+test -x $(type -p $lisp) || die "$lisp can't be found."
+test -e $clfswm_asd_path/clfswm.asd || die "can't find clfswm.asd in $clfswm_asd_path"
+test -e $asdf_path/asdf.lisp || die "can't find asdf.lisp in $asdf_path"
+
+dump_image="$dump_path/clfswm-$(cksum $(type -p $lisp) | cut -d ' ' -f 1).core"
+
+if test yes = "$force" && test -e "$dump_image"
+then
+    echo "Removing old image."
+    rm -f "$dump_image"
+fi
+
+if test ! -e "$dump_image" ||
+    (   for i in "$(dirname $(readlink $clfswm_asd_path/clfswm.asd))"/*.lisp
+        do  test "$dump_image" -ot "$i" && exit 1
         done )
 then
-	clisp -m 8MB -E ISO-8859-1 -q -K full -i $ASDF/asdf.lisp -x "(asdf:oos 'asdf:load-op :clfswm)\
-       		(EXT:SAVEINITMEM \"$IMAGE\" :INIT-FUNCTION 'clfswm:main :EXECUTABLE t :norc t)"
+	eval build_$lisp
 fi
 
-$IMAGE
+# Run the resulting image
+if test no = "$no_start"
+then
+    case $lisp in
+	clisp ) $dump_image ;;
+	sbcl ) exec sbcl --core "$dump_image" ;;
+	*) echo "..." ;;
+    esac
+else
+    echo "As requested, we have just dumped the image."
+fi

-- 
http://www.gnu.org
http://www.april.org
http://www.lolica.org



More information about the clfswm-devel mailing list