[Merge] ~waveform/livecd-rootfs:general-tidy into livecd-rootfs:ubuntu/master
Dave Jones
mp+450874 at code.launchpad.net
Tue Dec 5 12:20:16 UTC 2023
I've added a commit with some comments detailing precisely what the awk code does. Here's some examples of the transformation, assuming "fstab.awk" contains the awk snippet proposed. First, demonstrating the basic transformation of the root mount's source, its options, its fsck order, and that no other lines are affected:
$ cat fstab1
/dev/mmcblk0p1 /boot/firmware vfat defaults 0 0
# A random swap appears!
/dev/mmcblk0p2 none swap sw 0 0
/dev/mmcblk0p3 / ext4 defaults 0 0
$ awk -v root_fs_label=cloudimg-rootfs -v root_fs_options=discard,commit=30,errors=remount-ro -f fstab.awk < fstab1
/dev/mmcblk0p1 /boot/firmware vfat defaults 0 0
# A random swap appears!
/dev/mmcblk0p2 none swap sw 0 0
LABEL=cloudimg-rootfs / ext4 discard,commit=30,errors=remount-ro 0 1
Next demonstrating the addition of a root-mount in the event none is found, and removal of the UNCONFIGURED FSTAB warning:
$ cat fstab2
# UNCONFIGURED FSTAB
$ awk -v root_fs_label=cloudimg-rootfs -v root_fs_options=discard,commit=30,errors=remount-ro -f fstab.awk < fstab2
LABEL=cloudimg-rootfs / ext4 discard,commit=30,errors=remount-ro 0 1
Finally, demonstrating handling of multiple root-mount lines (elimination of all but the first with the source, option, and fsck transforms applied):
$ cat fstab3
/dev/sda1 /boot/efi vfat defaults 0 1
/dev/sda2 / ext4 defaults 0 0
LABEL=writable / ext4 defaults 0 2
$ awk -v root_fs_label=cloudimg-rootfs -v root_fs_options=discard,commit=30,errors=remount-ro -f fstab.awk < fstab3
/dev/sda1 /boot/efi vfat defaults 0 1
LABEL=cloudimg-rootfs / ext4 discard,commit=30,errors=remount-ro 0 1
If you wish, I can include these in the commentary in the shell script too, but it feels ... a bit bulky to me, and the awk isn't terribly complicated (vastly simpler than the line-noise of shell-interpolated-sed-interpreted regex it's intending to replace, at least to my eyes :)
--
https://code.launchpad.net/~waveform/livecd-rootfs/+git/livecd-rootfs/+merge/450874
Your team Ubuntu Core Development Team is subscribed to branch livecd-rootfs:ubuntu/master.
More information about the Ubuntu-reviews
mailing list