From 4af56d67e88ce0b93a5393c9425a551cc5fbc35f Mon Sep 17 00:00:00 2001 From: michel-schinz Date: Sun, 13 Jun 2004 17:49:52 +0000 Subject: [PATCH] - bindir is now extracted from scsh's "configure" module by default, - better error handling. --- pkg-def.scm | 55 ++++++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/pkg-def.scm b/pkg-def.scm index 9e6356d..57226a5 100644 --- a/pkg-def.scm +++ b/pkg-def.scm @@ -10,35 +10,38 @@ exec scsh -le ~a/load.scm -o install-lib -e install-main -s "$0" "$@" END ) -(define-package "install-lib" (1 1 0) - ((options (bindir "Destination directory for executables" "" #t #f #f - ,identity ,identity))) +(define-package "install-lib" (1 1 1) + ((options (bindir "Destination directory for executables" "" #t #f + ,(bin-dir) ,identity ,identity))) + ;; Install "package" part (doc & Scheme code) + (install-file "doc/install-lib.pdf" 'doc "pdf") + (install-files '("scheme/install-lib.scm" + "scheme/install-lib-version.scm" + "scheme/install-lib-module.scm") + 'scheme) + (write-to-load-script + `((config) + (load ,(absolute-file-name "install-lib-module.scm" + (get-directory 'scheme #f))) + (user))) + + ;; Install "program" part (scsh-install-pkg script). (let ((bindir (get-option-value 'bindir))) - (if (not bindir) - (display-error-and-exit - "no binary directory specified (use --bindir option).")) - - ;; Install "package" part (doc & Scheme code) - (install-file "doc/install-lib.pdf" 'doc "pdf") - (install-files '("scheme/install-lib.scm" - "scheme/install-lib-version.scm" - "scheme/install-lib-module.scm") - 'scheme) - (write-to-load-script - `((config) - (load ,(absolute-file-name "install-lib-module.scm" - (get-directory 'scheme #f))) - (user))) - - ;; Install "program" part (scsh-install-pkg script). (if (or (get-option-value 'dry-run) (get-option-value 'verbose)) (format #t "creating scsh-install-pkg script in ~a\n" bindir)) (if (not (get-option-value 'dry-run)) - (begin - (create-directory&parents bindir #o755) - (call-with-output-file (absolute-file-name "scsh-install-pkg" bindir) - (lambda (port) - (format port scsh-install-pkg-template (get-directory 'base #f)) - (set-file-mode port #o755))))))) + (let ((wrapper-name (absolute-file-name "scsh-install-pkg" bindir))) + + (with-errno-handler + ((errno packet) + (else ((display-error-and-exit "cannot create wrapper script " + wrapper-name ":\n " + (first packet))))) + + (create-directory&parents bindir #o755) + (call-with-output-file wrapper-name + (lambda (port) + (format port scsh-install-pkg-template (get-directory 'base #f)) + (set-file-mode port #o755))))))))