I want to know is it possible to edit a custom rom from zip and then zipping it again (flashable) to a device. Will it brick the device?
Depends on how the ROM is packaged and what you change in it before repacking. You should be able to unpack and make edits using suitable tools for unpacking the ROM.
A better option is to first flash it, then root and make your changes in the files as needed :-)
And yeah it can brick the device if you flash bad code 😁
Well, the best would be to first flash the rom, test all of its functions and bugs and then, after testing, you can unzip the rom zip, make your own changes and then just rezip the files.But be careful for all the changes you make, a few changes can be like changing and removing if you want any system apps, change the default wallpapers and ringtones, but you shouldn't never touch any other files.
Yes it is certainly possible. You need a Linux system however
First determine the format that has been used
If the zip has a system directory it's the old KitKat format Otherwise check system.transfer.list for the version
Anyway if it's just a system directory you can just extract the zip, add files, modify the updater-script and pack it back
The more complicated stuff:
Case 1: assume system.new.dat This is actually a sparse (iirc, not really sure) system image that you can extract with sdat2img You'll get a system.img Mount this as an ext4 loop device Perform your modifications Unmount the system image Use img2simg to convert system.img to a sparse image then flash it with fastboot like this
fastboot flash system system.img
Case 2: system.new.dat.br This is just a system.new.dat compressed with brotli. Do not directly run sdat2img on this First install brotli and decompress it to system.new.dat Follow everything as said in case 1
There is no easy way to convert it back to system.new.dat. You could use the AOSP build system to do so but if you want to make a flashable zip use the edify command "package_extract_file()" to extract the system.img from a flashable zip onto the system partition.
Also be careful. Remember that any files you add this way will have incorrect selinux contexts. You will have to use chcon to set the correct selinux contexts. Use ls -Z to check what contexts other files have and apply a suitable context