fix label parser

This commit is contained in:
Aiden McClelland
2022-02-10 16:16:36 -07:00
committed by Aiden McClelland
parent ed6ad25565
commit e3fd98f8c9
2 changed files with 8 additions and 13 deletions

1
.gitignore vendored
View File

@@ -6,4 +6,5 @@
/*-raspios-bullseye-arm64-lite.img /*-raspios-bullseye-arm64-lite.img
/*-raspios-bullseye-arm64-lite.zip /*-raspios-bullseye-arm64-lite.zip
/product_key.txt /product_key.txt
/*_product_key.txt
.vscode/settings.json .vscode/settings.json

View File

@@ -130,7 +130,7 @@ struct NewLabel(WritableDrives);
struct CurrentLabel(WritableDrives); struct CurrentLabel(WritableDrives);
lazy_static! { lazy_static! {
static ref PARSE_COLOR: Regex = Regex::new("#LABEL=(\\w+) /media/root-ro/").unwrap(); static ref PARSE_COLOR: Regex = Regex::new("LABEL=(\\w+)[ \t]+/").unwrap();
} }
#[instrument(skip(ctx))] #[instrument(skip(ctx))]
@@ -480,18 +480,12 @@ async fn swap_boot_label(new_label: NewLabel) -> Result<(), Error> {
#[test] #[test]
fn test_capture() { fn test_capture() {
let output = r#" let output = r#"
# LABEL=blue / ext4 discard,errors=remount-ro 0 1
# This fstab is for overlayroot. The real one can be found at LABEL=system-boot /media/boot-rw vfat defaults 0 1
# /media/root-ro/etc/fstab /media/boot-rw /boot none defaults,bind,ro 0 0
# The original entry for '/' and other mounts have been updated to be placed LABEL=EMBASSY /embassy-os vfat defaults 0 1
# under /media/root-ro. # a swapfile is not a swap partition, no line here
# To permanently modify this (or any other file), you should change-root into # use dphys-swapfile swap[on|off] for that
# a writable view of the underlying filesystem using:
# sudo overlayroot-chroot
#
#LABEL=blue /media/root-ro/ ext4 ro,discard,errors=remount-ro,noauto 0 1
/media/root-ro/ / overlay lowerdir=/media/root-ro/,upperdir=/media/root-rw/overlay/,workdir=/media/root-rw/overlay-workdir/_ 0 1
LABEL=system-boot /boot/firmware vfat defaults 0 1 # overlayroot:fs-unsupported
"#; "#;
assert_eq!(&PARSE_COLOR.captures(&output).unwrap()[1], "blue"); assert_eq!(&PARSE_COLOR.captures(&output).unwrap()[1], "blue");
} }