blob: fb862aabfc7b9b6f29ec67b54e19f3cfcc587f9a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
;;; Consfigurator -- Lisp declarative configuration management system
;;; Copyright (C) 2021 Sean Whitton <spwhitton@spwhitton.name>
;;; This file 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, or (at your option)
;;; any later version.
;;; This file 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.
;;; You should have received a copy of the GNU General Public License
;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
(in-package :consfigurator.connection.sbcl)
(named-readtables:in-readtable :consfigurator)
(defproplist sbcl-available :posix ()
(os:etypecase
(debianlike (apt:installed "sbcl"))))
(defparameter *sbcl* '("sbcl" "--noinform" "--noprint"
"--disable-debugger" "--no-sysinit" "--no-userinit"))
(defmethod establish-connection ((type (eql :sbcl)) remaining &key)
(when (lisp-connection-p)
(warn
"Looks like you might be starting a fresh Lisp image directly from the root
Lisp. This can mean that prerequisite data gets extracted from encrypted
stores and stored unencrypted under ~~/.cache, and as such is not
recommended."))
(unless (zerop (mrun :for-exit "command" "-v" "sbcl"))
;; If we're not the final hop then we don't know the OS of the host to
;; which we're currently connected, so we can't apply SBCL-AVAILABLE.
;;
;; TODO In the case of INSTALLER:CLEANLY-INSTALLED-ONCE this code will
;; have us trying to use apt to install sbcl on a Fedora host, say, upon
;; the first connection, before Debian has been installed. Perhaps we
;; should just have some code which tries to install sbcl based on the
;; package manager(s) it can find on PATH. Could reuse that code for
;; CHROOT::%DEBOOTSTRAP-MANUALLY-INSTALLED.
(if remaining
(failed-change "sbcl not on PATH and don't know how to install.")
(sbcl-available)))
(let ((requirements (asdf-requirements-for-host-and-features
(safe-read-from-string
(run :input "(prin1 *features*)" *sbcl*)
:package :cl-user))))
(request-asdf-requirements requirements)
(upload-all-prerequisite-data)
(inform t "Waiting for remote Lisp to exit, this may take some time ... ")
(force-output)
(multiple-value-bind (program forms)
(continue-deploy*-program remaining requirements)
(multiple-value-bind (out err exit) (run :may-fail :input program *sbcl*)
(inform t (if (< exit 2) "done." "failed.") :fresh-line nil)
(when-let ((lines (lines out)))
(inform t " Output was:" :fresh-line nil)
(with-indented-inform (inform t lines)))
(unless (< exit 2)
;; print FORMS not PROGRAM because latter might contain sudo passwords
(failed-change
"~&Remote Lisp failed; stderr was:~%~%~A~&~%Program we sent:~%~%~S"
err forms))
(values nil (if (zerop exit) :no-change nil))))))
|