diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-10 10:59:06 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2021-03-10 10:59:06 -0700 |
commit | 16c7fe24b16204072c24598c3b917c8695e87a27 (patch) | |
tree | c164c34745c9c69ea63681099cecf08f3d5e3086 /src/property/apt.lisp | |
parent | ae809cf7d95190ca366f3192499f017ab301d590 (diff) | |
download | consfigurator-16c7fe24b16204072c24598c3b917c8695e87a27.tar.gz |
add APT:MIRROR and APT:STANDARD-SOURCES.LIST
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/property/apt.lisp')
-rw-r--r-- | src/property/apt.lisp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/property/apt.lisp b/src/property/apt.lisp index de5ffc2..0942c5e 100644 --- a/src/property/apt.lisp +++ b/src/property/apt.lisp @@ -19,7 +19,7 @@ (named-readtables:in-readtable :interpol-syntax) -;;;; Macros +;;;; Static definitions (defmacro with-maybe-update (form) `(handler-case ,form @@ -27,6 +27,8 @@ (apt-get :princ "update") ,form))) +(define-constant sections '("main" "contrib" "non-free") :test #'equal) + ;;;; Properties @@ -52,6 +54,37 @@ (:apply (apt-get :princ "-y" "remove" packages))) +(defprop mirror :posix (uri) + (:desc #?"${uri} apt mirror selected") + (:hostattrs + (pushnew-hostattrs :apt.mirror uri))) + +(defun get-mirrors () + (or (get-hostattrs :apt.mirror) (call-with-os #'get-default-mirrors))) + +(defmethod get-default-mirrors ((os os:debian)) + '("http://deb.debian.org/debian")) + +(defprop standard-sources.list :posix () + (:desc "Standard sources.list") + (:apply + (file:has-content "/etc/apt/sources.list" + (call-with-os #'standard-sources-for)))) + +(defmethod standard-sources-for ((os os:debian)) + (let* ((suite (os:debian-suite os)) + (archive (mapcar (lambda (m) (cons m (cons suite sections))) + (get-mirrors))) + (security-suite (if (stringmem suite '("stretch" "jessie" "buster")) + #?"${suite}/updates" + #?"${suite}-security")) + (security (and (not (subtypep (type-of os) 'os:debian-unstable)) + (list + (cons "http://security.debian.org/debian-security" + (cons security-suite sections)))))) + (mapcan (lambda (l) (list #?"deb @{l}" #?"deb-src @{l}")) + (nconc archive security)))) + ;;;; Reports on installation status |