Support TWRP 3.2.0+
Source: https://forum.xda-developers.com/showthread.php?t=1943625
Note that TWRP only supports v2 fstabs in version 3.2.0 and higher. You will still need to use the "old" format of fstab for older TWRP (example of that format is below), and even TWRP 3.2.0 still supports the v1 format in addition to the v2 format. To maximize TWRP's compatibility with your build tree, you can create a twrp.fstab and use PRODUCT_COPY_FILES to place the file in /etc/twrp.fstab When TWRP boots, if it finds a twrp.fstab in the ramdisk it will rename /etc/recovery.fstab to /etc/recovery.fstab.bak and then rename /etc/twrp.fstab to /etc/recovery.fstab. Effectively this will "replace" the fstab 2 file that your device files are providing with the TWRP fstab allowing you to maintain compatibility within your device files and with other recoveries.
So it seems to me that TWRP until version 3.2.0 supported "v1" fstab in the format of /etc/recovery.fstab, and since 3.2.0 it also supports /etc/twrp.fstab which is the default.
This is problematic in at least two PMOS scripts, /pmos_chroot
and /chroot/bin/pmos_install_functions
which only expect /recovery.fstab.
Note: I rewrote recovery.fstab to twrp.fstab in these examples already. Works on TWRP 3.2.3, but needs to be further edited to support both. I guess a || rule would suffice.
pmos_chroot part:
# Create copy of fstab file provided by the recovery
cp /etc/twrp.fstab "$CHROOT"/twrp.fstab || { [ "$?" = '255' ] && echo 'twrp.fstab not found, continuing...' || exit "$?" ; }
I absolutely do not understand the middle rule. if $? is 255 (as in script EXITED) it continues with "NOT FOUND".
However if the file is not found, it throws a cp: can't stat '/etc/recovery.fstab': No such file or directory
, which is error code 1.
Furthermore the pmos_install_functions
seems to REQUIRE this file anyway, so I do not get why it should continue executing upon not finding it out.
So I'd just shorten it to
cp /etc/twrp.fstab "$CHROOT"/twrp.fstab || exit "$?" ; }
Next in the second script there's there instances of recovery.fstab -
_INSTALL_DEVICE=$(readlink -fn "$(awk '$1 == "/system" {print $3; exit;}' /twrp.fstab)")
...
_INSTALL_DEVICE=$(readlink -fn "$(awk '$1 == "/external_sd" {print $4; exit;}' /twrp.fstab)")
...
_BOOT_PARTITION=$(awk '$1 == "/boot" {print $3; exit;}' /twrp.fstab)
This (at least partially) fixes - #1635 (closed)