From f4e742594d9c33481e9902706787e0bdb093f19d Mon Sep 17 00:00:00 2001 From: aszlig Date: Wed, 11 Oct 2017 02:22:57 +0200 Subject: [PATCH] nixos: Fix detection of btrfs root volume Regression introduced by 801c920e95642ec663d4aa486c81e5443e25b182. Since then, the btrfsSimple subtest of the installer VM test fails with: Btrfs did not return a path for the subvolume at / The reason for this is that the output for "btrfs subvol show" has changed between version 4.8.2 and 4.13.1. For example the output of "btrfs subvol show /" in version 4.8.2 was: / is toplevel subvolume In version 4.13.1, the output now is the following and thus the regular expressions used in nixos-generate-config.pl and install-grub.pl now match (which results in the error mentioned above): / Name: UUID: - Parent UUID: - Received UUID: - Creation time: - Subvolume ID: 5 Generation: 287270 Gen at creation: 0 Parent ID: 0 Top level ID: 0 Flags: - Snapshot(s): In order to fix this I've changed nixos-generate-config.pl and install-grub.pl, because both use "btrfs subvol show" in a similar vein, so the regex for parsing the output now doesn't match anymore whenever the volume path is "/", which should result in the same behaviour as we had with btrfs-progs version 4.8.2. Tested against the btrfsSimple, btrfsSubvols and btrfsSubvolDefault subtests of the installer VM test and they all succeed now. Signed-off-by: aszlig --- nixos/modules/installer/tools/nixos-generate-config.pl | 2 +- nixos/modules/system/boot/loader/grub/install-grub.pl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/installer/tools/nixos-generate-config.pl b/nixos/modules/installer/tools/nixos-generate-config.pl index 97a30634dc7..926d1e3133f 100644 --- a/nixos/modules/installer/tools/nixos-generate-config.pl +++ b/nixos/modules/installer/tools/nixos-generate-config.pl @@ -402,7 +402,7 @@ EOF if ($status != 0 || join("", @info) =~ /ERROR:/) { die "Failed to retrieve subvolume info for $mountPoint\n"; } - my @ids = join("", @info) =~ m/Subvolume ID:[ \t\n]*([0-9]*)/; + my @ids = join("\n", @info) =~ m/^(?!\/\n).*Subvolume ID:[ \t\n]*([0-9]+)/s; if ($#ids > 0) { die "Btrfs subvol name for $mountPoint listed multiple times in mount\n" } elsif ($#ids == 0) { diff --git a/nixos/modules/system/boot/loader/grub/install-grub.pl b/nixos/modules/system/boot/loader/grub/install-grub.pl index 82b5bcda921..cc03e54ead6 100644 --- a/nixos/modules/system/boot/loader/grub/install-grub.pl +++ b/nixos/modules/system/boot/loader/grub/install-grub.pl @@ -197,7 +197,7 @@ sub GrubFs { if ($status != 0) { die "Failed to retrieve subvolume info for @{[$fs->mount]}\n"; } - my @ids = join("", @id_info) =~ m/Subvolume ID:[ \t\n]*([^ \t\n]*)/; + my @ids = join("\n", @id_info) =~ m/^(?!\/\n).*Subvolume ID:[ \t\n]*([0-9]+)/s; if ($#ids > 0) { die "Btrfs subvol name for @{[$fs->device]} listed multiple times in mount\n" } elsif ($#ids == 0) {