[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Maintaining Source Code



At SPAR, we've been using the following hack for years, ever since Release 5:
we used the file type .5BIN for compiled files that work under Release 5, and
we use .6BIN for Rel 6 and .7BIN for Rel 7.

This works with no modification of Symbolics code, and if applications programs
are careful to use canonical types, they won't break either.  It works because
the Lisp Machine is already capable of spelling the canonical type :BIN in
different ways -- it knows how to spell it "bn" on a pre-4.2 UNIX machine and
"bin" on other machines.

Here is the code that does this -- less than two dozen lines.  (This is the
"7" version; we make the necessary substitutions by hand when a new major
release comes out.)

					--Kanef

==================== SYS:FLAIR;Release-7-BIN-Hack.lisp ====================
;;; -*- Mode: LISP; Package: FILE-SYSTEM; Base: 8; Syntax: Zetalisp -*-

;;This file is never compiled, and it's loaded very early in the process
;;of building the locally-modified world (with the LOAD function in the
;;same file that contains the DEFSYSTEM of Local-Mods).

;;This code changes the release-7 system so that BIN files are stored
;;with filetypes of 7BIN instead of BIN, or 7BN instead of BN, etc.  We
;;will also look for 6BIN and 5BIN files in preference to BIN.  We may
;;want to change this later...
;;The algorithm is:
;;  For each type of system, if there is no translation for :BIN, then use (:BIN "7BIN" "6BIN" "5BIN" "BIN"),
;;  i.e. write 7BIN files and look for those or for 6BIN, 5BIN or BIN files.
;;  If there is already a translation for BIN, then if one of it's members begins with 6 we
;;  leave that translation alone.  If there isn't such a one, then we look at the prefered translation
;;  (e.g. "BN" for UNIX) and put a 7 on the front and stick that at the front of the list.
;;  Thus (:UNIX (:BIN "BN" "BIN")) becomes (:UNIX (:BIN "7BN" "6BN" "5BN" "BN" "BIN"))

(defun add-7-bin-types ()
  (loop for entry in fs:*canonical-types-alist*
	for (system-type . translations) = entry
	for btrans = (assoc ':BIN translations)	;Get (:BIN ... )
	doing
	(cond ((null btrans)			;Not one there yet?
	       (push (copylist '(:BIN "7BIN" "6BIN" "5BIN" "BIN"))
		     (cdr entry)))		;Push it on the front of the translations list
	      (t				;There is an entry
	       (unless (loop for type in (cdr btrans)	;Look down the type list
			     thereis (char= (aref type 0) #\7))	;for a type beginning with 7.  If there is one, exit now
		 (setf (cdr btrans)
		       (list* (string-append #\7 (second btrans))	;Put type with a 7 before it
			      (string-append #\6 (second btrans))	;Then with 6.
			      (string-append #\5 (second btrans))	;then type with a 5
			      (cdr btrans)))		;And insert this Before the other :BIN translations
		 )))))

(add-7-bin-types)

(defmacro suppressing-bin-type-hack ((&optional (for-host-type :logical))
				     &body body)
  `(letf (((nth (cl:position :bin (rest1 (assoc ,for-host-type *canonical-types-alist*)) :key 'first)
		(rest1 (assoc ,for-host-type *canonical-types-alist*)))
	   '(:bin "BIN")))
     ,@body))

#|| ;;For exporting systems to other sites that do not use this hack, you want to write all the .6BIN files
    ;;onto tape as .BIN files.  To do this, simply say:
    ;;We're considering making logical hosts ALWAYS exempt from the bin-hack.  That is,
    ;;SYS:FOO;BAR.BIN would expand to BAR.7BIN in Rel 7, BAR.6BIN in Rel 6, etc.
    ;;This should work, in theory, unless some luser refers to "sys:foo;bar.6bin"
    ;;somewhere.  That's unlikely, because anyone careful enough to use logical names
    ;;is careful enough to use the generic pathname.  --Kanef, 7/87
(suppressing-bin-type-hack ()
  (dis:write-distribution-tape))
||#
==================== SYS:FLAIR;Release-7-BIN-Hack.lisp ====================