diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-05 12:21:48 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-05 12:24:29 -0700 |
commit | 7522b073f5a6faf9fb658e79ed4bde7b23367d16 (patch) | |
tree | dbc86c3097fc7de331ec24d0f9d7bef44a5293dc | |
parent | c030b52faae2b6e06b98ff97bf9b1d518d27339d (diff) | |
download | consfigurator-7522b073f5a6faf9fb658e79ed4bde7b23367d16.tar.gz |
add APT:INSTALLED
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r-- | consfigurator.asd | 1 | ||||
-rw-r--r-- | src/package.lisp | 6 | ||||
-rw-r--r-- | src/property/apt.lisp | 45 |
3 files changed, 52 insertions, 0 deletions
diff --git a/consfigurator.asd b/consfigurator.asd index 3630eea..6f29d8b 100644 --- a/consfigurator.asd +++ b/consfigurator.asd @@ -27,6 +27,7 @@ (:file "src/property/cmd") (:file "src/property/file") (:file "src/property/os") + (:file "src/property/apt") (:file "src/property/chroot") (:file "src/data/asdf") (:file "src/data/pgp"))) diff --git a/src/package.lisp b/src/package.lisp index 0c214e2..24d3a97 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -198,6 +198,12 @@ #:debian-testing #:debian-unstable)) +(defpackage :consfigurator.property.apt + (:use #:cl #:consfigurator) + (:local-nicknames (#:re #:cl-ppcre) + (#:os #:consfigurator.property.os)) + (:export #:installed)) + (defpackage :consfigurator.data.asdf (:use #:cl #:consfigurator)) diff --git a/src/property/apt.lisp b/src/property/apt.lisp new file mode 100644 index 0000000..be433d0 --- /dev/null +++ b/src/property/apt.lisp @@ -0,0 +1,45 @@ +;;; 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.property.apt) +(named-readtables:in-readtable :interpol-syntax) + +(defprop installed :posix (&rest packages) + "Ensure all of the apt packages PACKAGES are installed." + (:desc #?"apt installed @{packages}") + (:hostattrs + (declare (ignore packages)) + (os:required 'os:debianlike)) + (:check + (all-installed packages)) + (:apply + (apt-get :print "-y" "install" packages))) + +(defun all-installed (packages) + (loop + with n = 0 + with lines = (runlines :env '(:LANG "C") "apt-cache" "policy" packages) + for line in lines + when (re:scan #?/^\s+Installed:\s+(?!\(none\))/ line) + do (incf n) + finally (return (= n (length packages))))) + +(defun apt-get (&rest args) + (apply #'run + :env '(:DEBIAN_FRONTEND "noninteractive" + :APT_LISTCHANGES_FRONTEND "none") + "apt-get" args)) |