[Android Q&A, Help & Troubleshooting] azithro:
Found this on:

https://www.miniand.com/wiki/Allwinner/Unpacking+and+building+LiveSuit+images

---------- Post added at 10:37 PM ---------- Previous post was at 10:29 PM ----------

Converting a ZIP ROM to a system.img

This is basically for Rockchip ROMs.

OK so first lets understand the difference.

system.img is nothing more than a image file that is formatted EXT4 and mounted in Linux.

You make the image file using DD and then format it EXT4 (or EXT3 for older devices).

Then you mount it in Linux and copy all your stuff into it.

Now this is EASY when you mount an existing system.img and copy it into a new system.img Why? Because that original system.img has all the symbolic links and permissions already set!

However, if you get a update that is a ZIP file this is not the case. Or if you get a CWM backup and untar it, you can loose the symlinks and permissions.

So one day I got a ROM that was only supplied as a zip. It used what is called a edify script to install it which that script copies all the files into system then does all the file permissions and setup up the needed symlinks.

The commands in the script do not map in Linux! Thus I had to convert them. Let me tell you this was somewhat a pain and special thanks to 900Supersport and Petrus for helping me understand and convert.

So here is how you do it.

First create a directory to unzip or un-tar all the files into. I called mine system_orig

Then this is my script to build a system.img The harder part is getting the IMG file size correct. You have to watch out making it too big as the parameter file defines how big system can be. If yours is bigger than what the parameter file allows, you will need to adjust the parameter file. I believe most parameter files today allow up to 500megs.

#create the system dir

mkdir system2

# create the system image using DD. Set size here:

dd if=/dev/zero of=system.img count=471000000

#format the image you just created. This is EXT4 but you can use anything the kernel allows as defined in init.rc

sudo /sbin/mkfs.ext4 -q system.img

#Now mount it in Linux

sudo mount -o loop system.img system2

# Now copy everything from your unzipped folder into the new image.

