From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mathieu Lirzin Subject: [PATCH 3/3] support: Rename user-dmddir to %user-shepherd-dir. Date: Sat, 16 Jan 2016 23:17:41 +0100 Message-ID: <1452982661-17268-4-git-send-email-mthl@gnu.org> References: <1452982661-17268-1-git-send-email-mthl@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.6.4" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aKZAV-0005aV-8P for guix-devel@gnu.org; Sat, 16 Jan 2016 17:18:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aKZAS-0001Ks-B1 for guix-devel@gnu.org; Sat, 16 Jan 2016 17:17:59 -0500 In-Reply-To: <1452982661-17268-1-git-send-email-mthl@gnu.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org This is a multi-part message in MIME format. --------------2.6.4 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: quoted-printable * modules/shepherd/support.scm (user-dmddir): Rename to ... (%user-shepherd-dir): ... this. Honor XDG variables and use '~/.config/shepherd' as default value. All consumers changed. (mkdir-p): New procedure. Export it. (default-config-file): Use it. (verify-dir): Likewise. --- modules/shepherd/support.scm | 45 ++++++++++++++++++++++++++++++++++++--= ------ 1 file changed, 37 insertions(+), 8 deletions(-) --------------2.6.4 Content-Type: text/x-patch; name="0003-support-Rename-user-dmddir-to-user-shepherd-dir.patch" Content-Disposition: inline; filename="0003-support-Rename-user-dmddir-to-user-shepherd-dir.patch" Content-Transfer-Encoding: quoted-printable diff --git a/modules/shepherd/support.scm b/modules/shepherd/support.scm index b6af5eb..4591e65 100644 --- a/modules/shepherd/support.scm +++ b/modules/shepherd/support.scm @@ -32,6 +32,7 @@ with-system-error-handling EINTR-safe with-atomic-file-output + mkdir-p =20 l10n local-output @@ -155,6 +156,31 @@ output port, and PROC's result is returned." (lambda (key . args) (catch-system-error (delete-file template)))))) =20 +(define* (mkdir-p dir #:optional (mode (umask))) ;copied from Guix + "Create directory DIR and all its ancestors." + (define absolute? + (string-prefix? "/" dir)) + + (define not-slash + (char-set-complement (char-set #\/))) + + (let loop ((components (string-tokenize dir not-slash)) + (root (if absolute? + "" + "."))) + (match components + ((head tail ...) + (let ((path (string-append root "/" head))) + (catch 'system-error + (lambda () + (mkdir path mode) + (loop tail path)) + (lambda args + (if (=3D EEXIST (system-error-errno args)) + (loop tail path) + (apply throw args)))))) + (() #t)))) + =0C =20 ;; Localized version of STR. @@ -186,8 +212,11 @@ There is NO WARRANTY, to the extent permitted by law= ."))) (false-if-exception (passwd:dir (getpwuid (getuid)))) "/")) =20 -;; dmd default subdirectory if dmd is run as a normal user. -(define user-dmddir (string-append user-homedir "/.dmd.d")) +(define %user-shepherd-dir + ;; sheperd default directory if shepherd is run as a normal user. + (string-append (or (getenv "XDG_CONFIG_HOME") + (string-append user-homedir "/.config")) + "/shepherd")) =20 (define (make-bare-init-file target) "Return #t if a bare init file was created at TARGET; #f otherwise. @@ -216,7 +245,7 @@ TARGET should be a string representing a filepath + n= ame." (define default-logfile (if (zero? (getuid)) (string-append %localstatedir "/log/shepherd.log") - (string-append user-dmddir "/shepherd.log"))) + (string-append %user-shepherd-dir "/shepherd.log"))) =20 ;; Configuration file. (define (default-config-file) @@ -225,8 +254,8 @@ global system configuration file when running as 'roo= t'. As a side effect, create a template configuration file if non exists." (if (zero? (getuid)) (string-append %sysconfdir "/dmdconf.scm") - (let ((config-file (string-append user-dmddir "/init.scm"))) - (catch-system-error (mkdir user-dmddir)) + (let ((config-file (string-append %user-shepherd-dir "/init.scm"))= ) + (mkdir-p %user-shepherd-dir #o700) (if (not (file-exists? config-file)) (make-bare-init-file config-file)) config-file))) @@ -239,7 +268,7 @@ create a template configuration file if non exists." (define default-socket-dir (if (zero? (getuid)) %system-socket-dir - (string-append user-dmddir "/run"))) + (string-append %user-shepherd-dir "/run"))) =20 ;; Unix domain socket for receiving commands in dmd. (define default-socket-file @@ -253,7 +282,7 @@ create a template configuration file if non exists." (define default-persistency-state-file (if (zero? (getuid)) (string-append %localstatedir "/lib/misc/dmd-state") - (string-append user-dmddir "/dmd-state"))) + (string-append %user-shepherd-dir "/dmd-state"))) =20 ;; Global variables set from (dmd). (define persistency #f) @@ -284,7 +313,7 @@ directory are not checked." (and (string=3D? dir default-socket-dir) ;; If it exists already, this is fine, thus ignore errors. (catch-system-error - (mkdir default-socket-dir #o700))) + (mkdir-p default-socket-dir #o700))) ;; Check for permissions. (when secure? (let ((dir-stat (stat dir))) --------------2.6.4--