*** empty log message ***
This commit is contained in:
parent
9fdff3a77c
commit
d73107f673
|
@ -0,0 +1,30 @@
|
|||
Copyright (c) 2004, Michel Schinz
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided
|
||||
with the distribution.
|
||||
|
||||
* The name of the author may not be used to endorse or promote
|
||||
products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@ -0,0 +1,61 @@
|
|||
# Makefile for the scsh installation library. Needs GNU make.
|
||||
# $Id: Makefile,v 1.1 2004/03/31 19:47:07 michel-schinz Exp $
|
||||
|
||||
NAME = scsh-install-lib
|
||||
VERSION = 1.0.0
|
||||
FULL_NAME = $(NAME)-$(VERSION)
|
||||
|
||||
LIB_FILES += scheme/install-lib/install-lib.scm
|
||||
LIB_FILES += scheme/install-lib/install-lib-module.scm
|
||||
|
||||
DOC_FILES += doc/latex/proposal.pdf
|
||||
|
||||
DIST_FILES = $(LIB_FILES) $(DOC_FILES) install.scm README COPYING
|
||||
|
||||
DIST_TMP_DIR = distrib-tmp
|
||||
DIST_MAIN_DIR = $(DIST_TMP_DIR)/$(FULL_NAME)
|
||||
|
||||
ARCHIVE = $(FULL_NAME).tar.gz
|
||||
MD5_FILE = $(ARCHIVE).md5
|
||||
|
||||
WEB_USER = schinz
|
||||
WEB_HOST = lamppc29.epfl.ch
|
||||
WEB_DIR = /home/schinz/public_html/scsh_packages/
|
||||
|
||||
# Commands used in the rules
|
||||
CP = cp
|
||||
INSTALL = install
|
||||
MD5SUM = md5sum
|
||||
MKDIR = mkdir
|
||||
PDFLATEX = pdflatex
|
||||
SCP = scp
|
||||
RM = rm
|
||||
TAR = tar
|
||||
|
||||
all:
|
||||
|
||||
clean:
|
||||
$(RM) -f $(ARCHIVE) $(MD5_FILE) $(DOC_FILES)
|
||||
|
||||
distrib: $(ARCHIVE)
|
||||
|
||||
$(ARCHIVE): $(DIST_FILES)
|
||||
$(RM) -rf $(DIST_TMP_DIR)
|
||||
$(MKDIR) $(DIST_TMP_DIR)
|
||||
$(MKDIR) $(DIST_MAIN_DIR)
|
||||
$(MKDIR) $(DIST_MAIN_DIR)/doc
|
||||
$(CP) -p $(DOC_FILES) $(DIST_MAIN_DIR)/doc
|
||||
$(MKDIR) $(DIST_MAIN_DIR)/scheme
|
||||
$(CP) -p $(LIB_FILES) $(DIST_MAIN_DIR)/scheme
|
||||
$(CP) -p install.scm README COPYING $(DIST_MAIN_DIR)
|
||||
$(TAR) --create --gzip --file=$@ --directory=$(DIST_TMP_DIR) $(FULL_NAME)
|
||||
$(RM) -rf $(DIST_TMP_DIR)
|
||||
|
||||
install-web: $(ARCHIVE) $(DOC_FILES) $(MD5_FILE)
|
||||
$(SCP) $^ $(WEB_USER)@$(WEB_HOST):$(WEB_DIR)
|
||||
|
||||
%.pdf: %.tex
|
||||
cd $(dir $^); $(PDFLATEX) $(notdir $^); $(PDFLATEX) $(notdir $^)
|
||||
|
||||
%.md5: %
|
||||
$(MD5SUM) $^ > $@
|
|
@ -0,0 +1,55 @@
|
|||
scsh installation library
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
This is the scsh installation library, which aims at making it easy to
|
||||
install extension libraries for scsh.
|
||||
|
||||
The complete documentation for this library can be found in
|
||||
doc/proposal.pdf. Apart from describing the library itself, this
|
||||
document also explains how to install and use scsh packages in
|
||||
general.
|
||||
|
||||
Notice that this library needs scsh v0.6.6 or newer, and will not
|
||||
work at all with older versions.
|
||||
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
This library must be installed before any attempt at installing scsh
|
||||
packages is made.
|
||||
|
||||
Installation is performed by running the install.scm script found in
|
||||
the same directory as the present file. This script accepts the
|
||||
following option:
|
||||
|
||||
--prefix <dir> directory in which to install files
|
||||
(default: /usr/local)
|
||||
|
||||
The following files are installed:
|
||||
|
||||
<prefix>/bin/scsh-install-pkg
|
||||
|
||||
The script to run in order to install scsh packages. Its use is
|
||||
explained in the documentation (see below).
|
||||
|
||||
<prefix>/share/scsh/install-lib/scheme/install-lib.scm
|
||||
<prefix>/share/scsh/install-lib/scheme/install-lib-module.scm
|
||||
|
||||
The Scheme code for the installation library.
|
||||
|
||||
<prefix>/share/doc/scsh/install-lib/proposal.pdf
|
||||
|
||||
The documentation describing the installation library, and how to
|
||||
manage scsh packages in general.
|
||||
|
||||
|
||||
Staged installation
|
||||
-------------------
|
||||
|
||||
The installation script provides support for staged installation, as
|
||||
needed by some package managment systems. The destination directory in
|
||||
which files should be installed can be specified using the
|
||||
"--dest-dir" option.
|
|
@ -0,0 +1,132 @@
|
|||
#!/bin/sh
|
||||
exec scsh -e main -o let-opt -o srfi-1 -o srfi-37 -s "$0" "$@"
|
||||
!#
|
||||
|
||||
;; Install scsh's installation library as follows:
|
||||
;; - files install-lib.scm and install-lib-module.scm go to
|
||||
;; <prefix>/share/scsh/install-lib/scheme/
|
||||
;; - file proposal.pdf goes to
|
||||
;; <prefix>/share/scsh/doc/install-lib/
|
||||
;; - a new file called scsh-install-pkg, providing an entry point to
|
||||
;; the installation library, is installed in <prefix>/bin
|
||||
|
||||
;; TODO most of the following functions were lifted straight from
|
||||
;; install-lib.scm, but should really be shared in some way.
|
||||
|
||||
;; Replace all bindings of KEY in ALIST with one binding KEY to DATUM.
|
||||
(define (alist-replace key datum alist)
|
||||
(alist-cons key datum (alist-delete key alist)))
|
||||
|
||||
;; Return the value associated with KEY in ALIST. If none exists,
|
||||
;; return DEFAULT, or signal an error if no DEFAULT was given.
|
||||
(define (alist-get key alist . rest)
|
||||
(cond ((assoc key alist) => cdr)
|
||||
((not (null? rest)) (first rest))
|
||||
(else (error "cannot find key in alist" key alist))))
|
||||
|
||||
;; Return the name of the parent directory of FNAME.
|
||||
(define (parent-directory fname)
|
||||
(file-name-directory (directory-as-file-name fname)))
|
||||
|
||||
;; Create directory FNAME and all its parents, as needed.
|
||||
(define (create-directory&parents fname . rest)
|
||||
(let-optionals rest ((perms #o777))
|
||||
(let ((parent (parent-directory fname)))
|
||||
(if (not (file-exists? parent))
|
||||
(apply create-directory&parents parent rest))
|
||||
(if (not (file-exists? fname))
|
||||
(create-directory fname perms)))))
|
||||
|
||||
;; Return the name of FNAME, which must be absolute, with NEW-ROOT as
|
||||
;; root.
|
||||
(define (re-root-file-name fname new-root)
|
||||
(let ((fname-pl (split-file-name fname))
|
||||
(new-root-pl (split-file-name new-root)))
|
||||
(if (string=? (first fname-pl) "")
|
||||
(path-list->file-name (append new-root-pl (cdr fname-pl)))
|
||||
(error "no root to replace in relative file name" fname))))
|
||||
|
||||
;; Copy SOURCE to TARGET-DIR, with the same name.
|
||||
(define (copy-file-to-dir source target-dir)
|
||||
(let ((target (absolute-file-name (file-name-nondirectory source)
|
||||
target-dir)))
|
||||
(run (cp ,source ,target))
|
||||
(set-file-mode target (file-mode source))))
|
||||
|
||||
(define usage #<<END
|
||||
Usage: ~a [options]
|
||||
|
||||
options:
|
||||
-h, --help display this help message, then exit
|
||||
--prefix <dir> specify directory where files are installed
|
||||
(default: /usr/local)
|
||||
--dest-dir <dir> specify prefix to used during installation
|
||||
(to be used only during staged installations)
|
||||
|
||||
END
|
||||
)
|
||||
|
||||
;; Template for scsh-install-pkg script, must be plugged with the
|
||||
;; directory containing the Scheme code.
|
||||
(define scsh-install-pkg-template #<<END
|
||||
#!/bin/sh
|
||||
exec scsh -lm ~a/install-lib-module.scm -o pp -o configure -o install -e install-main -s "$0" "$@"
|
||||
!#
|
||||
|
||||
END
|
||||
)
|
||||
|
||||
(define (display-usage-and-exit prog . args)
|
||||
(format (current-error-port) usage prog)
|
||||
(if (not (null? args))
|
||||
(for-each (lambda (thing) (display thing (current-error-port)))
|
||||
(cons "Error: " args)))
|
||||
(exit 1))
|
||||
|
||||
(define (parse-options prog args)
|
||||
(args-fold
|
||||
args
|
||||
(let ((alist-arg-updater (lambda (key)
|
||||
(lambda (opt name arg alist)
|
||||
(alist-replace key arg alist)))))
|
||||
(list (option '(#\h "help") #f #f
|
||||
(lambda ignored (display-usage-and-exit prog)))
|
||||
(option '("prefix") #t #f (alist-arg-updater 'prefix))
|
||||
(option '("dest-dir") #t #f (alist-arg-updater 'dest-dir))))
|
||||
(lambda (option name . rest)
|
||||
(display-usage-and-exit prog "Unknown option "name))
|
||||
(lambda (operand . rest)
|
||||
(display-usage-and-exit prog
|
||||
"Don't know what to do with "
|
||||
operand))
|
||||
'((prefix . "/usr/local")
|
||||
(dest-dir . "/"))))
|
||||
|
||||
(define (main cmd-line)
|
||||
(let* ((options (parse-options (car cmd-line) (cdr cmd-line)))
|
||||
(prefix (alist-get 'prefix options))
|
||||
(r-prefix (absolute-file-name prefix "/"))
|
||||
(i-prefix (re-root-file-name r-prefix (alist-get 'dest-dir options))))
|
||||
|
||||
;; Install documentation
|
||||
(let ((doc-dir (absolute-file-name "share/doc/scsh/install-lib"
|
||||
i-prefix)))
|
||||
(create-directory&parents doc-dir)
|
||||
(copy-file-to-dir "doc/proposal.pdf" doc-dir))
|
||||
|
||||
;; Install Scheme code
|
||||
(let ((scheme-dir (absolute-file-name "share/scsh/install-lib/scheme"
|
||||
i-prefix)))
|
||||
(create-directory&parents scheme-dir)
|
||||
(copy-file-to-dir "scheme/install-lib.scm" scheme-dir)
|
||||
(copy-file-to-dir "scheme/install-lib-module.scm" scheme-dir))
|
||||
|
||||
;; Install script
|
||||
(let ((bin-dir (absolute-file-name "bin" i-prefix))
|
||||
(r-scheme-dir (absolute-file-name "share/scsh/install-lib/scheme"
|
||||
r-prefix)))
|
||||
(create-directory&parents bin-dir)
|
||||
(call-with-output-file (absolute-file-name "scsh-install-pkg" bin-dir)
|
||||
(lambda (p)
|
||||
(format p scsh-install-pkg-template r-scheme-dir)
|
||||
(set-file-mode p #o755))))))
|
Loading…
Reference in New Issue