aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2021-07-09 20:43:14 -0700
committerSean Whitton <spwhitton@spwhitton.name>2021-07-10 21:42:22 -0700
commit5d25eb6f35f2067057fd2a4b1af91b1663f8d229 (patch)
tree30e7931ba770af91c70f4d183857fa468ff6a7fd /src
parentefc93e2f7763f3c906e44122d0b5643b9d8da3df (diff)
downloadconsfigurator-5d25eb6f35f2067057fd2a4b1af91b1663f8d229.tar.gz
FILE:UPDATE-UNIX-TABLE: add sorting of lines at end
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
Diffstat (limited to 'src')
-rw-r--r--src/package.lisp2
-rw-r--r--src/property/file.lisp17
2 files changed, 18 insertions, 1 deletions
diff --git a/src/package.lisp b/src/package.lisp
index 504acf7..1de47d8 100644
--- a/src/package.lisp
+++ b/src/package.lisp
@@ -8,6 +8,7 @@
#:string-prefix-p
#:string-suffix-p
#:split-string
+ #:first-char
#:last-char
#:run-program
#:read-file-string
@@ -39,6 +40,7 @@
#:string-prefix-p
#:string-suffix-p
#:split-string
+ #:first-char
#:last-char
#:run-program
#:read-file-string
diff --git a/src/property/file.lisp b/src/property/file.lisp
index a1435cf..2a3921f 100644
--- a/src/property/file.lisp
+++ b/src/property/file.lisp
@@ -519,4 +519,19 @@ NO-SOURCE or \"PLACEHOLDER\", use the existing field value."
if entry
collect it into accum and do (remhash line-target pending)
else collect line into accum
- finally (return (nconc accum (hash-table-values pending))))))))
+ finally
+ ;; Sort the lines lexicographically by the TARGETth field.
+ ;; This avoids problems of failing to mount because the
+ ;; filesystem containing the mount point is not mounted yet.
+ ;;
+ ;; Sort all targets beginning with '/' before all targets not
+ ;; beginning with '/' so that all filesystems are available
+ ;; before trying to mount to virtual targets like "swap".
+ ;; (STRING< already sorts like this but be explicit about it.)
+ (return
+ (sort (nconc accum (hash-table-values pending))
+ (lambda (a b)
+ (or (and (char= #\/ (first-char a))
+ (not (char= #\/ (first-char b))))
+ (string< a b)))
+ :key (compose (curry #'nth target) #'words))))))))