sudo cp -r system_orig/* system2

#OK lets create all the symbolic links

#make symlinks

sudo ln -s Roboto-Bold.ttf system2/fonts/DroidSans-Bold.ttf

sudo ln -s Roboto-Regular.ttf system2/fonts/DroidSans.ttf

sudo ln -s mksh system2/bin/sh

sudo ln -s toolbox system2/bin/cat

sudo ln -s toolbox system2/bin/chmod

sudo ln -s toolbox system2/bin/chown

sudo ln -s toolbox system2/bin/cmp

sudo ln -s toolbox system2/bin/date

sudo ln -s toolbox system2/bin/dd

sudo ln -s toolbox system2/bin/df

sudo ln -s toolbox system2/bin/dmesg

sudo ln -s toolbox system2/bin/getevent

sudo ln -s toolbox system2/bin/getprop

sudo ln -s toolbox system2/bin/hd

sudo ln -s toolbox system2/bin/id

sudo ln -s toolbox system2/bin/ifconfig

sudo ln -s toolbox system2/bin/iftop

sudo ln -s toolbox system2/bin/insmod

sudo ln -s toolbox system2/bin/ioctl

sudo ln -s toolbox system2/bin/ionice

sudo ln -s toolbox system2/bin/kill

sudo ln -s toolbox system2/bin/ln

sudo ln -s toolbox system2/bin/log

sudo ln -s toolbox system2/bin/ls

sudo ln -s toolbox system2/bin/lsmod

sudo ln -s toolbox system2/bin/lsof

sudo ln -s toolbox system2/bin/md5

sudo ln -s toolbox system2/bin/mkdir

sudo ln -s toolbox system2/bin/mount

sudo ln -s toolbox system2/bin/mv

sudo ln -s toolbox system2/bin/nandread

sudo ln -s toolbox system2/bin/netstat

sudo ln -s toolbox system2/bin/newfs_msdos

sudo ln -s toolbox system2/bin/notify

sudo ln -s toolbox system2/bin/printenv

sudo ln -s toolbox system2/bin/ps

sudo ln -s toolbox system2/bin/r

sudo ln -s toolbox system2/bin/reboot

sudo ln -s toolbox system2/bin/renice

sudo ln -s toolbox system2/bin/rm

sudo ln -s toolbox system2/bin/rmdir

sudo ln -s toolbox system2/bin/rmmod

sudo ln -s toolbox system2/bin/route

sudo ln -s toolbox system2/bin/schedtop

sudo ln -s toolbox system2/bin/sendevent

sudo ln -s toolbox system2/bin/setconsole

sudo ln -s toolbox system2/bin/setprop

sudo ln -s toolbox system2/bin/sleep

sudo ln -s toolbox system2/bin/smd

sudo ln -s toolbox system2/bin/start

sudo ln -s toolbox system2/bin/stop

sudo ln -s toolbox system2/bin/sync

sudo ln -s toolbox system2/bin/top

sudo ln -s toolbox system2/bin/touch

sudo ln -s toolbox system2/bin/umount

sudo ln -s toolbox system2/bin/uptime

sudo ln -s toolbox system2/bin/vmstat

sudo ln -s toolbox system2/bin/watchprops

sudo ln -s toolbox system2/bin/wipe

#OK now lets set all the permissions

sudo chown -R 0:0 system2

sudo chmod -R 0755 system2

sudo find system2 -type d -exec chmod 0755 {} \;

sudo find system2 -type f -exec chmod 0644 {} \;

sudo chown -R 0:2000 system2/bin

sudo chmod 0755 system2/bin

sudo find system2/bin -type d -exec chmod 0755 {} \;

sudo find system2/bin -type f -exec chmod 0755 {} \;

sudo chown 0:3003 system2/bin/netcfg

sudo chmod 2750 system2/bin/netcfg

sudo chown 0:3004 system2/bin/ping

sudo chmod 2755 system2/bin/ping

sudo chown 0:2000 system2/bin/run-as

sudo chmod 6755 system2/bin/run-as

sudo chown -R 1002:1002 system2/etc/bluetooth

sudo chmod 0755 system2/etc/bluetooth

sudo find system2/etc/bluetooth -type d -exec chmod 0755 {} \;

sudo find system2/etc/bluetooth -type f -exec chmod 0440 {} \;

sudo chown 0:0 system2/etc/bluetooth

sudo chmod 0755 system2/etc/bluetooth

sudo chown 1000:1000 system2/etc/bluetooth/auto_pairing.conf

sudo chmod 0640 system2/etc/bluetooth/auto_pairing.conf

sudo chown 3002:3002 system2/etc/bluetooth/blacklist.conf

sudo chmod 0444 system2/etc/bluetooth/blacklist.conf

sudo chown 1002:1002 system2/etc/dbus.conf

sudo chmod 0440 system2/etc/dbus.conf

sudo chown 1014:2000 system2/etc/dhcpcd/dhcpcd-run-hooks

sudo chmod 0550 system2/etc/dhcpcd/dhcpcd-run-hooks

sudo chown 0:2000 system2/etc/init.goldfish.sh

sudo chmod 0550 system2/etc/init.goldfish.sh

sudo chown 0:0 system2/etc/install-recovery.sh

sudo chmod 0544 system2/etc/install-recovery.sh

sudo chown -R 0:0 system2/etc/ppp

sudo chmod -R 0755 system2/etc/ppp

sudo find system2/etc/ppp -type d -exec chmod 0755 {} \;

sudo find system2/etc/ppp -type f -exec chmod 0555 {} \;

sudo chown -R 0:2000 system2/vendor

sudo chmod -R 0755 system2/vendor

sudo find system2/vendor -type d -exec chmod 0755 {} \;

sudo find system2/vendor -type f -exec chmod 0644 {} \;

sudo chown -R 0:2000 system2/xbin

sudo chmod -R 0755 system2/xbin

sudo find system2/xbin -type d -exec chmod 0755 {} \;

sudo find system2/xbin -type f -exec chmod 0755 {} \;

sudo chown 0:0 system2/xbin/librank

sudo chmod 06755 system2/xbin/librank

sudo chown 0:0 system2/xbin/procmem

sudo chmod 06755 system2/xbin/procmem

sudo chown 0:0 system2/xbin/procrank

sudo chmod 06755 system2/xbin/procrank

sudo chown 0:0 system2/xbin/tcpdump

sudo chmod 06755 system2/xbin/tcpdump

# Note I added this to ROOT the new ROM. I simply copied in SU and Superuser and busybox.

# However if you want stock remove this area.

# Also note, some only put busybox and SU in /bin or /xbin. I usually do both.

sudo chown 0:0 system2/bin/su

sudo chmod 06755 system2/bin/su

sudo chown 0:0 system2/xbin/su

sudo chmod 06755 system2/xbin/su

sudo chown 0:0 system2/bin/busybox

sudo chmod 6755 system2/bin/busybox

sudo chown 0:0 system2/xbin/busybox

sudo chmod 6755 system2/xbin/busybox

sudo chown 0:0 system2/app/Superuser.apk

sudo chmod 6755 system2/app/Superuser.apk

# OK now lets unmount system.img

sudo umount system2

# for clean up I usually delete system2 folder.

sudo rm -f -R system2

That should do it!

FYI, you do not RKCRC system.img.

Hope this helps