install.stk 2.64 KB
Newer Older
Erick Gallesio's avatar
Erick Gallesio committed
1 2
;;;;
;;;; install.stk	-- Installin/Uninstalling packages
3 4 5 6
;;;;
;;;; Copyright © 2007-2008 Erick Gallesio - I3S-CNRS/ESSI <eg@essi.fr>
;;;;
;;;;
Erick Gallesio's avatar
Erick Gallesio committed
7 8 9 10
;;;; 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 2 of the License, or
;;;; (at your option) any later version.
11
;;;;
Erick Gallesio's avatar
Erick Gallesio committed
12 13 14 15
;;;; This program is distributed in the hope that it will be useful,
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;;; GNU General Public License for more details.
16
;;;;
Erick Gallesio's avatar
Erick Gallesio committed
17 18
;;;; You should have received a copy of the GNU General Public License
;;;; along with this program; if not, write to the Free Software
19
;;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
Erick Gallesio's avatar
Erick Gallesio committed
20
;;;; USA.
21
;;;;
Erick Gallesio's avatar
Erick Gallesio committed
22 23
;;;;           Author: Erick Gallesio [eg@essi.fr]
;;;;    Creation date: 30-May-2007 11:42 (eg)
24
;;;; Last file update: 15-Apr-2008 23:21 (eg)
Erick Gallesio's avatar
Erick Gallesio committed
25 26 27 28 29 30 31 32 33
;;;;

;; ----------------------------------------------------------------------
;; 	show-installed-packages ...
;; ----------------------------------------------------------------------
(define (show-installed-packages)

  (define (do-print dir)
    (for-each (lambda(x) (printf "  ~a\n" x))
34
	      (sort (directory-files dir) string<=?)))
35

Erick Gallesio's avatar
Erick Gallesio committed
36 37
  (let ((system (make-path (stklos-pkg-system-directory) "etc"))
	(user   (make-path (stklos-pkg-directory) "etc")))
38 39
    (when (and (file-is-directory? user)
	       (not (null? (directory-files user))))
Erick Gallesio's avatar
Erick Gallesio committed
40 41
      (printf "User installed packages:\n")
      (do-print user))
42 43
    (when (and (file-is-directory? system)
	       (not (null? (directory-files system))))
Erick Gallesio's avatar
Erick Gallesio committed
44 45
      (printf "System-wide installed packages:\n")
      (do-print system))))
46

Erick Gallesio's avatar
Erick Gallesio committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60

;; ----------------------------------------------------------------------
;; 	show-installed-packages ...
;; ----------------------------------------------------------------------
(define (uninstall-package package)
  (let* ((dir (if (stklos-pkg-swide)
		  (stklos-pkg-system-directory)
		  (stklos-pkg-directory)))
	 (filedir (make-path dir "etc" package)))
    (if (file-exists? filedir)
	(let ((files (with-input-from-file filedir read)))
	  (for-each remove-file files)
	  (remove-file filedir)
	  (eprintf "Package ~a is un-installed\n" package))
61
	(error-pkg "package ~a is not installed" package))))
Erick Gallesio's avatar
Erick Gallesio committed
62

63 64 65 66
;; ----------------------------------------------------------------------
;; 	install-packages ...
;; ----------------------------------------------------------------------
(define (install-package name dir)
67
  (system (format "cd ~a; ~a all install" dir (make-command))))