aboutsummaryrefslogtreecommitdiff
path: root/src/property
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2022-07-23 15:26:07 -0700
committerSean Whitton <spwhitton@spwhitton.name>2022-07-27 13:24:19 -0700
commit6aa9f99ee91ac8c55114b386088fc8f715fc61d3 (patch)
tree31b55670eb4a5edaa5eb32a50d91303bf11b0294 /src/property
parent8bc6c6a3a82051e773942e21b9497b01fb692a4f (diff)
downloadconsfigurator-6aa9f99ee91ac8c55114b386088fc8f715fc61d3.tar.gz
replace DISK:HOST-VOLUMES-CREATED, update & improve tutorial
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src/property')
-rw-r--r--src/property/disk.lisp113
-rw-r--r--src/property/installer.lisp85
2 files changed, 148 insertions, 50 deletions
diff --git a/src/property/disk.lisp b/src/property/disk.lisp
index af1e7e6..c1759a0 100644
--- a/src/property/disk.lisp
+++ b/src/property/disk.lisp
@@ -978,8 +978,108 @@ filesystems will be incrementally updated when other properties change."
(caches-cleaned)))
(%raw-image-created
,volumes :chroot ,chroot :rebuild ,rebuild))
- (consfigurator.property.installer:chroot-installed-to-volumes-for
- ,host ,chroot ,volumes))))
+ (consfigurator.property.installer:files-installed-to-volumes-for
+ nil ,host ,volumes :chroot ,chroot))))
+
+(defprop %volumes-created :lisp (volumes)
+ (:desc "Created host volumes")
+ (:hostattrs (os:required 'os:linux) (require-volumes-data volumes))
+ (:apply
+ (dolist (volume volumes)
+ (when (subtypep (type-of volume) 'physical-disk)
+ (setf (volume-size volume)
+ (floor (/ (parse-integer
+ (stripln
+ (run "blockdev" "--getsize64" (device-file volume))))
+ 1048576)))))
+ (create-volumes-and-contents volumes)))
+
+(defpropspec first-disk-installed-for :lisp
+ (options host device-file &key chroot)
+ "Install HOST to the DISK:PHYSICAL-DISK accessible at DEVICE-FILE.
+**THIS PROPERTY UNCONDITIONALLY FORMATS DISKS, POTENTIALLY DESTROYING DATA,
+ EACH TIME IT IS APPLIED.**
+
+Do not apply in DEFHOST. Apply with DEPLOY-THESE/HOSTDEPLOY-THESE.
+
+The DISK:VOLUME-CONTENTS of the first DISK:PHYSICAL-DISK entry in the host's
+volumes, as specified using DISK:HAS-VOLUMES, will be created at DEVICE-FILE;
+there must be at least one such DISK:PHYSICAL-DISK entry. Other
+DISK:PHYSICAL-DISK entries will be ignored, so ensure that none of the
+properties of the host will write to areas of the filesystem where filesystems
+stored on other physical disks would normally be mounted.
+
+OPTIONS will be passed on to CHROOT:OS-BOOTSTRAPPED-FOR, which see.
+
+In most cases you will need to ensure that HOST has properties which do at
+least the following:
+
+ - declare the host's OS
+
+ - install a kernel
+
+ - install the binaries/packages needed to install the host's bootloader to
+ its volumes (usually with INSTALLER:BOOTLOADER-BINARIES-INSTALLED).
+
+If CHROOT, an intermediate chroot is bootstrapped at CHROOT, and HOST's
+properties are applied to that. Otherwise, HOST's OS is bootstrapped directly
+to DEVICE-FILE. It's useful to supply CHROOT when you expect to install the
+same HOST to a number of physical disks.
+
+Applying this property is similar to applying DISK:RAW-IMAGE-BUILT-FOR and
+then immediately dd'ing out the image to DEVICE-FILE. The advantage of this
+property is that there is no need to resize filesystems to fill the size of
+the host's actual physical disk upon first boot."
+ (:desc #?"Installed ${(get-hostname host)} to ${device-file}")
+ (let ((volumes (host-volumes-just-one-physical-disk
+ host (lambda (v)
+ (setf (device-file v)
+ (parse-unix-namestring device-file))))))
+ `(eseqprops
+ (%volumes-created ,volumes)
+ ,@(and chroot
+ (list (propapp (chroot:os-bootstrapped-for. options chroot host
+ (caches-cleaned)))))
+ (consfigurator.property.installer:files-installed-to-volumes-for
+ ,options ,host ,volumes :chroot ,chroot))))
+
+(defpropspec volumes-installed-for :lisp (options host &key chroot leave-open)
+ "Install HOST to its volumes, as specified using DISK:HAS-VOLUMES.
+**THIS PROPERTY UNCONDITIONALLY FORMATS DISKS, POTENTIALLY DESTROYING DATA,
+ EACH TIME IT IS APPLIED.**
+
+Do not apply in DEFHOST. Apply with DEPLOY-THESE/HOSTDEPLOY-THESE.
+
+OPTIONS will be passed on to CHROOT:OS-BOOTSTRAPPED-FOR, which see.
+
+In most cases you will need to ensure that HOST has properties which do at
+least the following:
+
+ - declare the host's OS
+
+ - install a kernel
+
+ - install the binaries/packages needed to install the host's bootloader to
+ its volumes (usually with INSTALLER:BOOTLOADER-BINARIES-INSTALLED).
+
+If CHROOT, an intermediate chroot is bootstrapped at CHROOT, and HOST's
+properties are applied to that. Otherwise, HOST's OS is bootstrapped directly
+to its volumes. This parameter is useful for the case of installing HOST from
+a live system which might not have network access. See \"Tutorial: OS
+installation\" in the Consfigurator user's manual.
+
+If LEAVE-OPEN, HOST's volumes will not be closed. This allows you to inspect
+the result of the installation. If you want to run this property again, you
+should first manually close all the volumes."
+ (:desc #?"Installed ${(get-hostname host)}")
+ (let ((volumes (get-hostattrs :volumes host)))
+ `(eseqprops
+ (%volumes-created ,volumes)
+ ,@(and chroot
+ (list (propapp (chroot:os-bootstrapped-for. options chroot host
+ (caches-cleaned)))))
+ (consfigurator.property.installer:files-installed-to-volumes-for
+ ,options ,host ,volumes :chroot ,chroot :leave-open ,leave-open))))
(defprop %squashfsed :posix (chroot image &optional (compression "xz"))
(:apply
@@ -1086,15 +1186,6 @@ Currently only BIOS boot is implemented."
,iso-root)))))
-(defprop host-volumes-created :lisp ()
- "Recursively create the volumes as specified by DISK:HAS-VOLUMES.
-**THIS PROPERTY UNCONDITIONALLY FORMATS DISKS, POTENTIALLY DESTROYING DATA,
- EACH TIME IT IS APPLIED.**
-
-Do not apply in DEFHOST. Apply with DEPLOY-THESE/HOSTDEPLOY-THESE."
- (:desc "Host volumes created")
- (:apply (create-volumes-and-contents (get-hostattrs :volumes))))
-
;; TODO Possibly we want (a version of) this to not fail, but just do nothing,
;; if the relevant volume groups etc. are inactive?
(defproplist host-logical-volumes-exist :lisp ()
diff --git a/src/property/installer.lisp b/src/property/installer.lisp
index b70e2a1..e2d8585 100644
--- a/src/property/installer.lisp
+++ b/src/property/installer.lisp
@@ -59,11 +59,11 @@ BOOTLOADER-TYPE to VOLUME."))
;; At :HOSTATTRS time we don't have the OPENED-VOLUME values required by the
;; :APPLY subroutines which actually install the bootloaders. So we call
-;; GET-PROPSPECS twice: (in CHROOT-INSTALLED-TO-VOLUMES-FOR) at :HOSTATTRS
-;; time to generate propspecs for the sake of running :HOSTATTRS subroutines,
-;; and then at :APPLY time where we can get at the OPENED-VOLUME values, we
-;; ignore the previously generated propspecs and call GET-PROPSPECS again.
-;; This approach should work for any sensible VOLUME<->OPENED-VOLUME pairs.
+;; GET-PROPSPECS twice: (in FILES-INSTALLED-TO-VOLUMES-FOR) at :HOSTATTRS time
+;; to generate propspecs for the sake of running :HOSTATTRS subroutines, and
+;; then at :APPLY time where we can get at the OPENED-VOLUME values, we ignore
+;; the previously generated propspecs and call GET-PROPSPECS again. This
+;; approach should work for any sensible VOLUME<->OPENED-VOLUME pairs.
(define-function-property-combinator %install-bootloaders (&rest propapps)
(:retprop
:type :lisp
@@ -89,44 +89,51 @@ BOOTLOADER-TYPE to VOLUME."))
(strcat (unix-namestring chroot) "/")
(strcat (unix-namestring target) "/"))))
-(defpropspec chroot-installed-to-volumes-for :lisp
- (host chroot volumes &key leave-open)
+(defun chroot-target (chroot)
+ (ensure-directory-pathname
+ (strcat
+ (drop-trailing-slash (unix-namestring (ensure-directory-pathname chroot)))
+ ".target")))
+
+(defpropspec files-installed-to-volumes-for :lisp
+ (options host volumes &key chroot leave-open
+ (mount-below (if chroot (chroot-target chroot) #P"/target/")))
"Where CHROOT contains the root filesystem of HOST and VOLUMES is a list of
volumes, recursively open the volumes and rsync in the contents of CHROOT.
Also update the fstab and crypttab, and try to install bootloader(s).
-LEAVE-OPEN is passed on to DISK:WITH-OPENED-VOLUMES, which see."
- (:desc #?"${chroot} installed to volumes")
- (let ((target
- (ensure-directory-pathname
- (strcat
- (drop-trailing-slash
- (unix-namestring (ensure-directory-pathname chroot)))
- ".target"))))
- `(with-opened-volumes
- (,volumes :mount-below ,target :leave-open ,leave-open)
- (%update-target-from-chroot ,chroot ,target)
- (chroot:deploys-these
- ,target ,host
- ,(make-propspec
- :propspec
- `(eseqprops
- ,(propapp
- (os:etypecase
- (debianlike
- (file:lacks-lines
- "/etc/fstab" "# UNCONFIGURED FSTAB FOR BASE SYSTEM")
- ;; These will overwrite any custom mount options, etc.,
- ;; with values from VOLUMES. Possibly it would be better
- ;; to use properties which only update the fs-spec/source
- ;; fields. However, given that VOLUMES ultimately comes
- ;; from the volumes the user has declared for the host, it
- ;; is unlikely there are other properties setting mount
- ;; options etc. which are in conflict with VOLUMES.
- (fstab:has-entries-for-opened-volumes)
- (crypttab:has-entries-for-opened-volumes))))
- (%install-bootloaders
- ,@(get-propspecs (get-hostattrs :volumes)))))))))
+If CHROOT is NIL, bootstrap a root filesystem for HOST directly to VOLUMES.
+In that case, OPTIONS is passed on to CHROOT:OS-BOOTSTRAPPED-FOR, which see.
+
+MOUNT-BELOW and LEAVE-OPEN are passed on to WITH-OPENED-VOLUMES, which see."
+ (:desc (format nil "~A installed to volumes"
+ (or chroot (get-hostname host))))
+ `(with-opened-volumes
+ (,volumes :mount-below ,mount-below :leave-open ,leave-open)
+ ,(if chroot
+ `(%update-target-from-chroot ,chroot ,mount-below)
+ `(chroot:os-bootstrapped-for ,options ,mount-below ,host))
+ (chroot:deploys-these
+ ,mount-below ,host
+ ,(make-propspec
+ :propspec
+ `(eseqprops
+ ,(propapp
+ (os:etypecase
+ (debianlike
+ (file:lacks-lines
+ "/etc/fstab" "# UNCONFIGURED FSTAB FOR BASE SYSTEM")
+ ;; These will overwrite any custom mount options, etc., with
+ ;; values from VOLUMES. Possibly it would be better to use
+ ;; properties which only update the fs-spec/source fields.
+ ;; However, given that VOLUMES ultimately comes from the
+ ;; volumes the user has declared for the host, it is unlikely
+ ;; there are other properties setting mount options etc. which
+ ;; are in conflict with VOLUMES.
+ (fstab:has-entries-for-opened-volumes)
+ (crypttab:has-entries-for-opened-volumes))))
+ (%install-bootloaders
+ ,@(get-propspecs (get-hostattrs :volumes))))))))
(defpropspec bootloader-binaries-installed :posix ()
"Install whatever binaries/packages need to be available to install the host's