Commit 7380d8d04e93ab89d0aa8847672b41a83c40379e

Thomas de Grivel 2018-07-10T12:35:13

host

diff --git a/core/defs.lisp b/core/defs.lisp
index b8d723c..2e84350 100644
--- a/core/defs.lisp
+++ b/core/defs.lisp
@@ -189,11 +189,14 @@
   ((shell :initarg :shell
 	  :type shell))
   ((probe-os-using-uname :properties (:os))
-   (probe-hostname :properties (:hostname))
+   (probe-host-locale :properties (:locale))
+   (probe-host-packages :properties (:packages))
    (probe-boot-time :properties (:boot-time))
    (probe-host-user :properties (:user))
-   (probe-host-packages :properties (:packages)))
-  ((op-hostname :properties (:hostname))))
+   (probe-hostname :properties (:hostname)))
+  ((op-host-locale :properties (:locale))
+   (op-host-packages :properties (:packages))
+   (op-hostname :properties (:hostname))))
 
 (defgeneric probe-os-using-uname (host os))
 (defgeneric probe-hostname (host os))
diff --git a/core/host.lisp b/core/host.lisp
index 0fc8926..75fceac 100644
--- a/core/host.lisp
+++ b/core/host.lisp
@@ -45,17 +45,20 @@
   (specified-property host :user))
 
 (defun host-connect (host)
-  (let ((id (resource-id host)))
-    (cond
-      ((string-equal (local-hostname) id)
-       (setf (host-shell host) (make-shell "/bin/sh")))
-      (:otherwise
-       (let ((user (host-user host)))
-         (setf (host-shell host)
-               (apply #'make-shell
-                      `("/usr/bin/ssh"
-                        ,@(when user `("-l" ,user))
-                        ,id "/bin/sh"))))))))
+  (let* ((id (resource-id host))
+         (locale (specified-property host :locale))
+         (shell (cond ((string-equal (local-hostname) id)
+                       (make-shell "/bin/sh"))
+                      (:otherwise
+                       (let ((user (host-user host)))
+                         (apply #'make-shell
+                                `("/usr/bin/ssh"
+                                  ,@(when user `("-l" ,user))
+                                  ,id "/bin/sh")))))))
+    (when locale
+      (shell-run shell "export LANG=" locale))
+    (setf (host-shell host) shell)
+    shell))
 
 (defun current-host ()
   (or (when (boundp '*host*)
@@ -100,15 +103,8 @@
            (return)))
     (apply #'shell-run shell command)))
 
-(defmacro with-connected-host ((var hostname) &body body)
-  (let ((g!host (gensym "HOST-")))
-    `(let ((,g!host (make-instance 'host :id ,hostname)))
-       (unwind-protect (let ((,var ,g!host)) ,@body)
-         (unless (eq (localhost) ,g!host)
-           (host-disconnect ,g!host))))))
-
 (defmethod host-run ((hostname string) &rest command)
-  (with-connected-host (host hostname)
+  (let ((host (host hostname)))
     (apply #'host-run host command)))
 
 ;;  With host