[Sony Xperia L] utsavkoju:
Dear all

I know there are numbers of you who want to start developing for our XL. There are numbers of way to flashROM. Either you can flash your ROM via system.img or ROM.zip etc etc. And here are we to explore creating rom via adb script. The earlier two ROM flashing mean require you to have unlocked bootloader but adb script ROM can be flashed on L/UL mobile devices. Lets get started with:

Preparation

Please create two folders inside your working folder with name [Your ROM Name] and [Your ROM Name_PC].

Copy all your system files/folder inside your [Your ROM Name] folder.

Please avoid creating folder within folder to avoid confusion. For example: if you are adding ringtones in your ROM consider creating folder inside [Your ROM Name] with name ringtones instead of creating folder structure like media/audio/ringtones.

In [Your ROM Name_PC] folder create a folder with name adb and copy adb.exe, AdbWinApi.dll and AdbWinUsbApi.dll inside it from your android sdk. If you are using my template then you can skip this step as i have already included adb folder inside [Your ROM Name_PC]

Scripting ADB Flasher

1. Create a new text file and rename it as Setup.bat. Remember to remove .txt extension and replace it with .bat extension.

Right Click on Setup.bat and click Edit. The file will open in notepad.

2. Copy Following lines of Code and paste it in your Setup.bat file.

[MENTION=279333]ECHO[/MENTION] off
TITLE [YOUR ROM NAME] by [Dev_Name] [Version 1.0]
COLOR 70
mode con:cols=100 lines=40
ECHO.
Pause
ECHO Waiting For Device.....

[MENTION=302893]adb[/MENTION]\adb wait-for-device

[MENTION=302893]adb[/MENTION]\adb shell "su -c 'stop'"
ECHO Getting System access.....
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'mount -o rw,remount /system/ /system/'"

This will mount system folder with read write privilege.

3. Before flashing your apks and other stuff you need to make sure you remove corresponding stuffs from the system. I have listed generic folders inside the code below please add/delete lines as per your application preferences.

ECHO Removing system files
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'rm /system/app/*.odex'"
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'rm /system/app/*.apk'"
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'rm /system/fonts/*.ttf'"
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'rm /system/framework/*.jar'"
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'rm /system/framework/*.apk'"
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'rm /system/framework/*.odex'"
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'rm /system/media/audio/ringtones/*.ogg'"
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'rm /system/media/audio/alarms/*.ogg'"
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'rm /system/media/audio/notifications/*.ogg'"
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'rm /system/media/audio/ui/*.ogg'"
ECHO System files removed successfully!
ECHO.

4. Copy each and every content of each folder you want to flash in corresponding folders of the system. Below is the sample code please consider adding/deleting as per your preferences.

ECHO COPYING FILES.....
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'cp /sdcard/[Your ROM Name]/framework/* /system/framework/'"
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'cp /sdcard/[Your ROM Name]/app/* /system/app/'"
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'cp /sdcard/[Your ROM Name]/fonts/* /system/fonts/'"
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'cp /sdcard/[Your ROM Name]/media/* /system/media/'"
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'cp /sdcard/[Your ROM Name]/ringtones/* /system/media/audio/ringtones/'"
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'cp /sdcard/[Your ROM Name]/alarms/* /system/media/audio/alarms/'"
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'cp /sdcard/[Your ROM Name]/notifications/* /system/media/audio/notifications/'"
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'cp /sdcard/[Your ROM Name]/ui/* /system/media/audio/ui/'"

5. After you have copied all your files/folders into the system you need to add permission in case of framework and apps and any other folders requiring special permission. Below is the sample code please consider adding/deleting as per your preferences.

ECHO SETTING PERMISSION.....
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'chown 0.0 /system/framework/*.jar'"
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'chmod 0644 /system/framework/*.jar'"
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'chown 0.0 /system/framework/*.apk'"
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'chmod 0644 /system/framework/*.apk'"
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'chown 0.0 /system/app/*.apk'"
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'chmod 0644 /system/app/*.apk'"

6. We are almost done now. Please consider copying following codes and adding them at the end of your script to remount system as read-only and rebooting the mobile device.

ECHO.
ECHO --------------------------------------------------------
ECHO ----------ROM INSTALLED SUCCESSFULLY------------
ECHO --------------------------------------------------------
ECHO.
[MENTION=302893]adb[/MENTION]\adb shell "su -c 'mount -o ro,remount /system/ /system/'"
ECHO Rebooting System
[MENTION=302893]adb[/MENTION]\adb reboot
ECHO.
ECHO Please be patient till device reboot!
ECHO.
ECHO.
ECHO --------------------------------------------------------
ECHO -----------------------THANK YOU------------------------
ECHO --------------------------------------------------------
ECHO.
pause

7. Now zip both [Your ROM Name] and [Your ROM Name_PC] folders and upload them to the file sharing sites of your convenience.

If all goes well you will have a superb ROM to share here at XDA. Please find the attached template along with this post.

If you like this tutorial please press thanx at the bottom of the post.

Have a happy time porting.

CREDITS will be highly appreciated.