sysupdate: Allow patterns to match path with directories

`MatchPattern` for regular-file and directory as target can now match
subdirectories This is useful to install files for examples in `.extra.d`
directories:

```
[Target]
Type=regular-file
Path=/EFI/Linux
PathRelativeTo=boot
MatchPattern=gnomeos_@v.efi.extra.d/apparmor.addon.efi
```

The if the directories in the path do not exist, they will be created.  Whereas
the part in `Path` is not created.
This commit is contained in:
Valentin David
2023-09-28 11:41:29 +02:00
parent 18c3ffbfcc
commit 8b051623cd
5 changed files with 141 additions and 35 deletions
+23
View File
@@ -50,6 +50,9 @@ new_version() {
# Create a random "UKI" payload
echo $RANDOM >"/var/tmp/72-source/uki-$2.efi"
# Create a random extra payload
echo $RANDOM >"/var/tmp/72-source/uki-extra-$2.efi"
# Create tarball of a directory
mkdir -p "/var/tmp/72-source/dir-$2"
echo $RANDOM >"/var/tmp/72-source/dir-$2/foo.txt"
@@ -88,6 +91,9 @@ verify_version() {
cmp "/var/tmp/72-source/uki-$3.efi" "/var/tmp/72-xbootldr/EFI/Linux/uki_$3+3-0.efi"
test -z "$(ls -A /var/tmp/72-esp/EFI/Linux)"
# Check the extra efi
cmp "/var/tmp/72-source/uki-extra-$3.efi" "/var/tmp/72-xbootldr/EFI/Linux/uki_$3.efi.extra.d/extra.addon.efi"
# Check the directories
cmp "/var/tmp/72-source/dir-$3/foo.txt" /var/tmp/72-dirs/current/foo.txt
cmp "/var/tmp/72-source/dir-$3/bar.txt" /var/tmp/72-dirs/current/bar.txt
@@ -183,6 +189,21 @@ Mode=0444
TriesLeft=3
TriesDone=0
InstancesMax=2
EOF
cat >/var/tmp/72-defs/05-fifth.conf <<EOF
[Source]
Type=regular-file
Path=/var/tmp/72-source
MatchPattern=uki-extra-@v.efi
[Target]
Type=regular-file
Path=/EFI/Linux
PathRelativeTo=boot
MatchPattern=uki_@v.efi.extra.d/extra.addon.efi
Mode=0444
InstancesMax=2
EOF
rm -rf /var/tmp/72-esp /var/tmp/72-xbootldr
@@ -206,6 +227,8 @@ EOF
update_now
verify_version "$blockdev" "$sector_size" v3 1 3
test ! -f "/var/tmp/72-xbootldr/EFI/Linux/uki_v1+3-0.efi"
test ! -f "/var/tmp/72-xbootldr/EFI/Linux/uki_v1.efi.extra.d/extra.addon.efi"
test ! -d "/var/tmp/72-xbootldr/EFI/Linux/uki_v1.efi.extra.d"
# Create fourth version, and update through a file:// URL. This should be
# almost as good as testing HTTP, but is simpler for us to set up. file:// is