[SuperR Kitchen] SuperR.:
v3.1.8.7

Changes:

Use file_contexts3-* (if it exists) to set file contexts when building ext4 img files.

Automatically generate a minimum file_contexts file, file_contexts_min, to be used as a backup if a context is not in file_contexts3-*.

Added option for a file_contexts_custom file in 00_project_files to be used in place of file_contexts_min if it exists.

Fixed crash when extracting ext4 img and finding files with no contexts set.

Fixed crash when extracting zip files with spaces in the file name.

Log img file creation in img_build.log instead of main.log.

Windows: Hopefully fixed not allowing you to choose the heapsize even when in range.

NOTE:

An explanation for the new file contexts system:

Retrieving a file contexts file is becoming more complicated. It used to be a simple text file in the boot.img, then the .bin format, then onto various files all over the place with different names that could be merged into one file. Sometimes contexts need to be set on the system.img when the file contexts files are located in vendor, oem, odm, or somewhere I haven't seen yet. If you don't extract the img that contains them, we don't have them. The icing on the cake...as [MENTION=3844620]firefds[/MENTION] pointed out it seems the various files cannot be succsessfully merged in Samsung Pie ROMs. I am sure it will continue to become more difficult in the future. As a result, I am removing myself from the game of chasing file contexts... We will no longer use a traditional file_context file when building an ext4 img file.

Since the kitchen already generates a file with every context for every file/directory from the original firmware, we are going to use file_context3-* instead :)

Questions you may have:

Q: How will this affect my ROM?

A: Now that the file permissions, capabilities, and contexts will all be identical to the original firmware you extract, I would say only positive affects on your ROM. I will not be surprised if this fixes several things we did not know were broken.

Q: What happens if I add new files to the system directory and there are no contexts set for them in file_contexts3-system?

A: The kitchen generates a minimal file_contexts file named file_context_min. It only contains a few lines to cover files included in the img that do not have contexts assigned in file_contexts3-system.

Q: What if I want to use my own file_contexts_min file and add my own context defaults instead of using the kitchen generated one?

A: No problem. Create a new file, 00_project_files/file_contexts_custom, with any lines you want. You must at least include a context for the root directory and for lost+found or you will get errors (see example below). The syntax is the same as traditional file_context files including double tab separations and regex. Keep in mind that setting contexts here will only work if the files/directories are not listed in file_contexts3-*. This file is only used as a backup to catch everything not found in file_contexts3-*.

Here is an example minimum file_contexts_custom file:

/	u:object_r:rootfs:s0
/lost\+found	u:object_r:rootfs:s0
/system(/.*)?	u:object_r:system_file:s0
/system/lost\+found	u:object_r:system_file:s0

Q: Does this mean I can add or modify the file_contexts that are set when creating an ext4 img file?

A: Yes. You can add or edit lines in 00_project_files/file_contexts3-*. Anything you set in these files will be set in the new img during build (assuming the corresponding files exist). Side note, you can do the same for permissions and capabilities in the fs_config-* files. That's right, full control over your new img. However, there is a good chance you will not need to edit anything :)

NOTE2:

After updating, you will need to extract your original firmware again as the file_contexts3-* files have changed. Without the changes the symlinks will not have the correct contexts when building img files. If you have made a lot of changes to your ROM and do not want to start over, you can extract the firmware in a new project, and just copy the 00_project_files/file_contexts3-* files into the old project directory in the same location.

NOTE3:

The new make_ext4fs binary will have unexpected results with kitchen versions below v3.1.8.7. The easiest way to avoid this is to update to v3.1.8.7 and not fresh install any lower versions.