]> git.bundesbrandschatzamt.de Git - emacsconfig.git/commitdiff
added ob-cfengine3
authorAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Fri, 8 Dec 2017 17:52:48 +0000 (18:52 +0100)
committerAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Fri, 8 Dec 2017 17:52:48 +0000 (18:52 +0100)
Signed-off-by: Andreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
elpa/ob-cfengine3-20170915.634/ob-cfengine3-autoloads.el [new file with mode: 0644]
elpa/ob-cfengine3-20170915.634/ob-cfengine3-pkg.el [new file with mode: 0644]
elpa/ob-cfengine3-20170915.634/ob-cfengine3.el [new file with mode: 0644]
elpa/ob-cfengine3-readme.txt [new file with mode: 0644]

diff --git a/elpa/ob-cfengine3-20170915.634/ob-cfengine3-autoloads.el b/elpa/ob-cfengine3-20170915.634/ob-cfengine3-autoloads.el
new file mode 100644 (file)
index 0000000..65aec3c
--- /dev/null
@@ -0,0 +1,16 @@
+;;; ob-cfengine3-autoloads.el --- automatically extracted autoloads
+;;
+;;; Code:
+(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))
+\f
+;;;### (autoloads nil nil ("ob-cfengine3.el") (23082 53516 115159
+;;;;;;  478000))
+
+;;;***
+\f
+;; Local Variables:
+;; version-control: never
+;; no-byte-compile: t
+;; no-update-autoloads: t
+;; End:
+;;; ob-cfengine3-autoloads.el ends here
diff --git a/elpa/ob-cfengine3-20170915.634/ob-cfengine3-pkg.el b/elpa/ob-cfengine3-20170915.634/ob-cfengine3-pkg.el
new file mode 100644 (file)
index 0000000..c039649
--- /dev/null
@@ -0,0 +1,2 @@
+;;; -*- no-byte-compile: t -*-
+(define-package "ob-cfengine3" "20170915.634" "Org Babel functions for CFEngine 3" 'nil :commit "f38f87256efcb2b02f5c7042900087be941c1ddc" :url "https://github.com/nickanderson/ob-cfengine3" :keywords '("tools" "convenience"))
diff --git a/elpa/ob-cfengine3-20170915.634/ob-cfengine3.el b/elpa/ob-cfengine3-20170915.634/ob-cfengine3.el
new file mode 100644 (file)
index 0000000..e2939a0
--- /dev/null
@@ -0,0 +1,90 @@
+;;; ob-cfengine3.el --- Org Babel functions for CFEngine 3
+
+;; Copyright (C) 2017  Nick Anderson
+
+;; Permission is hereby granted, free of charge, to any person obtaining a copy
+;; of this software and associated documentation files (the "Software"), to deal
+;; in the Software without restriction, including without limitation the rights
+;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+;; copies of the Software, and to permit persons to whom the Software is
+;; furnished to do so, subject to the following conditions:
+;; The above copyright notice and this permission notice shall be included in
+;; all copies or substantial portions of the Software.
+
+;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+;; THE SOFTWARE.
+
+;; Author: Nick Anderson <nickNOSPAMcmdln.org>
+;; Keywords: tools, convenience
+;; Package-Version: 20170915.634
+;; URL: https://github.com/nickanderson/ob-cfengine3
+;; Version: 0.0.1
+
+
+;;; Commentary:
+;; Execute CFEngine 3 policy inside org-mode src blocks.
+
+;;; Code:
+
+(defvar ob-cfengine3-command "cf-agent"
+  "Name of command to use for executing cfengine policy.")
+
+(defvar ob-cfengine3-command-options ""
+  "Option string that should be passed to the agent.
+Note that --file will be appended to the options.")
+
+(defvar ob-cfengine3-file-control-stdlib "body file control{ inputs => { '$(sys.libdir)/stdlib.cf' };}\n"
+  "File control body to include the standard libriary from $(sys.libdir).
+It is useful to inject into an example source block before execution.")
+
+(defconst ob-cfengine3-header-args-cfengine3
+  '(
+    (no-lock . :any)
+    (include-stdlib . :any)
+    (define . :any)
+    (bundlesequence . :any))
+  "CFEngine specific header arguments.")
+
+(defun org-babel-execute:cfengine3 (body params)
+  "Actuate a block of CFEngine 3 policy.
+This function is called by `org-babel-execute-src-block'.
+
+  A temporary file is constructed containing
+  `ob-cfengine3-file-control-stdlib and the BODY of the src
+  block. `ob-cfengine3-command' is used to execute the
+  temporary file."
+
+    (let* ((temporary-file-directory ".")
+           (use-locks (cdr (assoc :use-locks params)))
+           (include-stdlib (not (string= "no" (cdr (assoc :include-stdlib params)))))
+           (define (cdr (assoc :define params)))
+           (bundlesequence (cdr (assoc :bundlesequence params)))
+    (tempfile (make-temp-file "cfengine3-")))
+      (with-temp-file tempfile
+        (when include-stdlib (insert ob-cfengine3-file-control-stdlib))
+        (insert body))
+      (unwind-protect
+         (shell-command-to-string
+           (concat
+            ob-cfengine3-command
+            " "
+            (when bundlesequence (concat "--bundlesequence "  bundlesequence ))
+            " "
+            (when define (concat "--define "  define ))
+            " "
+            (unless use-locks "--no-lock")
+            ob-cfengine3-command-options
+            " "
+            (format " --file %s" (shell-quote-argument tempfile))))
+        (delete-file tempfile))))
+
+(add-to-list 'org-src-lang-modes '("cfengine3" . cfengine3))
+(add-to-list 'org-babel-tangle-lang-exts '("cfengine3" . "cf"))
+
+(provide 'ob-cfengine3)
+;;; ob-cfengine3.el ends here
diff --git a/elpa/ob-cfengine3-readme.txt b/elpa/ob-cfengine3-readme.txt
new file mode 100644 (file)
index 0000000..552480a
--- /dev/null
@@ -0,0 +1 @@
+Execute CFEngine 3 policy inside org-mode src blocks.