repart: Allow target directory excludes

Currently, ExcludeFiles= supports excluding directories on the host
from being copied. Let's extend this to also support preventing files
from being copied into specific directories in the partition by adding
a new option ExcludeFilesTarget=. An example where this is useful is
when setting up btrfs subvolumes in the top level that are intended to
be mounted into specific locations, so /usr would be stored in @usr,
/home in @home, .... To accomplish this, we need to copy /usr to @usr
and prevent any files from being copied into /usr in the partition,
which with this commit, we'd be able to do as follows:

```
[Partition]
CopyFiles=/usr:@usr
ExcludeFilesTarget=/usr
```
This commit is contained in:
Daan De Meyer
2023-05-30 13:45:49 +02:00
committed by Zbigniew Jędrzejewski-Szmek
parent afbe20b7d4
commit 600bf76c17
3 changed files with 61 additions and 29 deletions
+7
View File
@@ -868,6 +868,8 @@ testcase_exclude_files() {
Type=root-${architecture}
CopyFiles=/
CopyFiles=/zzz:/
CopyFiles=/:/oiu
ExcludeFilesTarget=/oiu/usr
EOF
runas testuser tee "$defs/10-usr.conf" <<EOF
@@ -921,6 +923,11 @@ EOF
# Test that /zzz/usr/prs did not end up in the usr partition.
assert_rc 2 ls "$imgs/mnt/usr/prs"
# Test that /oiu/ and /oiu/zzz ended up in the root partition but /oiu/usr did not.
assert_rc 0 ls "$imgs/mnt/oiu"
assert_rc 0 ls "$imgs/mnt/oiu/zzz"
assert_rc 2 ls "$imgs/mnt/oiu/usr"
umount -R "$imgs/mnt"
losetup -d "$loop"
}