From f17ba7c62bef8ce11bb0d837d529995967c1e3e4 Mon Sep 17 00:00:00 2001 From: Dietmar Rieder Date: Wed, 7 Feb 2024 17:02:02 +0100 Subject: [PATCH] Make mounting into sub-directoies work fixes #1073 --- CHANGELOG.md | 1 + .../rootfs/etc/systemd/system/ww4-disks.target.ww | 11 +++++++++-- .../wwinit/rootfs/etc/systemd/system/ww4-mounts.ww | 5 ++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 61516c5a8..05f271f5c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 has a container these binaries are extracted from the container image. ### Fixed +- Make mounting of local patitions into sub-directories work - Make Variables.mk consistent with spec file w.r.t. WWPROVISIONDIR, e.g. instead of basing in `/srv`, handle it the same as chroots and overlays. - Enable spec file to work with Fedora diff --git a/overlays/wwinit/rootfs/etc/systemd/system/ww4-disks.target.ww b/overlays/wwinit/rootfs/etc/systemd/system/ww4-disks.target.ww index c1a547cf7..a2cc693b2 100644 --- a/overlays/wwinit/rootfs/etc/systemd/system/ww4-disks.target.ww +++ b/overlays/wwinit/rootfs/etc/systemd/system/ww4-disks.target.ww @@ -10,11 +10,18 @@ After=ignition-ww4-disks.service Requisite=ignition-ww4-disks.service # Get the mounts {{- range $fsdevice,$fs := .FileSystems }} -{{- $prefix := $fsdevice }}{{ $suffix := "mount" }} +{{- $prefix := $fsdevice }} +{{- $prefix = tr $fsdevice "-" "\\x2d" }} +{{- $prefix = tr $prefix "/" "-" }} +{{- $prefix = slice $prefix 1 }}{{ $suffix := "mount" }} {{- if eq $fs.Format "swap"}} {{- $prefix = tr $fsdevice "/dev/disk/by-partlabel/" "dev-disk-by\\x2dpartlabel-"}}{{ $suffix = "swap"}} {{- else }} -{{- if $fs.Path }}{{ $prefix = tr $fs.Path "/" "" }}{{ end }} +{{- if ne $fs.Path "" }} +{{- $prefix = tr $fs.Path "-" "\\x2d" }} +{{- $prefix = tr $prefix "/" "-" }} +{{- $prefix = slice $prefix 1 }} +{{- end }} {{- end }} Wants={{ print $prefix "." $suffix }} {{- end }} diff --git a/overlays/wwinit/rootfs/etc/systemd/system/ww4-mounts.ww b/overlays/wwinit/rootfs/etc/systemd/system/ww4-mounts.ww index 39a5fb9ac..1f47a8e2c 100644 --- a/overlays/wwinit/rootfs/etc/systemd/system/ww4-mounts.ww +++ b/overlays/wwinit/rootfs/etc/systemd/system/ww4-mounts.ww @@ -2,7 +2,10 @@ {{- $time := .BuildTime }} {{- $source := .BuildSource }} {{- range $fsdevice,$fs := .FileSystems }} -{{- $prefix := tr $fs.Path "/" "" }}{{ $suffix:="mount"}} +{{- $prefix := tr $fs.Path "-" "\\x2d" }} +{{- $prefix = tr $prefix "/" "-" }} +{{- $prefix = slice $prefix 1 }} +{{ $suffix := "mount"}} {{- if $fs.Label }}{{ $prefix = $fs.Label }}{{ end }} {{- if eq $fs.Format "swap"}}{{ $prefix = tr $fsdevice "/dev/disk/by-partlabel/" "dev-disk-by\\x2dpartlabel-"}}{{ $suffix = "swap"}}{{ end }} {{- $filename := print $prefix "." $suffix }}